diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0e4e872..d442eaa 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ android:sharedUserId="android.uid.system" android:name=".ClockApplication" tools:replace="android:theme" + android:installLocation="internalOnly" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"> @@ -30,6 +31,14 @@ + + + + + @@ -39,6 +48,8 @@ tools:ignore="ProtectedPermissions" /> + + \ No newline at end of file diff --git a/app/src/main/java/clock/socoolby/com/clock/BootReceiver.java b/app/src/main/java/clock/socoolby/com/clock/BootReceiver.java new file mode 100644 index 0000000..19b6676 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/BootReceiver.java @@ -0,0 +1,26 @@ +package clock.socoolby.com.clock; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class BootReceiver extends BroadcastReceiver +{ + public BootReceiver() + { + } + + @Override + public void onReceive(Context context, Intent intent) + { + if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) + { + + if(ClockApplication.getInstance().model.isBootStart()) { + Intent i = new Intent(context, MainActivity.class); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(i); + } + } + } +} \ No newline at end of file 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 94a7133..133f056 100755 --- a/app/src/main/java/clock/socoolby/com/clock/ClockApplication.java +++ b/app/src/main/java/clock/socoolby/com/clock/ClockApplication.java @@ -15,8 +15,8 @@ import com.openbravo.data.loader.dialect.SQLite.SQLite; import clock.socoolby.com.clock.dao.base.ThemeUIDao; import clock.socoolby.com.clock.dao.base.TimeFontStyleDao; import clock.socoolby.com.clock.db.WorkClockDatabase; -import clock.socoolby.com.clock.protocol.BusinessService; import clock.socoolby.com.clock.model.DateModel; +import clock.socoolby.com.clock.net.BusinessService; import clock.socoolby.com.clock.utils.FileUtils; import clock.socoolby.com.clock.model.SharePerferenceModel; import e.odbo.DB; diff --git a/app/src/main/java/clock/socoolby/com/clock/FamousQuotesManager.java b/app/src/main/java/clock/socoolby/com/clock/FamousQuotesManager.java new file mode 100644 index 0000000..abfdcb0 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/FamousQuotesManager.java @@ -0,0 +1,202 @@ +package clock.socoolby.com.clock; + +public class FamousQuotesManager { + + public static final String[] FAMOUS_QUOTES=new String[]{ + "人生在勤,不索何获?——张衡", + "尊重人不应该胜于尊重真理。——柏拉图", + "血沃中原肥劲草,寒凝大地发春华。——鲁迅", + "读书百遍,其义自见。——陈遇", + "真理是时间的女儿。——达·芬奇", + "宽恕而不忘却,就如同把斧头埋在土里而把斧柄留在外面一样。——美国.巴斯克里", + "君子喻于义,小人喻于利。——孔丘", + "差以毫厘,谬以千里。——《汉书》", + "它山之石,可以攻玉。——《诗经·小雅》", + "从善如登,从恶如崩。——《国语》", + "生活就是战斗。——柯罗连科", + "一个伟大的人有两颗心:一颗心流血,一颗心宽容。——纪伯伦", + "吃一堑,长一智。——古谚语", + "锲而舍之,朽木不折;锲而不舍,金石可镂。——荀况", + "天下事有难易乎,为之,则难者亦易矣;不为,则易者亦难矣。——彭端叔", + "坚持真理的人是伟大的。——雨果", + "星星之火,可以燎原。——尚书", + "地不耕种,再肥沃也长不出果实;人不学习,再聪明也目不识丁。——西塞罗", + "国耻未雪,何由成名?——李白", + "操千曲而后晓声,观千剑而后识器。——刘勰", + "辱,莫大于不知耻。——王通", + "不满足是向上的车轮。——鲁迅", + "出师未捷身先死,长使英雄泪沾襟。——杜甫", + "度尽劫波兄弟在,相逢一笑泯恩仇。——鲁迅", + "先天下之忧而忧,后天下之乐而乐。——范仲淹", + "天意怜幽草,人间重晚晴。——李商隐", + "土扶可城墙,积德为厚地。——李白", + "忍耐是痛苦的,但它的结果是甜蜜的。——法.卢梭", + "臣心一片磁针石,不指南方不肯休。——文天祥", + "学问是苦根上长出来的甜果。——李嘉图", + "学而不思则罔,思而不学则殆。——孔子", + "私心胜者,可以灭公。——林逋", + "不积跬步,无以至千里;不积小流,无以成江海。——荀况", + "不责人小过,不发人阴私,不念人旧恶——三者可以养德,也可以远害。——洪应明", + "学无止境。——荀子", + "学而不厌,诲人不倦。——孔子", + "天时不如地利,地利不如人和。——《孟子》", + "春蚕到死丝方尽,蜡炬成灰泪始干。——李商隐", + "心事浩茫连广宇,于无声处听惊雷。——鲁迅", + "仓廪实则知礼节,衣食足则知荣辱。——《管子》", + "深以刻薄为戒,每事当从忠厚。——薜渲", + "春风得意马蹄疾,一日看尽长安花。——孟郊", + "静以修身,俭以养德。——诸葛亮", + "白日莫闲过,青春不再来。——林宽", + "提出一个问题,往往比解决一个问题更重要。——爱因斯坦", + "宽宏精神是一切事物中最伟大的。——欧文", + "世界上最宽阔的是海洋,比海洋更宽阔的是天空,比天空更宽阔的是人的胸怀。——法.雨果", + "天下兴亡,匹夫有责。——顾炎武", + "宽容意味着尊重别人的任何信念。——爱因斯坦", + "踏破铁鞋无觅处,得来全不费功夫。——《水浒传》", + "上下同欲者胜。——孙武", + "沉舟侧畔千帆过,病树前头万木春。——刘禹锡", + "唯宽可以容人,唯厚可以载物。——薜渲", + "读书破万卷,下笔如有神。——杜甫", + "海纳百川有容乃大,山高万仞无欲则刚。——林则徐", + "贫而无谄,富而无骄。——子贡", + "君子忧道不忧贫。——孔丘", + "有时宽容引起的道德震动比惩罚更强烈。——原苏联.苏霍姆林斯基", + "志当存高远。——诸葛亮", + "察己则可以知人,察今则可以知古。——《吕氏春秋》", + "不会宽容别人的人,是不配受别人宽容的,但谁能说自己是不需要宽容的呢?——屠格涅夫", + "天行有常,不为尧存,不为桀亡。——《苟子》", + "采得百花成蜜后,为谁辛苦为谁甜。——罗隐", + "信言不美,美言不信。善者不辩,辩者不善。——老子", + "不知则问,不能则学。——董仲舒", + "希望是厄运的忠实的姐妹。——普希金", + "必须有勇气正视无情的真理。——列宁", + "桃李不言,下自成蹊。——史记", + "知耻近乎勇。——孔丘", + "新沐者必弹冠,新浴者必振衣。——屈原", + "小荷才露尖尖角,早有蜻蜓立上头。——杨万里", + "只有人的劳动才是神圣的。——高尔基", + "夕阳无限好,只是近黄昏。——李商隐", + "燕雀安知鸿鹄之志哉!——陈涉", + "人心不是靠武力征服,而是靠爱和宽容大度征服。——斯宾诺", + "业精于勤,荒于嬉。——韩愈", + "没有宽宏大量的心肠,便算不上真正的英雄。——俄.普希金", + "春色满园关不住,一枝红杏出墙来。——叶绍翁", + "要知天下事,须读古人书。——冯梦龙", + "尺有所短,寸有所长。——屈原", + "学然后知不足。——礼记", + "长风破浪会有时,直挂云帆济沧海。——李白" + }; + + + public static final String[] POETRY_OF_THE_TANG_DYNASTY=new String[]{ + "珠箔因风起,飞蛾入最能。不教人夜作,方便杀明灯。--【春夜裁缝】蒋维翰", + "空山不见人,但闻人语响。返景入深林,复照青苔上。--鹿柴 唐代:王维", + "千山鸟飞绝,万径人踪灭。孤舟蓑笠翁,独钓寒江雪。--江雪  唐代:柳宗元", + "白日依山尽,黄河入海流。欲穷千里目,更上一层楼。--登鹳雀楼  唐代:王之涣", + "驿外断桥边,寂寞开无主。已是黄昏独自愁,更著风和雨。无意苦争春,一任群芳妒。零落成泥碾作尘,只有香如故。--卜算子·咏梅 宋代:陆游", + "昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否,知否?应是绿肥红瘦.--如梦令·昨夜雨疏风骤 宋代:李清照" + }; + + public static final String[] KONGZI=new String[]{ + "三人行,必有我师焉,择其善者而从之,择其不善者而改之。", + "三军可夺帅也,匹夫不可夺志也!", + "君子欲讷于言而敏于行。", + "言未及之而言谓之躁,言及之而不言谓之隐,未见颜色而言谓之瞽。", + "无欲速,无见小利。欲速,则不达;见小利,则大事不成。", + "执德不弘,信道不笃,焉能为有,焉能为亡。", + "过而不改,是谓过矣!", + "好直不好学,其蔽也绞;好勇不好学,其蔽也乱;好刚不好学,其蔽也狂。", + "人无远虑,必有近忧。", + "君子食无求饱,居无求安,敏于事而慎于言,就有道而正焉,可谓好学也已。", + "恭而无礼则劳,慎而无礼则葸,勇而无礼则乱,直而无礼则绞。", + "己所不欲,匆施于人。", + "居处恭,执事敬,与人忠。", + "躬自厚而薄责于人,则远怨矣。", + "与朋友交,言而有信。以文会友,以友辅仁。", + "君子名之必可言也,言之必可行也,君子于其言,无所苟而已矣。", + "君子义以为质,礼以行之,孙以出之,(www.lz13.cn)信以成之。君子哉!", + "孔子曰:“能行五者于天下为仁矣。”请问之。曰:“恭宽信敏惠。恭则不侮,宽则得众,信则人任焉,敏则有功,惠则足以使人”。", + "益者三友,损者三友。友直,友谅,友多闻,益矣。友便辟,友善柔,友便佞,损矣。", + "可与言而不与之言,失人;不可与言而与之言,失言。知者不失人,亦不失言。", + "过,则匆惮改。", + "士不可不弘毅,任重而道远。仁以为己任,不亦重乎?死而后己,不亦远乎?", + "君子敬而无失,与人恭而有礼,四海之内皆兄弟也,言忠信,行笃敬,虽蛮貊之邦,行矣。言不忠信,行不笃敬,虽州里,行乎哉?", + "以文会友,以友辅仁。", + "行己有耻,使于四方,不辱君命,可谓士矣。", + "己欲立而立人,己欲达而达人。", + "见贤思齐焉,见不贤而内自省也。" + }; + + public static final String[] LAOZI=new String[]{ + "太上,不知有之;其次,亲而誉之;其次,畏之;其次,侮之。信不足焉,有不信焉。", + "宠辱若惊,贵大患若身。", + "江海所以能为百谷王者,以其善下之。——《道德经》第六十六章", + "金玉满堂,莫之能守。富贵而骄,自遗其咎。功遂身退,天之道。——《道德经》第九章", + "五色令人目盲;五音令人耳聋;五味令人口爽;驰骋畋猎,令人心发狂;难得之货,令人行妨。是以圣人为腹不为目,故去彼取此。", + "人之所畏,不可不畏。", + "上善若水,水善利万物而不争,处众人之所恶,故几于道。居善地,心善渊,与善仁,言善信,正善治,事善能,动善时。", + "天下皆知美之为美,斯恶已,皆知善之为善,斯不善已……", + "居善地,心善渊,与善仁,言善信,政善治,事善能,动善时。夫唯不争,故无尤。", + "持而盈之,不如其已;揣而锐之,不可长保。金玉满堂,莫之能守;富贵而骄,自遗其咎。功遂身退,天之道也。", + "上德不德,是以有德;下德不失德,是以无德。", + "三十辐,共一毂,当其无,有车之用。埏埴以为器,当其无,有器之用。凿户牖以为室,当其无,有室之用。故有之以为利,无之以为用。", + "天网恢恢,疏而不失。——《道德经》第七十三章", + "天下皆知美之为美,斯恶矣;皆知善之为善,斯不善已。——《道德经》第二章", + "知人者智,自知者明;胜人者有力,自胜者强。", + "俗人昭昭,我独昏昏。俗人察察,我独闷闷。", + "不出户,知天下;不窥牖,见天道。", + "天之道,损有余而补不足。人之道,则不然,损不足以奉有余。", + "圣人自知不自见;自爱不自贵。——《道德经》第七十二章", + "绝圣弃智,民利百倍;绝仁弃义,民复孝慈;绝巧弃利,盗贼无有。此三者以为文,不足。故令有所属:见素抱朴,少思寡欲,绝学无忧。", + "是以圣人不行而知,不见而名,不为而成。", + "希言自然。——《道德经》第二十三章", + "人法地,地法天,天法道,道法自然。", + "夫唯不争,故天下莫能与之争。", + "天道无亲,常与善人。", + "大道废,有仁义;智慧出,有大伪;六亲不和,有孝慈;国家昏乱,有正臣。——《道德经》第十八章", + "道可道,非常道。名可名,非常名。", + "大道废,有仁义;智慧出,有大伪;六亲不和,有孝慈;国家昏乱,有忠臣。", + "天地不仁,以万物为刍狗;圣人不仁,以百姓为刍狗。——《道德经》第五章", + "曲则全,枉则直,洼则盈,敝则新,少则多,多则惑。", + "天地所以能长且久者,以其不自生,故能长生。——《道德经》第七章", + "民不畏死,奈何以死惧之。——《道德经》第七十四章", + "大成若缺,其用不弊;大盈若冲,其用不穷。大直若屈,大巧若拙,大辫若讷。", + "绝圣弃智,民利百倍;绝仁弃义,民复孝慈;绝巧弃利,盗贼无有。——《道德经》第十九章", + "民之难治,以其智多。故以智治国,国之贼。不以智治国,国之福。——《道德经》第六十五章" + }; + + public static String roundAutoQuotes(){ + int index=new java.util.Random().nextInt(4); + switch (index){ + case 1: + return roundTangShi(); + case 2: + return roundLaoZi(); + case 3: + return roundKonZi(); + default: + return roundFamousQuotes(); + } + } + + public static String roundFamousQuotes(){ + return roundFamousQuotes(FAMOUS_QUOTES); + } + + public static String roundLaoZi(){ + return roundFamousQuotes(LAOZI); + } + + public static String roundKonZi(){ + return roundFamousQuotes(KONGZI); + } + + public static String roundTangShi(){ + return roundFamousQuotes(POETRY_OF_THE_TANG_DYNASTY); + } + + public static String roundFamousQuotes(String[] arrays){ + int index=new java.util.Random().nextInt(arrays.length); + return arrays[index]; + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/MainActivity.java b/app/src/main/java/clock/socoolby/com/clock/MainActivity.java index 3a4e3ac..f4f6469 100755 --- a/app/src/main/java/clock/socoolby/com/clock/MainActivity.java +++ b/app/src/main/java/clock/socoolby/com/clock/MainActivity.java @@ -41,6 +41,7 @@ import java.util.List; import clock.socoolby.com.clock.alter.AlterManager; import clock.socoolby.com.clock.dao.base.TimeFontStyle; +import clock.socoolby.com.clock.fragment.SystemAppConfigFragment; import clock.socoolby.com.clock.fragment.handup.AbstractHandUpFragment; import clock.socoolby.com.clock.fragment.handup.AlterFragmentFactory; import clock.socoolby.com.clock.fragment.digit.DigitClockConfigFragment; @@ -50,7 +51,7 @@ import clock.socoolby.com.clock.fragment.simulate.SimulateClockConfigFragment; import clock.socoolby.com.clock.fragment.simulate.SimulateClockFragment; import clock.socoolby.com.clock.fragment.ThemeUIDefaultFragment; import clock.socoolby.com.clock.fragment.ThemeUISampleFragment; -import clock.socoolby.com.clock.protocol.WeatherResponse; +import clock.socoolby.com.clock.net.protocol.weather.WeatherResponse; import clock.socoolby.com.clock.service.ProximityService; import clock.socoolby.com.clock.state.ClockModeEnum; import clock.socoolby.com.clock.state.ClockStateMachine; @@ -150,14 +151,12 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges }else getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - //创建手势检测器 detector = new GestureDetector(this, this); detector.setOnDoubleTapListener(this); scaleGestureDetector=new ScaleGestureDetector(this,this); - ClockApplication.getInstance().setMainActivity(this); init(); @@ -165,10 +164,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges //ClockApplication.valueOf().getBusinessService().checkUpdate(); } - public FrameLayout getThemeUIContainer() { - return themeUIContainer; - } - private boolean isPowerManagerDisable(){ return wakeLock==null; } @@ -212,7 +207,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges proximityServiceIntent = new Intent(this, ProximityService.class); fontManager=new FontManager(ClockApplication.getInstance().getEntityManager()); - //fontManager.setCurrentFontName(model.getFontName()); animatorManager=new AnimatorManager(); @@ -231,8 +225,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges bindViewModel(); - //digitViewModel.getTimeFontStyle().setValue(fontManager.getCurrentFontStyle()); - themeUIManager=new ThemeUIManager(ClockApplication.getInstance().getEntityManager(),model); testSetup(); @@ -243,6 +235,8 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges globalViewModel.getHourAlterTypeName().setValue(FishAnimator.NAME); + //model.setBootStart(true); + //globalViewModel.getHandUpTypeName().setValue(HandUpSelect123Fragment.NAME); /*Observer timeChange= new Observer() { @@ -437,6 +431,8 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges @Override public boolean onTouchEvent(MotionEvent me) { + if(globalViewModel.getAppConfig()) + return false; if(me.getPointerCount()>1) return scaleGestureDetector.onTouchEvent(me); return detector.onTouchEvent(me); @@ -552,6 +548,11 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges if(isScreenLock()) return super.onKeyDown(keyCode, event); if (keyCode == KeyEvent.KEYCODE_BACK) { + if(globalViewModel.getAppConfig()) { + getSupportFragmentManager().popBackStack(); + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + return true; + } if(!isFullScreen()){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(android.R.drawable.ic_dialog_info); @@ -567,7 +568,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges }); builder.create().show(); } - //changeThemeUI(); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); return true; } else if (keyCode == KeyEvent.KEYCODE_MENU) { @@ -577,9 +577,9 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges } public void setup(){ - Intent intent = new Intent(this, SettingActivity.class); - startActivityForResult(intent, SETTING_REQUEST_CODE); - //switchMode(MODE_SETTING_OTHER); + //Intent intent = new Intent(this, SettingActivity.class); + //startActivityForResult(intent, SETTING_REQUEST_CODE); + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SystemAppConfigFragment(model)).addToBackStack(null).commit(); } @Override @@ -700,7 +700,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges return false; } - boolean isShowAdvConfig=false; + //boolean isShowAdvConfig=false; @Override public boolean onDoubleTap(MotionEvent e) { @@ -714,18 +714,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges return ; switch (globalViewModel.getClockInterfaceTypeEnum().getValue()){ case Digit: - if(!isShowAdvConfig) - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment(themeUIManager)).addToBackStack(null).commit(); - else - getSupportFragmentManager().popBackStack(); - isShowAdvConfig=!isShowAdvConfig; + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment(themeUIManager)).addToBackStack(null).commit(); break; case Simulate: - if(!isShowAdvConfig) - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SimulateClockConfigFragment(themeUIManager)).addToBackStack(null).commit(); - else - getSupportFragmentManager().popBackStack(); - isShowAdvConfig=!isShowAdvConfig; + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SimulateClockConfigFragment(themeUIManager)).addToBackStack(null).commit(); break; } } diff --git a/app/src/main/java/clock/socoolby/com/clock/SettingActivity.java b/app/src/main/java/clock/socoolby/com/clock/SettingActivity.java index f1a9444..298f8e3 100755 --- a/app/src/main/java/clock/socoolby/com/clock/SettingActivity.java +++ b/app/src/main/java/clock/socoolby/com/clock/SettingActivity.java @@ -22,204 +22,6 @@ import clock.socoolby.com.clock.widget.wheelview.adapters.ArrayWheelAdapter; public class SettingActivity extends AppCompatActivity implements View.OnClickListener { - public static final String[] FAMOUS_QUOTES=new String[]{ - "人生在勤,不索何获?——张衡", - "尊重人不应该胜于尊重真理。——柏拉图", - "血沃中原肥劲草,寒凝大地发春华。——鲁迅", - "读书百遍,其义自见。——陈遇", - "真理是时间的女儿。——达·芬奇", - "宽恕而不忘却,就如同把斧头埋在土里而把斧柄留在外面一样。——美国.巴斯克里", - "君子喻于义,小人喻于利。——孔丘", - "差以毫厘,谬以千里。——《汉书》", - "它山之石,可以攻玉。——《诗经·小雅》", - "从善如登,从恶如崩。——《国语》", - "生活就是战斗。——柯罗连科", - "一个伟大的人有两颗心:一颗心流血,一颗心宽容。——纪伯伦", - "吃一堑,长一智。——古谚语", - "锲而舍之,朽木不折;锲而不舍,金石可镂。——荀况", - "天下事有难易乎,为之,则难者亦易矣;不为,则易者亦难矣。——彭端叔", - "坚持真理的人是伟大的。——雨果", - "星星之火,可以燎原。——尚书", - "地不耕种,再肥沃也长不出果实;人不学习,再聪明也目不识丁。——西塞罗", - "国耻未雪,何由成名?——李白", - "操千曲而后晓声,观千剑而后识器。——刘勰", - "辱,莫大于不知耻。——王通", - "不满足是向上的车轮。——鲁迅", - "出师未捷身先死,长使英雄泪沾襟。——杜甫", - "度尽劫波兄弟在,相逢一笑泯恩仇。——鲁迅", - "先天下之忧而忧,后天下之乐而乐。——范仲淹", - "天意怜幽草,人间重晚晴。——李商隐", - "土扶可城墙,积德为厚地。——李白", - "忍耐是痛苦的,但它的结果是甜蜜的。——法.卢梭", - "臣心一片磁针石,不指南方不肯休。——文天祥", - "学问是苦根上长出来的甜果。——李嘉图", - "学而不思则罔,思而不学则殆。——孔子", - "私心胜者,可以灭公。——林逋", - "不积跬步,无以至千里;不积小流,无以成江海。——荀况", - "不责人小过,不发人阴私,不念人旧恶——三者可以养德,也可以远害。——洪应明", - "学无止境。——荀子", - "学而不厌,诲人不倦。——孔子", - "天时不如地利,地利不如人和。——《孟子》", - "春蚕到死丝方尽,蜡炬成灰泪始干。——李商隐", - "心事浩茫连广宇,于无声处听惊雷。——鲁迅", - "仓廪实则知礼节,衣食足则知荣辱。——《管子》", - "深以刻薄为戒,每事当从忠厚。——薜渲", - "春风得意马蹄疾,一日看尽长安花。——孟郊", - "静以修身,俭以养德。——诸葛亮", - "白日莫闲过,青春不再来。——林宽", - "提出一个问题,往往比解决一个问题更重要。——爱因斯坦", - "宽宏精神是一切事物中最伟大的。——欧文", - "世界上最宽阔的是海洋,比海洋更宽阔的是天空,比天空更宽阔的是人的胸怀。——法.雨果", - "天下兴亡,匹夫有责。——顾炎武", - "宽容意味着尊重别人的任何信念。——爱因斯坦", - "踏破铁鞋无觅处,得来全不费功夫。——《水浒传》", - "上下同欲者胜。——孙武", - "沉舟侧畔千帆过,病树前头万木春。——刘禹锡", - "唯宽可以容人,唯厚可以载物。——薜渲", - "读书破万卷,下笔如有神。——杜甫", - "海纳百川有容乃大,山高万仞无欲则刚。——林则徐", - "贫而无谄,富而无骄。——子贡", - "君子忧道不忧贫。——孔丘", - "有时宽容引起的道德震动比惩罚更强烈。——原苏联.苏霍姆林斯基", - "志当存高远。——诸葛亮", - "察己则可以知人,察今则可以知古。——《吕氏春秋》", - "不会宽容别人的人,是不配受别人宽容的,但谁能说自己是不需要宽容的呢?——屠格涅夫", - "天行有常,不为尧存,不为桀亡。——《苟子》", - "采得百花成蜜后,为谁辛苦为谁甜。——罗隐", - "信言不美,美言不信。善者不辩,辩者不善。——老子", - "不知则问,不能则学。——董仲舒", - "希望是厄运的忠实的姐妹。——普希金", - "必须有勇气正视无情的真理。——列宁", - "桃李不言,下自成蹊。——史记", - "知耻近乎勇。——孔丘", - "新沐者必弹冠,新浴者必振衣。——屈原", - "小荷才露尖尖角,早有蜻蜓立上头。——杨万里", - "只有人的劳动才是神圣的。——高尔基", - "夕阳无限好,只是近黄昏。——李商隐", - "燕雀安知鸿鹄之志哉!——陈涉", - "人心不是靠武力征服,而是靠爱和宽容大度征服。——斯宾诺", - "业精于勤,荒于嬉。——韩愈", - "没有宽宏大量的心肠,便算不上真正的英雄。——俄.普希金", - "春色满园关不住,一枝红杏出墙来。——叶绍翁", - "要知天下事,须读古人书。——冯梦龙", - "尺有所短,寸有所长。——屈原", - "学然后知不足。——礼记", - "长风破浪会有时,直挂云帆济沧海。——李白" - }; - - - public static final String[] POETRY_OF_THE_TANG_DYNASTY=new String[]{ - "珠箔因风起,飞蛾入最能。不教人夜作,方便杀明灯。--【春夜裁缝】蒋维翰", - "空山不见人,但闻人语响。返景入深林,复照青苔上。--鹿柴 唐代:王维", - "千山鸟飞绝,万径人踪灭。孤舟蓑笠翁,独钓寒江雪。--江雪  唐代:柳宗元", - "白日依山尽,黄河入海流。欲穷千里目,更上一层楼。--登鹳雀楼  唐代:王之涣", - "驿外断桥边,寂寞开无主。已是黄昏独自愁,更著风和雨。无意苦争春,一任群芳妒。零落成泥碾作尘,只有香如故。--卜算子·咏梅 宋代:陆游", - "昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否,知否?应是绿肥红瘦.--如梦令·昨夜雨疏风骤 宋代:李清照" - }; - - public static final String[] KONGZI=new String[]{ - "三人行,必有我师焉,择其善者而从之,择其不善者而改之。", - "三军可夺帅也,匹夫不可夺志也!", - "君子欲讷于言而敏于行。", - "言未及之而言谓之躁,言及之而不言谓之隐,未见颜色而言谓之瞽。", - "无欲速,无见小利。欲速,则不达;见小利,则大事不成。", - "执德不弘,信道不笃,焉能为有,焉能为亡。", - "过而不改,是谓过矣!", - "好直不好学,其蔽也绞;好勇不好学,其蔽也乱;好刚不好学,其蔽也狂。", - "人无远虑,必有近忧。", - "君子食无求饱,居无求安,敏于事而慎于言,就有道而正焉,可谓好学也已。", - "恭而无礼则劳,慎而无礼则葸,勇而无礼则乱,直而无礼则绞。", - "己所不欲,匆施于人。", - "居处恭,执事敬,与人忠。", - "躬自厚而薄责于人,则远怨矣。", - "与朋友交,言而有信。以文会友,以友辅仁。", - "君子名之必可言也,言之必可行也,君子于其言,无所苟而已矣。", - "君子义以为质,礼以行之,孙以出之,(www.lz13.cn)信以成之。君子哉!", - "孔子曰:“能行五者于天下为仁矣。”请问之。曰:“恭宽信敏惠。恭则不侮,宽则得众,信则人任焉,敏则有功,惠则足以使人”。", - "益者三友,损者三友。友直,友谅,友多闻,益矣。友便辟,友善柔,友便佞,损矣。", - "可与言而不与之言,失人;不可与言而与之言,失言。知者不失人,亦不失言。", - "过,则匆惮改。", - "士不可不弘毅,任重而道远。仁以为己任,不亦重乎?死而后己,不亦远乎?", - "君子敬而无失,与人恭而有礼,四海之内皆兄弟也,言忠信,行笃敬,虽蛮貊之邦,行矣。言不忠信,行不笃敬,虽州里,行乎哉?", - "以文会友,以友辅仁。", - "行己有耻,使于四方,不辱君命,可谓士矣。", - "己欲立而立人,己欲达而达人。", - "见贤思齐焉,见不贤而内自省也。" - }; - - public static final String[] LAOZI=new String[]{ - "太上,不知有之;其次,亲而誉之;其次,畏之;其次,侮之。信不足焉,有不信焉。", - "宠辱若惊,贵大患若身。", - "江海所以能为百谷王者,以其善下之。——《道德经》第六十六章", - "金玉满堂,莫之能守。富贵而骄,自遗其咎。功遂身退,天之道。——《道德经》第九章", - "五色令人目盲;五音令人耳聋;五味令人口爽;驰骋畋猎,令人心发狂;难得之货,令人行妨。是以圣人为腹不为目,故去彼取此。", - "人之所畏,不可不畏。", - "上善若水,水善利万物而不争,处众人之所恶,故几于道。居善地,心善渊,与善仁,言善信,正善治,事善能,动善时。", - "天下皆知美之为美,斯恶已,皆知善之为善,斯不善已……", - "居善地,心善渊,与善仁,言善信,政善治,事善能,动善时。夫唯不争,故无尤。", - "持而盈之,不如其已;揣而锐之,不可长保。金玉满堂,莫之能守;富贵而骄,自遗其咎。功遂身退,天之道也。", - "上德不德,是以有德;下德不失德,是以无德。", - "三十辐,共一毂,当其无,有车之用。埏埴以为器,当其无,有器之用。凿户牖以为室,当其无,有室之用。故有之以为利,无之以为用。", - "天网恢恢,疏而不失。——《道德经》第七十三章", - "天下皆知美之为美,斯恶矣;皆知善之为善,斯不善已。——《道德经》第二章", - "知人者智,自知者明;胜人者有力,自胜者强。", - "俗人昭昭,我独昏昏。俗人察察,我独闷闷。", - "不出户,知天下;不窥牖,见天道。", - "天之道,损有余而补不足。人之道,则不然,损不足以奉有余。", - "圣人自知不自见;自爱不自贵。——《道德经》第七十二章", - "绝圣弃智,民利百倍;绝仁弃义,民复孝慈;绝巧弃利,盗贼无有。此三者以为文,不足。故令有所属:见素抱朴,少思寡欲,绝学无忧。", - "是以圣人不行而知,不见而名,不为而成。", - "希言自然。——《道德经》第二十三章", - "人法地,地法天,天法道,道法自然。", - "夫唯不争,故天下莫能与之争。", - "天道无亲,常与善人。", - "大道废,有仁义;智慧出,有大伪;六亲不和,有孝慈;国家昏乱,有正臣。——《道德经》第十八章", - "道可道,非常道。名可名,非常名。", - "大道废,有仁义;智慧出,有大伪;六亲不和,有孝慈;国家昏乱,有忠臣。", - "天地不仁,以万物为刍狗;圣人不仁,以百姓为刍狗。——《道德经》第五章", - "曲则全,枉则直,洼则盈,敝则新,少则多,多则惑。", - "天地所以能长且久者,以其不自生,故能长生。——《道德经》第七章", - "民不畏死,奈何以死惧之。——《道德经》第七十四章", - "大成若缺,其用不弊;大盈若冲,其用不穷。大直若屈,大巧若拙,大辫若讷。", - "绝圣弃智,民利百倍;绝仁弃义,民复孝慈;绝巧弃利,盗贼无有。——《道德经》第十九章", - "民之难治,以其智多。故以智治国,国之贼。不以智治国,国之福。——《道德经》第六十五章" - }; - - public static String roundAutoQuotes(){ - int index=new java.util.Random().nextInt(4); - switch (index){ - case 1: - return roundTangShi(); - case 2: - return roundLaoZi(); - case 3: - return roundKonZi(); - default: - return roundFamousQuotes(); - } - } - - public static String roundFamousQuotes(){ - return roundFamousQuotes(FAMOUS_QUOTES); - } - - public static String roundLaoZi(){ - return roundFamousQuotes(LAOZI); - } - - public static String roundKonZi(){ - return roundFamousQuotes(KONGZI); - } - - public static String roundTangShi(){ - return roundFamousQuotes(POETRY_OF_THE_TANG_DYNASTY); - } - - public static String roundFamousQuotes(String[] arrays){ - int index=new java.util.Random().nextInt(arrays.length); - return arrays[index]; - } - private WheelView weel_startTime; private WheelView weel_stopTime; @@ -228,11 +30,11 @@ public class SettingActivity extends AppCompatActivity implements View.OnClickLi RadioButton rb_noreport; private EditText et_description; private EditText et_city; - + String[] listTime = new String[48]; private SharePerferenceModel model; - String[] listTime = new String[48]; + @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/clock/socoolby/com/clock/ThemeUIManager.java b/app/src/main/java/clock/socoolby/com/clock/ThemeUIManager.java index 3824637..eececc9 100644 --- a/app/src/main/java/clock/socoolby/com/clock/ThemeUIManager.java +++ b/app/src/main/java/clock/socoolby/com/clock/ThemeUIManager.java @@ -6,12 +6,6 @@ import com.openbravo.data.basic.BasicException; import org.json.JSONException; import org.json.JSONObject; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.Reader; -import java.sql.Clob; -import java.sql.SQLException; import java.util.List; import clock.socoolby.com.clock.dao.base.ThemeUI; diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/AbstractThemeUIFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/AbstractThemeUIFragment.java index bc682d6..a2c3045 100644 --- a/app/src/main/java/clock/socoolby/com/clock/fragment/AbstractThemeUIFragment.java +++ b/app/src/main/java/clock/socoolby/com/clock/fragment/AbstractThemeUIFragment.java @@ -20,6 +20,7 @@ import java.util.Timer; import java.util.TimerTask; import clock.socoolby.com.clock.ClockApplication; +import clock.socoolby.com.clock.FamousQuotesManager; import clock.socoolby.com.clock.MainActivity; import clock.socoolby.com.clock.R; import clock.socoolby.com.clock.SettingActivity; @@ -466,7 +467,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O private void setDiscriptForModel() { String dis = model.getDescription(); if (dis == null || dis.isEmpty()) - dis = SettingActivity.roundFamousQuotes(); + dis = FamousQuotesManager.roundFamousQuotes(); setDiscript(dis); } @@ -519,7 +520,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O mainActivity.getClockStateMachine().countingCheck(); break; case R.id.tv_descript: - setDiscript(SettingActivity.roundAutoQuotes()); + setDiscript(FamousQuotesManager.roundAutoQuotes()); break; case R.id.tv_background_color: if (colorPickerDialog == null) diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/SystemAppConfigFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/SystemAppConfigFragment.java new file mode 100644 index 0000000..e7f4586 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/fragment/SystemAppConfigFragment.java @@ -0,0 +1,235 @@ +package clock.socoolby.com.clock.fragment; + +import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.RadioButton; +import android.widget.RadioGroup; + +import androidx.fragment.app.Fragment; +import androidx.lifecycle.ViewModelProviders; + +import clock.socoolby.com.clock.AboutActivity; +import clock.socoolby.com.clock.ActivateAdmin; +import clock.socoolby.com.clock.ClockApplication; +import clock.socoolby.com.clock.Constants; +import clock.socoolby.com.clock.R; +import clock.socoolby.com.clock.model.DateModel; +import clock.socoolby.com.clock.model.SharePerferenceModel; +import clock.socoolby.com.clock.utils.FuncUnit; +import clock.socoolby.com.clock.viewmodel.GlobalViewModel; +import clock.socoolby.com.clock.viewmodel.ViewModelFactory; +import clock.socoolby.com.clock.widget.wheelview.WheelView; +import clock.socoolby.com.clock.widget.wheelview.adapters.ArrayWheelAdapter; + +import static android.content.Context.DEVICE_POLICY_SERVICE; + +public class SystemAppConfigFragment extends Fragment implements View.OnClickListener{ + public static final String TAG= SystemAppConfigFragment.class.getSimpleName(); + private GlobalViewModel globalViewModel; + + private WheelView weel_startTime; + private WheelView weel_stopTime; + RadioButton rb_halfhour; + RadioButton rb_hours; + RadioButton rb_noreport; + private EditText et_description; + private EditText et_city; + String[] listTime = new String[48]; + + RadioGroup rg_taking_clock; + CheckBox cb_tick; + CheckBox cb_trigger_screen; + Button btn_uninstall; + Button btn_about; + Button btn_save; + + private SharePerferenceModel model; + + public SystemAppConfigFragment(SharePerferenceModel model) { + this.model = model; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); + globalViewModel.setAppConfig(true); + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View themeRootView = inflater.inflate(R.layout.fragment_setting, container, false); + + rg_taking_clock = themeRootView.findViewById(R.id.rg_talking_clock); + rb_halfhour = themeRootView.findViewById(R.id.rb_halfhour); + rb_hours = themeRootView.findViewById(R.id.rb_hours); + rb_noreport = themeRootView.findViewById(R.id.rb_noreport); + weel_startTime = themeRootView.findViewById(R.id.weel_start_time); + weel_stopTime = themeRootView.findViewById(R.id.weel_stop_time); + + et_city =themeRootView.findViewById(R.id.et_city); + et_description = themeRootView.findViewById(R.id.et_description); + + + cb_tick = themeRootView.findViewById(R.id.cb_tick); + + cb_tick.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + model.setTickSound(b); + } + }); + + cb_trigger_screen = themeRootView.findViewById(R.id.cb_trigger_screen); + + cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + model.setTriggerScreen(isChecked); + } + }); + + btn_uninstall = themeRootView.findViewById(R.id.btn_uninstall); + btn_uninstall.setOnClickListener(this); + btn_about = themeRootView.findViewById(R.id.btn_about); + btn_about.setOnClickListener(this); + + btn_save= themeRootView.findViewById(R.id.btn_save); + btn_save.setOnClickListener(this); + + for (int i = 0; i < 48; i++) { + int hours = i / 2; + int minutes = i % 2 * 30; + String timeString = String.format("%02d:%02d", hours, (minutes + 1)); + listTime[i] = timeString; + } + + ArrayWheelAdapter timeAdpater = new ArrayWheelAdapter(getContext(), listTime); + weel_startTime.setViewAdapter(timeAdpater); + ArrayWheelAdapter durationAdapter = new ArrayWheelAdapter(getContext(), listTime); + weel_stopTime.setViewAdapter(durationAdapter); + + loadDataFromModel(); + + rg_taking_clock.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup radioGroup, int index) { + int checkID = radioGroup.getCheckedRadioButtonId(); + switch (checkID) { + case R.id.rb_halfhour: + model.setTypeHourPower(Constants.TALKING_HALF_AN_HOUR); + break; + case R.id.rb_hours: + model.setTypeHourPower(Constants.TALKING_HOURS); + break; + case R.id.rb_noreport: + model.setTypeHourPower(Constants.TALKING_NO_REPORT); + break; + + } + + } + }); + + + return themeRootView; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + globalViewModel.setAppConfig(false); + } + + private void loadDataFromModel() { + int startTimeIndex = indexOfTimeString(String.format("%02d:%02d", model.getStartHourPowerTime().getHour(), model.getStartHourPowerTime().getMinute())); + int stopTimeIndex = indexOfTimeString(String.format("%02d:%02d", model.getStopHourPowerTime().getHour(), model.getStopHourPowerTime().getMinute())); + weel_startTime.setCurrentItem(startTimeIndex); + weel_stopTime.setCurrentItem(stopTimeIndex); + + cb_tick.setChecked(model.isTickSound()); + + cb_trigger_screen.setChecked(model.isTriggerScreen()); + + switch (model.getTypeHourPower()) { + case Constants.TALKING_HALF_AN_HOUR: + rb_halfhour.setChecked(true); + break; + case Constants.TALKING_HOURS: + rb_hours.setChecked(true); + break; + case Constants.TALKING_NO_REPORT: + rb_noreport.setChecked(true); + break; + } + et_city.setText(model.getCity()); + et_description.setText(model.getDescription()); + } + + private void saveToModel() { + reportTimeConfirm(); + model.setCity(et_city.getText().toString()); + model.setDescription(et_description.getText().toString()); + globalViewModel.loadFromModel(); + } + + private int indexOfTimeString(String timeString) { + for (int i = listTime.length - 1; i >= 0; i--) { + if (listTime[i].equals(timeString)) + return i; + } + return 0; + } + + private void reportTimeConfirm() { + String timeStart = listTime[weel_startTime.getCurrentItem()]; + String timeStop = listTime[weel_stopTime.getCurrentItem()]; + + DateModel startTimeModel = new DateModel(); + startTimeModel.setTimeString(timeStart); + DateModel stopTimeModel = new DateModel(); + stopTimeModel.setTimeString(timeStop); + model.setStartHourPowerTime(startTimeModel); + model.setStopHourPowerTime(stopTimeModel); + } + + private void uninstallActivity() { + DevicePolicyManager policyManager; + ComponentName componentName; + policyManager = (DevicePolicyManager) getActivity().getSystemService(DEVICE_POLICY_SERVICE); + + componentName = new ComponentName(getActivity(), ActivateAdmin.class); + policyManager.removeActiveAdmin(componentName); + startActivity(new Intent("android.intent.action.DELETE", Uri.parse("package:" + FuncUnit.getBoxPackageName()))); + getActivity().finish(); + } + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.btn_uninstall: + uninstallActivity(); + break; + case R.id.btn_about: + Intent intent = new Intent(getActivity(), AboutActivity.class); + startActivity(intent); + break; + case R.id.btn_save: + saveToModel(); + getFragmentManager().popBackStack(); + break; + } + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockConfigFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockConfigFragment.java index fa17bd6..042544c 100644 --- a/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockConfigFragment.java +++ b/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockConfigFragment.java @@ -50,7 +50,6 @@ public class DigitClockConfigFragment extends Fragment { ThemeUIManager themeUIManager; - @BindView(R.id.tv_hourSystem12) RadioButton tvHourSystem12; @BindView(R.id.tv_hourSystem24) @@ -131,6 +130,12 @@ public class DigitClockConfigFragment extends Fragment { VerticalRangeSeekBar tvTimeTextBaslineDown; @BindView(R.id.tv_textStyle_border_divider_color) Button tvTextStyleBorderDividerColor; + @BindView(R.id.tv_time_text_subscript_scale) + VerticalRangeSeekBar tvTimeTextSubscriptScale; + @BindView(R.id.tv_time_text_padding) + VerticalRangeSeekBar tvTimeTextPadding; + @BindView(R.id.tv_textStyle_border_doubble) + CheckBox tvTextStyleBorderDoubble; public DigitClockConfigFragment(ThemeUIManager themeUIManager) { this.themeUIManager = themeUIManager; @@ -142,6 +147,7 @@ public class DigitClockConfigFragment extends Fragment { globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class); themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code); + globalViewModel.setAppConfig(true); } private Unbinder unbinder; @@ -155,7 +161,19 @@ public class DigitClockConfigFragment extends Fragment { unbinder = ButterKnife.bind(this, view); - tvTimeTextBaslineDown.setTickMarkTextArray(new CharSequence[]{"100", "位移", "100"}); + view.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + getFragmentManager().popBackStack(); + return true; + } + }); + + tvTimeTextBaslineDown.setTickMarkTextArray(new CharSequence[]{"下", "位移", "上"}); + + tvTimeTextSubscriptScale.setTickMarkTextArray(new CharSequence[]{"1", "秒比", "100"}); + + tvTimeTextPadding.setTickMarkTextArray(new CharSequence[]{"0", "间隔", "20"}); loadForViewModel(); @@ -290,6 +308,7 @@ public class DigitClockConfigFragment extends Fragment { tvSecondSubscript.setOnCheckedChangeListener((group, checkedId) -> { digitViewModel.setSecondSubscript(tvSecondSubscript.isChecked()); + tvTimeTextSubscriptScale.setVisibility(tvSecondSubscript.isChecked() ? View.VISIBLE : View.GONE); }); tvTextStyleBorder.setOnCheckedChangeListener((group, checkedId) -> { @@ -332,6 +351,10 @@ public class DigitClockConfigFragment extends Fragment { colorPickerDialog.show(digitViewModel.getCharBackgroundBorderColor().getValue()); }); + tvTextStyleBorderDoubble.setOnCheckedChangeListener((group, checkedId) -> { + digitViewModel.setCharBackgroundBorderWithDoubble(tvTextStyleBorderDoubble.isChecked()); + }); + tvTimeTextBaslineDown.setOnRangeChangedListener(new OnRangeChangedListener() { @Override public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) { @@ -349,6 +372,40 @@ public class DigitClockConfigFragment extends Fragment { } }); + tvTimeTextSubscriptScale.setOnRangeChangedListener(new OnRangeChangedListener() { + @Override + public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) { + digitViewModel.setSubscriptFontScale(new Float(leftValue).intValue()); + } + + @Override + public void onStartTrackingTouch(RangeSeekBar view, boolean isLeft) { + + } + + @Override + public void onStopTrackingTouch(RangeSeekBar view, boolean isLeft) { + + } + }); + + tvTimeTextPadding.setOnRangeChangedListener(new OnRangeChangedListener() { + @Override + public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) { + digitViewModel.setTimeTextPadding(new Float(leftValue).intValue()); + } + + @Override + public void onStartTrackingTouch(RangeSeekBar view, boolean isLeft) { + + } + + @Override + public void onStopTrackingTouch(RangeSeekBar view, boolean isLeft) { + + } + }); + return view; } @@ -412,6 +469,7 @@ public class DigitClockConfigFragment extends Fragment { @Override public void onDestroyView() { super.onDestroyView(); + globalViewModel.setAppConfig(false); unbinder.unbind(); } @@ -496,6 +554,8 @@ public class DigitClockConfigFragment extends Fragment { tvTextStyleBorderColor.setBackgroundColor(digitViewModel.getCharBackgroundBorderColor().getValue()); tvTextStyleBorderDividerColor.setBackgroundColor(digitViewModel.getCharBackgroundBorderDividerColor().getValue()); + tvTextStyleBorderDoubble.setChecked(digitViewModel.getCharBackgroundBorderWithDoubble().getValue()); + float baseLineDown = 100f + digitViewModel.getBaseLineDown().getValue(); if (baseLineDown > 200) baseLineDown = 200; @@ -503,10 +563,17 @@ public class DigitClockConfigFragment extends Fragment { baseLineDown = 100; tvTimeTextBaslineDown.setProgress(baseLineDown); - digitViewModel.getCharBackgroundBorder().observe(this,(able)->{ + tvTimeTextSubscriptScale.setVisibility(digitViewModel.getDisplaySecond().getValue() ? View.VISIBLE : View.GONE); + tvTimeTextSubscriptScale.setProgress(digitViewModel.getSubscriptFontScale().getValue()); + + digitViewModel.getCharBackgroundBorder().observe(this, (able) -> { tvTextStyleBorderColor.setClickable(able); tvTextStyleBorderDividerColor.setClickable(able); + tvTextStyleBorderDoubble.setClickable(able); }); + + tvTimeTextPadding.setProgress(digitViewModel.getTimeTextPadding().getValue()); + } private void setTextColor(int color) { @@ -550,9 +617,11 @@ public class DigitClockConfigFragment extends Fragment { tvTextStyleBorder.setTextColor(color); tvTextStyleBorderColor.setTextColor(color); tvTextStyleBorderDividerColor.setTextColor(color); + tvTextStyleBorderDoubble.setTextColor(color); tvTimeTextBaslineDown.setTickMarkTextColor(color); - + tvTimeTextSubscriptScale.setTickMarkTextColor(color); + tvTimeTextPadding.setTickMarkTextColor(color); } static Random rand = new Random(); diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockFragment.java index a1e82c6..0a29fb8 100644 --- a/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockFragment.java +++ b/app/src/main/java/clock/socoolby/com/clock/fragment/digit/DigitClockFragment.java @@ -143,8 +143,13 @@ public class DigitClockFragment extends Fragment { digitViewModel.getCharBackgroundBorderDividerColor().observe(this,color->tv_time.setBackgroundBorderDividerColor(color)); digitViewModel.getCharBackgroundBorderDividerWidth().observe(this,width->tv_time.setBackgroundBorderDividerWidth(width)); - } + digitViewModel.getSubscriptFontScale().observe(this,scale->tv_time.setFontScale(scale)); + + digitViewModel.getTimeTextPadding().observe(this,padding->tv_time.setPaddingScale(padding)); + + digitViewModel.getCharBackgroundBorderWithDoubble().observe(this,doubble->tv_time.setCharBackgroundBorderWithDoubble(doubble)); + } protected void reflushFontStyle(TimeFontStyle fontStyle){ diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockConfigFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockConfigFragment.java index 8dc072c..b9723f3 100644 --- a/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockConfigFragment.java +++ b/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockConfigFragment.java @@ -112,6 +112,7 @@ public class SimulateClockConfigFragment extends Fragment { globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class); simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class); themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code); + globalViewModel.setAppConfig(true); } @Override @@ -125,6 +126,14 @@ public class SimulateClockConfigFragment extends Fragment { View view = inflater.inflate(R.layout.fragment_simulate_config, container, false); unbinder = ButterKnife.bind(this, view); + view.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + getFragmentManager().popBackStack(); + return true; + } + }); + bindViewModel(); tvSimulateTextShowGroup.setOnCheckedChangeListener((view1, checkId) -> { @@ -318,6 +327,7 @@ public class SimulateClockConfigFragment extends Fragment { @Override public void onDestroyView() { super.onDestroyView(); + globalViewModel.setAppConfig(false); unbinder.unbind(); } diff --git a/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockFragment.java b/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockFragment.java index 170275d..302c8c0 100644 --- a/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockFragment.java +++ b/app/src/main/java/clock/socoolby/com/clock/fragment/simulate/SimulateClockFragment.java @@ -111,7 +111,7 @@ public class SimulateClockFragment extends Fragment { AbstractClock clock; private void setClockStyle(String clockStyle){ - //clockAnimator.setColor(globalViewModel.getForegroundColor().getValue()); + //clockAnimator.setParticleColor(globalViewModel.getForegroundColor().getValue()); clock= ClockFactory.build(clockStyle); clockAnimator.setClock(clock); clockAnimator.setClockPointer(PointerFactory.build(simulateViewModel.getPointerTypeName().getValue())); diff --git a/app/src/main/java/clock/socoolby/com/clock/model/DigitPerferenceModel.java b/app/src/main/java/clock/socoolby/com/clock/model/DigitPerferenceModel.java index 2050424..b2bbd7c 100644 --- a/app/src/main/java/clock/socoolby/com/clock/model/DigitPerferenceModel.java +++ b/app/src/main/java/clock/socoolby/com/clock/model/DigitPerferenceModel.java @@ -45,6 +45,15 @@ public class DigitPerferenceModel { protected final static String KEY_TIME_TEXT_BASELINE_DOWN= "key_time_text_baseline_down"; protected Integer baseLineDown=0; + protected final static String KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE= "key_time_text_subscript_font_scale"; + protected Integer subscriptFontScale=40; + + protected final static String KEY_TIME_TEXT_PADDING= "key_time_text_padding"; + protected Integer timeTextPadding=2; + + + protected final static String KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE = "key_is_char_background_border_dubble"; + protected boolean charBackgroundBorderWithDoubble = false; public void fromJsonString(JSONObject jsonObject) throws JSONException { @@ -61,6 +70,9 @@ public class DigitPerferenceModel { baseLineDown=jsonObject.optInt(KEY_TIME_TEXT_BASELINE_DOWN,0); charBackgroundBorderDividerColor=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_COLOR, Color.BLACK); charBackgroundBorderDividerStrokeWidth=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_STROKE_WIDTH, 10); + subscriptFontScale=jsonObject.optInt(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE, 40); + timeTextPadding=jsonObject.optInt(KEY_TIME_TEXT_PADDING, 2); + charBackgroundBorderWithDoubble=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE, false); } @@ -78,7 +90,9 @@ public class DigitPerferenceModel { jsonObject.put(KEY_TIME_TEXT_BASELINE_DOWN,baseLineDown); jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_COLOR,charBackgroundBorderDividerColor); jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_STROKE_WIDTH,charBackgroundBorderDividerStrokeWidth); - + jsonObject.put(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE,subscriptFontScale); + jsonObject.put(KEY_TIME_TEXT_PADDING,timeTextPadding); + jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE,charBackgroundBorderWithDoubble); } public static String integerArrayToString(Integer[] fromArrays){ @@ -207,4 +221,28 @@ public class DigitPerferenceModel { public void setCharBackgroundBorderDividerStrokeWidth(Integer charBackgroundBorderDividerStrokeWidth) { this.charBackgroundBorderDividerStrokeWidth = charBackgroundBorderDividerStrokeWidth; } + + public Integer getSubscriptFontScale() { + return subscriptFontScale; + } + + public void setSubscriptFontScale(Integer subscriptFontScale) { + this.subscriptFontScale = subscriptFontScale; + } + + public Integer getTimeTextPadding() { + return timeTextPadding; + } + + public void setTimeTextPadding(Integer timeTextPadding) { + this.timeTextPadding = timeTextPadding; + } + + public boolean isCharBackgroundBorderWithDoubble() { + return charBackgroundBorderWithDoubble; + } + + public void setCharBackgroundBorderWithDoubble(boolean charBackgroundBorderWithDoubble) { + this.charBackgroundBorderWithDoubble = charBackgroundBorderWithDoubble; + } } 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 1f2f760..31acbdc 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 @@ -114,6 +114,9 @@ public class SharePerferenceModel implements Serializable { protected final static String KEY_THEME_UI_TYPE="key_theme_ui_type"; protected int themeUIType=1; + protected final static String KEY_SYS_BOOT_START="key_sys_boot_start"; + protected boolean bootStart=false; + private int dirtyDelaySecond=10000; @@ -252,6 +255,8 @@ public class SharePerferenceModel implements Serializable { clockInterfaceType =jsonObject.optInt(KEY_UI_CLOCK_INTERFACE_TYPE,0); autoFullscreen=jsonObject.optBoolean(KEY_UI_AUTO_FULLSCREEN,false); + bootStart=jsonObject.optBoolean(KEY_SYS_BOOT_START,false); + themeUILoad(jsonObject); } catch (JSONException e) { @@ -299,6 +304,8 @@ public class SharePerferenceModel implements Serializable { jsonObject.put(KEY_UI_AUTO_FULLSCREEN,autoFullscreen); + jsonObject.put(KEY_SYS_BOOT_START,bootStart); + themeUISave(jsonObject); } catch (JSONException e) { @@ -744,4 +751,39 @@ public class SharePerferenceModel implements Serializable { dirtySave(); } + public boolean isBootStart() { + return bootStart; + } + + public void setBootStart(boolean bootStart) { + this.bootStart = bootStart; + dirtySave(); + } + + public Integer getSubscriptFontScale() { + return digitPerferenceModel.getSubscriptFontScale(); + } + + public void setSubscriptFontScale(Integer subscriptFontScale) { + digitPerferenceModel.setSubscriptFontScale(subscriptFontScale); + dirtySave(); + } + + public Integer getTimeTextPadding() { + return digitPerferenceModel.getTimeTextPadding(); + } + + public void setTimeTextPadding(Integer timeTextPadding) { + digitPerferenceModel.setTimeTextPadding(timeTextPadding); + dirtySave(); + } + + public boolean isCharBackgroundBorderWithDoubble() { + return digitPerferenceModel.isCharBackgroundBorderWithDoubble(); + } + + public void setCharBackgroundBorderWithDoubble(boolean charBackgroundBorderWithDoubble) { + digitPerferenceModel.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble); + dirtySave(); + } } diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/BusinessService.java b/app/src/main/java/clock/socoolby/com/clock/net/BusinessService.java similarity index 82% rename from app/src/main/java/clock/socoolby/com/clock/protocol/BusinessService.java rename to app/src/main/java/clock/socoolby/com/clock/net/BusinessService.java index 6dc9c06..2b3d99d 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/BusinessService.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/BusinessService.java @@ -1,4 +1,4 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net; import android.util.Log; @@ -6,6 +6,11 @@ import org.json.JSONException; import org.json.JSONObject; import clock.socoolby.com.clock.ClockApplication; +import clock.socoolby.com.clock.net.protocol.ProtocolConstants; +import clock.socoolby.com.clock.net.protocol.update.UpdateRequest; +import clock.socoolby.com.clock.net.protocol.update.UpdateResponse; +import clock.socoolby.com.clock.net.protocol.weather.WeatherRequest; +import clock.socoolby.com.clock.net.protocol.weather.WeatherResponse; import clock.socoolby.com.clock.utils.FuncUnit; import clock.socoolby.com.clock.service.NetworkService; @@ -27,7 +32,7 @@ public class BusinessService { WeatherResponse weatherResponse = new WeatherResponse(response); try { weatherResponse.parse(response); - if (weatherResponse.mResultCode == 0) { + if (weatherResponse.getResultCode() == 0) { ClockApplication.getInstance().getMainActivity().setWeather(weatherResponse); } } catch (JSONException e) { diff --git a/app/src/main/java/clock/socoolby/com/clock/net/protocol/ProtocolConstants.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/ProtocolConstants.java new file mode 100755 index 0000000..169cb90 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/ProtocolConstants.java @@ -0,0 +1,12 @@ +package clock.socoolby.com.clock.net.protocol; + +public class ProtocolConstants { + + public static final String STR_RESULT_CODE = "code"; + public static final String STR_RESULT_DES = "msg"; + + public static final int RESULT_OK = 0; + public static final int RESULT_FAILED = 1; + public static final int RESULT_NETWORK_ERROR = -1; + +} diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/RequestBase.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/RequestBase.java similarity index 86% rename from app/src/main/java/clock/socoolby/com/clock/protocol/RequestBase.java rename to app/src/main/java/clock/socoolby/com/clock/net/protocol/RequestBase.java index d64c51e..5ff8ee0 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/RequestBase.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/RequestBase.java @@ -1,11 +1,11 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net.protocol; import org.json.JSONException; import org.json.JSONObject; public abstract class RequestBase { - RequestBase() { + public RequestBase() { } public String getUrl() { diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/ResponseBase.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/ResponseBase.java similarity index 74% rename from app/src/main/java/clock/socoolby/com/clock/protocol/ResponseBase.java rename to app/src/main/java/clock/socoolby/com/clock/net/protocol/ResponseBase.java index ec8d0c2..d90ebad 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/ResponseBase.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/ResponseBase.java @@ -1,11 +1,11 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net.protocol; import org.json.JSONException; import org.json.JSONObject; -class ResponseBase { - int mResultCode = ProtocolConstants.RESULT_FAILED; +public class ResponseBase { + protected int mResultCode = ProtocolConstants.RESULT_FAILED; public int getResultCode() { return mResultCode; @@ -26,7 +26,7 @@ class ResponseBase { return false; } - protected boolean parse(JSONObject object) throws JSONException { + public boolean parse(JSONObject object) throws JSONException { return true; } } diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/UpdateRequest.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/update/UpdateRequest.java similarity index 71% rename from app/src/main/java/clock/socoolby/com/clock/protocol/UpdateRequest.java rename to app/src/main/java/clock/socoolby/com/clock/net/protocol/update/UpdateRequest.java index 75e93d4..2b47ec8 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/UpdateRequest.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/update/UpdateRequest.java @@ -1,12 +1,13 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net.protocol.update; import org.json.JSONException; import org.json.JSONObject; +import clock.socoolby.com.clock.net.protocol.RequestBase; import clock.socoolby.com.clock.utils.FuncUnit; -class UpdateRequest extends RequestBase { +public class UpdateRequest extends RequestBase { @Override public String getUrl() { return "http://www.socoolby.com/clock/update"; diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/UpdateResponse.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/update/UpdateResponse.java similarity index 78% rename from app/src/main/java/clock/socoolby/com/clock/protocol/UpdateResponse.java rename to app/src/main/java/clock/socoolby/com/clock/net/protocol/update/UpdateResponse.java index 1de0c91..43cd7fc 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/UpdateResponse.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/update/UpdateResponse.java @@ -1,8 +1,11 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net.protocol.update; import org.json.JSONException; import org.json.JSONObject; +import clock.socoolby.com.clock.net.protocol.ProtocolConstants; +import clock.socoolby.com.clock.net.protocol.ResponseBase; + /** * Alway zuo,never die. * Created by socoolby on 04/01/2017. @@ -26,12 +29,12 @@ public class UpdateResponse extends ResponseBase { private String updateURL = null; private String description = null; - UpdateResponse(JSONObject response) { + public UpdateResponse(JSONObject response) { super.parseResponse(response); } @Override - protected boolean parse(JSONObject object) throws JSONException { + public boolean parse(JSONObject object) throws JSONException { if (object == null) return false; // object = new JSONObject("{\"message\":\"success\",\"code\":0,\"data\":{\"url\":\"http://www.baidu.com/\",\"description\":\"new version\"}}"); diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/WeatherRequest.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/weather/WeatherRequest.java similarity index 82% rename from app/src/main/java/clock/socoolby/com/clock/protocol/WeatherRequest.java rename to app/src/main/java/clock/socoolby/com/clock/net/protocol/weather/WeatherRequest.java index 6f2464f..dccce8d 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/WeatherRequest.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/weather/WeatherRequest.java @@ -1,4 +1,4 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net.protocol.weather; import org.json.JSONException; import org.json.JSONObject; @@ -6,8 +6,10 @@ import org.json.JSONObject; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import clock.socoolby.com.clock.net.protocol.RequestBase; -class WeatherRequest extends RequestBase { + +public class WeatherRequest extends RequestBase { private String mCity; @Override diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/WeatherResponse.java b/app/src/main/java/clock/socoolby/com/clock/net/protocol/weather/WeatherResponse.java similarity index 96% rename from app/src/main/java/clock/socoolby/com/clock/protocol/WeatherResponse.java rename to app/src/main/java/clock/socoolby/com/clock/net/protocol/weather/WeatherResponse.java index 33504ae..56e4cda 100755 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/WeatherResponse.java +++ b/app/src/main/java/clock/socoolby/com/clock/net/protocol/weather/WeatherResponse.java @@ -1,4 +1,4 @@ -package clock.socoolby.com.clock.protocol; +package clock.socoolby.com.clock.net.protocol.weather; import org.json.JSONArray; import org.json.JSONException; @@ -7,6 +7,8 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.List; +import clock.socoolby.com.clock.net.protocol.ResponseBase; + public class WeatherResponse extends ResponseBase { /* { @@ -160,7 +162,7 @@ public class WeatherResponse extends ResponseBase { } @Override - protected boolean parse(JSONObject object) throws JSONException { + public boolean parse(JSONObject object) throws JSONException { mErrorCode = object.getInt("error"); if (mErrorCode == 0) { JSONArray results = object.getJSONArray("results"); diff --git a/app/src/main/java/clock/socoolby/com/clock/pop/WeatherPopup.java b/app/src/main/java/clock/socoolby/com/clock/pop/WeatherPopup.java index d868a2c..f065a90 100644 --- a/app/src/main/java/clock/socoolby/com/clock/pop/WeatherPopup.java +++ b/app/src/main/java/clock/socoolby/com/clock/pop/WeatherPopup.java @@ -1,7 +1,6 @@ package clock.socoolby.com.clock.pop; import android.content.Context; -import android.media.Image; import android.net.Uri; import android.view.View; import android.widget.ImageView; @@ -13,7 +12,7 @@ import com.bumptech.glide.request.RequestOptions; import java.util.List; import clock.socoolby.com.clock.R; -import clock.socoolby.com.clock.protocol.WeatherResponse; +import clock.socoolby.com.clock.net.protocol.weather.WeatherResponse; import razerdp.basepopup.BasePopupWindow; public class WeatherPopup extends BasePopupWindow { diff --git a/app/src/main/java/clock/socoolby/com/clock/protocol/ProtocolConstants.java b/app/src/main/java/clock/socoolby/com/clock/protocol/ProtocolConstants.java deleted file mode 100755 index 14852ed..0000000 --- a/app/src/main/java/clock/socoolby/com/clock/protocol/ProtocolConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package clock.socoolby.com.clock.protocol; - -class ProtocolConstants { - - - static final String STR_RESULT_CODE = "code"; - static final String STR_RESULT_DES = "msg"; - - static final int RESULT_OK = 0; - static final int RESULT_FAILED = 1; - public static final int RESULT_NETWORK_ERROR = -1; - -} diff --git a/app/src/main/java/clock/socoolby/com/clock/service/NetworkService.java b/app/src/main/java/clock/socoolby/com/clock/service/NetworkService.java index dbe5bb9..9ebd41d 100755 --- a/app/src/main/java/clock/socoolby/com/clock/service/NetworkService.java +++ b/app/src/main/java/clock/socoolby/com/clock/service/NetworkService.java @@ -18,7 +18,7 @@ import org.json.JSONObject; import java.io.UnsupportedEncodingException; import clock.socoolby.com.clock.ClockApplication; import clock.socoolby.com.clock.Constants; -import clock.socoolby.com.clock.protocol.RequestBase; +import clock.socoolby.com.clock.net.protocol.RequestBase; public final class NetworkService { private static NetworkService mInstance; 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 index 775360e..a900f91 100644 --- a/app/src/main/java/clock/socoolby/com/clock/viewmodel/DigitViewModel.java +++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/DigitViewModel.java @@ -42,6 +42,13 @@ public class DigitViewModel extends ViewModel { private MutableLiveData charBackgroundBorderDividerWidth=new MutableLiveData<>(); + private MutableLiveData subscriptFontScale=new MutableLiveData<>(); + + private MutableLiveData timeTextPadding=new MutableLiveData<>(); + + private MutableLiveData charBackgroundBorderWithDoubble=new MutableLiveData<>(); + + SharePerferenceModel model; public DigitViewModel(SharePerferenceModel model) { @@ -64,6 +71,9 @@ public class DigitViewModel extends ViewModel { charBackgroundBorderColor.setValue(model.getCharBackgroundBorderColor()); charBackgroundBorderDividerColor.setValue(model.getCharBackgroundBorderDividerColor()); charBackgroundBorderDividerWidth.setValue(model.getCharBackgroundBorderDividerStrokeWidth()); + subscriptFontScale.setValue(model.getSubscriptFontScale()); + timeTextPadding.setValue(model.getTimeTextPadding()); + charBackgroundBorderWithDoubble.setValue(model.isCharBackgroundBorderWithDoubble()); } public MutableLiveData getDisplaySecond() { @@ -203,4 +213,31 @@ public class DigitViewModel extends ViewModel { this.charBackgroundBorderDividerWidth.setValue(charBackgroundBorderDividerWidth); model.setCharBackgroundBorderDividerStrokeWidth(charBackgroundBorderDividerWidth); } + + public MutableLiveData getSubscriptFontScale() { + return subscriptFontScale; + } + + public void setSubscriptFontScale(Integer subscriptFontScale) { + this.subscriptFontScale.setValue(subscriptFontScale); + model.setSubscriptFontScale(subscriptFontScale); + } + + public MutableLiveData getTimeTextPadding() { + return timeTextPadding; + } + + public void setTimeTextPadding(Integer timeTextPadding) { + this.timeTextPadding.setValue(timeTextPadding); + model.setTimeTextPadding(timeTextPadding); + } + + public MutableLiveData getCharBackgroundBorderWithDoubble() { + return charBackgroundBorderWithDoubble; + } + + public void setCharBackgroundBorderWithDoubble(Boolean charBackgroundBorderWithDoubble) { + this.charBackgroundBorderWithDoubble.setValue(charBackgroundBorderWithDoubble); + model.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble); + } } 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 index 9e29d75..ad3c72e 100644 --- a/app/src/main/java/clock/socoolby/com/clock/viewmodel/GlobalViewModel.java +++ b/app/src/main/java/clock/socoolby/com/clock/viewmodel/GlobalViewModel.java @@ -36,6 +36,8 @@ public class GlobalViewModel extends ViewModel { //system private Boolean tickSound=false; + private Boolean appConfig=false; + private MutableLiveData mCity=new MutableLiveData<>(); private MutableLiveData brightness=new MutableLiveData<>(); @@ -106,6 +108,8 @@ public class GlobalViewModel extends ViewModel { timeHourAnimatorStarting.setValue(false); timeHourAnimatordialy.setValue(model.getTimeHourAlterDialy()); + + appConfig=false; } public MutableLiveData getCity() { @@ -320,5 +324,11 @@ public class GlobalViewModel extends ViewModel { this.timeHourAnimatorStarting.setValue(timeHourAnimatorStarting); } + public Boolean getAppConfig() { + return appConfig; + } + public void setAppConfig(Boolean appConfig) { + this.appConfig = appConfig; + } } diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/CarrouselAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/CarrouselAnimator.java index 76669e3..fe03a29 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/CarrouselAnimator.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/CarrouselAnimator.java @@ -155,7 +155,7 @@ public class CarrouselAnimator extends AbstractAnimator int color; //创建对象 //以一个圆为对象 - //设置随机的 x,y坐标,r半径,_mx,_my移动的距离 + //设置随机的 percent,y坐标,r半径,_mx,_my移动的距离 //this.r是创建圆的半径,参数越大半径越大 //this._mx,this._my是移动的距离,参数越大移动 public Circle(float x,float y,float mx,float my,float r,int color) { diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireworkAnimator.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireworkAnimator.java index 6460133..d842046 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireworkAnimator.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/FireworkAnimator.java @@ -241,7 +241,7 @@ public class FireworkAnimator extends AbstractCacheDifferenceAnimator { +public class FluorescenceAnimator extends AbstractCacheAbleAnimator { public static final String NAME="Fluorescence"; @@ -24,7 +23,7 @@ public class FluorescenceAnimator extends AbstractAnimator cache = new LinkedList<>(); @@ -32,49 +31,44 @@ public class FluorescenceAnimator extends AbstractAnimator { } public void printPosition(){ - Log.d("rainPoint", "x : " + point.left + " y : " + point.top + " r : " + point.right + " b : " + point.bottom); + Log.d("rainPoint", "percent : " + point.left + " y : " + point.top + " r : " + point.right + " b : " + point.bottom); } @Override 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 a96029f..22698e6 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 @@ -139,7 +139,7 @@ public class SnowAnimator extends AbstractAnimator { } public void printPosition() { - Log.d("SknowPoint", "x : " + rect.left + " y : " + rect.top + " r : " + Log.d("SknowPoint", "percent : " + rect.left + " y : " + rect.top + " r : " + rect.right + " b : " + rect.bottom); } 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 c358410..b0c3221 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 @@ -280,7 +280,7 @@ public class VorolayAnimator extends AbstractAnimator { } // draw site - // canvas.drawBorder((float)region.site.x, (float)region.site.y, 10, p); + // canvas.drawBorder((float)region.site.percent, (float)region.site.y, 10, p); } } 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 2c68179..711eccc 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 @@ -67,7 +67,7 @@ public class WaterAnimator extends AbstractAnimator { /*mBelowWavePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBelowWavePaint.setAntiAlias(true); mBelowWavePaint.setStyle(Paint.Style.FILL); - mBelowWavePaint.setColor(Color.BLUE); + mBelowWavePaint.setParticleColor(Color.BLUE); mBelowWavePaint.setAlpha(60);*/ //画布抗锯齿 mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); @@ -99,9 +99,9 @@ public class WaterAnimator extends AbstractAnimator { * k—偏距,反映在坐标系上则为图像的上移或下移。 */ y = (float) (30 * Math.cos(ω * x + φ) + 30)+y2; -// y2 = (float) (30 * Math.sin(ω * x + φ) + 30); +// y2 = (float) (30 * Math.sin(ω * percent + φ) + 30); mAbovePath.lineTo(x, y); -// mBelowWavePath.lineTo(x, y2); +// mBelowWavePath.lineTo(percent, y2); if (x == width / 2) { mPaint.setColor(color); canvas.drawCircle(x, y-40, 20, mPaint); 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 73e93a6..1906155 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 @@ -93,7 +93,7 @@ public class Wave3DAnimator extends AbstractAnimator { //this.engine.fillStyle = `hsla(${180 + hl * 180 | 0}, 70%, ${25 + (h * -1) * 25 | 0}%, ${0.5 + (h *-1) * 0.5})`; // this.engine.fillRect( - // this.midX + point.x * this.width * 0.3, + // this.midX + point.percent * this.width * 0.3, // this.midY + point.y * this.width * 0.1 + hs, // 3 * s, // 3 * s diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/AbstractClock.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/AbstractClock.java index 1be1540..cfb6a18 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/AbstractClock.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/AbstractClock.java @@ -69,7 +69,7 @@ public abstract class AbstractClock implements I_AnimatorEntry { mTextPaint.setStrokeWidth(mDefaultScaleWidth / 2); mTextPaint.setTextSize(mParticularlyScaleWidth * 4); mTextPaint.setTextAlign(Paint.Align.CENTER); - //mTextPaint.setColor(textColor); + //mTextPaint.setParticleColor(textColor); } diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HelixClock.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HelixClock.java index 72d5885..1bfc9f8 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HelixClock.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HelixClock.java @@ -14,7 +14,7 @@ public class HelixClock extends AbstractClock { /** canvas.save(); canvas.translate(mCenterX, mCenterY); mDefaultPaint.setStrokeWidth(mDefaultScaleWidth); - mDefaultPaint.setColor(mClockColor); + mDefaultPaint.setParticleColor(mClockColor); canvas.drawCircle(0, 0, mRadius, mDefaultPaint); @@ -22,14 +22,14 @@ public class HelixClock extends AbstractClock { if (i % 5 == 0) { // 特殊时刻 mDefaultPaint.setStrokeWidth(mParticularlyScaleWidth); - mDefaultPaint.setColor(mColorParticularyScale); + mDefaultPaint.setParticleColor(mColorParticularyScale); canvas.drawLine(0, -mRadius, 0, -mRadius + mParticularlyScaleLength, mDefaultPaint); } else { // 一般时刻 mDefaultPaint.setStrokeWidth(mDefaultScaleWidth); - mDefaultPaint.setColor(mColorDefaultScale); + mDefaultPaint.setParticleColor(mColorDefaultScale); canvas.drawLine(0, -mRadius, 0, -mRadius + mDefaultScaleLength, mDefaultPaint); diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HexagonalClock.java b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HexagonalClock.java index fa7b551..abdcf7a 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HexagonalClock.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/animatorview/animator/clockanimator/HexagonalClock.java @@ -30,7 +30,7 @@ public class HexagonalClock extends AbstractClock { //边框,好像不画好看 //mDefaultPaint.setStrokeWidth(mDefaultScaleWidth); - //mDefaultPaint.setColor(mClockColor); + //mDefaultPaint.setParticleColor(mClockColor); //canvas.drawLine(lineStartX, startY, lineStartX+octagonalLineLenght,startY, mDefaultPaint); mDefaultPaint.setStrokeWidth(mParticularlyScaleWidth); diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/ringslide/RingSlideTimeRangeSelector.java b/app/src/main/java/clock/socoolby/com/clock/widget/ringslide/RingSlideTimeRangeSelector.java index f0a50d9..b3cbbec 100644 --- a/app/src/main/java/clock/socoolby/com/clock/widget/ringslide/RingSlideTimeRangeSelector.java +++ b/app/src/main/java/clock/socoolby/com/clock/widget/ringslide/RingSlideTimeRangeSelector.java @@ -99,7 +99,7 @@ public class RingSlideTimeRangeSelector extends View { */ select_Paint=new Paint(Paint.ANTI_ALIAS_FLAG); select_Paint.setShader(new SweepGradient(0, 0, arrColorCircle, null)); - /*select_Paint.setColor(circle_color);*/ + /*select_Paint.setParticleColor(circle_color);*/ select_Paint.setAntiAlias(true); select_Paint.setStyle(Paint.Style.STROKE); select_Paint.setStrokeWidth(ring_width); 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 f8e97dd..7f60260 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 @@ -45,6 +45,8 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { private boolean charBackgroundBorder = false; + private boolean charBackgroundBorderWithDoubble=false; + private int charBackgroundBorderColor = Color.BLACK; private int textWidth = 0; @@ -52,10 +54,15 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { private int textFontHight; private int baseCharWidth; private int flagCharwidth; - private int smallTextHight; - private int smallCharWidth; + private int subscriptTextHight; + private int subscriptCharWidth; private int textLength; - private int textSmallSpan; + private int textSubscriptSpan; + + private int fontScale=80; + + private int fontBaseLineHeightChange; + private HashMap charAnimatorHashMap = new HashMap<>(); private CharAnimatorEnum currentCharAnimatorType = CharAnimatorEnum.Marquee3D_Up; @@ -68,18 +75,14 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { Paint mTextPaint; - float fontScale; - String charStr; - float centerY; - CharSequence textToDraw; - Paint.FontMetricsInt fm; - int padding = 2; + int paddingScale=20; + int charWidth; Paint mDividerPaint, mBackgroundPaint; @@ -108,7 +111,6 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { mDividerPaint.setColor(Color.WHITE); mDividerPaint.setStrokeWidth(10); - mBackgroundPaint = new Paint(); mBackgroundPaint.setAntiAlias(true); } @@ -224,21 +226,19 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { } private void layoutReflush(CharSequence textToDraw){ - fm = mTextPaint.getFontMetricsInt(); baseCharWidth = getCharWidth("8", mTextPaint); - padding = baseCharWidth / 20; - //baseCharWidth+=padding; + padding = baseCharWidth / paddingScale; flagCharwidth = getCharWidth(":", mTextPaint); textFontHight = (int) getFontHeight(mTextPaint); textBodyHight =(int)getFontBodyHeight(mTextPaint); - smallTextHight = textFontHight; - smallCharWidth = baseCharWidth; + subscriptTextHight = textFontHight; + subscriptCharWidth = baseCharWidth; textLength = textToDraw.length(); - textSmallSpan = 0; + textSubscriptSpan = 0; if (textLength > 4) { textWidth = (baseCharWidth + padding) * 4 + flagCharwidth; @@ -246,14 +246,12 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { if (textLength > 7) { if (secondSubscript) { - fontScale = getResources().getDisplayMetrics().scaledDensity; - smallCharPaint = getCustomTextPaint(mTextPaint, mTextPaint.getTextSize() / fontScale * 4 / 5); - smallCharWidth = getCharWidth("8", smallCharPaint); - fm = smallCharPaint.getFontMetricsInt(); - smallTextHight =(int) getFontHeight(smallCharPaint); + subscriptCharWidth = getCharWidth("8", smallCharPaint); + subscriptTextHight =(int) getFontHeight(smallCharPaint); + fontBaseLineHeightChange=(int)getFontBaseLineHeightChange(mTextPaint,smallCharPaint); } else - textSmallSpan = textSmallSpan + flagCharwidth; - textSmallSpan = textSmallSpan + smallCharWidth * 2; + textSubscriptSpan = textSubscriptSpan + flagCharwidth; + textSubscriptSpan = textSubscriptSpan + subscriptCharWidth * 2; } layoutReflushAble=false; @@ -274,15 +272,18 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { textToDraw = getText(); + if (linearGradientReCreate) + linearGradientReflush(); + + if(secondSubscript) + smallCharPaint = getCustomScaleTextPaint(mTextPaint, fontScale); + if(layoutReflushCheck(textToDraw)) layoutReflush(textToDraw); - startX = (getWidth() - textWidth - textSmallSpan) / 2; + startX = (getWidth() - textWidth - textSubscriptSpan) / 2; startY = (getHeight() + textBodyHight) / 2+baseLineDown; - if (linearGradientReCreate) - linearGradientReflush(); - for (int i = 0; i < textLength; i++) { charStr = String.valueOf(textToDraw.charAt(i)); if (i < 5) { @@ -295,32 +296,38 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { } } else if (i == 5) { if (secondSubscript) - startX += smallCharWidth / 2; + startX += subscriptCharWidth / 2; else { canvas.drawText(charStr, startX, startY , mTextPaint); startX += flagCharwidth; } } else { if (secondSubscript) { - centerY = (getHeight() + smallTextHight) / 2; - centerY = centerY + (startY - centerY) / 2 + smallCharPaint.getFontMetrics().descent; - smallCharPaint.setColor(getCurrentTextColor()); if (charBackgroundBorder) - drawBackground(canvas, startX, centerY - smallTextHight, smallCharWidth, smallTextHight, mBackgroundPaint); - drawChar(canvas, charStr, startX, centerY, smallCharPaint); + if(charBackgroundBorderWithDoubble) { + if (i == 6) + drawBackground(canvas, startX, startY+fontBaseLineHeightChange-subscriptTextHight+smallCharPaint.getFontMetrics().bottom, subscriptCharWidth*2, subscriptTextHight, mBackgroundPaint); + }else + drawBackground(canvas, startX, startY+fontBaseLineHeightChange-subscriptTextHight+smallCharPaint.getFontMetrics().bottom, subscriptCharWidth, subscriptTextHight, mBackgroundPaint); + drawChar(canvas, charStr, startX, startY+fontBaseLineHeightChange, smallCharPaint); + if (charBackgroundBorder) + if(charBackgroundBorderWithDoubble) { + if (i == 7) + drawDivider(canvas, startX-subscriptCharWidth, startY+fontBaseLineHeightChange-subscriptTextHight+smallCharPaint.getFontMetrics().bottom, subscriptCharWidth*2, subscriptTextHight, mDividerPaint); + }else + drawDivider(canvas, startX, startY+fontBaseLineHeightChange-subscriptTextHight+smallCharPaint.getFontMetrics().bottom, subscriptCharWidth, subscriptTextHight, mDividerPaint); } else { drawCharWithAnaimatorCheck(canvas, i, charStr, startX, startY, mTextPaint); startX += padding; } - startX += smallCharWidth; - //Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textBodyHight+"small text hight:"+smallTextHight); + startX += subscriptCharWidth; + //Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textBodyHight+"small text hight:"+subscriptTextHight); } } preString = textToDraw; //Log.d(Tag,"total draw time:"+(System.currentTimeMillis()-before)); } - private void drawBackground(Canvas canvas, float startX, float startY, int width, int height, Paint mBackgroundPaint) { mBackgroundPaint.setColor(charBackgroundBorderColor); //canvas.drawRoundRect(new RectF(startX, startY, startX + width, startY + height), 10, 10, mBackgroundPaint); @@ -345,7 +352,11 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { charWidth = getCharWidth(charStr, mTextPaint); //Log.d(Tag,"view width:"+getWidth()+"\t heitht:"+getHeight()+"\t startx:"+startX+"\t startY:"+startY+"\t baseCharWidth:"+baseCharWidth+"\t text hight:"+textBodyHight+"\t text font hight:"+textFontHight); if (charBackgroundBorder) - drawBackground(canvas, startX, startY-textFontHight+mTextPaint.getFontMetrics().bottom, baseCharWidth, textFontHight, mBackgroundPaint); + if(charBackgroundBorderWithDoubble) { + if (i == 0 || i == 3 || i == 6) + drawBackground(canvas, startX, startY - textFontHight + mTextPaint.getFontMetrics().bottom, baseCharWidth*2+padding, textFontHight, mBackgroundPaint); + }else + drawBackground(canvas, startX, startY-textFontHight+mTextPaint.getFontMetrics().bottom, baseCharWidth, textFontHight, mBackgroundPaint); if (currentCharAnimatorType != CharAnimatorEnum.NOSETUP) { charAnimator = charAnimatorHashMap.get(i); if (charAnimator != null && !charAnimator.isCharAnimatorRuning()) { @@ -360,17 +371,23 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { //charAnimator.drawCharAnimator(canvas, startX + (baseCharWidth - charWidth) / 2, startY , mTextPaint); charAnimator.drawCharAnimator(canvas, startX, startY , mTextPaint); //Log.d(Tag,"charAnimator index i:"+i+"\tanimator percent:"); - invalidate(); - } else { - drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY, mTextPaint); if (charBackgroundBorder) - drawDivider(canvas, startX, startY - textFontHight+mTextPaint.getFontMetrics().bottom, baseCharWidth, textFontHight, mDividerPaint); + if(charBackgroundBorderWithDoubble) { + if (i == 1 || i == 4 || i == 7) + drawDivider(canvas, startX-baseCharWidth-padding, startY - textFontHight + mTextPaint.getFontMetrics().bottom, baseCharWidth*2+padding, textFontHight, mDividerPaint); + }else + drawDivider(canvas, startX, startY - textFontHight+mTextPaint.getFontMetrics().bottom , baseCharWidth, textFontHight, mDividerPaint); + invalidate(); + return; } - } else { - drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY , mTextPaint); - if (charBackgroundBorder) - drawDivider(canvas, startX, startY - textFontHight+mTextPaint.getFontMetrics().bottom , baseCharWidth, textFontHight, mDividerPaint); } + drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY , mTextPaint); + if (charBackgroundBorder) + if(charBackgroundBorderWithDoubble) { + if (i == 1 || i == 4 || i == 7) + drawDivider(canvas, startX-baseCharWidth-padding, startY - textFontHight + mTextPaint.getFontMetrics().bottom, baseCharWidth*2+padding, textFontHight, mDividerPaint); + }else + drawDivider(canvas, startX, startY - textFontHight+mTextPaint.getFontMetrics().bottom , baseCharWidth, textFontHight, mDividerPaint); } Paint reflectedPaint; @@ -415,9 +432,9 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { return charAnimator; } - private static TextPaint getCustomTextPaint(Paint srcPaint, float fontSizeSp) { + private static TextPaint getCustomScaleTextPaint(Paint srcPaint, float fontSizeScale) { TextPaint paint = new TextPaint(srcPaint); - paint.setTextSize(fontSizeSp); //设定字体大小, sp转换为px + paint.setTextSize(srcPaint.getTextSize()*fontSizeScale/100); //设定字体大小, sp转换为px return paint; } @@ -440,6 +457,12 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { return fm.bottom - fm.top; } + public static float getFontBaseLineHeightChange(Paint base,Paint point){ + Paint.FontMetrics fmBase = base.getFontMetrics(); + Paint.FontMetrics fm = point.getFontMetrics(); + return fmBase.ascent-fmBase.top-(fm.ascent-fm.top); + } + public static float getFontBodyHeight(Paint paint) { Paint.FontMetrics fm = paint.getFontMetrics(); return fm.descent - fm.ascent; @@ -468,4 +491,30 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView { public void setBackgroundBorderDividerWidth(int width){ mDividerPaint.setStrokeWidth(width); } + + + public int getFontScale() { + return fontScale; + } + + public void setFontScale(int fontScale) { + this.fontScale = fontScale; + layoutReflushAble=true; + } + + + public void setPaddingScale(int padding) { + this.paddingScale = 20-padding; + if(paddingScale<=0) + paddingScale=1; + layoutReflushAble=true; + } + + public boolean isCharBackgroundBorderWithDoubble() { + return charBackgroundBorderWithDoubble; + } + + public void setCharBackgroundBorderWithDoubble(boolean charBackgroundBorderWithDoubble) { + this.charBackgroundBorderWithDoubble = charBackgroundBorderWithDoubble; + } } diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/I_Border.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/I_Border.java new file mode 100644 index 0000000..7cc94cd --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/I_Border.java @@ -0,0 +1,10 @@ +package clock.socoolby.com.clock.widget.textview; + +import android.graphics.Canvas; +import android.graphics.Paint; + +public interface I_Border { + void drawBackground(Canvas canvas, float startX, float startY, int width, int height, Paint mBackgroundPaint); + + void drawDivider(Canvas canvas, float startX, float startY, int width, int height, Paint mDividerPaint); +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/border/AbstractBorder.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/border/AbstractBorder.java new file mode 100644 index 0000000..9c9b118 --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/border/AbstractBorder.java @@ -0,0 +1,13 @@ +package clock.socoolby.com.clock.widget.textview.border; + +import android.graphics.Canvas; +import android.graphics.Paint; + +import clock.socoolby.com.clock.widget.textview.I_Border; + +public abstract class AbstractBorder implements I_Border { + + public void drawDivider(Canvas canvas, float startX, float startY, int width, int height, Paint mDividerPaint) { + canvas.drawLine(startX+mDividerPaint.getStrokeWidth(), startY+height/2, startX+width-mDividerPaint.getStrokeWidth(), startY+height/2, mDividerPaint); + } +} diff --git a/app/src/main/java/clock/socoolby/com/clock/widget/textview/border/DefaultBorder.java b/app/src/main/java/clock/socoolby/com/clock/widget/textview/border/DefaultBorder.java new file mode 100644 index 0000000..ed9f60c --- /dev/null +++ b/app/src/main/java/clock/socoolby/com/clock/widget/textview/border/DefaultBorder.java @@ -0,0 +1,12 @@ +package clock.socoolby.com.clock.widget.textview.border; + +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; + +public class DefaultBorder extends AbstractBorder { + + public void drawBackground(Canvas canvas, float startX, float startY, int width, int height, Paint mBackgroundPaint) { + canvas.drawRoundRect(new RectF(startX, startY, startX + width, startY + height), 10, 10, mBackgroundPaint); + } +} diff --git a/app/src/main/java/com/xenione/digit/TabDigit_old.java b/app/src/main/java/com/xenione/digit/TabDigit_old.java index 13156ac..e2f6d43 100644 --- a/app/src/main/java/com/xenione/digit/TabDigit_old.java +++ b/app/src/main/java/com/xenione/digit/TabDigit_old.java @@ -98,9 +98,9 @@ public class TabDigit_old{ } else if (attr == R.styleable.TabDigit_cornerSize) { cornerSize = ta.getDimensionPixelSize(attr, -1); } else if (attr == R.styleable.TabDigit_textColor) { - textColor = ta.getColor(attr, 1); + textColor = ta.getParticleColor(attr, 1); } else if (attr == R.styleable.TabDigit_backgroundColor) { - backgroundColor = ta.getColor(attr, 1); + backgroundColor = ta.getParticleColor(attr, 1); } else if (attr == R.styleable.TabDigit_reverseRotation) { reverseRotation = ta.getBoolean(attr, false); } @@ -120,11 +120,11 @@ public class TabDigit_old{ } if (textColor < 1) { - mNumberPaint.setColor(textColor); + mNumberPaint.setParticleColor(textColor); } if (backgroundColor < 1) { - mBackgroundPaint.setColor(backgroundColor); + mBackgroundPaint.setParticleColor(backgroundColor); } mReverseRotation = reverseRotation; @@ -137,17 +137,17 @@ public class TabDigit_old{ mNumberPaint = new Paint(); mNumberPaint.setAntiAlias(true); mNumberPaint.setStyle(Paint.Style.FILL_AND_STROKE); - mNumberPaint.setColor(Color.WHITE); + mNumberPaint.setParticleColor(Color.WHITE); mDividerPaint = new Paint(); mDividerPaint.setAntiAlias(true); mDividerPaint.setStyle(Paint.Style.FILL_AND_STROKE); - mDividerPaint.setColor(Color.WHITE); + mDividerPaint.setParticleColor(Color.WHITE); mDividerPaint.setStrokeWidth(1); mBackgroundPaint = new Paint(); mBackgroundPaint.setAntiAlias(true); - mBackgroundPaint.setColor(Color.BLACK); + mBackgroundPaint.setParticleColor(Color.BLACK); } private void initTabs() { @@ -244,7 +244,7 @@ public class TabDigit_old{ return (int) mNumberPaint.getTextSize(); } - public void setPadding(int padding) { + public void setPaddingScale(int padding) { mPadding = padding; requestLayout(); } @@ -265,7 +265,7 @@ public class TabDigit_old{ public void setDividerColor(int color) { - mDividerPaint.setColor(color); + mDividerPaint.setParticleColor(color); } public int getPadding(){ @@ -273,11 +273,11 @@ public class TabDigit_old{ } public void setTextColor(int color) { - mNumberPaint.setColor(color); + mNumberPaint.setParticleColor(color); } public int getTextColor() { - return mNumberPaint.getColor(); + return mNumberPaint.getParticleColor(); } public void setCornerSize(int cornerSize) { @@ -290,11 +290,11 @@ public class TabDigit_old{ } public void setBackgroundColor(int color) { - mBackgroundPaint.setColor(color); + mBackgroundPaint.setParticleColor(color); } public int getBackgroundColor() { - return mBackgroundPaint.getColor(); + return mBackgroundPaint.getParticleColor(); } public void start() { diff --git a/app/src/main/res/layout/fragment_digit_config.xml b/app/src/main/res/layout/fragment_digit_config.xml index 99ecb69..fd54d66 100644 --- a/app/src/main/res/layout/fragment_digit_config.xml +++ b/app/src/main/res/layout/fragment_digit_config.xml @@ -143,6 +143,13 @@ android:layout_weight="1" android:text="分割线" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +