diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..e69de29
diff --git a/LICENSE b/LICENSE
index 9cecc1d..a1ae679 100755
--- a/LICENSE
+++ b/LICENSE
@@ -653,9 +653,9 @@ Also add information on how to contact you by electronic and paper mail.
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This program comes with ABSOLUTELY NO WARRANTY; for details typeCode `show w'.
This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
+ under certain conditions; typeCode `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
diff --git a/README.md b/README.md
index 9315709..51239e9 100755
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ An Android clock [下载](#直接下载)
其它在设置页设置
-
+
6.0系统以下,可以用 近身感应锁屏。 在屏锁状态下无效
diff --git a/app/build.gradle b/app/build.gradle
index 0c7db3e..f49831a 100755
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -20,33 +20,51 @@ android {
productFlavors {
}
compileOptions {
- sourceCompatibility = '1.7'
- targetCompatibility = '1.7'
+ sourceCompatibility = '1.7'
+ targetCompatibility = '1.7'
+ }
+ packagingOptions {
+ exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
+ implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13-beta-2'
implementation 'com.mcxiaoke.volley:library:1.0.19'
- implementation 'com.github.razerdp:BasePopup:2.1.8'
- implementation 'com.haibin:calendarview:3.5.3'
- implementation 'androidx.annotation:annotation:1.0.1'
- implementation('com.github.bumptech.glide:glide:4.8.0'){
+
+ implementation 'com.github.razerdp:BasePopup:2.2.0'
+ //BasePopup androidx支持库(针对以上两个支持的androidX版本)
+ //implementation 'com.github.razerdp:BasePopup-compat-androidx:2.1.8'
+
+ implementation 'com.haibin:calendarview:3.6.2'
+ implementation 'androidx.annotation:annotation:1.0.2'
+
+ implementation('com.github.bumptech.glide:glide:4.8.0') {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'androidx.cardview:cardview:1.0.0'
- implementation 'com.blankj:utilcode:1.23.4'
+ implementation 'com.blankj:utilcode:1.23.7'
implementation 'com.larswerkman:HoloColorPicker:1.5'
- //implementation 'com.daimajia.easing:library:2.0@aar'
-
- implementation ('com.github.LuckSiege.PictureSelector:picture_library:v2.2.3'){
+ implementation('com.github.LuckSiege.PictureSelector:picture_library:v2.2.3') {
exclude group: "com.github.bumptech.glide"
}
+
+ // ViewModel and LiveData
+ implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
+
+ implementation('com.gitee.51danju.e-odbo:e-odbo-jdbc:V1.0-beta.1')
+ {
+ exclude(group: 'org.apache.logging.log4j', module: 'log4j-core')
+ }
+ implementation 'org.sqldroid:sqldroid:1.1.0-rc1'
+
+ implementation "com.github.DeweyReed:UltimateMusicPicker:2.0.4"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0226257..0e4e872 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -11,7 +11,8 @@
android:sharedUserId="android.uid.system"
android:name=".ClockApplication"
tools:replace="android:theme"
- android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
+
diff --git a/app/src/main/java/clock/socoolby/com/clock/AboutActivity.java b/app/src/main/java/clock/socoolby/com/clock/AboutActivity.java
index 03a8b94..231d1df 100755
--- a/app/src/main/java/clock/socoolby/com/clock/AboutActivity.java
+++ b/app/src/main/java/clock/socoolby/com/clock/AboutActivity.java
@@ -1,7 +1,7 @@
package clock.socoolby.com.clock;
-import android.app.Activity;
import android.os.Bundle;
+import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;
import clock.socoolby.com.clock.utils.FuncUnit;
@@ -11,7 +11,7 @@ import clock.socoolby.com.clock.utils.FuncUnit;
* Created by socoolby on 04/01/2017.
*/
-public class AboutActivity extends Activity {
+public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/app/src/main/java/clock/socoolby/com/clock/ClockApplication.java b/app/src/main/java/clock/socoolby/com/clock/ClockApplication.java
index 8bd7db9..3955985 100755
--- a/app/src/main/java/clock/socoolby/com/clock/ClockApplication.java
+++ b/app/src/main/java/clock/socoolby/com/clock/ClockApplication.java
@@ -12,6 +12,7 @@ import clock.socoolby.com.clock.protocol.BusinessService;
import clock.socoolby.com.clock.model.DateModel;
import clock.socoolby.com.clock.utils.FileUtils;
import clock.socoolby.com.clock.model.SharePerferenceModel;
+import e.odbo.data.dao.EntityManager;
public class ClockApplication extends Application {
@@ -23,13 +24,16 @@ public class ClockApplication extends Application {
return sEndzoneBoxApp;
}
+ SharePerferenceModel model;
+
+ EntityManager entityManager;
+
@Override
public void onCreate() {
super.onCreate();
sEndzoneBoxApp = this;
Utils.init(this);
init();
-
}
@@ -51,9 +55,8 @@ public class ClockApplication extends Application {
Log.d("app","supported permission denied...");
}
}).request();
-
+ model = new SharePerferenceModel();
if (!FileUtils.isExistsFile(Constants.SHARE_PERFERENCE_FILE)) {
- SharePerferenceModel model = new SharePerferenceModel();
model.setTypeHourPower(Constants.TALKING_HOURS);
DateModel startTimeModel = new DateModel();
startTimeModel.setTime(12, 31);
@@ -61,9 +64,8 @@ public class ClockApplication extends Application {
stopTimeModel.setTime(14, 31);
model.setStartHourPowerTime(startTimeModel);
model.setStopHourPowerTime(stopTimeModel);
- model.setCity(getString(R.string.shenzhen));
- model.save();
- }
+ }else
+ model.read();
}
public static Context getContext() {
@@ -84,4 +86,11 @@ public class ClockApplication extends Application {
return mMainActivity;
}
+ public SharePerferenceModel getModel() {
+ return model;
+ }
+
+ public EntityManager getEntityManager(){
+ return entityManager;
+ }
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/CountDownActivity.java b/app/src/main/java/clock/socoolby/com/clock/CountDownActivity.java
deleted file mode 100644
index e325450..0000000
--- a/app/src/main/java/clock/socoolby/com/clock/CountDownActivity.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package clock.socoolby.com.clock;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Message;
-import android.view.MotionEvent;
-import android.view.View;
-
-public class CountDownActivity extends Activity implements Handler.Callback, View.OnClickListener, android.view.GestureDetector.OnGestureListener {
-
-
- @Override
- public boolean handleMessage(Message message) {
- return false;
- }
-
- @Override
- public boolean onDown(MotionEvent motionEvent) {
- return false;
- }
-
- @Override
- public void onShowPress(MotionEvent motionEvent) {
-
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent motionEvent) {
- return false;
- }
-
- @Override
- public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
- return false;
- }
-
- @Override
- public void onLongPress(MotionEvent motionEvent) {
-
- }
-
- @Override
- public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
- return false;
- }
-
- @Override
- public void onClick(View view) {
-
- }
-}
diff --git a/app/src/main/java/clock/socoolby/com/clock/CountingActivity.java b/app/src/main/java/clock/socoolby/com/clock/CountingActivity.java
deleted file mode 100644
index 483d165..0000000
--- a/app/src/main/java/clock/socoolby/com/clock/CountingActivity.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package clock.socoolby.com.clock;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.os.Message;
-import android.view.MotionEvent;
-import android.view.View;
-
-public class CountingActivity extends Activity implements Handler.Callback, View.OnClickListener, android.view.GestureDetector.OnGestureListener{
- @Override
- public boolean handleMessage(Message message) {
- return false;
- }
-
- @Override
- public boolean onDown(MotionEvent motionEvent) {
- return false;
- }
-
- @Override
- public void onShowPress(MotionEvent motionEvent) {
-
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent motionEvent) {
- return false;
- }
-
- @Override
- public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
- return false;
- }
-
- @Override
- public void onLongPress(MotionEvent motionEvent) {
-
- }
-
- @Override
- public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent1, float v, float v1) {
- return false;
- }
-
- @Override
- public void onClick(View view) {
-
- }
-}
diff --git a/app/src/main/java/clock/socoolby/com/clock/FontManager.java b/app/src/main/java/clock/socoolby/com/clock/FontManager.java
new file mode 100644
index 0000000..d05b4fc
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/FontManager.java
@@ -0,0 +1,148 @@
+package clock.socoolby.com.clock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import clock.socoolby.com.clock.dao.base.TimeFontStyle;
+
+public class FontManager {
+
+ private List fontStyleList;
+
+ private TimeFontStyle currentFontStyle;
+
+ private int currentFontIndex;
+
+ public FontManager() {
+ initTimeFontStyle();
+ currentFontIndex=0;
+ currentFontStyle=fontStyleList.get(currentFontIndex);
+ }
+
+ private void initTimeFontStyle(){
+ fontStyleList=new ArrayList<>();
+ fontStyleList.add(new TimeFontStyle("affair",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("agenda",140,150,160,180));
+
+ fontStyleList.add(new TimeFontStyle("cheapfire",140,150,160,180));
+ fontStyleList.add(new TimeFontStyle("cherif",80,100,110,140));
+ fontStyleList.add(new TimeFontStyle("Cigar Box Guitar",120,130,140,150));
+ fontStyleList.add(new TimeFontStyle("Ciung Wanara Sejati",110,120,130,150));
+
+
+ fontStyleList.add(new TimeFontStyle("DK Bergelmir",120,130,140,180));
+ fontStyleList.add(new TimeFontStyle("ds_digi",140,150,160,200));
+
+
+ fontStyleList.add(new TimeFontStyle("Funk",110,120,130,150));
+
+ fontStyleList.add(new TimeFontStyle("GLADYS Regular",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("Granite Rock St",110,120,130,170));
+ fontStyleList.add(new TimeFontStyle("GROOT",120,130,140,170));
+
+
+ fontStyleList.add(new TimeFontStyle("juleslove",110,120,130,150));
+
+ fontStyleList.add(new TimeFontStyle("Kingthings Annexx",110,120,150,180));
+ fontStyleList.add(new TimeFontStyle("Kingthings Willow",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("KYLE Regular",110,120,130,150));
+
+ fontStyleList.add(new TimeFontStyle("LCD-U",130,140,150,180));
+ fontStyleList.add(new TimeFontStyle("loong07龙书势如破竹简",110,120,150,170));
+
+ fontStyleList.add(new TimeFontStyle("MILKDROP",110,120,130,160));
+ fontStyleList.add(new TimeFontStyle("Mosaicleaf086",110,120,130,150));
+
+
+ fontStyleList.add(new TimeFontStyle("Pro Display tfb",130,140,150,170));
+
+ fontStyleList.add(new TimeFontStyle("SailingJunco",130,140,150,200));
+ fontStyleList.add(new TimeFontStyle("scoreboard",120,130,140,190));
+ fontStyleList.add(new TimeFontStyle("SFWasabi-Bold",110,120,130,140));
+ fontStyleList.add(new TimeFontStyle("Spaghettica",110,120,130,150));
+
+ fontStyleList.add(new TimeFontStyle("the_vandor_spot",140,150,160,210));
+
+ fontStyleList.add(new TimeFontStyle("Woodplank",120,130,140,180));
+ fontStyleList.add(new TimeFontStyle("Xtra Power",100,110,120,160));
+
+ fontStyleList.add(new TimeFontStyle("海报圆圆",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("爱心小兔",110,115,130,140));
+ fontStyleList.add(new TimeFontStyle("王漢宗海報體一半天水",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("立体铁山硬笔行楷简",120,130,140,180));
+ fontStyleList.add(new TimeFontStyle("腾祥倩心简",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("苏新诗毛糙体简",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("谁能许我扶桑花期",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("造字工房凌黑",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("中国龙新草体",110,120,130,150));
+ fontStyleList.add(new TimeFontStyle("迷你简剪纸_0",110,120,130,150));
+ }
+
+ public static final TimeFontStyle getDefaultFontSytle=new TimeFontStyle("ds_digi",140,150,160,200);
+
+ public int getCurrentFontSize(boolean isFullScreen,boolean isDisplaySecond){
+ int fontSize=currentFontStyle.displaySecond;
+ if(isFullScreen){
+ if(isDisplaySecond) {
+ fontSize=currentFontStyle.displaySecondOnFull;
+ }else{
+ fontSize=currentFontStyle.noDisplaySecondOnFull;
+ }
+ }else{
+ if(isDisplaySecond) {
+ fontSize=currentFontStyle.displaySecond;
+ }else{
+ fontSize=currentFontStyle.noDisplaySecond;
+ }
+ }
+ return fontSize;
+ }
+
+ public int getMaxFontSize(boolean isDisplaySecond){
+ int fontSize=currentFontStyle.displaySecond;
+ if(isDisplaySecond) {
+ fontSize=currentFontStyle.displaySecondOnFull;
+ }else{
+ fontSize=currentFontStyle.noDisplaySecondOnFull;
+ }
+ return fontSize;
+ }
+
+ public TimeFontStyle getCurrentFontStyle(){
+ return currentFontStyle;
+ }
+
+
+ public TimeFontStyle nextFont(){
+ if(currentFontIndex fontStyleList;
-
- private void initTimeFontStyle(){
- fontStyleList=new ArrayList<>();
- fontStyleList.add(new TimeFontStyle("affair",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("agenda",140,150,160,180));
-
- fontStyleList.add(new TimeFontStyle("cheapfire",140,150,160,180));
- fontStyleList.add(new TimeFontStyle("cherif",80,100,110,140));
- fontStyleList.add(new TimeFontStyle("Cigar Box Guitar",120,130,140,150));
- fontStyleList.add(new TimeFontStyle("Ciung Wanara Sejati",110,120,130,150));
-
-
- fontStyleList.add(new TimeFontStyle("DK Bergelmir",120,130,140,180));
- fontStyleList.add(new TimeFontStyle("ds_digi",140,150,160,200));
-
-
- fontStyleList.add(new TimeFontStyle("Funk",110,120,130,150));
-
- fontStyleList.add(new TimeFontStyle("GLADYS Regular",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("Granite Rock St",110,120,130,170));
- fontStyleList.add(new TimeFontStyle("GROOT",120,130,140,170));
-
-
- fontStyleList.add(new TimeFontStyle("juleslove",110,120,130,150));
-
- fontStyleList.add(new TimeFontStyle("Kingthings Annexx",110,120,150,180));
- fontStyleList.add(new TimeFontStyle("Kingthings Willow",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("KYLE Regular",110,120,130,150));
-
- fontStyleList.add(new TimeFontStyle("LCD-U",130,140,150,180));
- fontStyleList.add(new TimeFontStyle("loong07龙书势如破竹简",110,120,150,170));
-
- fontStyleList.add(new TimeFontStyle("MILKDROP",110,120,130,160));
- fontStyleList.add(new TimeFontStyle("Mosaicleaf086",110,120,130,150));
-
-
- fontStyleList.add(new TimeFontStyle("Pro Display tfb",130,140,150,170));
-
- fontStyleList.add(new TimeFontStyle("SailingJunco",130,140,150,200));
- fontStyleList.add(new TimeFontStyle("scoreboard",120,130,140,190));
- fontStyleList.add(new TimeFontStyle("SFWasabi-Bold",110,120,130,140));
- fontStyleList.add(new TimeFontStyle("Spaghettica",110,120,130,150));
-
- fontStyleList.add(new TimeFontStyle("the_vandor_spot",140,150,160,210));
-
- fontStyleList.add(new TimeFontStyle("Woodplank",120,130,140,180));
- fontStyleList.add(new TimeFontStyle("Xtra Power",100,110,120,160));
-
- fontStyleList.add(new TimeFontStyle("海报圆圆",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("爱心小兔",110,115,130,140));
- fontStyleList.add(new TimeFontStyle("王漢宗海報體一半天水",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("立体铁山硬笔行楷简",120,130,140,180));
- fontStyleList.add(new TimeFontStyle("腾祥倩心简",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("苏新诗毛糙体简",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("谁能许我扶桑花期",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("造字工房凌黑",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("中国龙新草体",110,120,130,150));
- fontStyleList.add(new TimeFontStyle("迷你简剪纸_0",110,120,130,150));
- }
-
- private void updateTimeFontSize(){
- setFontSize(getCurrentFontSize());
- }
-
- private int getCurrentFontSize(){
- TimeFontStyle fontStyle=fontStyleList.get(currentFontIndex);
- int fontSize=fontStyle.displaySecond;
- if(isFullScreen){
- if(model.isDisplaySecond()) {
- fontSize=fontStyle.displaySecondOnFull;
- }else{
- fontSize=fontStyle.noDisplaySecondOnFull;
- }
- }else{
- if(model.isDisplaySecond()) {
- fontSize=fontStyle.displaySecond;
- }else{
- fontSize=fontStyle.noDisplaySecond;
- }
- }
- return fontSize;
- }
-
- private int getMaxFontSize(){
- TimeFontStyle fontStyle=fontStyleList.get(currentFontIndex);
- int fontSize=fontStyle.displaySecond;
- if(model.isDisplaySecond()) {
- fontSize=fontStyle.displaySecondOnFull;
- }else{
- fontSize=fontStyle.noDisplaySecondOnFull;
- }
- return fontSize;
- }
-
- private int currentFontIndex =4;
-
- protected void setFont(int index){
- currentFontIndex =index;
- if(currentFontIndex >fontStyleList.size())
- currentFontIndex =4;
- TimeFontStyle fontStyle=fontStyleList.get(index);
- String timeString=tv_time.getText().toString();
- Log.d(TAG,"befor setFont text:"+timeString+"\t witch:"+tv_time.getWidth()+"\t height:"+tv_time.getHeight());
- Log.d(TAG,"setFont index:"+index+"/t name:"+fontStyle.name+".ttf/t ");
- FontUtils.getInstance().replaceFontFromAsset(tv_time,"fonts/"+fontStyle.name+".ttf");
- FontUtils.getInstance().replaceFontFromAsset(tv_date,"fonts/"+fontStyle.name+".ttf");
- updateTimeFontSize();
- Log.d(TAG,"after setFont text:"+tv_time.getText()+"\t witch:"+tv_time.getWidth()+"\t height:"+tv_time.getHeight());
- }
-
- private void setFontSize(int fontSize){
- tv_time.setTextSize(fontSize);
- }
-
-
- private DigitTextView tv_time;
- private TextView tv_date;
- private TextView tv_day;
- private TextView tv_weather;
- private AutoScrollTextView tv_descript;
- private ImageButton tv_setting;
- private ImageButton tv_handup;
- private TextView tv_handup_image;
-
- private TextView tv_hand_time;
- private boolean hand_time_visable=true;
-
- private Timer timer;
- private Handler handler;
- private final static int UPDATE_TIME = 100;
-
//背景动画
private AnimatorView animatorView;
@@ -269,59 +98,41 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
private final static int ANIMATOR_TEXTLED=80;
- //前景动画
- private AnimatorView clockView;
-
- private int currentClockAnimatorIndex=0;
-
- private ImageButton tv_hours_system;
- //颜色相关
- private ImageButton tv_background_color;
- private ImageButton tv_foreground_color;
- private ImageButton tv_foreground_color1;
+ private FrameLayout themeUIContainer;
//背景图相关
- private ImageButton tv_background_image_hand;
private ImageView tv_background_image;
private String imagePath=null;
- ColorPickerPop colorPickerDialog;
-
// 定义手势检测器实例
GestureDetector detector;
ScaleGestureDetector scaleGestureDetector;
private PowerManager.WakeLock wakeLock = null;
-
private SharePerferenceModel model;
private PowerManager.WakeLock localWakeLock = null;
- public int mMode = MODE_NORMAL;
- private int brightness = 0;
-
- private boolean handUpAbla=false;
- private int handUpTime=-1;
WeatherResponse weatherAdape;
- private boolean screenLock=false;
- private ImageButton tv_screen_lock;
+ private ClockTimeTypeEnum showTimeType=ClockTimeTypeEnum.TIME;
- private Integer backgroundColor;
- private Integer foregroundColor;
- private FrameLayout mainBackground;
+ private ClockStateMachine clockStateMachine;
- private ImageButton tv_break;
- private Date countingDateTimeBase =null;
+ Intent proximityServiceIntent=null;
+ FontManager fontManager;
- private ShowTimeType showTimeType=ShowTimeType.TIME;
+ GlobalViewModel globalViewModel;
+ DigitViewModel digitViewModel;
+ SimulateViewModel simulateViewModel;
+ ThemeUIViewModel themeUIViewModel;
+ AlterViewModel alterViewModel;
- public enum ShowTimeType{
- TIME,COUNTING_DOWN,COUNTING;
- }
+ AlterManager alterManager;
+ ThemeUIManager themeUIManager;
public void setWeather(WeatherResponse weather) {
if (weather == null)
@@ -329,34 +140,29 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
Log.d(TAG,"setWeather...");
this.weatherAdape= weather;
if (weather.getTodayWeather() != null)
- tv_weather.setText(weather.getTodayWeather().weather+"/"+weather.getTodayWeather().temperature);
+ themeUIViewModel.getWeatherDescription().setValue(weather.getTodayWeather().weather+"/"+weather.getTodayWeather().temperature);
}
- TimerTask timerTask;
+
@SuppressLint("InvalidWakeLockTag")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
//Log.d(TAG,"onCreate...");
+
setContentView(R.layout.activity_main);
- mainBackground=findViewById(R.id.main_background);
+ themeUIContainer = findViewById(R.id.main_background);
tv_background_image=findViewById(R.id.tv_background_image);
animatorView=findViewById(R.id.tv_background_animatorview);
- clockView=findViewById(R.id.tv_foreground_animatorview);
-
- tv_time = findViewById(R.id.tv_time);
- //tv_time.setOnClickListener(this);
-
- handler = new Handler(this);
-
- if(PermissionUtils.isGranted("android.permission.WAKE_LOCK","android.permission.DEVICE_POWER")) {
- PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE);
- wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK |powerManager.ON_AFTER_RELEASE, "Clock");
- localWakeLock = powerManager.newWakeLock(32, "MyPower");
- }else
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ if(PermissionUtils.isGranted("android.permission.WAKE_LOCK","android.permission.DEVICE_POWER")) {
+ PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE);
+ wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK |powerManager.ON_AFTER_RELEASE, "Clock");
+ localWakeLock = powerManager.newWakeLock(32, "MyPower");
+ }else
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//创建手势检测器
@@ -365,229 +171,18 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
scaleGestureDetector=new ScaleGestureDetector(this,this);
- init();
-
- switchThemeType(currentThemeTypeId);
-
- initUI();
ClockApplication.getInstance().setMainActivity(this);
- //Log.d(TAG,"create timer and timerTask.................................");
- timer = new Timer();
- timerTask = new TimerTask() {
- @Override
- public void run() {
- //Log.d(TAG, "timerTask move...");
- if (!ScreenManager.isScreenOn())
- return;
- handler.sendEmptyMessage(UPDATE_TIME);
- }
- };
- timer.schedule(timerTask, 1000, 1000);
- //ClockApplication.getInstance().getBusinessService().checkUpdate();
+ init();
+
+ //ClockApplication.valueOf().getBusinessService().checkUpdate();
}
- private int currentThemeTypeId=R.layout.theme_sample;
- private float themeBaseLine=0;
- private View themeRoot=null;
- private void switchThemeType(int themeType){
- currentThemeTypeId=themeType;
- switch (themeType){
- case R.layout.theme_sample:
- themeBaseLine=-110;
- break;
- default:
- themeBaseLine=0;
- }
- initTheme(this,themeType);
- currentDate=null;
- setWeather(weatherAdape);
- resetThemeUI();
+ public FrameLayout getThemeUIContainer() {
+ return themeUIContainer;
}
- private void initTheme(Context context, int themeType){
- if(themeRoot!=null) {
- themeRoot.setVisibility(View.GONE);
- mainBackground.removeView(themeRoot);
- }
- themeRoot = LayoutInflater.from(context).inflate(themeType,null,false);
- mainBackground.addView(themeRoot);
-
- tv_background_image_hand=themeRoot.findViewById(R.id.tv_background_image_hand);
- tv_background_image_hand.setOnClickListener(this);
- tv_background_image_hand.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- configBackGroundImage();
- return true;
- }
- });
-
- tv_date = themeRoot.findViewById(R.id.tv_date);
- tv_date.setOnClickListener(this);
- tv_date.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if(currentThemeTypeId==R.layout.theme_default)
- switchThemeType(R.layout.theme_sample);
- else
- switchThemeType(R.layout.theme_default);
- return true;
- }
- });
-
- tv_day = themeRoot.findViewById(R.id.tv_day);
- tv_day.setOnClickListener(this);
- tv_day.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if(screenLock)
- return true;
- model.setHourSystem12(!model.isHourSystem12());
- model.save();
- updateHourSystem();
- return true;
- }
- });
-
- tv_weather = themeRoot.findViewById(R.id.tv_weather);
- tv_weather.setOnClickListener(this);
- tv_descript = findViewById(R.id.tv_descript);
- tv_descript.setOnClickListener(this);
- tv_descript.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- changeBackGroundAnimator(ANIMATOR_TEXTLED);
- return true;
- }
- });
-
- tv_break=themeRoot.findViewById(R.id.tv_break);
- tv_break.setOnClickListener(this);
- tv_break.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if(handUpAbla){
- if(showTimeType==ShowTimeType.COUNTING_DOWN)
- setCurrentShowTimeType(ShowTimeType.TIME);
- else
- setCurrentShowTimeType(ShowTimeType.COUNTING_DOWN);
- }
- return true;
- }
- });
-
- tv_handup=themeRoot.findViewById(R.id.tv_hand);
- tv_handup.setOnClickListener(this);
- tv_handup.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- if(screenLock)
- return true;
- setupHandUpTime();
- return true;
- }
- });
- tv_hand_time=themeRoot.findViewById(R.id.tv_hand_time);
- tv_hand_time.setOnClickListener(this);
- tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- hand_time_visable=false;
- tv_hand_time.setVisibility(View.GONE);
- return true;
- }
- });
-
- tv_hours_system=themeRoot.findViewById(R.id.tv_hours_system);
-
- tv_background_color=themeRoot.findViewById(R.id.tv_background_color);
- tv_background_color.setOnClickListener(this);
-
- tv_foreground_color=themeRoot.findViewById(R.id.tv_foreground_color);
- tv_foreground_color.setOnClickListener(this);
- tv_foreground_color.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if(screenLock)
- return true;
- if (colorPickerDialog == null)
- colorPickerDialog = new ColorPickerPop(MainActivity.this);
-
- colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
- @Override
- public void onEnsure(int color) {
-
- model.setForegroundColor(color);
- model.save();
- setForegroundColor(color);
- tv_foreground_color.setColorFilter(color);
- }
-
- @Override
- public void onBack() {
- }
- });
- colorPickerDialog.show(model.getForegroundColor());
- return true;
- }
- });
-
- tv_foreground_color1=themeRoot.findViewById(R.id.tv_foreground_color1);
- tv_foreground_color1.setOnClickListener(this);
- tv_foreground_color1.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if(screenLock)
- return true;
- if (colorPickerDialog == null)
- colorPickerDialog = new ColorPickerPop(MainActivity.this);
-
- colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
- @Override
- public void onEnsure(int color) {
- model.setForegroundColor1(color);
- model.save();
- setForegroundColor(color);
- tv_foreground_color1.setColorFilter(color);
- animatorView.setColor(color);
- }
-
- @Override
- public void onBack() {
- }
- });
- colorPickerDialog.show(model.getForegroundColor1());
- return true;
- }
- });
-
- tv_handup_image=themeRoot.findViewById(R.id.tv_handup_image);
- tv_handup_image.setOnClickListener(this);
-
- tv_setting = themeRoot.findViewById(R.id.tv_setting);
- tv_setting.setOnClickListener(this);
-
- //RelativeLayout rel_main = (RelativeLayout) findViewById(R.id.rel_main);
- //rel_main.setOnClickListener(this);
-
- tv_screen_lock =themeRoot.findViewById(R.id.tv_screen_lock);
- tv_screen_lock.setOnClickListener(this);
- tv_screen_lock.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- if(mMode!=MODE_FULLSCREEN) {
- screenLock(true);
- switchMode(MODE_FULLSCREEN);
- return true;
- }
- return false;
- }
- });
- }
-
-
private boolean isPowerManagerDisable(){
return wakeLock==null;
}
@@ -596,7 +191,7 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
if(isPowerManagerDisable())
return;
try{
- if(screenLock){
+ if(isScreenLock()){
stopService(proximityServiceIntent);
}else {
if (model.isTriggerScreen()) {
@@ -618,58 +213,150 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
permissions,
reqCode);
}else {
- //Toast.makeText(this,"权限已申请",Toast.LENGTH_LONG).show();
+ Toast.makeText(this,"权限已申请",Toast.LENGTH_LONG).show();
}
}
}
- Intent proximityServiceIntent=null;
private void init() {
- model = new SharePerferenceModel();
- model.read();
- initTimeFontStyle();
+ model = ((ClockApplication)getApplication()).getModel();
+
Log.d(TAG, "init model:" + model.toString());
proximityServiceIntent = new Intent(this, ProximityService.class);
+
+ fontManager=new FontManager();
+ fontManager.setCurrentFontName(model.getFontName());
+
+ alterManager=new AlterManager(model.getStartHourPowerTime(),model.getStopHourPowerTime());
+
+ ViewModelFactory viewModelFactory=new ViewModelFactory(model,null);
+ globalViewModel= ViewModelProviders.of(MainActivity.this, viewModelFactory).get(GlobalViewModel.class);
+ digitViewModel= ViewModelProviders.of(MainActivity.this, viewModelFactory).get(DigitViewModel.class);
+ simulateViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(SimulateViewModel.class);
+ themeUIViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
+ alterViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
+
+ clockStateMachine=new ClockStateMachine(alterManager,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel);
+
setUpProximityService();
- brightness=getSystemBrightness();
- handUpAbla=model.isHandUpAble();
+ bindViewModel();
+
+ themeUIManager=new ThemeUIManager(this,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel);
+
+ digitViewModel.getTimeFontStyle().setValue(fontManager.getCurrentFontStyle());
+
+ clockStateMachine.start();
}
- private void initUI(){
- upHandStatic();
- resetHandUpTime();
- updateHourSystem();
- resetColorFromModel();
+ private void bindViewModel(){
+
+ globalViewModel.getClockInterfaceTypeEnum().observe(this, new Observer() {
+ @Override
+ public void onChanged(ClockInterfaceTypeEnum clockInterfaceTypeEnum) {
+ switch (clockInterfaceTypeEnum){
+ case Digit:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DigitClockFragment()).commit();
+ break;
+ case Simulate:
+ getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SimulateClockFragment()).commit();
+ break;
+ }
+ }
+ });
+
+ globalViewModel.getBackgroundImageVisable().observe(this, new Observer() {
+ @Override
+ public void onChanged(Boolean visible) {
+ tv_background_image.setVisibility(visible?View.VISIBLE:View.GONE);
+ }
+ });
+
+ globalViewModel.getBackgroundImageUri().observe(this, new Observer() {
+ @Override
+ public void onChanged(Uri uri) {
+ if(uri==null) {
+ tv_background_image.setVisibility(View.GONE);
+ return;
+ }
+ RequestOptions options = new RequestOptions();
+ options.centerCrop();
+ tv_background_image.setVisibility(View.VISIBLE);
+ Glide.with(MainActivity.this)
+ .load(uri.toString())
+ .apply(options)
+ .into(tv_background_image);
+ }
+ });
+
+ globalViewModel.getSrceenLock().observe(this, new Observer() {
+ @Override
+ public void onChanged(Boolean aBoolean) {
+ setUpProximityService();
+ }
+ });
+
+ globalViewModel.getBackgroundColor().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ setBackGroundColor(integer);
+ }
+ });
+
+ globalViewModel.getBackgroundAnimatorName().observe(this, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ changeBackGroundAnimator(s,globalViewModel.getBackgroundAnimatorRandomColor());
+ }
+ });
+
+ globalViewModel.getBackgroundAnimatorColor().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ changeBackGroudAnimatorColor(integer);
+ }
+ });
+
+ globalViewModel.getBrightness().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ changeAppBrightness(integer);
+ }
+ });
+
+ digitViewModel.getTimeFontStyle().observe(this, new Observer() {
+ @Override
+ public void onChanged(TimeFontStyle timeFontStyle) {
+ digitViewModel.setTimeFontStyleSize(fontManager.getCurrentFontSize(themeUIViewModel.getClockUITypeEnum().getValue()==FULLSCREEN,model.isDisplaySecond()));
+ }
+ });
+
+ themeUIViewModel.getClockUITypeEnum().observe(this, new Observer() {
+ @Override
+ public void onChanged(ClockThemeUITypeEnum clockThemeUITypeEnum) {
+ int fontSize=0;
+ boolean displaySecond=model.isDisplaySecond();
+ switch (clockThemeUITypeEnum){
+ case FULLSCREEN:
+ fontSize=fontManager.getCurrentFontSize(true,displaySecond);
+ break;
+ default:
+ fontSize=fontManager.getCurrentFontSize(false,displaySecond);
+ }
+ digitViewModel.setTimeFontStyleSize(fontSize);
+ }
+ });
+
+ digitViewModel.getDisplaySecond().observe(this, new Observer() {
+ @Override
+ public void onChanged(Boolean aBoolean) {
+ digitViewModel.setTimeFontStyleSize(fontManager.getCurrentFontSize(themeUIViewModel.getClockUITypeEnum().getValue()==FULLSCREEN,aBoolean));
+ }
+ });
}
- private void resetThemeUI(){
- setDiscriptForModel();
- setFont(model.getFontIndex()==null?0:model.getFontIndex());
- Integer backUp=foregroundColor;
- if(foregroundColor!=null) {
- foregroundColor=null;
- setForegroundColor(backUp);
- }
- }
-
- private void resetColorFromModel(){
- setBackGroundColor(model.getBackgroundColor());
- setForegroundColor(model.getForegroundColor());
- tv_foreground_color.setColorFilter(model.getForegroundColor());
- tv_foreground_color1.setColorFilter(model.getForegroundColor1());
- animatorView.setColor(model.getForegroundColor1());
- }
-
-
- private void updateHourSystem(){
- if(model.isHourSystem12())
- tv_hours_system.setVisibility(View.VISIBLE);
- else
- tv_hours_system.setVisibility(View.GONE);
- }
//将该Activity上的触碰事件交给GestureDetector处理
@Override
@@ -680,17 +367,12 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
return detector.onTouchEvent(me);
}
- @Override
- protected void onRestart() {
- super.onRestart();
- //Log.d(TAG,"onRestart...");
- }
@Override
public void onDestroy() {
//Log.i(TAG, "onDestroy....");
super.onDestroy();
- timer.cancel();
+ clockStateMachine.onDestory();
try {
if (model.isTriggerScreen())
stopService(proximityServiceIntent);
@@ -724,14 +406,12 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
if(backGroundAnimator!=null)
backGroundAnimator.stop();
}
-
- private String backGroundImagePath=null;
- private void configBackGroundImage(){
+
+ public void configBackGroundImage(){
PictureSelector.create(MainActivity.this)
.openGallery(PictureMimeType.ofImage())
.imageSpanCount(4)
.forResult(PictureConfig.CHOOSE_REQUEST);
-
}
@Override
@@ -748,15 +428,8 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
// 3.media.getCompressPath();为压缩后path,需判断media.isCompressed();是否为true 注意:音视频除外
// 如果裁剪并压缩了,以取压缩路径为准,因为是先裁剪后压缩的
- backGroundImagePath=selectList.get(0).getPath();
-
- RequestOptions options = new RequestOptions();
- options.centerCrop();
- tv_background_image.setVisibility(View.VISIBLE);
- Glide.with(MainActivity.this)
- .load(selectList.get(0).getPath())
- .apply(options)
- .into(tv_background_image);
+ globalViewModel.getBackgroundImageUri().setValue(Uri.parse(selectList.get(0).getPath()));
+ globalViewModel.getBackgroundImageVisable().setValue(true);
break;
case SETTING_REQUEST_CODE:
init();
@@ -765,242 +438,12 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
}
}
- protected void setForegroundColor(Integer color){
- if(foregroundColor!=null&&foregroundColor==color)
- return;
- foregroundColor=color;
- tv_time.setTextColor(color);
- tv_date.setTextColor(color);
- tv_day.setTextColor(color);
- tv_weather.setTextColor(color);
- tv_descript.setTextColor(color);
- tv_handup_image.setTextColor(color);
-
- tv_handup.setColorFilter(color);
- tv_screen_lock.setColorFilter(color);
- tv_setting.setColorFilter(color);
- tv_background_color.setColorFilter(color);
- tv_hand_time.setTextColor(color);
- tv_hours_system.setColorFilter(color);
- tv_background_image_hand.setColorFilter(color);
-
- tv_break.setColorFilter(color);
- }
-
protected void setBackGroundColor(Integer color){
- if(backgroundColor!=null&&backgroundColor==color)
+ if(null==color)
return;
- backgroundColor=color;
- mainBackground.setBackgroundColor(color);
+ themeUIContainer.setBackgroundColor(color);
}
- CalendarPopup calendarPopup;
- WeatherPopup weatherPopup;
- ParticleSmasher particleSmasher;
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- @Override
- public void onClick(View view) {
- if(screenLock&&view.getId()!=R.id.tv_screen_lock&&view.getId()!=R.id.tv_handup_image) {
- return;
- }
- switch (view.getId()) {
- case R.id.tv_setting:
- setup();
- break;
- case R.id.tv_hand:
- if(!handUpAbla&&handUpTime<0) {
- setupHandUpTime();
- }else{
- handUpAbla=!handUpAbla;
- saveData();
- upHandStatic();
- resetHandUpTime();
- switchMode(MODE_NORMAL);
- }
- break;
- case R.id.tv_hand_time:
- setupTempHandUpTime();
- break;
- case R.id.tv_handup_image:
- switchMode(MODE_NORMAL);
- break;
- case R.id.tv_day:
- model.setDisplaySecond(!model.isDisplaySecond());
- model.save();
- updateTimeFontSize();
- break;
- case R.id.tv_date:
- if( calendarPopup ==null)
- calendarPopup =new CalendarPopup(this);
- calendarPopup.showPopupWindow();
- calendarPopup.setCurrentDay();
- break;
- case R.id.tv_weather:
- if( weatherPopup ==null)
- weatherPopup =new WeatherPopup(this);
- weatherPopup.init(weatherAdape.getWeatherList(),model.getCity()+" PM2.5 : "+weatherAdape.getmPM25());
- weatherPopup.showPopupWindow();
- break;
- case R.id.tv_screen_lock:
- if(isFullScreen) {
- isArtificialHiddle=false;
- fullScreen(false);
- }
- screenLock(!screenLock);
- break;
- case R.id.tv_break:
- if(showTimeType!=ShowTimeType.COUNTING){
- setCurrentShowTimeType(ShowTimeType.COUNTING);
- }else{
- setCurrentShowTimeType(ShowTimeType.TIME);
- }
- break;
- case R.id.tv_descript:
- setDiscript(SettingActivity.roundAutoQuotes());
- break;
- case R.id.tv_background_color:
- if (colorPickerDialog == null)
- colorPickerDialog = new ColorPickerPop(MainActivity.this);
-
- colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
- @Override
- public void onEnsure(int color) {
- model.setBackgroundColor(color);
- model.save();
- setBackGroundColor(color);
- }
- @Override
- public void onBack() {
- }
- });
- colorPickerDialog.show(model.getBackgroundColor());
- break;
- case R.id.tv_background_image_hand:
- if(backGroundImagePath==null)
- configBackGroundImage();
- else
- tv_background_image.setVisibility(tv_background_image.getVisibility()==View.VISIBLE?View.GONE:View.VISIBLE);
- case R.id.tv_foreground_color:
- setForegroundColor(model.getForegroundColor());
- break;
- case R.id.tv_foreground_color1:
- setForegroundColor(model.getForegroundColor1());
- break;
- }
- }
-
- public void setCurrentShowTimeType(ShowTimeType type){
- switch (type){
- case COUNTING:
- countingDateTimeBase =new Date();
- }
- showTimeType=type;
- }
-
-
- public void screenLock(boolean locked){
- screenLock=locked;
- tv_screen_lock.setImageResource(screenLock?R.drawable.ic_screen_lock:R.drawable.ic_screen_unlock);
- setUpProximityService();
- }
-
- private int prevMode=MODE_NORMAL;
- private boolean isArtificialHiddle=false;
- private boolean isFullScreen=false;
- private void switchMode(int mode) {
- Log.d(TAG,"switch mode to:"+mode);
- switch (mode) {
- case MODE_FULLSCREEN:
- fullScreen(true);
- break;
- case MODE_NORMAL:
- if(isFullScreen){
- if(!isArtificialHiddle)
- tv_time.setVisibility(View.VISIBLE);
- tv_handup_image.setVisibility(View.GONE);
- }else {
- tv_time.setVisibility(View.VISIBLE);
- tv_handup_image.setVisibility(View.GONE);
- tv_setting.setVisibility(View.GONE);
- tv_background_color.setVisibility(View.GONE);
- tv_foreground_color.setVisibility(View.GONE);
- tv_foreground_color1.setVisibility(View.GONE);
- tv_background_image_hand.setVisibility(View.GONE);
- }
- break;
- case MODE_SETTING_OTHER:
- tv_time.setVisibility(View.VISIBLE);
- tv_handup_image.setVisibility(View.GONE);
- tv_setting.setVisibility(View.VISIBLE);
- tv_background_color.setVisibility(View.VISIBLE);
- tv_foreground_color.setVisibility(View.VISIBLE);
- tv_foreground_color1.setVisibility(View.VISIBLE);
- tv_background_image_hand.setVisibility(View.VISIBLE);
- break;
- case MODE_HANDUP:
- if(isFullScreen){
- tv_time.setVisibility(View.GONE);
- tv_handup_image.setVisibility(View.VISIBLE);
- }else {
- tv_time.setVisibility(View.GONE);
- tv_handup_image.setVisibility(View.VISIBLE);
- tv_setting.setVisibility(View.GONE);
- tv_background_color.setVisibility(View.GONE);
- tv_foreground_color.setVisibility(View.GONE);
- tv_foreground_color1.setVisibility(View.GONE);
- tv_background_image_hand.setVisibility(View.GONE);
- setDiscriptForModel();
- }
- }
- prevMode=mMode;
- mMode = mode;
- }
-
- private void fullScreen(boolean fullable){
- isFullScreen=fullable;
- if(fullable) {
- // @tudo 可对其时行位置移动
- //tv_time.setVisibility(View.GONE);
- tv_date.setVisibility(View.GONE);
- tv_day.setVisibility(View.GONE);
- tv_weather.setVisibility(View.GONE);
- tv_descript.setVisibility(View.GONE);
- tv_handup_image.setVisibility(View.GONE);
-
- tv_handup.setVisibility(View.GONE);
-
- tv_setting.setVisibility(View.GONE);
- tv_background_color.setVisibility(View.GONE);
- //tv_hand_time.setTextColor(color);
-
- tv_background_color.setVisibility(View.GONE);
- tv_foreground_color.setVisibility(View.GONE);
- tv_foreground_color1.setVisibility(View.GONE);
- tv_background_image_hand.setVisibility(View.GONE);
-
- tv_break.setVisibility(View.GONE);
- }else{
- if(clockView.isRunning()) {
- clockView.stop();
- }
- clockView.setVisibility(View.GONE);
- tv_time.setVisibility(View.VISIBLE);
- tv_date.setVisibility(View.VISIBLE);
- tv_day.setVisibility(View.VISIBLE);
- tv_weather.setVisibility(View.VISIBLE);
- tv_descript.setVisibility(View.VISIBLE);
- tv_handup_image.setVisibility(View.VISIBLE);
-
- tv_handup.setVisibility(View.VISIBLE);
- tv_break.setVisibility(View.VISIBLE);
-
- if(prevMode==MODE_HANDUP)
- switchMode(MODE_NORMAL);
- else
- switchMode(prevMode);
- }
- updateTimeFontSize();
- }
StarFallAnimator starAnimator;
SkyAnimator skyAnimator;
@@ -1024,6 +467,7 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
Wave3DAnimator wave3DAnimator;
MagicLineAnimator magicLineAnimator;
public void changeBackGroundAnimator(int index){
+ int foregroundColor=globalViewModel.getForegroundColor().getValue();
switch(index){
case 0:
if(starAnimator==null) {
@@ -1315,123 +759,24 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
animatorView.setAnimator(backGroundAnimator);
}
-
- ClockAnimator clockAnimator=null;
- //AbstractClock fullScreenClock;
- private void changeFullScreenClock(int index) {
- Log.d(TAG,"changeFullScreenClock index:"+index);
-
- clockAnimator = new ClockAnimator();
- clockAnimator.init(clockView.getContext(),clockView);
- clockAnimator.setColor(foregroundColor);
- if(index>5)
- currentClockAnimatorIndex=index=0;
-
- switch (index) {
- case 0:
- clockAnimator.setClock(new CircleClock());
- break;
- case 2:
- clockAnimator.setClock(new OvalClock());
- break;
- case 1:
- clockAnimator.setClock(new SquareClock());
- break;
- case 3:
- clockAnimator.setClock(new CircleTwoClock());
- break;
- case 4:
- clockAnimator.setClock(new HexagonalClock());
- break;
- case 5:
- clockAnimator.setClock(new HelixClock());
- break;
- default:
- currentClockAnimatorIndex=0;
- clockAnimator=null;
- }
- //currentClockAnimatorIndex=index;
- clockView.setAnimator(clockAnimator);
+ public void changeBackGroundAnimator(String animatorName,boolean randomColor){
+ currectAnimatorIndex=0;
+ backGroundAnimator= AnimatorFactory.build(animatorName);
+ if(backGroundAnimator!=null)
+ backGroundAnimator.setRandColor(randomColor);
+ animatorView.setAnimator(backGroundAnimator);
}
-
- private void upHandStatic(){
- if(handUpAbla) {
- this.tv_handup.setColorFilter(foregroundColor);
- //if(hand_time_visable)
- hand_time_visable=true;
- this.tv_hand_time.setVisibility(View.VISIBLE);
- }else{
- this.tv_handup.setColorFilter(R.color.colorPrimaryDark);
- this.tv_hand_time.setVisibility(View.GONE);
- if(showTimeType==ShowTimeType.COUNTING_DOWN)
- setCurrentShowTimeType(ShowTimeType.TIME);
- }
- }
-
- private void resetHandUpTime(){
- this.handUpTime = model.getHandUpTime();
- Log.d(TAG,"reset handUp time:"+handUpTime);
- setDiscriptForModel();
- }
-
- TimeSetupPopup handUpTimePopup;
-
- private void setupHandUpTime(){
- int saveHandUpTime=model.getHandUpTime();
- int hour=0;
- int minute=0;
- if(handUpTimePopup==null) {
- handUpTimePopup = new TimeSetupPopup(this);
- handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
- @Override
- public void onChanged(int hour, int minute) {
- model.setHandUpTime(hour*60+minute);
- handUpAbla=true;
- if(hour==0&&minute==0) {
- handUpAbla = false;
- model.setHandUpTime(-1);
- }
- saveData();
- resetHandUpTime();
- upHandStatic();
- }
- });
- }
- if(saveHandUpTime>0){
- hour=saveHandUpTime/60;
- minute=saveHandUpTime-hour*60;
- }
- handUpTimePopup.init(hour,minute);
- handUpTimePopup.showPopupWindow();
- }
-
- private void setupTempHandUpTime(){
- handUpAbla=false;
- int hour=0;
- int minute=0;
- if(handUpTimePopup==null) {
- handUpTimePopup = new TimeSetupPopup(this);
- handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
- @Override
- public void onChanged(int hour, int minute) {
- handUpTime=hour*60+minute;
- }
- });
- }
- hour=handUpTime/60;
- minute=handUpTime-hour*60;
- handUpTimePopup.init(hour,minute);
- handUpTimePopup.showPopupWindow();
- handUpAbla=true;
+ public void changeBackGroudAnimatorColor(int color){
+ animatorView.setColor(color);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if(screenLock)
+ if(isScreenLock())
return super.onKeyDown(keyCode, event);
if (keyCode == KeyEvent.KEYCODE_BACK) {
- switchMode(MODE_NORMAL);
+ themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.NORMAL);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
return true;
} else if (keyCode == KeyEvent.KEYCODE_MENU) {
@@ -1440,10 +785,10 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
return super.onKeyDown(keyCode, event);
}
- private void setup(){
+ public void setup(){
Intent intent = new Intent(this, SettingActivity.class);
startActivityForResult(intent, SETTING_REQUEST_CODE);
- switchMode(MODE_SETTING_OTHER);
+ //switchMode(MODE_SETTING_OTHER);
}
@Override
@@ -1451,186 +796,26 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
super.onWindowFocusChanged(hasFocus);
}
-
@Override
- public boolean handleMessage(Message msg) {
- switch (msg.what) {
- case UPDATE_TIME:
- updateTime();
- checkHandUp();
- break;
- }
- return true;
+ public void onPointerCaptureChanged(boolean hasCapture) {
+
}
- private int handUPDialy=60;
-
- private void checkHandUp(){
- if(!handUpAbla) {
- return;
- }
- //Log.d(TAG,"checkHandUp..\thandUPDialy:"+handUPDialy+" \thandUpTime:"+handUpTime+"\thandUpAble:"+handUpAbla);
- if(mMode==MODE_HANDUP) {
- tv_handup_image.setText("hand up:"+handUPDialy);
- handUPDialy--;
- if(handUPDialy==0) {
- switchMode(MODE_NORMAL);
- if(!isArtificialHiddle&&showTimeType==ShowTimeType.TIME){
- setCurrentShowTimeType(ShowTimeType.COUNTING);
- }
- }else
- Player.getInstance().playHandUp(this);
- return;
- }
- handUpTime--;
- if(hand_time_visable)
- tv_hand_time.setText(DateModel.getTime(handUpTime));
- if (handUpTime <= 10&&handUpTime > 0)
- setDiscript("提醒时间倒计时: " + handUpTime);
- if (handUpTime == 0) {
- handUPDialy = 60;
- resetHandUpTime();
- switchMode(MODE_HANDUP);
- }
+ private boolean isScreenLock(){
+ return globalViewModel.getSrceenLock().getValue();
}
-
- private void setCurrentTimeToView(String timeString){
- if(isArtificialHiddle)
- return;
- if(isFullScreen){
- tv_time.setBaseLineDown(0);
- }else{
- tv_time.setBaseLineDown(themeBaseLine+tv_day.getHeight()/2);
- }
- tv_time.setText(timeString);
+ private boolean isFullScreen(){
+ return themeUIViewModel.getClockUITypeEnum().getValue()== FULLSCREEN;
}
-
- boolean heartbeat=false;
- private void updateTime() {
- heartbeat=!heartbeat;
- DateModel date = new DateModel();
- String timeString=null;
- switch (showTimeType){
- case COUNTING:
- DateModel temp=new DateModel(countingDateTimeBase);
- timeString=temp.getTimeString(false);
- if (!model.isTickSound()&&mMode!=MODE_HANDUP) {
- Player.getInstance().playTick(this,R.raw.tick2);
- }
- break;
- case COUNTING_DOWN:
- timeString=DateModel.getTimeFull(handUpTime);
- break;
- default:
- timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
- break;
- }
- setCurrentTimeToView(timeString);
- reportTime(date);
- updateDay(date);
- updateHourSytemStyle(date);
- }
-
- int beforeHourForUpdateSystem=-1;
- private void updateHourSytemStyle(DateModel date){
- if(model.isHourSystem12()&&beforeHourForUpdateSystem!=date.getHour()) {
- beforeHourForUpdateSystem=date.getHour();
- tv_hours_system.setImageResource(beforeHourForUpdateSystem>12?R.drawable.ic_pm:R.drawable.ic_am);
- }
- }
-
- DateModel currentDate=null;
- private void updateDay(DateModel date){
- if(currentDate==null||currentDate.getDay()!=date.getDay()) {
- Log.d(TAG,"updateDay."+date);
- currentDate=date;
- String dayString = date.getToday();
- String dateString = date.getDateString();
- if( calendarPopup ==null)
- calendarPopup =new CalendarPopup(this);
- calendarPopup.setCurrentDay();
- String calendarFestival=calendarPopup.getCalendarFestival();
- if(calendarFestival!=null&&!calendarFestival.isEmpty())
- dayString=calendarFestival+" "+dayString;
- tv_day.setText(dayString);
- tv_date.setText(dateString);
- ClockApplication.getInstance().getBusinessService().getWeather(model.getCity());
- }
- }
-
- private void setDiscript(String disp){
- tv_descript.setText(disp);
- tv_descript.init(this,false);
- //tv_descript.startScroll();
- }
-
- private void setDiscriptForModel(){
- String dis=model.getDescription();
- if(dis==null||dis.isEmpty())
- dis=SettingActivity.roundFamousQuotes();
- setDiscript(dis);
- }
-
- private boolean isReport(int hour, int minute) {
-
- DateModel startTime = model.getStartHourPowerTime();
- DateModel stopTime = model.getStopHourPowerTime();
- DateModel nowTime = new DateModel();
- nowTime.setTime(hour, minute);
-
- if (startTime.getShortTimeString().equals(stopTime.getShortTimeString()))
- return true;
- long minutes = startTime.minusTime(stopTime);
- if (minutes < 0) {//stop>start
- if (nowTime.minusTime(startTime) >= 0 && nowTime.minusTime(stopTime) <= 0) {
- return false;
- }
- }
- return true;
- }
-
- private void reportTime(DateModel date) {
- if (model.isTickSound()&&mMode!=MODE_HANDUP) {
- Player.getInstance().playTick(this,R.raw.tick2);
- }
- int year = date.getYear();
- int month = date.getMonth();
- int day = date.getDay();
- int hour = date.getHour();
- int minute = date.getMinute();
- int second = date.getSecond();
- int today = date.getWeek();
-
- if (model.getTypeHourPower() != Constants.TALKING_NO_REPORT) {
- if ((minute == 30 || minute == 0) && model.getTypeHourPower() == Constants.TALKING_HALF_AN_HOUR && second == 0) {
- Log.d(TAG, String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today));
- if (isReport(hour, minute))
- Player.getInstance().reportTime(this, year, month, day, hour, minute, today);
- } else if (model.getTypeHourPower() == Constants.TALKING_HOURS && minute == 0 && second == 0) {
- if (isReport(hour, minute))
- Player.getInstance().reportTime(this, year, month, day, hour, minute, today);
- }
- }
- }
-
- private void saveData(){
- model.setFontIndex(currentFontIndex);
- model.setHandUpAble(handUpAbla);
- model.save();
- }
-
-
@Override
public boolean onDown(MotionEvent motionEvent) {
-
return false;
}
@Override
public void onShowPress(MotionEvent motionEvent) {
-
}
@Override
@@ -1643,90 +828,69 @@ public class MainActivity extends Activity implements Handler.Callback, View.OnC
return false;
}
-
@Override
public void onLongPress(MotionEvent motionEvent) {
- if(screenLock&&isFullScreen) {
- if(tv_time.getVisibility()==View.GONE) {
- changeFullScreenClock(-1);
- tv_time.setVisibility(View.VISIBLE);
- isArtificialHiddle=false;
- clockView.stop();
- clockView.setVisibility(View.GONE);
- return;
- }
- if(particleSmasher==null)
- particleSmasher=new ParticleSmasher(this);
- particleSmasher.with(tv_time).setDuration(1000).addAnimatorListener(new SmashAnimator.OnAnimatorListener() {
- @Override
- public void onAnimatorStart() {
- super.onAnimatorStart();
- // 回调,动画开始
- }
-
- @Override
- public void onAnimatorEnd() {
- super.onAnimatorEnd();
- // 回调,动画结束
- particleSmasher.reShowView(tv_time);
- tv_time.setVisibility(View.GONE);
- isArtificialHiddle=true;
- changeFullScreenClock(currentClockAnimatorIndex++);
- clockView.setVisibility(View.VISIBLE);
- clockView.start();
- }
- }).startRandomAnimator();
- }
- if(screenLock)
- return;
if(!isPowerManagerDisable())
localWakeLock.isHeld();
- if(mMode==MODE_SETTING_OTHER)
- switchMode(MODE_NORMAL);
- else
- switchMode(MODE_SETTING_OTHER);
+ switch (globalViewModel.getClockInterfaceTypeEnum().getValue()){
+ case Digit:
+ if(getCurrentThemeMode()== FULLSCREEN)
+ switchMode(ClockThemeUITypeEnum.NORMAL);
+ else if(getCurrentThemeMode()== SETTING)
+ switchMode(ClockThemeUITypeEnum.FULLSCREEN);
+ else
+ switchMode(SETTING);
+ break;
+ case Simulate:
+ if(getCurrentThemeMode()== SETTING)
+ switchMode(FULLSCREEN);
+ else
+ switchMode(SETTING);
+ break;
+ }
}
+ private void switchMode(ClockThemeUITypeEnum uiTypeEnum){
+ themeUIViewModel.setClockUITypeEnum(uiTypeEnum);
+ }
+
+ private ClockThemeUITypeEnum getCurrentThemeMode(){
+ return themeUIViewModel.getClockUITypeEnum().getValue();
+ }
+
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float v, float v1) {
- if(screenLock&&!isFullScreen)
+ if(isScreenLock()&&!isFullScreen())
return true;
Log.d(TAG,"onFling");
+ int brightness=globalViewModel.getBrightness().getValue();
if (e2.getY() - e1.getY() < -100) { // 从上至下
Log.d(TAG, "change brightness +10");
brightness = brightness + 10;
if (brightness >= 255){
- brightness=255;
Toast.makeText(this,"最大亮度了",Toast.LENGTH_SHORT).show();
return true;
}
- changeAppBrightness(brightness);
+ globalViewModel.getBrightness().setValue(brightness);
return true;
}else if (e2.getY() - e1.getY() >100) { // 从下至上
Log.d(TAG,"change brightness -10");
brightness=brightness-10;
if(brightness<=0) {
- brightness=1;
Toast.makeText(this,"最小亮度了",Toast.LENGTH_SHORT).show();
return true;
}
- changeAppBrightness(brightness);
+ globalViewModel.getBrightness().setValue(brightness);
return true;
}
if (e2.getX() - e1.getX() > 120) { // 从左向右滑动(左进右出)
Log.d(TAG,"left->right");
- if(isFullScreen&&isArtificialHiddle){
- changeFullScreenClock(currentClockAnimatorIndex++);
+ if(globalViewModel.getClockInterfaceTypeEnum().getValue()== ClockInterfaceTypeEnum.Simulate){
+ simulateViewModel.setClockTypeName(CircleTwoClock.TYPE_CIRCLE_TWO);
return true;
}
-
- if(currentFontIndex maxFontSize*1.3){
// currentFontSize=maxFontSize;
//}
//if(currentFontSize() {
+ @Override
+ public void onChanged(String s) {
+ switchThemeType(s);
+ }
+ });
+
+ themeUIViewModel.getClockUITypeEnum().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(ClockThemeUITypeEnum uiTypeEnum) {
+ switchMode(uiTypeEnum);
+ }
+ });
+
+ globalViewModel.getHourSystem12().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(Boolean aBoolean) {
+ tv_hours_system.setVisibility(aBoolean ? View.VISIBLE : View.GONE);
+ }
+ });
+
+ globalViewModel.getTime_hour().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ tv_hours_system.setImageResource(integer > 12 ? R.drawable.ic_pm : R.drawable.ic_am);
+ }
+ });
+
+ themeUIViewModel.getDescription().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ setDiscript(s);
+ }
+ });
+
+ globalViewModel.getForegroundColor().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ setForegroundColor(integer);
+ }
+ });
+
+ themeUIViewModel.getHand_time_visable().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(Boolean aBoolean) {
+ tv_hand_time.setVisibility(aBoolean ? View.VISIBLE : View.GONE);
+ }
+ });
+
+
+ themeUIViewModel.getWeatherDescription().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ tv_weather.setText(s);
+ }
+ });
+
+
+ themeUIViewModel.getWeekDescription().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ tv_date.setText(s);
+ }
+ });
+
+ themeUIViewModel.getDayDescription().observe(mainActivity, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ tv_day.setText(s);
+ }
+ });
+ }
+
+ int currentThemeTypeId = -1;
+
+ private void switchThemeType(String themeType) {
+ switch (themeType) {
+ case "sample":
+ //themeBaseLine=-110;
+ currentThemeTypeId = R.layout.theme_sample;
+ break;
+ default:
+ //themeBaseLine=0;
+ currentThemeTypeId = R.layout.theme_default;
+ }
+ initTheme(mainActivity, currentThemeTypeId);
+
+ setForegroundColor(globalViewModel.getForegroundColor().getValue());
+
+ setDiscriptForModel();
+
+ tv_weather.setText(themeUIViewModel.getWeatherDescription().getValue());
+
+ tv_date.setText(themeUIViewModel.getWeekDescription().getValue());
+
+ tv_day.setText(themeUIViewModel.getDayDescription().getValue());
+
+ updateHourSystem();
+
+ updateColorSettingButtunColor();
+
+ configThemeUITypeWithNoFullScreen();
+
+ autoFullScreenCheck();
+ }
+
+
+ private void updateColorSettingButtunColor(){
+ tv_foreground_color.setColorFilter(model.getForegroundColor());
+ tv_foreground_color1.setColorFilter(model.getForegroundColor1());
+ }
+
+ private void initTheme(final Context context, int themeType) {
+ if (themeRootView != null) {
+ themeRootView.setVisibility(View.GONE);
+ themeUIContainer.removeView(themeRootView);
+ }
+ themeRootView = LayoutInflater.from(context).inflate(themeType, null, false);
+ themeUIContainer.addView(themeRootView);
+
+ tv_background_image_hand = themeRootView.findViewById(R.id.tv_background_image_hand);
+ tv_background_image_hand.setOnClickListener(this);
+ tv_background_image_hand.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ mainActivity.configBackGroundImage();
+ return true;
+ }
+ });
+
+ tv_date = themeRootView.findViewById(R.id.tv_date);
+ tv_date.setOnClickListener(this);
+ tv_date.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (currentThemeTypeId == R.layout.theme_default)
+ switchThemeType("sample");
+ else
+ switchThemeType("default");
+ return true;
+ }
+ });
+
+ tv_day = themeRootView.findViewById(R.id.tv_day);
+ tv_day.setOnClickListener(this);
+ tv_day.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (isScreenLock())
+ return true;
+ model.setHourSystem12(!model.isHourSystem12());
+ updateHourSystem();
+ return true;
+ }
+ });
+
+ tv_weather = themeRootView.findViewById(R.id.tv_weather);
+ tv_weather.setOnClickListener(this);
+ tv_descript = themeRootView.findViewById(R.id.tv_descript);
+ tv_descript.setOnClickListener(this);
+ tv_descript.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ //changeBackGroundAnimator(ANIMATOR_TEXTLED);
+ return true;
+ }
+ });
+
+ tv_break = themeRootView.findViewById(R.id.tv_break);
+ tv_break.setOnClickListener(this);
+ tv_break.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ /*if(handUpAbla){
+ if(showTimeType==ShowTimeType.COUNTING_DOWN)
+ setCurrentShowTimeType(ShowTimeType.TIME);
+ else
+ setCurrentShowTimeType(ShowTimeType.COUNTING_DOWN);
+ }*/
+ return true;
+ }
+ });
+
+ tv_handup = themeRootView.findViewById(R.id.tv_hand);
+ tv_handup.setOnClickListener(this);
+ tv_handup.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ if (isScreenLock())
+ return true;
+ setupHandUpTime();
+ return true;
+ }
+ });
+ tv_hand_time = themeRootView.findViewById(R.id.tv_hand_time);
+ tv_hand_time.setOnClickListener(this);
+ tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ //hand_time_visable=false;
+ tv_hand_time.setVisibility(View.GONE);
+ return true;
+ }
+ });
+
+ tv_hours_system = themeRootView.findViewById(R.id.tv_hours_system);
+
+ tv_background_color = themeRootView.findViewById(R.id.tv_background_color);
+ tv_background_color.setOnClickListener(this);
+
+ tv_foreground_color = themeRootView.findViewById(R.id.tv_foreground_color);
+ tv_foreground_color.setOnClickListener(this);
+ tv_foreground_color.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (isScreenLock())
+ return true;
+ if (colorPickerDialog == null)
+ colorPickerDialog = new ColorPickerPop(mainActivity);
+
+ colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
+ @Override
+ public void onEnsure(int color) {
+ model.setForegroundColor(color);
+ globalViewModel.setForegroundColor(color);
+ tv_foreground_color.setColorFilter(color);
+ autoFullScreenCheck();
+ }
+
+ @Override
+ public void onBack() {
+ }
+ });
+ colorPickerDialog.show(model.getForegroundColor());
+ return true;
+ }
+ });
+
+ tv_foreground_color1 = themeRootView.findViewById(R.id.tv_foreground_color1);
+ tv_foreground_color1.setOnClickListener(this);
+ tv_foreground_color1.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if (isScreenLock())
+ return true;
+ if (colorPickerDialog == null)
+ colorPickerDialog = new ColorPickerPop(mainActivity);
+
+ colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
+ @Override
+ public void onEnsure(int color) {
+ model.setForegroundColor1(color);
+ globalViewModel.setForegroundColor(color);
+ tv_foreground_color1.setColorFilter(color);
+ autoFullScreenCheck();
+ }
+
+ @Override
+ public void onBack() {
+ }
+ });
+ colorPickerDialog.show(model.getForegroundColor1());
+ return true;
+ }
+ });
+
+ tv_clock_interface = themeRootView.findViewById(R.id.tv_clock_interface);
+ tv_clock_interface.setOnClickListener(this);
+
+
+ tv_setting = themeRootView.findViewById(R.id.tv_setting);
+ tv_setting.setOnClickListener(this);
+
+
+ tv_screen_lock = themeRootView.findViewById(R.id.tv_screen_lock);
+ tv_screen_lock.setOnClickListener(this);
+
+ /*tv_screen_lock.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ if(!isFullScreen()){
+ screenLock(true);
+ themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.FULLSCREEN);
+ return true;
+ }
+ return false;
+ }
+ });*/
+
+ tv_descript.init(mainActivity, false);
+ }
+
+ private boolean isScreenLock() {
+ return globalViewModel.getSrceenLock().getValue();
+ }
+
+ private boolean isHandUpAble() {
+ return globalViewModel.getHandUpAble().getValue();
+ }
+
+ private void updateHourSystem() {
+ if (model.isHourSystem12())
+ tv_hours_system.setVisibility(View.VISIBLE);
+ else
+ tv_hours_system.setVisibility(View.GONE);
+ }
+
+ //handUp
+ private void upHandStatic() {
+ /*if(handUpAbla) {
+ if(foregroundColor!=null)
+ this.tv_handup.setColorFilter(foregroundColor);
+ hand_time_visable=true;
+ this.tv_hand_time.setVisibility(View.VISIBLE);
+ }else{
+ this.tv_handup.setColorFilter(R.color.colorPrimaryDark);
+ this.tv_hand_time.setVisibility(View.GONE);
+ if(showTimeType==ShowTimeType.COUNTING_DOWN)
+ setCurrentShowTimeType(ShowTimeType.TIME);
+ }*/
+ }
+
+ private void setupHandUpTime() {
+ /*int saveHandUpTime=model.getHandUpTime();
+ int hour=0;
+ int minute=0;
+ if(handUpTimePopup==null) {
+ handUpTimePopup = new TimeSetupPopup(this);
+ handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
+ @Override
+ public void onChanged(int hour, int minute) {
+ model.setHandUpTime(hour*60+minute);
+ handUpAbla=true;
+ if(hour==0&&minute==0) {
+ handUpAbla = false;
+ model.setHandUpTime(-1);
+ }
+ saveData();
+ resetHandUpTime();
+ upHandStatic();
+ }
+ });
+ }
+ if(saveHandUpTime>0){
+ hour=saveHandUpTime/60;
+ minute=saveHandUpTime-hour*60;
+ }
+ handUpTimePopup.init(hour,minute);
+ handUpTimePopup.showPopupWindow();*/
+ }
+
+ private void setupTempHandUpTime() {
+ /*handUpAbla=false;
+ int hour=0;
+ int minute=0;
+ if(handUpTimePopup==null) {
+ handUpTimePopup = new TimeSetupPopup(this);
+ handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
+ @Override
+ public void onChanged(int hour, int minute) {
+ handUpTime=hour*60+minute;
+ }
+ });
+ }
+ hour=handUpTime/60;
+ minute=handUpTime-hour*60;
+ handUpTimePopup.init(hour,minute);
+ handUpTimePopup.showPopupWindow();
+ handUpAbla=true;*/
+ }
+
+ private void resetHandUpTime() {
+ /*this.handUpTime = model.getHandUpTime();
+ Log.d(TAG,"reset handUp time:"+handUpTime);
+ setDiscriptForModel();*/
+ }
+
+ //Discript
+ private void setDiscript(String disp) {
+ tv_descript.setText(disp);
+ tv_descript.startScrollIfAble();
+ }
+
+ private void setDiscriptForModel() {
+ String dis = model.getDescription();
+ if (dis == null || dis.isEmpty())
+ dis = SettingActivity.roundFamousQuotes();
+ setDiscript(dis);
+ }
+
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ @Override
+ public void onClick(View view) {
+ if (isScreenLock() && view.getId() != R.id.tv_screen_lock && view.getId() != R.id.tv_handup_image) {
+ return;
+ }
+ switch (view.getId()) {
+ case R.id.tv_setting:
+ mainActivity.setup();
+ break;
+ case R.id.tv_hand:
+ /*if(!handUpAbla&&handUpTime<0) {
+ setupHandUpTime();
+ }else{
+ handUpAbla=!handUpAbla;
+ upHandStatic();
+ resetHandUpTime();
+ switchMode(MODE_NORMAL);
+ }*/
+ break;
+ case R.id.tv_hand_time:
+ setupTempHandUpTime();
+ break;
+ case R.id.tv_day:
+ digitViewModel.setDisplaySecond(!model.isDisplaySecond());
+ break;
+ case R.id.tv_date:
+ if (calendarPopup == null)
+ calendarPopup = new CalendarPopup(mainActivity);
+ calendarPopup.showPopupWindow();
+ calendarPopup.setCurrentDay();
+ break;
+ case R.id.tv_weather:
+ if (weatherPopup == null)
+ weatherPopup = new WeatherPopup(mainActivity);
+ weatherPopup.init(mainActivity.weatherAdape.getWeatherList(), model.getCity() + " PM2.5 : " + mainActivity.weatherAdape.getmPM25());
+ weatherPopup.showPopupWindow();
+ break;
+ case R.id.tv_screen_lock:
+ /*if(isFullScreen()) {
+ configThemeUITypeWithNoFullScreen();
+ }*/
+ globalViewModel.setSrceenLock(!isScreenLock());
+ screenLock(!isScreenLock());
+ break;
+ case R.id.tv_break:
+ /*if(showTimeType!= ClockTimeTypeEnum.COUNTING){
+ setCurrentShowTimeType(ClockTimeTypeEnum.COUNTING);
+ }else{
+ setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
+ }*/
+ break;
+ case R.id.tv_descript:
+ setDiscript(SettingActivity.roundAutoQuotes());
+ break;
+ case R.id.tv_background_color:
+ if (colorPickerDialog == null)
+ colorPickerDialog = new ColorPickerPop(mainActivity);
+
+ colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
+ @Override
+ public void onEnsure(int color) {
+ globalViewModel.setBackgroundColor(color);
+ }
+
+ @Override
+ public void onBack() {
+ }
+ });
+ colorPickerDialog.show(model.getBackgroundColor());
+ break;
+ case R.id.tv_background_image_hand:
+ if (globalViewModel.getBackgroundImageUri().getValue() == null)
+ mainActivity.configBackGroundImage();
+ else
+ globalViewModel.setBackgroundImageVisable(!globalViewModel.getBackgroundImageVisable().getValue());
+ break;
+ case R.id.tv_foreground_color:
+ globalViewModel.setForegroundColor(model.getForegroundColor());
+ break;
+ case R.id.tv_foreground_color1:
+ globalViewModel.setForegroundColor(model.getForegroundColor1());
+ break;
+ case R.id.tv_clock_interface:
+ changeClockInterface();
+ break;
+ }
+ autoFullScreenCheck();
+ }
+
+
+ protected void changeClockInterface() {
+ ClockInterfaceTypeEnum currentClockInterface = globalViewModel.getClockInterfaceTypeEnum().getValue();
+ switch (currentClockInterface) {
+ case Digit:
+ currentClockInterface = ClockInterfaceTypeEnum.Simulate;
+ break;
+ default:
+ currentClockInterface = ClockInterfaceTypeEnum.Digit;
+ }
+ globalViewModel.setClockInterfaceTypeEnum(currentClockInterface);
+ }
+
+ protected void setForegroundColor(Integer color) {
+ tv_date.setTextColor(color);
+ tv_day.setTextColor(color);
+ tv_weather.setTextColor(color);
+ tv_descript.setTextColor(color);
+
+ tv_handup.setColorFilter(color);
+ tv_screen_lock.setColorFilter(color);
+ tv_setting.setColorFilter(color);
+ tv_background_color.setColorFilter(color);
+ tv_hand_time.setTextColor(color);
+ tv_hours_system.setColorFilter(color);
+ tv_background_image_hand.setColorFilter(color);
+
+ tv_break.setColorFilter(color);
+
+ tv_clock_interface.setColorFilter(color);
+ }
+
+
+ private void switchMode(ClockThemeUITypeEnum mode) {
+ Log.d(TAG, "switch mode to:" + mode);
+ switch (mode) {
+ case FULLSCREEN:
+ tv_date.setVisibility(View.GONE);
+ tv_day.setVisibility(View.GONE);
+ tv_weather.setVisibility(View.GONE);
+ tv_descript.setVisibility(View.GONE);
+
+ tv_handup.setVisibility(View.GONE);
+
+ tv_setting.setVisibility(View.GONE);
+ tv_background_color.setVisibility(View.GONE);
+
+ tv_background_color.setVisibility(View.GONE);
+ tv_foreground_color.setVisibility(View.GONE);
+ tv_foreground_color1.setVisibility(View.GONE);
+ tv_background_image_hand.setVisibility(View.GONE);
+
+ tv_break.setVisibility(View.GONE);
+
+ tv_clock_interface.setVisibility(View.GONE);
+
+ tv_screen_lock.setVisibility(View.GONE);
+ break;
+ case NORMAL:
+ tv_date.setVisibility(View.VISIBLE);
+ tv_day.setVisibility(View.VISIBLE);
+ tv_weather.setVisibility(View.VISIBLE);
+ tv_descript.setVisibility(View.VISIBLE);
+
+ tv_handup.setVisibility(View.VISIBLE);
+ tv_break.setVisibility(View.VISIBLE);
+
+ tv_setting.setVisibility(View.GONE);
+ tv_background_color.setVisibility(View.GONE);
+ tv_foreground_color.setVisibility(View.GONE);
+ tv_foreground_color1.setVisibility(View.GONE);
+ tv_background_image_hand.setVisibility(View.GONE);
+
+ tv_clock_interface.setVisibility(View.GONE);
+
+ tv_screen_lock.setVisibility(View.VISIBLE);
+ break;
+ case SETTING:
+ tv_date.setVisibility(View.VISIBLE);
+ tv_day.setVisibility(View.VISIBLE);
+ tv_weather.setVisibility(View.VISIBLE);
+ tv_descript.setVisibility(View.VISIBLE);
+
+ tv_handup.setVisibility(View.VISIBLE);
+ tv_break.setVisibility(View.VISIBLE);
+
+ tv_setting.setVisibility(View.VISIBLE);
+ tv_background_color.setVisibility(View.VISIBLE);
+ tv_foreground_color.setVisibility(View.VISIBLE);
+ tv_foreground_color1.setVisibility(View.VISIBLE);
+ tv_background_image_hand.setVisibility(View.VISIBLE);
+
+ tv_clock_interface.setVisibility(View.VISIBLE);
+
+ tv_screen_lock.setVisibility(View.VISIBLE);
+ break;
+ }
+ }
+
+
+ private boolean isFullScreen(){
+ return themeUIViewModel.getClockUITypeEnum().getValue()==ClockThemeUITypeEnum.FULLSCREEN;
+ }
+
+ public void configThemeUITypeWithNoFullScreen(){
+ if(globalViewModel.getClockInterfaceTypeEnum().getValue()==ClockInterfaceTypeEnum.Digit)
+ themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.NORMAL);
+ else
+ themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.SETTING);
+ }
+
+ protected void reflushFontStyle(TimeFontStyle fontStyle) {
+ FontUtils.getInstance().replaceFontFromAsset(tv_date, "fonts/" + fontStyle.name + ".ttf");
+ }
+
+ public void screenLock(boolean locked) {
+ tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/alter/AlterManager.java b/app/src/main/java/clock/socoolby/com/clock/alter/AlterManager.java
new file mode 100644
index 0000000..4da1f8d
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/alter/AlterManager.java
@@ -0,0 +1,28 @@
+package clock.socoolby.com.clock.alter;
+
+import clock.socoolby.com.clock.model.DateModel;
+
+public class AlterManager {
+ DateModel startTime;
+ DateModel stopTime;
+
+ public AlterManager(DateModel startTime, DateModel stopTime) {
+ this.startTime = startTime;
+ this.stopTime = stopTime;
+ }
+
+ public boolean isReport(int hour, int minute) {
+ DateModel nowTime = new DateModel();
+ nowTime.setTime(hour, minute);
+
+ if (startTime.getShortTimeString().equals(stopTime.getShortTimeString()))
+ return true;
+ long minutes = startTime.minusTime(stopTime);
+ if (minutes < 0) {//stop>start
+ if (nowTime.minusTime(startTime) >= 0 && nowTime.minusTime(stopTime) <= 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntry.java b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntry.java
new file mode 100644
index 0000000..45ed5e8
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntry.java
@@ -0,0 +1,6 @@
+package clock.socoolby.com.clock.dao.alter;
+
+public class AlterEntry {
+ String name;
+ int type;
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryDao.java
new file mode 100644
index 0000000..f9e81c0
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.alter;
+
+public class AlterEntryDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryHistory.java b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryHistory.java
new file mode 100644
index 0000000..494c9ee
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryHistory.java
@@ -0,0 +1,9 @@
+package clock.socoolby.com.clock.dao.alter;
+
+import java.util.Date;
+
+public class AlterEntryHistory {
+ String alterEntryId;
+ Date startTime;
+ Date endTime;
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryHistoryDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryHistoryDao.java
new file mode 100644
index 0000000..ec55a55
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/alter/AlterEntryHistoryDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.alter;
+
+public class AlterEntryHistoryDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/base/TimeFontStyle.java b/app/src/main/java/clock/socoolby/com/clock/dao/base/TimeFontStyle.java
new file mode 100644
index 0000000..2b1c7a1
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/base/TimeFontStyle.java
@@ -0,0 +1,27 @@
+package clock.socoolby.com.clock.dao.base;
+
+public class TimeFontStyle {
+ public String name;
+ public int displaySecond;
+ public int noDisplaySecond;
+ public int displaySecondOnFull;
+ public int noDisplaySecondOnFull;
+ public float secondScale;
+
+ public TimeFontStyle(String name, int displaySecond, int noDisplaySecond) {
+ this(name,displaySecond,noDisplaySecond,displaySecond,noDisplaySecond);
+ }
+
+ public TimeFontStyle(String name, int displaySecond, int noDisplaySecond, int displaySecondOnFull, int noDisplaySecondOnFull) {
+ this(name,displaySecond,noDisplaySecond,displaySecondOnFull,noDisplaySecondOnFull,1/2);
+ }
+
+ public TimeFontStyle(String name, int displaySecond, int noDisplaySecond, int displaySecondOnFull, int noDisplaySecondOnFull, float second) {
+ this.name = name;
+ this.displaySecond = displaySecond;
+ this.noDisplaySecond = noDisplaySecond;
+ this.displaySecondOnFull = displaySecondOnFull;
+ this.noDisplaySecondOnFull = noDisplaySecondOnFull;
+ this.secondScale = second;
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/base/TimeFontStyleDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/base/TimeFontStyleDao.java
new file mode 100644
index 0000000..3a6b5fe
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/base/TimeFontStyleDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.base;
+
+public class TimeFontStyleDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/base/UITheme.java b/app/src/main/java/clock/socoolby/com/clock/dao/base/UITheme.java
new file mode 100644
index 0000000..f82e277
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/base/UITheme.java
@@ -0,0 +1,6 @@
+package clock.socoolby.com.clock.dao.base;
+
+public class UITheme {
+ String name;
+ String jsonString;
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/base/UIThemeDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/base/UIThemeDao.java
new file mode 100644
index 0000000..73e40c9
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/base/UIThemeDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.base;
+
+public class UIThemeDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntry.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntry.java
new file mode 100644
index 0000000..82f050f
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntry.java
@@ -0,0 +1,10 @@
+package clock.socoolby.com.clock.dao.work;
+
+public class WorkEntry {
+ public String name;
+ public int longTime;
+ public String ringUrl;
+ public int dailyTime=0;
+
+
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryDao.java
new file mode 100644
index 0000000..1e04d55
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.work;
+
+public class WorkEntryDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryHistory.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryHistory.java
new file mode 100644
index 0000000..ee55d73
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryHistory.java
@@ -0,0 +1,12 @@
+package clock.socoolby.com.clock.dao.work;
+
+import java.util.Date;
+
+public class WorkEntryHistory {
+ String alterRuleHostoryId;
+ String alterEntryId;
+ Date startTime;
+ Date stopTime;
+ Date endTime;
+ Date outTime;
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryHistoryDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryHistoryDao.java
new file mode 100644
index 0000000..d4ec540
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkEntryHistoryDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.work;
+
+public class WorkEntryHistoryDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRule.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRule.java
new file mode 100644
index 0000000..cc39baa
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRule.java
@@ -0,0 +1,18 @@
+package clock.socoolby.com.clock.dao.work;
+
+import java.util.Date;
+import java.util.List;
+
+
+public class WorkRule {
+ WorkEntry currentEntry;
+ List entryList;
+
+ public String name;
+
+ public int ruleLoopType;//这是一个组合
+
+ public Date alterDateTime;//只有LoopType为指定时间时有效
+
+
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleDao.java
new file mode 100644
index 0000000..bdbc5c5
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.work;
+
+public class WorkRuleDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleHistory.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleHistory.java
new file mode 100644
index 0000000..0ea49b9
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleHistory.java
@@ -0,0 +1,12 @@
+package clock.socoolby.com.clock.dao.work;
+
+import java.util.Date;
+
+public class WorkRuleHistory {
+ Date startTime;
+ boolean filash;
+ long entryTimeTotal;
+ long dailyTimeTotal;
+ long outTimeTotal;
+
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleHistoryDao.java b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleHistoryDao.java
new file mode 100644
index 0000000..4d12d60
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/dao/work/WorkRuleHistoryDao.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.dao.work;
+
+public class WorkRuleHistoryDao {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/db/WorkClockDatabase.java b/app/src/main/java/clock/socoolby/com/clock/db/WorkClockDatabase.java
new file mode 100644
index 0000000..09c6e6a
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/db/WorkClockDatabase.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.db;
+
+public class WorkClockDatabase {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/AlterFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/AlterFragment.java
new file mode 100644
index 0000000..fe0b830
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/fragment/AlterFragment.java
@@ -0,0 +1,82 @@
+package clock.socoolby.com.clock.fragment;
+
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import clock.socoolby.com.clock.ClockApplication;
+import clock.socoolby.com.clock.R;
+import clock.socoolby.com.clock.state.ClockModeEnum;
+import clock.socoolby.com.clock.viewmodel.AlterViewModel;
+import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
+import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Use the {@link AlterFragment} factory method to
+ * create an instance of this fragment.
+ */
+public class AlterFragment extends Fragment {
+
+ GlobalViewModel globalViewModel;
+ AlterViewModel alterViewModel;
+
+ private TextView tv_handup_text;
+
+ public AlterFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(GlobalViewModel.class);
+ alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(AlterViewModel.class);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view=inflater.inflate(R.layout.fragment_alter, container, false);
+ tv_handup_text=view.findViewById(R.id.tv_handup_image);
+ tv_handup_text.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ endHandUp(true);
+ }
+ });
+ bindViewModel();
+ return view;
+ }
+
+ private void bindViewModel(){
+ alterViewModel.getHandUpDescription().observe(this, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ tv_handup_text.setText(s);
+ }
+ });
+
+ globalViewModel.getHandUpTime().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer time) {
+ if(time==0)
+ endHandUp(false);
+ }
+ });
+ }
+
+ private void endHandUp(boolean userCheck){
+ globalViewModel.getClockModeEnum().setValue(ClockModeEnum.NORMAL);
+ }
+
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/DigitClockFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/DigitClockFragment.java
new file mode 100644
index 0000000..aa351a8
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/fragment/DigitClockFragment.java
@@ -0,0 +1,153 @@
+package clock.socoolby.com.clock.fragment;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import clock.socoolby.com.clock.ClockApplication;
+import clock.socoolby.com.clock.R;
+import clock.socoolby.com.clock.dao.base.TimeFontStyle;
+import clock.socoolby.com.clock.utils.FontUtils;
+import clock.socoolby.com.clock.viewmodel.DigitViewModel;
+import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
+import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
+import clock.socoolby.com.clock.widget.textview.DigitTextView;
+import clock.socoolby.com.clock.widget.textview.ShadowTypeEnum;
+import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * to handle interaction events.
+ * create an instance of this fragment.
+ */
+public class DigitClockFragment extends Fragment {
+
+ public DigitClockFragment() {
+ // Required empty public constructor
+ }
+
+ DigitViewModel digitViewModel;
+ GlobalViewModel globalViewModel;
+
+ private DigitTextView tv_time;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ digitViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(DigitViewModel.class);
+ globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(GlobalViewModel.class);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view=inflater.inflate(R.layout.fragment_digit_clock, container, false);
+ tv_time=view.findViewById(R.id.tv_time);
+ bindViewModel();
+ return view;
+ }
+
+ private void bindViewModel(){
+ digitViewModel.getTimeFontStyle().observe(this, new Observer() {
+ @Override
+ public void onChanged(TimeFontStyle timeFontStyle) {
+ reflushFontStyle(timeFontStyle);
+ }
+ });
+
+ digitViewModel.getTimeFontStyleSize().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ setFontSize(integer);
+ }
+ });
+
+ digitViewModel.getBaseLineDown().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ tv_time.setBaseLineDown(integer);
+ }
+ });
+
+ digitViewModel.getLinearGradientAble().observe(this, new Observer() {
+ @Override
+ public void onChanged(Boolean aBoolean) {
+ tv_time.setLinearGradientAble(aBoolean);
+ }
+ });
+
+ digitViewModel.getTimeLinearGradientColorsArray().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer[] integers) {
+ if(integers==null) {
+ tv_time.setLinearGradientAble(false);
+ return;
+ }
+ int[] toInts=new int[integers.length];
+ for(int i=0;i() {
+ @Override
+ public void onChanged(Boolean aBoolean) {
+ tv_time.setReflectedAble(aBoolean);
+ }
+ });
+
+ digitViewModel.getShadowType().observe(this, new Observer() {
+ @Override
+ public void onChanged(ShadowTypeEnum shadowTypeEnum) {
+ tv_time.setShadowType(shadowTypeEnum);
+ }
+ });
+
+ digitViewModel.getTimeText().observe(this, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ tv_time.setText(s);
+ }
+ });
+
+ digitViewModel.getTimeCharAnimatorType().observe(this, new Observer() {
+ @Override
+ public void onChanged(CharAnimatorEnum charAnimatorEnum) {
+ tv_time.setCurrentCharAnimatorType(charAnimatorEnum);
+ }
+ });
+
+ globalViewModel.getForegroundColor().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ tv_time.setTextColor(integer);
+ }
+ });
+ }
+
+ private void updateBaseLine(boolean isFullScreen){
+ if(isFullScreen){
+ tv_time.setBaseLineDown(0);
+ }else{
+ //tv_time.setBaseLineDown(themeBaseLine+tv_day.getHeight()/2);
+ tv_time.setBaseLineDown(digitViewModel.getBaseLineDown().getValue()+30);
+ }
+ }
+
+
+ protected void reflushFontStyle(TimeFontStyle fontStyle){
+ FontUtils.getInstance().replaceFontFromAsset(tv_time,"fonts/"+fontStyle.name+".ttf");
+ }
+
+ private void setFontSize(int fontSize){
+ tv_time.setTextSize(fontSize);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/SimulateClockFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/SimulateClockFragment.java
new file mode 100644
index 0000000..d1faa63
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/fragment/SimulateClockFragment.java
@@ -0,0 +1,150 @@
+package clock.socoolby.com.clock.fragment;
+
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.Observer;
+import androidx.lifecycle.ViewModelProviders;
+
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import clock.socoolby.com.clock.ClockApplication;
+import clock.socoolby.com.clock.R;
+import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
+import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
+import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
+import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
+import clock.socoolby.com.clock.widget.animatorview.animator.ClockAnimator;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.AbstractClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.CircleClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.CircleTwoClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.ClockFactory;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.HelixClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.HexagonalClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.OvalClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.SquareClock;
+import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.PointerFactory;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * to handle interaction events.
+ * create an instance of this fragment.
+ */
+public class SimulateClockFragment extends Fragment {
+ public static final String TAG=SimulateClockFragment.class.getSimpleName();
+
+ SimulateViewModel simulateViewModel;
+ GlobalViewModel globalViewModel;
+
+ AnimatorView clockView;
+
+ public SimulateClockFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ clockAnimator = new ClockAnimator();
+ simulateViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(SimulateViewModel.class);
+ globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(GlobalViewModel.class);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view=inflater.inflate(R.layout.fragment_simulate_clock, container, false);
+ clockView=view.findViewById(R.id.tv_foreground_animatorview);
+ clockAnimator.init(clockView.getContext(),clockView);
+ clockView.setAnimator(clockAnimator);
+ bindViewModel();
+ return view;
+ }
+
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if(clockAnimator!=null){
+ clockAnimator.start();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if(clockAnimator!=null){
+ clockAnimator.stop();
+ }
+ }
+
+ private void bindViewModel(){
+ simulateViewModel.getClockTypeName().observe(this, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ setClockStyle(s);
+ }
+ });
+
+ simulateViewModel.getPointerTypeName().observe(this, new Observer() {
+ @Override
+ public void onChanged(String s) {
+ setClockPointer(s);
+ }
+ });
+
+ globalViewModel.getForegroundColor().observe(this, new Observer() {
+ @Override
+ public void onChanged(Integer integer) {
+ clockAnimator.setColor(integer);
+ }
+ });
+ }
+
+ ClockAnimator clockAnimator=null;
+ private void changeFullScreenClock(int index) {
+ Log.d(TAG,"changeFullScreenClock index:"+index);
+
+ clockAnimator.setColor(globalViewModel.getForegroundColor().getValue());
+
+ switch (index) {
+ case 1:
+ clockAnimator.setClock(new SquareClock());
+ break;
+ case 2:
+ clockAnimator.setClock(new OvalClock());
+ break;
+ case 3:
+ clockAnimator.setClock(new CircleTwoClock());
+ break;
+ case 4:
+ clockAnimator.setClock(new HexagonalClock());
+ break;
+ case 5:
+ clockAnimator.setClock(new HelixClock());
+ break;
+ default:
+ clockAnimator.setClock(new CircleClock());
+ }
+ clockView.setAnimator(clockAnimator);
+ }
+
+ private void setFullScreenClock(String clockStyle,String pointerStyle){
+ setClockStyle(clockStyle);
+ setClockPointer(pointerStyle);
+ }
+
+ private void setClockStyle(String clockStyle){
+ clockAnimator.setColor(globalViewModel.getForegroundColor().getValue());
+ AbstractClock clock= ClockFactory.build(clockStyle);
+ clockAnimator.setClock(clock);
+ }
+
+ private void setClockPointer(String clockPointerStyle){
+ clockAnimator.setClockPointer(PointerFactory.build(clockPointerStyle));
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java b/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java
index 9936765..7fab293 100755
--- a/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java
+++ b/app/src/main/java/clock/socoolby/com/clock/model/SharePerferenceModel.java
@@ -7,12 +7,18 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.Serializable;
+import java.util.Timer;
+import java.util.TimerTask;
+
import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.Constants;
import clock.socoolby.com.clock.R;
import clock.socoolby.com.clock.utils.FileUtils;
public class SharePerferenceModel implements Serializable {
+
+ private boolean dirty=false;
+
protected int typeHourPower = Constants.TALKING_HALF_AN_HOUR;
protected final static String KEY_TYPE_HOUR_POWER = "key_type_hour_power";
@@ -21,11 +27,11 @@ public class SharePerferenceModel implements Serializable {
protected DateModel stopHourPowerTime = null;
protected final static String KEY_STOP_POWER = "key_stop_power";
- protected boolean isDisplaySecond = true;
+ protected boolean displaySecond = true;
protected final static String KEY_IS_DISPLAY_SECOND = "key_is_display_second";
- protected boolean isTickSound = false;
+ protected boolean tickSound = false;
protected final static String KEY_IS_TICK_SOUND = "key_is_tick_sound";
- protected boolean isTriggerScreen = true;
+ protected boolean triggerScreen = true;
protected final static String KEY_IS_TRIGGER_SCREEN = "key_is_trigger_screen";
protected boolean hourSystem12 = false;
@@ -38,8 +44,6 @@ public class SharePerferenceModel implements Serializable {
protected final static String KEY_DESCRPTION = "key_description";
protected String mDescription;
- protected final static String KEY_FONT_INDEX = "key_font_index";
- protected Integer fontIndex;
protected final static String KEY_DISPLAYVIEW_TIME = "key_displayview_time";
protected final static String KEY_DISPLAYVIEW_DATE = "key_dsplayview_date";
@@ -58,21 +62,104 @@ public class SharePerferenceModel implements Serializable {
protected final static String KEY_IS_HANDUP_ABLE="key_is_handup_able";
protected boolean handUpAble = false;
+ protected final static String KEY_HANDUP_MUSIC ="key_handup_music";
+ protected String handUpMusic = "";
+
protected final static String KEY_BACKGROUND_COLOR="key_background_color";
protected Integer backgroundColor=Color.rgb(0, 0, 0);
+ protected final static String KEY_BACKGROUND_IMAGE="key_background_image";
+ protected String backgroundImage="";
+
+ protected final static String KEY_BACKGROUND_ANIMATOR="key_background_animator";
+ protected String backgroundAnimatorName="";
+
+ protected final static String KEY_BACKGROUND_ANIMATOR_RANDOM_COLOR="key_background_animator_random_color";
+ protected boolean backgroundAnimatorRandomColor=false;
+
protected final static String KEY_FOREGROUND_COLOR="key_foreground_color";
protected Integer foregroundColor=Color.rgb(255, 255, 255);
protected final static String KEY_FOREGROUND_COLOR1="key_foreground_color1";
protected Integer foregroundColor1=Color.rgb(199,21,133);
+
+ protected final static String KEY_FONT_INDEX = "key_font_index";
+ protected Integer fontIndex;
+
+ //数字时钟 time text style
+
+ protected final static String KEY_FONT_NAME = "key_font_name";
+ protected String fontName;
+
+ protected final static String KEY_IS_LINEARGRADIENT_ABLE="key_time_text_is_linearGradient_able";
+ protected boolean linearGradientAble = false;
+
+ protected final static String KEY_FOREGROUND_TIME_COLORS_ARRAY="key_time_text_foreground_time_colors_array";
+ protected Integer[] timeColorsArray=null;
+
+ protected final static String KEY_IS_REFLECTED_ABLE="key_time_text_is_reflectedAble_able";
+ protected boolean reflectedAble = false;
+
+ protected final static String KEY_TIME_TEXT_SHADOW_TYPE="key_time_text_shadowType";
+ protected Integer shadowType=0;
+
+ protected final static String KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE="key_time_text_charAnimatorType";
+ protected Integer timeTextCharAnimatorType=0;
+
+ //模拟时钟
+ protected final static String KEY_SIMULATE_CLOCK_TYPE_NAME="key_simulate_clock_type_name";
+ protected String simulateClockTypeName;
+
+ protected final static String KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME="key_simulate_clock_pointer_type_name";
+ protected String simulateClockPointerTypeName;
+
+ //ui
+ protected final static String KEY_UI_CLOCK_INTERFACE_TYPE ="key_ui_clock_interface_type";
+ protected int clockInterfaceType;
+
+ protected final static String KEY_UI_AUTO_FULLSCREEN ="key_ui_auto_fullscreen";
+ protected boolean autoFullscreen=false;
+
+ //theme ui
+ protected final static String KEY_THEME_UI_NAME="key_theme_ui_name";
+ protected String themeName;
+
+ protected final static String KEY_THEME_UI_TYPE="key_theme_ui_type";
+ protected int themeUIType;
+
+
+ private int dirtyDelaySecond=10000;
+
+ private boolean dirtySaving=false;
+
+ Timer timer=null;
+
+ private void dirtySave(){
+ Log.d("model","comming in dirty save task...");
+ if(dirtySaving)
+ return;
+ dirtySaving=true;
+ if(timer==null)
+ timer = new Timer();
+ Log.d("model","dirty task created ...");
+ timer.schedule(new TimerTask() {
+ public void run() {
+ Log.d("model","dirty task running...");
+ save();
+ dirtySaving=false;
+ this.cancel();
+ }
+ }, dirtyDelaySecond);
+ }
+
public int getTypeHourPower() {
return typeHourPower;
}
public void setTypeHourPower(int typeHourPower) {
this.typeHourPower = typeHourPower;
+ dirtySave();
}
public DateModel getStartHourPowerTime() {
@@ -82,6 +169,7 @@ public class SharePerferenceModel implements Serializable {
public void setStartHourPowerTime(DateModel startHourPowerTime) {
this.startHourPowerTime = startHourPowerTime;
+ dirtySave();
}
public DateModel getStopHourPowerTime() {
@@ -90,30 +178,34 @@ public class SharePerferenceModel implements Serializable {
public void setStopHourPowerTime(DateModel stopHourPowerTime) {
this.stopHourPowerTime = stopHourPowerTime;
+ dirtySave();
}
public boolean isDisplaySecond() {
- return isDisplaySecond;
+ return displaySecond;
}
public void setDisplaySecond(boolean displaySecond) {
- isDisplaySecond = displaySecond;
+ this.displaySecond = displaySecond;
+ dirtySave();
}
public boolean isTickSound() {
- return isTickSound;
+ return tickSound;
}
public void setTickSound(boolean tickSound) {
- isTickSound = tickSound;
+ this.tickSound = tickSound;
+ dirtySave();
}
public boolean isTriggerScreen() {
- return isTriggerScreen;
+ return triggerScreen;
}
public void setTriggerScreen(boolean triggerScreen) {
- isTriggerScreen = triggerScreen;
+ this.triggerScreen = triggerScreen;
+ dirtySave();
}
public String getCity() {
@@ -122,6 +214,7 @@ public class SharePerferenceModel implements Serializable {
public void setCity(String city) {
this.mCity = city;
+ dirtySave();
}
public String getDescription() {
@@ -130,26 +223,32 @@ public class SharePerferenceModel implements Serializable {
public void setDescription(String mDescription) {
this.mDescription = mDescription;
+ dirtySave();
}
public void setTimeLocation(JSONObject timeLocation) {
this.timeLocation = timeLocation;
+ dirtySave();
}
public void setDateLocation(JSONObject dateLocation) {
this.dateLocation = dateLocation;
+ dirtySave();
}
public void setDayLocation(JSONObject dayLocation) {
this.dayLocation = dayLocation;
+ dirtySave();
}
public void setWeatherLocation(JSONObject weatherLocation) {
this.weatherLocation = weatherLocation;
+ dirtySave();
}
public void setDescriptionLocation(JSONObject descriptionLocation) {
this.descriptionLocation = descriptionLocation;
+ dirtySave();
}
public JSONObject getTimeLocation() {
@@ -176,10 +275,10 @@ public class SharePerferenceModel implements Serializable {
try {
JSONObject jsonObject = new JSONObject(jsonString);
typeHourPower = jsonObject.getInt(KEY_TYPE_HOUR_POWER);
- isDisplaySecond = jsonObject.getBoolean(KEY_IS_DISPLAY_SECOND);
- isTickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND);
- isTriggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,true);
- mCity = jsonObject.getString(KEY_CITY);
+ displaySecond = jsonObject.getBoolean(KEY_IS_DISPLAY_SECOND);
+ tickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND);
+ triggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,true);
+ mCity = jsonObject.optString(KEY_CITY,"jinhua");
mDescription = jsonObject.optString(KEY_DESCRPTION, ClockApplication.getContext().getResources().getString(R.string.always_zuo_never_die));
startHourPowerTime = new DateModel();
startHourPowerTime.setDataString(jsonObject.getString(KEY_START_POWER));
@@ -193,10 +292,37 @@ public class SharePerferenceModel implements Serializable {
fontIndex = jsonObject.optInt(KEY_FONT_INDEX,0);
handUpAble=jsonObject.optBoolean(KEY_IS_HANDUP_ABLE,false);
handUpTime=jsonObject.optInt(KEY_HANDUP_TIME,-1);
+ handUpMusic=jsonObject.optString(KEY_HANDUP_MUSIC,"");
+
backgroundColor=jsonObject.optInt(KEY_BACKGROUND_COLOR,Color.rgb(0, 0, 0));
+ backgroundImage=jsonObject.optString(KEY_BACKGROUND_IMAGE,"");
+ backgroundAnimatorName=jsonObject.optString(KEY_BACKGROUND_ANIMATOR,"");
+ backgroundAnimatorRandomColor=jsonObject.optBoolean(KEY_BACKGROUND_ANIMATOR_RANDOM_COLOR,false);
+
foregroundColor=jsonObject.optInt(KEY_FOREGROUND_COLOR,Color.rgb(255, 255, 255));
foregroundColor1=jsonObject.optInt(KEY_FOREGROUND_COLOR1,Color.rgb(199,21,133));
+
hourSystem12=jsonObject.optBoolean(KEY_IS_HOUR_SYSTEM_12,false);
+
+ linearGradientAble=jsonObject.optBoolean(KEY_IS_LINEARGRADIENT_ABLE,false);
+ timeColorsArray=stringToIntegerArray(jsonObject.optString(KEY_FOREGROUND_TIME_COLORS_ARRAY,null));
+ reflectedAble=jsonObject.optBoolean(KEY_IS_REFLECTED_ABLE);
+ shadowType=jsonObject.optInt(KEY_TIME_TEXT_SHADOW_TYPE,0);
+ timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
+ fontName=jsonObject.optString(KEY_FONT_NAME,"default");
+
+
+ simulateClockTypeName=jsonObject.optString(KEY_SIMULATE_CLOCK_TYPE_NAME,"default");
+ simulateClockPointerTypeName=jsonObject.optString(KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME,"default");
+
+ themeName=jsonObject.optString(KEY_THEME_UI_NAME,"default");
+
+ clockInterfaceType =jsonObject.optInt(KEY_UI_CLOCK_INTERFACE_TYPE,0);
+ autoFullscreen=jsonObject.optBoolean(KEY_UI_AUTO_FULLSCREEN,false);
+
+ themeUIType=jsonObject.optInt(KEY_THEME_UI_TYPE,1);
+
+
} catch (JSONException e) {
e.printStackTrace();
}
@@ -206,14 +332,13 @@ public class SharePerferenceModel implements Serializable {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put(KEY_TYPE_HOUR_POWER, typeHourPower);
- jsonObject.put(KEY_IS_DISPLAY_SECOND, isDisplaySecond);
- jsonObject.put(KEY_IS_TICK_SOUND, isTickSound);
- jsonObject.put(KEY_IS_TRIGGER_SCREEN, isTriggerScreen);
+ jsonObject.put(KEY_IS_DISPLAY_SECOND, displaySecond);
+ jsonObject.put(KEY_IS_TICK_SOUND, tickSound);
+ jsonObject.put(KEY_IS_TRIGGER_SCREEN, triggerScreen);
jsonObject.put(KEY_CITY, mCity);
jsonObject.put(KEY_DESCRPTION, mDescription);
jsonObject.put(KEY_START_POWER, startHourPowerTime.getTime());
jsonObject.put(KEY_STOP_POWER, stopHourPowerTime.getTime());
-
jsonObject.put(KEY_DISPLAYVIEW_TIME, timeLocation.toString());
jsonObject.put(KEY_DISPLAYVIEW_DATE, dateLocation.toString());
jsonObject.put(KEY_DISPLAYVIEW_DAY, dayLocation.toString());
@@ -222,10 +347,33 @@ public class SharePerferenceModel implements Serializable {
jsonObject.put(KEY_FONT_INDEX, fontIndex);
jsonObject.put(KEY_HANDUP_TIME,handUpTime);
jsonObject.put(KEY_IS_HANDUP_ABLE,handUpAble);
+ jsonObject.put(KEY_HANDUP_MUSIC,handUpMusic);
jsonObject.put(KEY_BACKGROUND_COLOR,backgroundColor);
+ jsonObject.put(KEY_BACKGROUND_IMAGE,backgroundImage);
+
+ jsonObject.put(KEY_BACKGROUND_ANIMATOR,backgroundAnimatorName);
+ jsonObject.put(KEY_BACKGROUND_ANIMATOR_RANDOM_COLOR,backgroundAnimatorRandomColor);
+
jsonObject.put(KEY_FOREGROUND_COLOR,foregroundColor);
jsonObject.put(KEY_FOREGROUND_COLOR1,foregroundColor1);
jsonObject.put(KEY_IS_HOUR_SYSTEM_12,hourSystem12);
+
+ jsonObject.put(KEY_IS_LINEARGRADIENT_ABLE,linearGradientAble);
+ jsonObject.put(KEY_FOREGROUND_TIME_COLORS_ARRAY,integerArrayToString(timeColorsArray));
+ jsonObject.put(KEY_IS_REFLECTED_ABLE,reflectedAble);
+ jsonObject.put(KEY_TIME_TEXT_SHADOW_TYPE,shadowType);
+ jsonObject.put(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,timeTextCharAnimatorType);
+ jsonObject.put(KEY_FONT_NAME,fontName);
+
+ jsonObject.put(KEY_SIMULATE_CLOCK_TYPE_NAME,simulateClockTypeName);
+ jsonObject.put(KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME,simulateClockPointerTypeName);
+
+ jsonObject.put(KEY_THEME_UI_NAME,themeName);
+
+ jsonObject.put(KEY_UI_CLOCK_INTERFACE_TYPE, clockInterfaceType);
+ jsonObject.put(KEY_UI_AUTO_FULLSCREEN,autoFullscreen);
+
+ jsonObject.put(KEY_THEME_UI_TYPE,themeUIType);
} catch (JSONException e) {
e.printStackTrace();
}
@@ -233,6 +381,29 @@ public class SharePerferenceModel implements Serializable {
}
+ public static String integerArrayToString(Integer[] fromArrays){
+ if(fromArrays==null)
+ return "";
+ StringBuffer sb = new StringBuffer();
+ for(int i=0;i 0)
+ setDiscript("提醒时间倒计时: " + handUpTime);
+ if (handUpTime == 0) {
+ handUPDialy = 60;
+ resetHandUpTime();
+ switchMode(MODE_HANDUP);
+ }*/
+ }
+
+
+ private void updateTime() {
+ heartbeat=!heartbeat;
+ DateModel date = new DateModel();
+ String timeString=null;
+ switch (globalViewModel.getClockModeEnum().getValue()){
+ case NORMAL:
+ switch (showTimeType){
+ case COUNTING:
+ DateModel temp=new DateModel(countingDateTimeBase);
+ timeString=temp.getTimeString(false);
+ if (!model.isTickSound()) {
+ Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
+ }
+ break;
+ case COUNTING_DOWN:
+ //timeString=DateModel.getTimeFull(handUpTime);
+ break;
+ default:
+ timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
+ break;
+ }
+ digitViewModel.getTimeText().setValue(timeString);
+ break;
+ case HANDUP:
+
+ break;
+ case DELAY:
+
+ break;
+ }
+ reportTime(date);
+ updateDay(date);
+ updateHourSytemStyle(date);
+ }
+
+ int beforeHourForUpdateSystem=-1;
+ private void updateHourSytemStyle(DateModel date){
+ if(beforeHourForUpdateSystem!=date.getHour()) {
+ beforeHourForUpdateSystem=date.getHour();
+ globalViewModel.getTime_hour().setValue(date.getHour());
+ }
+ }
+
+ DateModel currentDate=null;
+ private void updateDay(DateModel date){
+ if(currentDate==null||currentDate.getDay()!=date.getDay()) {
+ Log.d(TAG,"updateDay."+date);
+ currentDate=date;
+ String dayString = date.getToday();
+ String dateString = date.getDateString();
+ String calendarFestival=getCalendarFestival(date);
+ if(calendarFestival!=null&&!calendarFestival.isEmpty())
+ dayString=calendarFestival+" "+dayString;
+ themeUIViewModel.getDayDescription().setValue(dayString);
+ themeUIViewModel.getWeekDescription().setValue(dateString);
+ ClockApplication.getInstance().getBusinessService().getWeather(model.getCity());
+ }
+ }
+
+ private String getCalendarFestival(DateModel dateModel){
+ String festival=LunarCalendarManager.gregorianFestival(dateModel.getMonth(),dateModel.getDay());
+ String ret=LunarCalendarManager.getTraditionFestival(dateModel.getYear(),dateModel.getMonth(),dateModel.getDay());
+ if(ret==null&&festival==null)
+ return null;
+ if(ret==null||ret.isEmpty())
+ return festival;
+ if(festival==null||festival.isEmpty())
+ return ret;
+ return festival+" "+ret;
+ }
+
+
+ private void reportTime(DateModel date) {
+ if (globalViewModel.isTickSound()&&globalViewModel.getClockModeEnum().getValue()!=ClockModeEnum.HANDUP) {
+ Player.getInstance().playTick(ClockApplication.getContext(),R.raw.tick2);
+ }
+ int year = date.getYear();
+ int month = date.getMonth();
+ int day = date.getDay();
+ int hour = date.getHour();
+ int minute = date.getMinute();
+ int second = date.getSecond();
+ int today = date.getWeek();
+
+ if (model.getTypeHourPower() != Constants.TALKING_NO_REPORT) {
+ if ((minute == 30 || minute == 0) && model.getTypeHourPower() == Constants.TALKING_HALF_AN_HOUR && second == 0) {
+ Log.d(TAG, String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today));
+ if (alterManager.isReport(hour, minute))
+ Player.getInstance().reportTime(ClockApplication.getContext(), year, month, day, hour, minute, today);
+ } else if (model.getTypeHourPower() == Constants.TALKING_HOURS && minute == 0 && second == 0) {
+ if (alterManager.isReport(hour, minute))
+ Player.getInstance().reportTime(ClockApplication.getContext(), year, month, day, hour, minute, today);
+ }
+ }
+ }
+
+ public void onDestory() {
+ timer.cancel();
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/state/ClockThemeUITypeEnum.java b/app/src/main/java/clock/socoolby/com/clock/state/ClockThemeUITypeEnum.java
new file mode 100644
index 0000000..6ff0a8b
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/state/ClockThemeUITypeEnum.java
@@ -0,0 +1,21 @@
+package clock.socoolby.com.clock.state;
+
+public enum ClockThemeUITypeEnum {
+ NORMAL(0),SETTING(1),FULLSCREEN(2);
+
+ public int code;
+
+ ClockThemeUITypeEnum(int code) {
+ this.code = code;
+ }
+
+ public static ClockThemeUITypeEnum valueOf(int code){
+ switch (code){
+ case 1:
+ return SETTING;
+ case 2:
+ return FULLSCREEN;
+ }
+ return NORMAL;
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/state/ClockTimeTypeEnum.java b/app/src/main/java/clock/socoolby/com/clock/state/ClockTimeTypeEnum.java
new file mode 100644
index 0000000..e05bdd4
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/state/ClockTimeTypeEnum.java
@@ -0,0 +1,22 @@
+package clock.socoolby.com.clock.state;
+
+public enum ClockTimeTypeEnum {
+ TIME(0),COUNTING_DOWN(1),COUNTING(2);
+
+ public int code;
+
+ ClockTimeTypeEnum(int code) {
+ this.code = code;
+ }
+
+ public static ClockTimeTypeEnum valueOf(int code){
+ switch (code){
+ case 1:
+ return COUNTING_DOWN;
+ case 2:
+ return COUNTING;
+ default:
+ return TIME;
+ }
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/themeUI/DefaultThemeUI.java b/app/src/main/java/clock/socoolby/com/clock/themeUI/DefaultThemeUI.java
deleted file mode 100644
index 692cc26..0000000
--- a/app/src/main/java/clock/socoolby/com/clock/themeUI/DefaultThemeUI.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package clock.socoolby.com.clock.themeUI;
-
-public class DefaultThemeUI {
-}
diff --git a/app/src/main/java/clock/socoolby/com/clock/themeUI/I_ThemeUI.java b/app/src/main/java/clock/socoolby/com/clock/themeUI/I_ThemeUI.java
deleted file mode 100644
index 55a7d53..0000000
--- a/app/src/main/java/clock/socoolby/com/clock/themeUI/I_ThemeUI.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package clock.socoolby.com.clock.themeUI;
-
-public interface I_ThemeUI {
-}
diff --git a/app/src/main/java/clock/socoolby/com/clock/utils/ScreenManager.java b/app/src/main/java/clock/socoolby/com/clock/utils/ScreenManager.java
index 29ca5bf..1310992 100755
--- a/app/src/main/java/clock/socoolby/com/clock/utils/ScreenManager.java
+++ b/app/src/main/java/clock/socoolby/com/clock/utils/ScreenManager.java
@@ -1,36 +1,35 @@
package clock.socoolby.com.clock.utils;
-import android.app.Activity;
import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
-import android.os.SystemClock;
+import androidx.appcompat.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import java.util.List;
-import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.ActivateAdmin;
+import clock.socoolby.com.clock.ClockApplication;
public class ScreenManager {
public static boolean isScreenOn() {
- PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(Activity.POWER_SERVICE);
+ PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE);
return pm.isScreenOn();
}
public static void turnScreenOff() {
- PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(Activity.POWER_SERVICE);
+ PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE);
//pm.goToSleep(SystemClock.uptimeMillis());
}
- public static void systemLock(Activity context) {
+ public static void systemLock(AppCompatActivity context) {
DevicePolicyManager policyManager;
ComponentName componentName;
- policyManager = (DevicePolicyManager) context.getSystemService(Activity.DEVICE_POLICY_SERVICE);
+ policyManager = (DevicePolicyManager) context.getSystemService(AppCompatActivity.DEVICE_POLICY_SERVICE);
componentName = new ComponentName(context, ActivateAdmin.class);
@@ -50,7 +49,7 @@ public class ScreenManager {
}
public static void systemUnLock() {
- PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(Activity.POWER_SERVICE);
+ PowerManager pm = (PowerManager) ClockApplication.getContext().getSystemService(AppCompatActivity.POWER_SERVICE);
//PowerManager.WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK, "SimpleTimer");
//mWakelock.acquire();
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/viewmodel/AlterViewModel.java b/app/src/main/java/clock/socoolby/com/clock/viewmodel/AlterViewModel.java
new file mode 100644
index 0000000..b5ce6a5
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/AlterViewModel.java
@@ -0,0 +1,45 @@
+package clock.socoolby.com.clock.viewmodel;
+
+import android.net.Uri;
+
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+import clock.socoolby.com.clock.model.SharePerferenceModel;
+
+public class AlterViewModel extends ViewModel {
+
+
+ private MutableLiveData handUpMusic=new MutableLiveData<>();
+
+ private MutableLiveData handUPDialy=new MutableLiveData<>();
+
+ //alter handUp UI
+ private MutableLiveData handUpDescription=new MutableLiveData<>();
+
+ SharePerferenceModel model;
+
+ public AlterViewModel(SharePerferenceModel model) {
+ this.model = model;
+ loadFromModel();
+ }
+
+ public void loadFromModel(){
+
+ String handUpMusicString=model.getHandUpMusic();
+ Uri musicUri=handUpMusicString.isEmpty()?null:Uri.parse(handUpMusicString);
+ handUpMusic.setValue(musicUri);
+ }
+
+ public MutableLiveData getHandUpMusic() {
+ return handUpMusic;
+ }
+
+ public MutableLiveData getHandUpDescription() {
+ return handUpDescription;
+ }
+
+ public MutableLiveData getHandUPDialy() {
+ return handUPDialy;
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/viewmodel/DigitViewModel.java b/app/src/main/java/clock/socoolby/com/clock/viewmodel/DigitViewModel.java
new file mode 100644
index 0000000..35aad47
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/DigitViewModel.java
@@ -0,0 +1,137 @@
+package clock.socoolby.com.clock.viewmodel;
+
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+import clock.socoolby.com.clock.dao.base.TimeFontStyle;
+import clock.socoolby.com.clock.model.SharePerferenceModel;
+import clock.socoolby.com.clock.widget.textview.ShadowTypeEnum;
+import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
+
+public class DigitViewModel extends ViewModel {
+
+ private MutableLiveData displaySecond=new MutableLiveData<>();
+
+ private MutableLiveData timeFontStyle =new MutableLiveData<>();
+
+ private MutableLiveData timeText =new MutableLiveData<>();
+
+ private MutableLiveData linearGradientAble=new MutableLiveData<>();
+
+ private MutableLiveData timeLinearGradientColorsArray=new MutableLiveData<>();
+
+ private MutableLiveData reflectedAble=new MutableLiveData<>();//倒影
+
+ private MutableLiveData timeFontStyleSize=new MutableLiveData<>();
+
+ private MutableLiveData shadowType=new MutableLiveData<>();//0:不设置,1:阴影,2:浮雕
+
+ private MutableLiveData timeCharAnimatorType=new MutableLiveData<>();
+
+ private MutableLiveData baseLineDown=new MutableLiveData<>();
+
+ SharePerferenceModel model;
+
+ public DigitViewModel(SharePerferenceModel model) {
+ this.model = model;
+ loadFromModel();
+ }
+
+ private void loadFromModel(){
+ displaySecond.setValue(model.isDisplaySecond());
+ linearGradientAble.setValue(model.isLinearGradientAble());
+ timeLinearGradientColorsArray.setValue(model.getTimeColorsArray());
+ reflectedAble.setValue(model.isReflectedAble());
+ shadowType.setValue(ShadowTypeEnum.valueOf(model.getShadowType()));
+ timeCharAnimatorType.setValue(CharAnimatorEnum.valueOf(model.getTimeTextCharAnimatorType()));
+ baseLineDown.setValue(0);
+ timeFontStyleSize.setValue(100);
+ }
+
+ public MutableLiveData getDisplaySecond() {
+ return displaySecond;
+ }
+
+ public MutableLiveData getTimeFontStyle() {
+ return timeFontStyle;
+ }
+
+ public MutableLiveData getTimeText() {
+ return timeText;
+ }
+
+ public MutableLiveData getLinearGradientAble() {
+ return linearGradientAble;
+ }
+
+ public MutableLiveData getTimeLinearGradientColorsArray() {
+ return timeLinearGradientColorsArray;
+ }
+
+ public MutableLiveData getReflectedAble() {
+ return reflectedAble;
+ }
+
+ public MutableLiveData getTimeFontStyleSize() {
+ return timeFontStyleSize;
+ }
+
+ public MutableLiveData getShadowType() {
+ return shadowType;
+ }
+
+ public MutableLiveData getTimeCharAnimatorType() {
+ return timeCharAnimatorType;
+ }
+
+ public MutableLiveData getBaseLineDown() {
+ return baseLineDown;
+ }
+
+
+ public void setDisplaySecond(Boolean displaySecond) {
+ this.displaySecond.setValue(displaySecond);
+ model.setDisplaySecond(displaySecond);
+ }
+
+ public void setTimeFontStyle(TimeFontStyle timeFontStyle) {
+ this.timeFontStyle.setValue(timeFontStyle);
+ model.setFontName(timeFontStyle.name);
+ }
+
+ public void setTimeText(String timeText) {
+ this.timeText.setValue(timeText);
+ }
+
+ public void setLinearGradientAble(Boolean linearGradientAble) {
+ this.linearGradientAble.setValue(linearGradientAble);
+ model.setLinearGradientAble(linearGradientAble);
+ }
+
+ public void setTimeLinearGradientColorsArray(Integer[] timeLinearGradientColorsArray) {
+ this.timeLinearGradientColorsArray.setValue(timeLinearGradientColorsArray);
+ model.setTimeColorsArray(timeLinearGradientColorsArray);
+ }
+
+ public void setReflectedAble(MutableLiveData reflectedAble) {
+ this.reflectedAble = reflectedAble;
+ }
+
+ public void setTimeFontStyleSize(Integer timeFontStyleSize) {
+ this.timeFontStyleSize.setValue(timeFontStyleSize);
+ }
+
+ public void setShadowType(ShadowTypeEnum shadowType) {
+ this.shadowType.setValue(shadowType);
+ model.setShadowType(shadowType.getTypeCode());
+ }
+
+ public void setTimeCharAnimatorType(CharAnimatorEnum timeCharAnimatorType) {
+ this.timeCharAnimatorType.setValue(timeCharAnimatorType);
+ model.setTimeTextCharAnimatorType(timeCharAnimatorType.getStyleCode());
+ }
+
+ public void setBaseLineDown(Integer baseLineDown) {
+ this.baseLineDown.setValue(baseLineDown);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/viewmodel/GlobalViewModel.java b/app/src/main/java/clock/socoolby/com/clock/viewmodel/GlobalViewModel.java
new file mode 100644
index 0000000..3c42413
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/GlobalViewModel.java
@@ -0,0 +1,256 @@
+package clock.socoolby.com.clock.viewmodel;
+
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+import android.net.Uri;
+
+import java.util.Date;
+
+import clock.socoolby.com.clock.model.SharePerferenceModel;
+import clock.socoolby.com.clock.state.ClockModeEnum;
+import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
+
+public class GlobalViewModel extends ViewModel {
+
+ //ui
+ private MutableLiveData backgroundColor=new MutableLiveData<>();
+
+ private MutableLiveData foregroundColor=new MutableLiveData<>();
+
+ private MutableLiveData backgroundImageUri=new MutableLiveData<>();
+
+ private MutableLiveData backgroundAnimatorName=new MutableLiveData<>();
+
+ private MutableLiveData backgroundAnimatorColor=new MutableLiveData<>();
+
+ private Boolean backgroundAnimatorRandomColor=false;
+
+ private MutableLiveData clockInterfaceTypeEnum =new MutableLiveData<>();
+
+ private MutableLiveData srceenLock=new MutableLiveData<>();
+
+ private MutableLiveData backgroundImageVisable=new MutableLiveData<>();
+
+ private MutableLiveData autoFullScreen=new MutableLiveData<>();
+
+ //system
+ private Boolean tickSound=false;
+
+ private MutableLiveData mCity=new MutableLiveData<>();
+
+ private MutableLiveData brightness=new MutableLiveData<>();
+
+ //alter handUp
+ private MutableLiveData handUpTime=new MutableLiveData<>();
+
+ private MutableLiveData handUpAble=new MutableLiveData<>();
+
+
+ //state
+ private MutableLiveData clockModeEnum=new MutableLiveData<>();
+
+ private MutableLiveData hourSystem12=new MutableLiveData<>();
+
+ private MutableLiveData time_hour=new MutableLiveData<>();
+
+ private MutableLiveData time_day=new MutableLiveData<>();
+
+ SharePerferenceModel model;
+
+ public GlobalViewModel(SharePerferenceModel model) {
+ this.model = model;
+ loadFromModel();
+ }
+
+ public void loadFromModel(){
+ srceenLock.setValue(false);
+ brightness.setValue(100);
+
+ mCity.setValue(model.getCity());
+ backgroundColor.setValue(model.getBackgroundColor());
+ foregroundColor.setValue(model.getForegroundColor());
+ String backgroundImage=model.getBackgroundImage();
+ Uri imageUri=backgroundImage.isEmpty()?null:Uri.parse(backgroundImage);
+ backgroundImageUri.setValue(imageUri);
+ tickSound=model.isTickSound();
+ backgroundAnimatorName.setValue(model.getBackgroundAnimatorName());
+ backgroundAnimatorColor.setValue(model.getForegroundColor1());
+ backgroundAnimatorRandomColor=model.isBackgroundAnimatorRandomColor();
+
+ clockInterfaceTypeEnum.setValue(ClockInterfaceTypeEnum.valueOf(model.getClockInterfaceType()));
+
+ autoFullScreen.setValue(model.isAutoFullscreen());
+
+ clockModeEnum.setValue(ClockModeEnum.NORMAL);
+
+ handUpAble.setValue(model.isHandUpAble());
+ handUpTime.setValue(model.getHandUpTime());
+ }
+
+ public MutableLiveData getCity() {
+ return mCity;
+ }
+
+ public MutableLiveData getBackgroundColor() {
+ return backgroundColor;
+ }
+
+ public MutableLiveData getForegroundColor() {
+ return foregroundColor;
+ }
+
+ public MutableLiveData getBackgroundImageUri() {
+ return backgroundImageUri;
+ }
+
+ public Boolean isTickSound() {
+ return tickSound;
+ }
+
+ public MutableLiveData getBackgroundAnimatorName() {
+ return backgroundAnimatorName;
+ }
+
+ public Boolean getBackgroundAnimatorRandomColor() {
+ return backgroundAnimatorRandomColor;
+ }
+
+ public MutableLiveData getSrceenLock() {
+ return srceenLock;
+ }
+
+ public MutableLiveData getBrightness() {
+ return brightness;
+ }
+
+ public MutableLiveData getClockInterfaceTypeEnum() {
+ return clockInterfaceTypeEnum;
+ }
+
+ public MutableLiveData getClockModeEnum() {
+ return clockModeEnum;
+ }
+
+ public MutableLiveData getBackgroundImageVisable() {
+ return backgroundImageVisable;
+ }
+
+ public MutableLiveData getHourSystem12() {
+ return hourSystem12;
+ }
+
+ public MutableLiveData getTime_hour() {
+ return time_hour;
+ }
+
+ public MutableLiveData getTime_day() {
+ return time_day;
+ }
+
+
+ public Boolean getTickSound() {
+ return tickSound;
+ }
+
+ public MutableLiveData getBackgroundAnimatorColor() {
+ return backgroundAnimatorColor;
+ }
+
+ public MutableLiveData getHandUpTime() {
+ return handUpTime;
+ }
+
+ public MutableLiveData getHandUpAble() {
+ return handUpAble;
+ }
+
+ public void setCity(String mCity) {
+ this.mCity.setValue(mCity);
+ model.setCity(mCity);
+ }
+
+ public void setBackgroundColor(Integer backgroundColor) {
+ this.backgroundColor.setValue(backgroundColor);
+ model.setBackgroundColor(backgroundColor);
+ }
+
+ public void setForegroundColor(Integer foregroundColor) {
+ this.foregroundColor.setValue(foregroundColor);
+ }
+
+ public void setBackgroundImageUri(Uri backgroundImageUri) {
+ this.backgroundImageUri.setValue(backgroundImageUri);
+ }
+
+ public void setBackgroundAnimatorName(String backgroundAnimatorName) {
+ this.backgroundAnimatorName.setValue(backgroundAnimatorName);
+ model.setBackgroundAnimatorName(backgroundAnimatorName);
+ }
+
+ public void setBackgroundAnimatorColor(Integer backgroundAnimatorColor) {
+ this.backgroundAnimatorColor.setValue(backgroundAnimatorColor);
+ }
+
+ public void setBackgroundAnimatorRandomColor(Boolean backgroundAnimatorRandomColor) {
+ this.backgroundAnimatorRandomColor=backgroundAnimatorRandomColor;
+ }
+
+ public void setClockInterfaceTypeEnum(ClockInterfaceTypeEnum clockInterfaceTypeEnum) {
+ this.clockInterfaceTypeEnum.setValue(clockInterfaceTypeEnum);
+ model.setClockInterfaceType(clockInterfaceTypeEnum.code);
+ }
+
+ public void setSrceenLock(Boolean srceenLock) {
+ this.srceenLock.setValue(srceenLock);
+ }
+
+ public void setBackgroundImageVisable(Boolean backgroundImageVisable) {
+ this.backgroundImageVisable.setValue(backgroundImageVisable);
+ }
+
+ public void setTickSound(Boolean tickSound) {
+ this.tickSound = tickSound;
+ model.setTickSound(tickSound);
+ }
+
+
+ public void setBrightness(Integer brightness) {
+ this.brightness.setValue(brightness);
+ }
+
+ public void setClockModeEnum(ClockModeEnum clockModeEnum) {
+ this.clockModeEnum.setValue(clockModeEnum);
+ }
+
+ public void setHourSystem12(Boolean hourSystem12) {
+ this.hourSystem12.setValue(hourSystem12);
+ model.setHourSystem12(hourSystem12);
+ }
+
+ public void setTime_hour(Integer time_hour) {
+ this.time_hour.setValue(time_hour);
+ }
+
+ public void setTime_day(Date time_day) {
+ this.time_day.setValue(time_day);
+ }
+
+ public MutableLiveData getAutoFullScreen() {
+ return autoFullScreen;
+ }
+
+ public void setAutoFullScreen(Boolean autoFullScreen) {
+ this.autoFullScreen.setValue(autoFullScreen);
+ model.setAutoFullscreen(autoFullScreen);
+ }
+
+ public void setHandUpTime(Integer handUpTime) {
+ this.handUpTime.setValue(handUpTime);
+ model.setHandUpTime(handUpTime);
+ }
+
+ public void setHandUpAble(Boolean handUpAble) {
+ this.handUpAble.setValue(handUpAble);
+ model.setHandUpAble(handUpAble);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/viewmodel/SimulateViewModel.java b/app/src/main/java/clock/socoolby/com/clock/viewmodel/SimulateViewModel.java
new file mode 100644
index 0000000..55966f2
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/SimulateViewModel.java
@@ -0,0 +1,43 @@
+package clock.socoolby.com.clock.viewmodel;
+
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+import clock.socoolby.com.clock.model.SharePerferenceModel;
+
+public class SimulateViewModel extends ViewModel {
+
+ private MutableLiveData clockTypeName=new MutableLiveData<>();
+
+ private MutableLiveData pointerTypeName=new MutableLiveData<>();
+
+ SharePerferenceModel model;
+
+ public SimulateViewModel(SharePerferenceModel model) {
+ this.model = model;
+ loadFromModel();
+ }
+
+ private void loadFromModel(){
+ clockTypeName.setValue(model.getSimulateClockTypeName());
+ pointerTypeName.setValue(model.getSimulateClockPointerTypeName());
+ }
+
+ public MutableLiveData getClockTypeName() {
+ return clockTypeName;
+ }
+
+ public MutableLiveData getPointerTypeName() {
+ return pointerTypeName;
+ }
+
+ public void setClockTypeName(String clockTypeName) {
+ this.clockTypeName.setValue(clockTypeName);
+ model.setSimulateClockTypeName(clockTypeName);
+ }
+
+ public void setPointerTypeName(String pointerTypeName) {
+ this.pointerTypeName.setValue(pointerTypeName);
+ model.setSimulateClockPointerTypeName(pointerTypeName);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/viewmodel/ThemeUIViewModel.java b/app/src/main/java/clock/socoolby/com/clock/viewmodel/ThemeUIViewModel.java
new file mode 100644
index 0000000..9971632
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/ThemeUIViewModel.java
@@ -0,0 +1,99 @@
+package clock.socoolby.com.clock.viewmodel;
+
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+import clock.socoolby.com.clock.model.SharePerferenceModel;
+import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
+
+public class ThemeUIViewModel extends ViewModel {
+ //Theme UI部分
+ private MutableLiveData description=new MutableLiveData<>();
+
+ private MutableLiveData clockUITypeEnum=new MutableLiveData<>();
+
+ private MutableLiveData weatherDescription=new MutableLiveData<>();
+
+ private MutableLiveData dayDescription=new MutableLiveData<>();
+
+ private MutableLiveData weekDescription=new MutableLiveData<>();
+
+ private MutableLiveData hand_time_visable=new MutableLiveData<>();
+
+ private MutableLiveData themeName=new MutableLiveData<>();
+
+ SharePerferenceModel model;
+
+ public ThemeUIViewModel(SharePerferenceModel model) {
+ this.model = model;
+ loadFromModel();
+ }
+
+ private void loadFromModel(){
+ description.setValue(model.getDescription());
+
+ themeName.setValue(model.getThemeName());
+
+ clockUITypeEnum.setValue(ClockThemeUITypeEnum.valueOf(model.getThemeUIType()));
+ }
+
+
+ public MutableLiveData getDescription() {
+ return description;
+ }
+
+ public MutableLiveData getClockUITypeEnum() {
+ return clockUITypeEnum;
+ }
+
+ public MutableLiveData getWeatherDescription() {
+ return weatherDescription;
+ }
+
+ public MutableLiveData getDayDescription() {
+ return dayDescription;
+ }
+
+ public MutableLiveData getWeekDescription() {
+ return weekDescription;
+ }
+
+ public MutableLiveData getHand_time_visable() {
+ return hand_time_visable;
+ }
+
+ public MutableLiveData getThemeName() {
+ return themeName;
+ }
+
+
+ public void setDescription(String description) {
+ this.description.setValue(description);
+ }
+
+ public void setClockUITypeEnum(ClockThemeUITypeEnum clockUITypeEnum) {
+ this.clockUITypeEnum.setValue(clockUITypeEnum);
+ model.setThemeUIType(clockUITypeEnum.code);
+ }
+
+ public void setWeatherDescription(String weatherDescription) {
+ this.weatherDescription.setValue(weatherDescription);
+ }
+
+ public void setDayDescription(String dayDescription) {
+ this.dayDescription.setValue(dayDescription);
+ }
+
+ public void setWeekDescription(String weekDescription) {
+ this.weekDescription.setValue(weekDescription);
+ }
+
+ public void setHand_time_visable(Boolean hand_time_visable) {
+ this.hand_time_visable.setValue(hand_time_visable);
+ }
+
+ public void setThemeName(String themeName) {
+ this.themeName.setValue(themeName);
+ model.setThemeName(themeName);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/viewmodel/ViewModelFactory.java b/app/src/main/java/clock/socoolby/com/clock/viewmodel/ViewModelFactory.java
new file mode 100644
index 0000000..624852b
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/ViewModelFactory.java
@@ -0,0 +1,35 @@
+package clock.socoolby.com.clock.viewmodel;
+
+import androidx.lifecycle.ViewModel;
+import androidx.lifecycle.ViewModelProvider;
+import androidx.annotation.NonNull;
+
+import clock.socoolby.com.clock.model.SharePerferenceModel;
+import e.odbo.data.dao.EntityManager;
+
+public class ViewModelFactory extends ViewModelProvider.NewInstanceFactory{
+
+ SharePerferenceModel model;
+ EntityManager entityManager;
+
+ public ViewModelFactory(SharePerferenceModel model, EntityManager entityManager) {
+ this.model = model;
+ this.entityManager = entityManager;
+ }
+
+ @NonNull
+ @Override
+ public T create(@NonNull Class modelClass) {
+ if(GlobalViewModel.class.isAssignableFrom(modelClass))
+ return (T)new GlobalViewModel(model);
+ if(SimulateViewModel.class.isAssignableFrom(modelClass))
+ return (T)new SimulateViewModel(model);
+ if(DigitViewModel.class.isAssignableFrom(modelClass))
+ return (T)new DigitViewModel(model);
+ if(ThemeUIViewModel.class.isAssignableFrom(modelClass))
+ return (T)new ThemeUIViewModel(model);
+ if(AlterViewModel.class.isAssignableFrom(modelClass))
+ return (T)new AlterViewModel(model);
+ return super.create(modelClass);
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AbstractAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AbstractAnimator.java
index edec844..e08f398 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AbstractAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AbstractAnimator.java
@@ -4,11 +4,13 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
-import android.support.v4.graphics.drawable.DrawableCompat;
+import androidx.core.graphics.drawable.DrawableCompat;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.view.WindowManager;
@@ -19,7 +21,9 @@ import java.util.Random;
public abstract class AbstractAnimator implements I_Animator{
protected Random rand=new Random();
protected boolean isRuning=false;
- protected int color=200;
+
+ protected int color= Color.BLACK;
+
protected View mainView;
protected Context context;
@@ -74,7 +78,8 @@ public abstract class AbstractAnimator implements I_A
protected void init(){
initPaint(mPaint);
- initEntryList();
+ if(entryQuantity!=DYNAMIC_QUANTITY)
+ initEntryList();
}
protected void initEntryList(){
@@ -119,14 +124,13 @@ public abstract class AbstractAnimator implements I_A
}
protected void initPaint(Paint mPaint){
- mPaint.reset();
+ mPaint.setColor(color);
}
protected void beforeRemoveAnimatorEntry(T entry){
}
-
public void reset(){
if(entryQuantity!=DYNAMIC_QUANTITY) {
for (T entry : list)
@@ -173,11 +177,17 @@ public abstract class AbstractAnimator implements I_A
@Override
public void setColor(int color) {
+ if(!isColorUseAble())
+ return;
this.color=color;
+ mPaint.setColor(color);
+ for(T entry:list)
+ entry.setAnimatorEntryColor(color);
}
@Override
public void onSizeChanged(int w, int h, int oldw, int oldh) {
+ Log.d("animator","onSizeChanged w:"+w+"h:"+h+"oldw:"+oldw+"oldh:"+oldh);
width=w;
height=h;
if(isRuning)
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AnimatorView.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AnimatorView.java
index 7dde3c1..6df33a0 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AnimatorView.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/AnimatorView.java
@@ -2,6 +2,7 @@ package clock.socoolby.com.clock.widget.animatorview;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
@@ -12,7 +13,7 @@ public class AnimatorView extends View {
private Context context;
private I_Animator animator;
- private int color=0;
+ private int color= Color.BLACK;
public AnimatorView(Context context) {
super(context);
@@ -85,7 +86,6 @@ public class AnimatorView extends View {
this.color=color;
if(animator!=null&&animator.isColorUseAble()&&!animator.isRandColor()) {
animator.setColor(color);
- animator.restart();
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/I_AnimatorEntry.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/I_AnimatorEntry.java
index ca8e446..25b890b 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/I_AnimatorEntry.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/I_AnimatorEntry.java
@@ -8,4 +8,6 @@ public interface I_AnimatorEntry {
void move(int maxWidth, int maxHight);
void onDraw(Canvas canvas, Paint mPaint);
+
+ void setAnimatorEntryColor(int color);
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/AnimatorFactory.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/AnimatorFactory.java
new file mode 100644
index 0000000..1e82cec
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/AnimatorFactory.java
@@ -0,0 +1,95 @@
+package clock.socoolby.com.clock.widget.animatorview.animator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator;
+import clock.socoolby.com.clock.widget.animatorview.animator.textanimator.EZLedAnimator;
+import clock.socoolby.com.clock.widget.animatorview.animator.textanimator.EvaporateTextAnimator;
+
+public class AnimatorFactory {
+
+ public static Map entryMap=new HashMap<>();
+
+ public static Class[] animatorClassArray = new Class[]{
+ StarFallAnimator.class,
+ SkyAnimator.class,
+ RainAnimator.class,
+ SnowAnimator.class,
+ BubbleWhirlPoolAnimator.class,
+ BubbleAnimator.class,
+ FluorescenceAnimator.class,
+ BubbleCollisionAnimator.class,
+ FireworkAnimator.class,
+ DotsLineAnimator.class,
+ WaterAnimator.class,
+ FireAnimator.class,
+ SawtoothAnimator.class,
+ WindmillAnimator.class,
+ VorolayAnimator.class,
+ EZLedAnimator.class,
+ EvaporateTextAnimator.class,
+ PhaserBallAnimator.class,
+ CarrouselAnimator.class,
+ Wave3DAnimator.class,
+ MagicLineAnimator.class
+ };
+
+ static {
+ for(Class c:animatorClassArray)
+ addAnimatorEntryToMap(c);
+ }
+
+ public static void addAnimatorEntryToMap(Class animatorClass){
+ addAnimatorEntryToMap(getInstance(animatorClass));
+ }
+
+ public static void addAnimatorEntryToMap(Class animatorClass,boolean randomColorAble){
+ addAnimatorEntryToMap(getInstance(animatorClass,randomColorAble));
+ }
+
+ public static void addAnimatorEntryToMap(AnimatorEntry animatorEntry){
+ entryMap.put(animatorEntry.type,animatorEntry);
+ }
+
+ public static AnimatorEntry getInstance(Class animatorClass){
+ return getInstance(animatorClass,true);
+ }
+
+ public static AnimatorEntry getInstance(Class animatorClass,boolean randomColorAble){
+ return new AnimatorEntry(animatorClass,randomColorAble);
+ }
+
+ public static class AnimatorEntry{
+ String type;
+ Class animatorClass;
+ boolean randomColorAble;
+
+ public AnimatorEntry(Class animatorClass) {
+ this.animatorClass = animatorClass;
+ this.type=animatorClass.getSimpleName();
+ randomColorAble=true;
+ }
+
+ public AnimatorEntry(Class animatorClass, boolean randomColorAble) {
+ this.animatorClass = animatorClass;
+ this.randomColorAble = randomColorAble;
+ this.type=animatorClass.getSimpleName();
+ }
+ }
+
+ public static AbstractAnimator build(String name){
+ AnimatorEntry entry=entryMap.get(name);
+ if(entry==null)
+ return null;
+ AbstractAnimator ret=null;
+ try {
+ ret= (AbstractAnimator) entry.animatorClass.newInstance();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ }
+ return ret;
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleAnimator.java
index ba87fdf..6a28141 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleAnimator.java
@@ -109,6 +109,11 @@ public class BubbleAnimator extends AbstractAnimator {
mPaint.setColor(color);
canvas.drawCircle(x, y,radius, mPaint);
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ this.color=color;
+ }
}
// 尝试创建气泡
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleCollisionAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleCollisionAnimator.java
index 6dcda03..109549c 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleCollisionAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/BubbleCollisionAnimator.java
@@ -127,5 +127,12 @@ public class BubbleCollisionAnimator extends AbstractAnimator {
@Override
public boolean run() {
+ //Log.d("clock","animator is running: "+(clock!=null));
if(clock==null)
return false;
return super.run();
@@ -36,11 +41,24 @@ public class ClockAnimator extends AbstractAnimator {
public void setClock(AbstractClock clock1){
list.clear();
this.clock=clock1;
- int textColor=color;
- randomColorIfAble();
int minHigh=Math.min(width,height);
- clock.init(width,height,width/2,height/2,minHigh/2,color,textColor);
+ clock.init(width,height,width/2,height/2,minHigh/2,color,color);
list.add(clock);
+ Log.d("clock","set clock type: "+clock1.typeName()+"\t color:"+ color);
+ }
+
+ public void setClockPointer(I_Pointer pointer){
+ clock.setPointer(pointer);
+ }
+
+
+ @Override
+ public void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ if(clock!=null) {
+ int minHigh=Math.min(width,height);
+ clock.init(width, height, width / 2, height / 2, minHigh / 2, color, color);
+ }
}
int randPointerIndex=1;
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DotsLineAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DotsLineAnimator.java
index 21daf15..99576b9 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DotsLineAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DotsLineAnimator.java
@@ -100,5 +100,10 @@ public class DotsLineAnimator extends AbstractAnimator
public void onDraw(Canvas canvas, Paint mPaint) {
drawCircle(canvas,mPaint);
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ this.color=color;
+ }
}
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DrawableArrayFallAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DrawableArrayFallAnimator.java
index 54f065e..9936be6 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DrawableArrayFallAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/DrawableArrayFallAnimator.java
@@ -133,6 +133,11 @@ public class DrawableArrayFallAnimator extends AbstractAnimator bitmapCacheMap = new HashMap();
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireAnimator.java
index 9194cec..529eb2d 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireAnimator.java
@@ -12,12 +12,10 @@ import clock.socoolby.com.clock.widget.animatorview.I_AnimatorEntry;
//参考: https://www.jianshu.com/p/0d4ab16a6b7b
public class FireAnimator extends AbstractCacheDifferenceAnimator {
-
public FireAnimator() {
super(1);
}
-
int high=0;
int fireWidth=0;
int particlesCount;
@@ -26,10 +24,11 @@ public class FireAnimator extends AbstractCacheDifferenceAnimator150?particlesCount:particlesCount+150;
- return new ParticleSystem(width/2,height,high,fireWidth,particlesCount,rand.nextInt(30));
+ return new ParticleSystem(width/2,height,high,fireWidth,particlesCount,rand.nextInt(30),color);
}
@@ -37,11 +36,10 @@ public class FireAnimator extends AbstractCacheDifferenceAnimator particles = new ArrayList<>();
private int fire_width = 20;
private int particle_width=20;
- private Paint paint = new Paint();
private int x,y,high;
+ private int color;
-
- public ParticleSystem(int x,int y,int high,int fire_width,int particlesCount,int particle_width) {
+ public ParticleSystem(int x,int y,int high,int fire_width,int particlesCount,int particle_width,int color) {
this.x=x;
this.y=y;
this.high=high;
@@ -49,11 +47,7 @@ public class FireAnimator extends AbstractCacheDifferenceAnimator cache = new LinkedList<>();
@@ -180,5 +179,10 @@ public class FluorescenceAnimator extends AbstractAnimator corrDatas;
//动画绘制的时间
@@ -68,18 +76,18 @@ public class MagicLineAnimator extends AbstractCacheDifferenceAnimator();
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/PhaserBallAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/PhaserBallAnimator.java
index 73ba786..54c6ebc 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/PhaserBallAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/PhaserBallAnimator.java
@@ -135,5 +135,10 @@ public class PhaserBallAnimator extends AbstractAnimator {
return new Rain();
}
-
private final int size = 50; //长度在0-50像素
public class Rain implements I_AnimatorEntry {
@@ -42,7 +41,6 @@ public class RainAnimator extends AbstractAnimator {
reset();
}
-
private void reset(){
int x = rand.nextInt(width);
int y = rand.nextInt(height);
@@ -94,5 +92,10 @@ public class RainAnimator extends AbstractAnimator {
mPaint.setColor(rainColor);
canvas.drawLine(point.left, point.top, point.right, point.bottom, mPaint);
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ this.rainColor=color;
+ }
}
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java
index 349ec8d..9764dbf 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/RippleAnimator.java
@@ -24,7 +24,6 @@ public class RippleAnimator extends AbstractAnimator {
list.add(createNewEntry());
}
-
@Override
public Ripple createNewEntry() {
Style style;
@@ -38,6 +37,12 @@ public class RippleAnimator extends AbstractAnimator {
return new Ripple(width,height,color,style);
}
+ @Override
+ protected void initPaint(Paint mPaint) {
+ super.initPaint(mPaint);
+
+ }
+
public enum Style{
IN,OUT,BREATH;
}
@@ -75,7 +80,6 @@ public class RippleAnimator extends AbstractAnimator {
Style style;
-
public Ripple(float mWidth, float mHeight, int mColor,Style style) {
this.mWidth = mWidth;
this.mHeight = mHeight;
@@ -326,6 +330,11 @@ public class RippleAnimator extends AbstractAnimator {
drawInCircle(canvas);
}
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+
+ }
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SawtoothAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SawtoothAnimator.java
index 49bbaa8..7a952bd 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SawtoothAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SawtoothAnimator.java
@@ -113,6 +113,7 @@ public class SawtoothAnimator extends AbstractAnimator {
private final int METEOR = 2;
private int state = NORMAL;
- private Paint paint = new Paint();
+ private Paint paint;
private final int size = 20; // 长度在0-size像素
private int radius;
private Point point; // 星星
@@ -57,6 +57,7 @@ public class SkyAnimator extends AbstractAnimator {
public Star(){
point = new Point();
+ paint=new Paint();
paint.setColor(0xffffffff);
reset();
}
@@ -71,7 +72,7 @@ public class SkyAnimator extends AbstractAnimator {
paint.setColor(color);
}
- private void drawLightStar (Canvas canvas){
+ private void drawLightStar (Canvas canvas){
switch (lightState) {
case LIGHT_HALF:
@@ -187,5 +188,10 @@ public class SkyAnimator extends AbstractAnimator {
break;
}
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ paint.setColor(color);
+ }
}
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SnowAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SnowAnimator.java
index d820946..dc19c91 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SnowAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/SnowAnimator.java
@@ -169,6 +169,11 @@ public class SnowAnimator extends AbstractAnimator {
drawSknow(canvas,mPaint);
}
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ this.color=color;
+ }
}
public class SnowPoint2 extends SnowPoint{
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/VorolayAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/VorolayAnimator.java
index d0d51c1..13ce218 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/VorolayAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/VorolayAnimator.java
@@ -285,5 +285,10 @@ public class VorolayAnimator extends AbstractAnimator {
// canvas.drawBorder((float)region.site.x, (float)region.site.y, 10, p);
}
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ p.setColor(color);
+ }
}
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java
index 1571547..401de76 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WaterAnimator.java
@@ -31,7 +31,8 @@ public class WaterAnimator extends AbstractAnimator {
class Water implements I_AnimatorEntry {
private Path mAbovePath, mBelowWavePath;
- private Paint mAboveWavePaint, mBelowWavePaint;
+ private Paint mAboveWavePaint;
+ //private Paint mBelowWavePaint;
private DrawFilter mDrawFilter;
@@ -62,11 +63,11 @@ public class WaterAnimator extends AbstractAnimator {
mAboveWavePaint.setStyle(Paint.Style.FILL);
mAboveWavePaint.setColor(Color.BLUE);
//下方波浪
- mBelowWavePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ /*mBelowWavePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBelowWavePaint.setAntiAlias(true);
mBelowWavePaint.setStyle(Paint.Style.FILL);
mBelowWavePaint.setColor(Color.BLUE);
- mBelowWavePaint.setAlpha(60);
+ mBelowWavePaint.setAlpha(60);*/
//画布抗锯齿
mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
@@ -112,6 +113,11 @@ public class WaterAnimator extends AbstractAnimator {
canvas.drawPath(mAbovePath, mAboveWavePaint);
// canvas.drawPath(mBelowWavePath, mBelowWavePaint);
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ mAboveWavePaint.setColor(color);
+ }
}
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/Wave3DAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/Wave3DAnimator.java
index 725f6fd..20d5c41 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/Wave3DAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/Wave3DAnimator.java
@@ -103,6 +103,13 @@ public class Wave3DAnimator extends AbstractAnimator {
}
}
+
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ for(PointCicle point:datas){
+ point.color=color;
+ }
+ }
}
public class PointCicle{
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java
index 44284a3..c4e0ed0 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/WindmillAnimator.java
@@ -128,5 +128,11 @@ public class WindmillAnimator extends AbstractAnimator {
}
}
+ @Override
+ public void setAnimatorEntryColor(int color) {
+ this.ledColor=color;
+ paint.setColor(ledColor);
+ }
+
/**
* Transform text to bitmap
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/textanimator/EvaporateTextAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/textanimator/EvaporateTextAnimator.java
index 49e7c62..ffa4bfd 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/textanimator/EvaporateTextAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/textanimator/EvaporateTextAnimator.java
@@ -146,6 +146,11 @@ public class EvaporateTextAnimator extends AbstractAnimator"+textLength+"--->"+viewWidth+"-->"+getTextSize());
- if(viewWidth == 0)
- {
- viewWidth = 600;//获取屏幕的宽度
- }
- //Log.e(TAG,"屏幕的宽度-->"+ 600);
- step = textLength;//文字真实的长度
- temp_view_plus_text_length = viewWidth/2 + textLength;
- temp_view_plus_two_text_length = viewWidth + textLength * 2;//文字移动的距离应该是控件的长度+左边一个文字的长度+右边一个文字的长度
- y = getTextSize() + getPaddingTop();
if(clickScroll)
setOnClickListener(this);
- if(textLength>viewWidth)
- isStarting=true;
- else {
- paint.measureText(text);
- isStarting=false;
- temp_view_plus_text_length = step+(viewWidth - textLength)/2;
- invalidate();
- }
}
@Override
@@ -91,6 +63,8 @@ public class AutoScrollTextView extends android.support.v7.widget.AppCompatTextV
}
+
+
@Override
public void onRestoreInstanceState(Parcelable state)
{
@@ -103,7 +77,6 @@ public class AutoScrollTextView extends android.support.v7.widget.AppCompatTextV
step = ss.step;
isStarting = ss.isStarting;
-
}
public static class SavedState extends BaseSavedState {
@@ -151,6 +124,38 @@ public class AutoScrollTextView extends android.support.v7.widget.AppCompatTextV
invalidate();
}
+ public void startScrollIfAble(){
+
+ text = getText().toString();
+ mTextColor = getCurrentTextColor();
+ mTextSize = getTextSize();
+ paint.setColor(mTextColor);
+ paint.setTextSize(mTextSize);
+ textLength = paint.measureText(text);
+ viewWidth = getWidth();
+
+ //Log.e(TAG,"--->"+textLength+"--->"+viewWidth+"-->"+getTextSize());
+ if(viewWidth == 0)
+ {
+ viewWidth = 600;//获取屏幕的宽度
+ }
+ //Log.e(TAG,"屏幕的宽度-->"+ 600);
+ step = textLength;//文字真实的长度
+ temp_view_plus_text_length = viewWidth/2 + textLength;
+ temp_view_plus_two_text_length = viewWidth + textLength * 2;//文字移动的距离应该是控件的长度+左边一个文字的长度+右边一个文字的长度
+ y = getTextSize() + getPaddingTop();
+
+ if(textLength>viewWidth)
+ isStarting=true;
+ else {
+ paint.measureText(text);
+ isStarting=false;
+ temp_view_plus_text_length = step+(viewWidth - textLength)/2;
+ invalidate();
+ }
+ }
+
+
public void stopScroll()
{
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java
index 39fc7d4..65d11d7 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/DigitTextView.java
@@ -10,7 +10,7 @@ import android.graphics.Shader;
import android.text.TextPaint;
import android.text.style.ReplacementSpan;
import android.util.AttributeSet;
-import android.util.Log;
+
import androidx.annotation.Nullable;
import java.util.HashMap;
@@ -22,7 +22,7 @@ import clock.socoolby.com.clock.widget.textview.charanimator.Down2UpCharAnimator
import clock.socoolby.com.clock.widget.textview.charanimator.Marquee3DCharAnimator;
import clock.socoolby.com.clock.widget.textview.charanimator.Up2DownCharAnimator;
-public class DigitTextView extends android.support.v7.widget.AppCompatTextView {
+public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
public static final String Tag=DigitTextView.class.getSimpleName();
float baseLineDown=0;
@@ -31,7 +31,7 @@ public class DigitTextView extends android.support.v7.widget.AppCompatTextView {
private boolean isLinearGradientAble=false;
- private int shadowType=0;//0:不设置,1:阴影,2:浮雕
+ private ShadowTypeEnum shadowType=ShadowTypeEnum.NOSETUP;//0:不设置,1:阴影,2:浮雕
private int[] linearGradientColors;
@@ -68,7 +68,7 @@ public class DigitTextView extends android.support.v7.widget.AppCompatTextView {
isReflectedAble=rand.nextBoolean();
}
setLinearGradientAble(able);
- setShadowType(rand.nextInt(3));
+ setShadowType(ShadowTypeEnum.valueOf(rand.nextInt(3)));
}
public void setLinearGradientAble(boolean able){
@@ -90,13 +90,13 @@ public class DigitTextView extends android.support.v7.widget.AppCompatTextView {
mTextPaint.setShader(mLinearGradient);
}
- public void setShadowType(int shadowType){
+ public void setShadowType(ShadowTypeEnum shadowType){
this.shadowType=shadowType;
switch (shadowType){
- case 1://阴影效果
+ case SHADOW://阴影效果
setShadowLayer(4, 10, 10, Color.BLACK);
break;
- case 2:
+ case RELIEF:
//setShadowLayer(1, 0.5f, 0.5f, Color.argb(200,204,204,204));//浮雕效果
setShadowLayer(10, 0, 0, Color.parseColor("#FF4141"));//边缘模糊
break;
@@ -105,7 +105,7 @@ public class DigitTextView extends android.support.v7.widget.AppCompatTextView {
}
}
- public int getShadowType(){
+ public ShadowTypeEnum getShadowType(){
return shadowType;
}
@@ -137,6 +137,14 @@ public class DigitTextView extends android.support.v7.widget.AppCompatTextView {
this.currentCharAnimatorType = currentCharAnimatorType;
}
+ public boolean isReflectedAble() {
+ return isReflectedAble;
+ }
+
+ public void setReflectedAble(boolean reflectedAble) {
+ isReflectedAble = reflectedAble;
+ }
+
private int textHight;
private int baseCharWidth;
private int flagCharwidth;
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/ShadowTypeEnum.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/ShadowTypeEnum.java
new file mode 100644
index 0000000..22c9462
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/ShadowTypeEnum.java
@@ -0,0 +1,26 @@
+package clock.socoolby.com.clock.widget.textview;
+
+public enum ShadowTypeEnum {
+ NOSETUP(0),SHADOW(1),RELIEF(2);
+
+ int typeCode;
+
+ ShadowTypeEnum(int typeCode) {
+ this.typeCode = typeCode;
+ }
+
+ public static ShadowTypeEnum valueOf(int type){
+ switch (type){
+ case 1:
+ return SHADOW;
+ case 2:
+ return RELIEF;
+ default:
+ return NOSETUP;
+ }
+ }
+
+ public int getTypeCode() {
+ return typeCode;
+ }
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/AbstractCharAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/AbstractCharAnimator.java
index d721651..3aed059 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/AbstractCharAnimator.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/AbstractCharAnimator.java
@@ -35,4 +35,5 @@ public abstract class AbstractCharAnimator {
public boolean isCharAnimatorRuning() {
return charAnimatorRuning;
}
+
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/CharAnimatorEnum.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/CharAnimatorEnum.java
index 2621b08..9f1ea71 100644
--- a/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/CharAnimatorEnum.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/charanimator/CharAnimatorEnum.java
@@ -1,5 +1,24 @@
package clock.socoolby.com.clock.widget.textview.charanimator;
public enum CharAnimatorEnum{
- NOSETUP,UP2DOWN,DOWN2UP,Marquee3D_Up,Marquee3D_Down;
+ NOSETUP(0),UP2DOWN(1),DOWN2UP(2),Marquee3D_Up(3),Marquee3D_Down(4);
+
+ int styleCode;
+
+ CharAnimatorEnum(int styleCode) {
+ this.styleCode = styleCode;
+ }
+
+ public static CharAnimatorEnum valueOf(int code){
+ for (CharAnimatorEnum styleEnum: values()) {
+ if(styleEnum.styleCode == code){
+ return styleEnum;
+ }
+ }
+ return NOSETUP;
+ }
+
+ public int getStyleCode() {
+ return styleCode;
+ }
}
diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/wheelview/WheelView.java b/app/src/main/java/clock/socoolby/com/clock/widget/wheelview/WheelView.java
index d9dfb64..55ade49 100755
--- a/app/src/main/java/clock/socoolby/com/clock/widget/wheelview/WheelView.java
+++ b/app/src/main/java/clock/socoolby/com/clock/widget/wheelview/WheelView.java
@@ -701,7 +701,7 @@ public class WheelView extends View {
/**
* Scroll the wheel
- * @param itemsToSkip items to scroll
+ * @param itemsToScroll items to scroll
* @param time scrolling duration
*/
public void scroll(int itemsToScroll, int time) {
diff --git a/app/src/main/java/clock/socoolby/com/clock/work/WorkManager.java b/app/src/main/java/clock/socoolby/com/clock/work/WorkManager.java
new file mode 100644
index 0000000..a0b3f95
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/work/WorkManager.java
@@ -0,0 +1,4 @@
+package clock.socoolby.com.clock.work;
+
+public class WorkManager {
+}
diff --git a/app/src/main/java/clock/socoolby/com/clock/work/WorkRuleLoopType.java b/app/src/main/java/clock/socoolby/com/clock/work/WorkRuleLoopType.java
new file mode 100644
index 0000000..bd55c15
--- /dev/null
+++ b/app/src/main/java/clock/socoolby/com/clock/work/WorkRuleLoopType.java
@@ -0,0 +1,11 @@
+package clock.socoolby.com.clock.work;
+
+public enum WorkRuleLoopType {
+ DateTime(0),EventDay(0xff),Mod(0x01),Tur(0x02);
+
+ int loopType;
+
+ WorkRuleLoopType(int loopType) {
+ this.loopType = loopType;
+ }
+}
diff --git a/app/src/main/java/com/daimajia/androidanimations/library/YoYo.java b/app/src/main/java/com/daimajia/androidanimations/library/YoYo.java
index 05fcfcf..6171b40 100755
--- a/app/src/main/java/com/daimajia/androidanimations/library/YoYo.java
+++ b/app/src/main/java/com/daimajia/androidanimations/library/YoYo.java
@@ -27,7 +27,7 @@ package com.daimajia.androidanimations.library;
import android.animation.Animator;
import android.animation.ValueAnimator;
-import android.support.v4.view.ViewCompat;
+import androidx.core.view.ViewCompat;
import android.view.View;
import android.view.animation.Interpolator;
diff --git a/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java b/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java
index 4ab7695..91c04de 100755
--- a/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java
+++ b/app/src/main/java/com/fadai/particlesmasher/ParticleSmasher.java
@@ -1,10 +1,10 @@
package com.fadai.particlesmasher;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
+import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -26,9 +26,9 @@ public class ParticleSmasher extends View {
private List mAnimators = new ArrayList<>();
private Canvas mCanvas;
- private Activity mActivity;
+ private AppCompatActivity mActivity;
- public ParticleSmasher(Activity activity) {
+ public ParticleSmasher(AppCompatActivity activity) {
super((Context) activity);
this.mActivity = activity;
addView2Window(activity);
@@ -38,7 +38,7 @@ public class ParticleSmasher extends View {
/**
* 添加View到当前界面
*/
- private void addView2Window(Activity activity) {
+ private void addView2Window(AppCompatActivity activity) {
ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
// 需要足够的空间展现动画,因此这里使用的是充满父布局
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
diff --git a/app/src/main/java/com/haibin/calendarview/LunarCalendarManager.java b/app/src/main/java/com/haibin/calendarview/LunarCalendarManager.java
new file mode 100644
index 0000000..8b0be1e
--- /dev/null
+++ b/app/src/main/java/com/haibin/calendarview/LunarCalendarManager.java
@@ -0,0 +1,382 @@
+/*
+ * Copyright (C) 2016 huanghaibin_dev
+ * WebSite https://github.com/MiracleTimes-Dev
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.haibin.calendarview;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.text.TextUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public final class LunarCalendarManager {
+
+
+ public static void init(Context context) {
+ if (MONTH_STR != null) {
+ return;
+ }
+ TrunkBranchAnnals.init(context);
+ SolarTermUtil.init(context);
+ MONTH_STR = context.getResources().getStringArray(R.array.lunar_first_of_month);
+ TRADITION_FESTIVAL_STR = context.getResources().getStringArray(R.array.tradition_festival);
+ DAY_STR = context.getResources().getStringArray(R.array.lunar_str);
+ SPECIAL_FESTIVAL_STR = context.getResources().getStringArray(R.array.special_festivals);
+ SOLAR_CALENDAR = context.getResources().getStringArray(R.array.solar_festival);
+ }
+
+ /**
+ * 农历月份第一天转写
+ */
+ private static String[] MONTH_STR = null;
+
+ /**
+ * 传统农历节日
+ */
+ private static String[] TRADITION_FESTIVAL_STR = null;
+
+ /**
+ * 农历大写
+ */
+ private static String[] DAY_STR = null;
+
+ /**
+ * 特殊节日的数组
+ */
+ private static String[] SPECIAL_FESTIVAL_STR = null;
+
+ /**
+ * 特殊节日、母亲节和父亲节,感恩节等
+ */
+ @SuppressLint("UseSparseArrays")
+ private static final Map SPECIAL_FESTIVAL = new HashMap<>();
+
+ /**
+ * 公历节日
+ */
+ private static String[] SOLAR_CALENDAR = null;
+
+ /**
+ * 保存每年24节气
+ */
+ @SuppressLint("UseSparseArrays")
+ private static final Map SOLAR_TERMS = new HashMap<>();
+
+ /**
+ * 返回传统农历节日
+ *
+ * @param year 农历年
+ * @param month 农历月
+ * @param day 农历日
+ * @return 返回传统农历节日
+ */
+ public static String getTraditionFestival(int year, int month, int day) {
+ if (month == 12) {
+ int count = daysInLunarMonth(year, month);
+ if (day == count) {
+ return TRADITION_FESTIVAL_STR[0];//除夕
+ }
+ }
+ String text = getString(month, day);
+ String festivalStr = "";
+ for (String festival : TRADITION_FESTIVAL_STR) {
+ if (festival.contains(text)) {
+ festivalStr = festival.replace(text, "");
+ break;
+ }
+ }
+ return festivalStr;
+ }
+
+
+ /**
+ * 数字转换为汉字月份
+ *
+ * @param month 月
+ * @param leap 1==闰月
+ * @return 数字转换为汉字月份
+ */
+ public static String numToChineseMonth(int month, int leap) {
+ if (leap == 1) {
+ return String.format("闰%s", MONTH_STR[month - 1]);
+ }
+ return MONTH_STR[month - 1];
+ }
+
+ /**
+ * 数字转换为农历节日或者日期
+ *
+ * @param month 月
+ * @param day 日
+ * @param leap 1==闰月
+ * @return 数字转换为汉字日
+ */
+ public static String numToChinese(int month, int day, int leap) {
+ if (day == 1) {
+ return numToChineseMonth(month, leap);
+ }
+ return DAY_STR[day - 1];
+ }
+
+ /**
+ * 用来表示1900年到2099年间农历年份的相关信息,共24位bit的16进制表示,其中:
+ * 1. 前4位表示该年闰哪个月;
+ * 2. 5-17位表示农历年份13个月的大小月分布,0表示小,1表示大;
+ * 3. 最后7位表示农历年首(正月初一)对应的公历日期。
+ *
+ * 以2014年的数据0x955ABF为例说明:
+ * 1001 0101 0101 1010 1011 1111
+ * 闰九月 农历正月初一对应公历1月31号
+ */
+ public static final int LUNAR_INFO[] = {
+ 0x84B6BF,/*1900*/
+ 0x04AE53, 0x0A5748, 0x5526BD, 0x0D2650, 0x0D9544, 0x46AAB9, 0x056A4D, 0x09AD42, 0x24AEB6, 0x04AE4A,/*1901-1910*/
+ 0x6A4DBE, 0x0A4D52, 0x0D2546, 0x5D52BA, 0x0B544E, 0x0D6A43, 0x296D37, 0x095B4B, 0x749BC1, 0x049754,/*1911-1920*/
+ 0x0A4B48, 0x5B25BC, 0x06A550, 0x06D445, 0x4ADAB8, 0x02B64D, 0x095742, 0x2497B7, 0x04974A, 0x664B3E,/*1921-1930*/
+ 0x0D4A51, 0x0EA546, 0x56D4BA, 0x05AD4E, 0x02B644, 0x393738, 0x092E4B, 0x7C96BF, 0x0C9553, 0x0D4A48,/*1931-1940*/
+ 0x6DA53B, 0x0B554F, 0x056A45, 0x4AADB9, 0x025D4D, 0x092D42, 0x2C95B6, 0x0A954A, 0x7B4ABD, 0x06CA51,/*1941-1950*/
+ 0x0B5546, 0x555ABB, 0x04DA4E, 0x0A5B43, 0x352BB8, 0x052B4C, 0x8A953F, 0x0E9552, 0x06AA48, 0x6AD53C,/*1951-1960*/
+ 0x0AB54F, 0x04B645, 0x4A5739, 0x0A574D, 0x052642, 0x3E9335, 0x0D9549, 0x75AABE, 0x056A51, 0x096D46,/*1961-1970*/
+ 0x54AEBB, 0x04AD4F, 0x0A4D43, 0x4D26B7, 0x0D254B, 0x8D52BF, 0x0B5452, 0x0B6A47, 0x696D3C, 0x095B50,/*1971-1980*/
+ 0x049B45, 0x4A4BB9, 0x0A4B4D, 0xAB25C2, 0x06A554, 0x06D449, 0x6ADA3D, 0x0AB651, 0x095746, 0x5497BB,/*1981-1990*/
+ 0x04974F, 0x064B44, 0x36A537, 0x0EA54A, 0x86B2BF, 0x05AC53, 0x0AB647, 0x5936BC, 0x092E50, 0x0C9645,/*1991-2000*/
+ 0x4D4AB8, 0x0D4A4C, 0x0DA541, 0x25AAB6, 0x056A49, 0x7AADBD, 0x025D52, 0x092D47, 0x5C95BA, 0x0A954E,/*2001-2010*/
+ 0x0B4A43, 0x4B5537, 0x0AD54A, 0x955ABF, 0x04BA53, 0x0A5B48, 0x652BBC, 0x052B50, 0x0A9345, 0x474AB9,/*2011-2020*/
+ 0x06AA4C, 0x0AD541, 0x24DAB6, 0x04B64A, 0x6a573D, 0x0A4E51, 0x0D2646, 0x5E933A, 0x0D534D, 0x05AA43,/*2021-2030*/
+ 0x36B537, 0x096D4B, 0xB4AEBF, 0x04AD53, 0x0A4D48, 0x6D25BC, 0x0D254F, 0x0D5244, 0x5DAA38, 0x0B5A4C,/*2031-2040*/
+ 0x056D41, 0x24ADB6, 0x049B4A, 0x7A4BBE, 0x0A4B51, 0x0AA546, 0x5B52BA, 0x06D24E, 0x0ADA42, 0x355B37,/*2041-2050*/
+ 0x09374B, 0x8497C1, 0x049753, 0x064B48, 0x66A53C, 0x0EA54F, 0x06AA44, 0x4AB638, 0x0AAE4C, 0x092E42,/*2051-2060*/
+ 0x3C9735, 0x0C9649, 0x7D4ABD, 0x0D4A51, 0x0DA545, 0x55AABA, 0x056A4E, 0x0A6D43, 0x452EB7, 0x052D4B,/*2061-2070*/
+ 0x8A95BF, 0x0A9553, 0x0B4A47, 0x6B553B, 0x0AD54F, 0x055A45, 0x4A5D38, 0x0A5B4C, 0x052B42, 0x3A93B6,/*2071-2080*/
+ 0x069349, 0x7729BD, 0x06AA51, 0x0AD546, 0x54DABA, 0x04B64E, 0x0A5743, 0x452738, 0x0D264A, 0x8E933E,/*2081-2090*/
+ 0x0D5252, 0x0DAA47, 0x66B53B, 0x056D4F, 0x04AE45, 0x4A4EB9, 0x0A4D4C, 0x0D1541, 0x2D92B5 /*2091-2099*/
+ };
+
+
+ /**
+ * 传回农历 year年month月的总天数,总共有13个月包括闰月
+ *
+ * @param year 将要计算的年份
+ * @param month 将要计算的月份
+ * @return 传回农历 year年month月的总天数
+ */
+ public static int daysInLunarMonth(int year, int month) {
+ if ((LUNAR_INFO[year - CalendarViewDelegate.MIN_YEAR] & (0x100000 >> month)) == 0)
+ return 29;
+ else
+ return 30;
+ }
+
+ /**
+ * 获取公历节日
+ *
+ * @param month 公历月份
+ * @param day 公历日期
+ * @return 公历节日
+ */
+ public static String gregorianFestival(int month, int day) {
+ String text = getString(month, day);
+ String solar = "";
+ for (String aMSolarCalendar : SOLAR_CALENDAR) {
+ if (aMSolarCalendar.contains(text)) {
+ solar = aMSolarCalendar.replace(text, "");
+ break;
+ }
+ }
+ return solar;
+ }
+
+ public static String getString(int month, int day) {
+ return (month >= 10 ? String.valueOf(month) : "0" + month) + (day >= 10 ? day : "0" + day);
+ }
+
+
+ /**
+ * 返回24节气
+ *
+ * @param year 年
+ * @param month 月
+ * @param day 日
+ * @return 返回24节气
+ */
+ public static String getSolarTerm(int year, int month, int day) {
+ if (!SOLAR_TERMS.containsKey(year)) {
+ SOLAR_TERMS.put(year, SolarTermUtil.getSolarTerms(year));
+ }
+ String[] solarTerm = SOLAR_TERMS.get(year);
+ String text = String.format("%s%s", year, getString(month, day));
+ String solar = "";
+ for (String solarTermName : solarTerm) {
+ if (solarTermName.contains(text)) {
+ solar = solarTermName.replace(text, "");
+ break;
+ }
+ }
+ return solar;
+ }
+
+
+ /**
+ * 获取农历节日
+ *
+ * @param year 年
+ * @param month 月
+ * @param day 日
+ * @return 农历节日
+ */
+ public static String getLunarText(int year, int month, int day) {
+ String termText = LunarCalendarManager.getSolarTerm(year, month, day);
+ String solar = LunarCalendarManager.gregorianFestival(month, day);
+ if (!TextUtils.isEmpty(solar))
+ return solar;
+ if (!TextUtils.isEmpty(termText))
+ return termText;
+ int[] lunar = LunarUtil.solarToLunar(year, month, day);
+ String festival = getTraditionFestival(lunar[0], lunar[1], lunar[2]);
+ if (!TextUtils.isEmpty(festival))
+ return festival;
+ return LunarCalendarManager.numToChinese(lunar[1], lunar[2], lunar[3]);
+ }
+
+
+ /**
+ * 获取特殊计算方式的节日
+ * 如:每年五月的第二个星期日为母亲节,六月的第三个星期日为父亲节
+ * 每年11月第四个星期四定为"感恩节"
+ *
+ * @param year year
+ * @param month month
+ * @param day day
+ * @return 获取西方节日
+ */
+ public static String getSpecialFestival(int year, int month, int day) {
+ if (!SPECIAL_FESTIVAL.containsKey(year)) {
+ SPECIAL_FESTIVAL.put(year, getSpecialFestivals(year));
+ }
+ String[] specialFestivals = SPECIAL_FESTIVAL.get(year);
+ String text = String.format("%s%s", year, getString(month, day));
+ String solar = "";
+ for (String special : specialFestivals) {
+ if (special.contains(text)) {
+ solar = special.replace(text, "");
+ break;
+ }
+ }
+ return solar;
+ }
+
+
+ /**
+ * 获取每年的母亲节和父亲节和感恩节
+ * 特殊计算方式的节日
+ *
+ * @param year 年
+ * @return 获取每年的母亲节和父亲节、感恩节
+ */
+ public static String[] getSpecialFestivals(int year) {
+ String[] festivals = new String[3];
+ java.util.Calendar date = java.util.Calendar.getInstance();
+ date.set(year, 4, 1);
+ int week = date.get(java.util.Calendar.DAY_OF_WEEK);
+ int startDiff = 7 - week + 1;
+ if (startDiff == 7) {
+ festivals[0] = dateToString(year, 5, startDiff + 1) + SPECIAL_FESTIVAL_STR[0];
+ } else {
+ festivals[0] = dateToString(year, 5, startDiff + 7 + 1) + SPECIAL_FESTIVAL_STR[0];
+ }
+ date.set(year, 5, 1);
+ week = date.get(java.util.Calendar.DAY_OF_WEEK);
+ startDiff = 7 - week + 1;
+ if (startDiff == 7) {
+ festivals[1] = dateToString(year, 6, startDiff + 7 + 1) + SPECIAL_FESTIVAL_STR[1];
+ } else {
+ festivals[1] = dateToString(year, 6, startDiff + 7 + 7 + 1) + SPECIAL_FESTIVAL_STR[1];
+ }
+
+ date.set(year, 10, 1);
+ week = date.get(java.util.Calendar.DAY_OF_WEEK);
+ startDiff = 7 - week + 1;
+ if (startDiff <= 2) {
+ festivals[2] = dateToString(year, 11, startDiff + 21 + 5) + SPECIAL_FESTIVAL_STR[2];
+ } else {
+ festivals[2] = dateToString(year, 11, startDiff + 14 + 5) + SPECIAL_FESTIVAL_STR[2];
+ }
+ return festivals;
+ }
+
+
+ private static String dateToString(int year, int month, int day) {
+ return String.format("%s%s", year, getString(month, day));
+ }
+
+ /**
+ * 初始化各种农历、节日
+ *
+ * @param calendar calendar
+ */
+ static void setupLunarCalendar(Calendar calendar) {
+ int year = calendar.getYear();
+ int month = calendar.getMonth();
+ int day = calendar.getDay();
+ calendar.setWeekend(CalendarUtil.isWeekend(calendar));
+ calendar.setWeek(CalendarUtil.getWeekFormCalendar(calendar));
+
+ Calendar lunarCalendar = new Calendar();
+ calendar.setLunarCalendar(lunarCalendar);
+ int[] lunar = LunarUtil.solarToLunar(year, month, day);
+ lunarCalendar.setYear(lunar[0]);
+ lunarCalendar.setMonth(lunar[1]);
+ lunarCalendar.setDay(lunar[2]);
+ calendar.setLeapYear(CalendarUtil.isLeapYear(year));
+ if (lunar[3] == 1) {//如果是闰月
+ calendar.setLeapMonth(lunar[1]);
+ lunarCalendar.setLeapMonth(lunar[1]);
+ }
+ String solarTerm = LunarCalendarManager.getSolarTerm(year, month, day);
+ String gregorian = LunarCalendarManager.gregorianFestival(month, day);
+ String festival = getTraditionFestival(lunar[0], lunar[1], lunar[2]);
+ String lunarText = LunarCalendarManager.numToChinese(lunar[1], lunar[2], lunar[3]);
+ if (TextUtils.isEmpty(gregorian)) {
+ gregorian = getSpecialFestival(year, month, day);
+ }
+ calendar.setSolarTerm(solarTerm);
+ calendar.setGregorianFestival(gregorian);
+ calendar.setTraditionFestival(festival);
+ lunarCalendar.setTraditionFestival(festival);
+ lunarCalendar.setSolarTerm(solarTerm);
+ if (!TextUtils.isEmpty(solarTerm)) {
+ calendar.setLunar(solarTerm);
+ } else if (!TextUtils.isEmpty(gregorian)) {
+ calendar.setLunar(gregorian);
+ } else if (!TextUtils.isEmpty(festival)) {
+ calendar.setLunar(festival);
+ } else {
+ calendar.setLunar(lunarText);
+ }
+ lunarCalendar.setLunar(lunarText);
+ }
+
+ /**
+ * 获取农历节日
+ *
+ * @param calendar calendar
+ * @return 获取农历节日
+ */
+ public static String getLunarText(Calendar calendar) {
+ return getLunarText(calendar.getYear(), calendar.getMonth(), calendar.getDay());
+ }
+}
+
diff --git a/app/src/main/res/drawable/ic_clock_interface_simulate.xml b/app/src/main/res/drawable/ic_clock_interface_simulate.xml
new file mode 100644
index 0000000..48eca8b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_clock_interface_simulate.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 79cb8d0..fe4db19 100755
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -24,18 +24,10 @@
android:background="#00FFFFFF"
/>
-
+ android:orientation="vertical" />
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_alter.xml b/app/src/main/res/layout/fragment_alter.xml
new file mode 100644
index 0000000..82aa4e4
--- /dev/null
+++ b/app/src/main/res/layout/fragment_alter.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_digit_clock.xml b/app/src/main/res/layout/fragment_digit_clock.xml
new file mode 100644
index 0000000..27f4c40
--- /dev/null
+++ b/app/src/main/res/layout/fragment_digit_clock.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_simulate_clock.xml b/app/src/main/res/layout/fragment_simulate_clock.xml
new file mode 100644
index 0000000..4e92c56
--- /dev/null
+++ b/app/src/main/res/layout/fragment_simulate_clock.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/pop_calendar.xml b/app/src/main/res/layout/pop_calendar.xml
index 2f314b2..8c45433 100644
--- a/app/src/main/res/layout/pop_calendar.xml
+++ b/app/src/main/res/layout/pop_calendar.xml
@@ -23,7 +23,7 @@ tools:context="clock.socoolby.com.clock.MainActivity">
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="20dp"
- android:src="@drawable/ic_back" />
+ app:srcCompat="@drawable/ic_back" />
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:scaleType="centerInside"
- android:src="@mipmap/ic_calendar"
+ app:srcCompat="@mipmap/ic_calendar"
android:tint="#000000" />
+ ColorBars:srcCompat="@drawable/ic_back" />
+ ColorBars:srcCompat="@drawable/ic_check_box_black_24dp" />
+ app:srcCompat="@drawable/ic_back" />
-
-
+ android:textSize="22sp" />
+ app:srcCompat="@drawable/ic_alarm_clock" />
+
+
+ android:textSize="22sp" />
@@ -177,7 +180,7 @@ android:background="#00FFFFFF"
android:layout_marginLeft="40dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
- android:src="@drawable/ic_screen_unlock" />
+ app:srcCompat="@drawable/ic_screen_unlock" />
+ app:srcCompat="@drawable/ic_settings_black_24dp"
+ />
\ No newline at end of file
diff --git a/app/src/main/res/layout/theme_sample.xml b/app/src/main/res/layout/theme_sample.xml
index 5c2d856..1b83278 100644
--- a/app/src/main/res/layout/theme_sample.xml
+++ b/app/src/main/res/layout/theme_sample.xml
@@ -1,7 +1,8 @@
+ app:srcCompat="@drawable/ic_alarm_clock" />
+
+
+ app:srcCompat="@drawable/ic_screen_unlock" />
+ app:srcCompat="@drawable/ic_settings_black_24dp"
+ />
+
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+ - 7
+ - 8
+ - 9
+ - 10
+ - 11
+ - 12
+
+
+ - 酉
+ - 戌
+ - 亥
+ - 子
+ - 丑
+ - 寅
+ - 卯
+ - 辰
+ - 巳
+ - 午
+ - 未
+ - 申
+
+
+
+ - 春节
+ - 二月
+ - 三月
+ - 四月
+ - 五月
+ - 六月
+ - 七月
+ - 八月
+ - 九月
+ - 十月
+ - 冬月
+ - 腊月
+
+
+ - 初一
+ - 初二
+ - 初三
+ - 初四
+ - 初五
+ - 初六
+ - 初七
+ - 初八
+ - 初九
+ - 初十
+ - 十一
+ - 十二
+ - 十三
+ - 十四
+ - 十五
+ - 十六
+ - 十七
+ - 十八
+ - 十九
+ - 二十
+ - 廿一
+ - 廿二
+ - 廿三
+ - 廿四
+ - 廿五
+ - 廿六
+ - 廿七
+ - 廿八
+ - 廿九
+ - 三十
+
+
+ - 1月
+ - 2月
+ - 3月
+ - 4月
+ - 5月
+ - 6月
+ - 7月
+ - 8月
+ - 9月
+ - 10月
+ - 11月
+ - 12月
+
+
+ - 0101元旦
+ - 0214情人节
+ - 0308妇女节
+ - 0312植树节
+ - 0315消权日
+ - 0401愚人节
+ - 0422地球日
+ - 0501劳动节
+ - 0504青年节
+ - 0601儿童节
+ - 0701建党节
+ - 0801建军节
+ - 0910教师节
+ - 1001国庆节
+ - 1031万圣节
+ - 1111光棍节
+ - 1224平安夜
+ - 1225圣诞节
+
+
+ - 春分
+ - 清明
+ - 谷雨
+ - 立夏
+ - 小满
+ - 芒种
+ - 夏至
+ - 小暑
+ - 大暑
+ - 立秋
+ - 处暑
+ - 白露
+ - 秋分
+ - 寒露
+ - 霜降
+ - 立冬
+ - 小雪
+ - 大雪
+ - 冬至
+ - 小寒
+ - 大寒
+ - 立春
+ - 雨水
+ - 惊蛰
+
+
+ - 母亲节
+ - 父亲节
+ - 感恩节
+
+
+ - 除夕
+ - 0101春节
+ - 0115元宵
+ - 0505端午
+ - 0707七夕
+ - 0815中秋
+ - 0909重阳
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+ - 7
+ - 8
+ - 9
+ - 10
+
+
+
+ - 辛
+ - 壬
+ - 癸
+ - 甲
+ - 乙
+ - 丙
+ - 丁
+ - 戊
+ - 己
+ - 庚
+
+
+ - 日
+ - 一
+ - 二
+ - 三
+ - 四
+ - 五
+ - 六
+
+
+ - 日
+ - 一
+ - 二
+ - 三
+ - 四
+ - 五
+ - 六
+
+ 五
+ 一
+ 六
+ 日
+ 四
+ 二
+ 三
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index de38813..bd90c8b 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -30,4 +30,7 @@
color_depth
transparency
examples_text
+
+
+ Hello blank fragment
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index c092958..6c3dc10 100755
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,12 +1,12 @@
-
+
-
+
//设置最大进度
@@ -25,4 +25,11 @@
+
+
diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml
new file mode 100644
index 0000000..1f0e931
--- /dev/null
+++ b/app/src/main/res/values/values.xml
@@ -0,0 +1,202 @@
+
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+ - 7
+ - 8
+ - 9
+ - 10
+ - 11
+ - 12
+
+
+ - 酉
+ - 戌
+ - 亥
+ - 子
+ - 丑
+ - 寅
+ - 卯
+ - 辰
+ - 巳
+ - 午
+ - 未
+ - 申
+
+
+
+ - 春节
+ - 二月
+ - 三月
+ - 四月
+ - 五月
+ - 六月
+ - 七月
+ - 八月
+ - 九月
+ - 十月
+ - 冬月
+ - 腊月
+
+
+ - 初一
+ - 初二
+ - 初三
+ - 初四
+ - 初五
+ - 初六
+ - 初七
+ - 初八
+ - 初九
+ - 初十
+ - 十一
+ - 十二
+ - 十三
+ - 十四
+ - 十五
+ - 十六
+ - 十七
+ - 十八
+ - 十九
+ - 二十
+ - 廿一
+ - 廿二
+ - 廿三
+ - 廿四
+ - 廿五
+ - 廿六
+ - 廿七
+ - 廿八
+ - 廿九
+ - 三十
+
+
+ - JAN
+ - FEB
+ - MAR
+ - APR
+ - MAY
+ - JUN
+ - JUL
+ - AUG
+ - SEP
+ - OCT
+ - NOV
+ - DEC
+
+
+ - 0101元旦
+ - 0214情人节
+ - 0308妇女节
+ - 0312植树节
+ - 0315消权日
+ - 0401愚人节
+ - 0422地球日
+ - 0501劳动节
+ - 0504青年节
+ - 0601儿童节
+ - 0701建党节
+ - 0801建军节
+ - 0910教师节
+ - 1001国庆节
+ - 1031万圣节
+ - 1111光棍节
+ - 1224平安夜
+ - 1225圣诞节
+
+
+ - 春分
+ - 清明
+ - 谷雨
+ - 立夏
+ - 小满
+ - 芒种
+ - 夏至
+ - 小暑
+ - 大暑
+ - 立秋
+ - 处暑
+ - 白露
+ - 秋分
+ - 寒露
+ - 霜降
+ - 立冬
+ - 小雪
+ - 大雪
+ - 冬至
+ - 小寒
+ - 大寒
+ - 立春
+ - 雨水
+ - 惊蛰
+
+
+ - 母亲节
+ - 父亲节
+ - 感恩节
+
+
+ - 除夕
+ - 0101春节
+ - 0115元宵
+ - 0505端午
+ - 0707七夕
+ - 0815中秋
+ - 0909重阳
+
+
+ - 1
+ - 2
+ - 3
+ - 4
+ - 5
+ - 6
+ - 7
+ - 8
+ - 9
+ - 10
+
+
+
+ - 辛
+ - 壬
+ - 癸
+ - 甲
+ - 乙
+ - 丙
+ - 丁
+ - 戊
+ - 己
+ - 庚
+
+
+ - Sun
+ - Mon
+ - Tue
+ - Wed
+ - Thu
+ - Fri
+ - Sat
+
+
+ - S
+ - M
+ - T
+ - W
+ - T
+ - F
+ - S
+
+ Fri
+ Mon
+ Sat
+ Sun
+ Thu
+ Tue
+ Wed
+
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index 9de4793..e256cac 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,3 +17,5 @@
#systemProp.http.proxyHost=127.0.0.1
#systemProp.https.proxyHost=127.0.0.1
#systemProp.http.proxyPort=6223
+android.enableJetifier=true
+android.useAndroidX=true
\ No newline at end of file
diff --git a/gradlew b/gradlew
index 9d82f78..6c6fd53 100755
--- a/gradlew
+++ b/gradlew
@@ -112,7 +112,7 @@ if $cygwin ; then
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -typeCode d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
diff --git a/demonstrate.gif b/screenshot/demonstrate.gif
similarity index 100%
rename from demonstrate.gif
rename to screenshot/demonstrate.gif