mirror of
https://gitee.com/51danju/workclock.git
synced 2025-06-29 05:32:49 +08:00
增加视频Fragment,更新app
This commit is contained in:
parent
07061787eb
commit
73c347f021
49
README.md
49
README.md
@ -1,7 +1,6 @@
|
|||||||
# WorkClock
|
# WorkClock
|
||||||
An Android clock [下载](#直接下载)
|
An Android clock [下载](#直接下载)
|
||||||
|
|
||||||
|
|
||||||
<img src="/screenshot/demo.gif" width="768" height="382"/>
|
<img src="/screenshot/demo.gif" width="768" height="382"/>
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
@ -14,7 +13,7 @@ An Android clock [下载](#直接下载)
|
|||||||
右滑:改变字本
|
右滑:改变字本
|
||||||
上滑:增加亮度
|
上滑:增加亮度
|
||||||
下滑:减小亮度
|
下滑:减小亮度
|
||||||
双击:改变文字特效
|
双击:界面(简单-详细-全屏)
|
||||||
|
|
||||||
定时器 单击->改变状态,长按-> 设置时间
|
定时器 单击->改变状态,长按-> 设置时间
|
||||||
|
|
||||||
@ -30,9 +29,9 @@ An Android clock [下载](#直接下载)
|
|||||||
|
|
||||||
下面说明条 单击->随机名言
|
下面说明条 单击->随机名言
|
||||||
|
|
||||||
时间 长按-->显示[更多功能状态](#更多功能)
|
时间 长按-->进入[定制设置]
|
||||||
|
|
||||||
锁 单击->锁定屏幕,长按->进入[全屏精简模式](#全屏精简模式)
|
锁 单击->锁定屏幕
|
||||||
|
|
||||||
### 定时提醒状态
|
### 定时提醒状态
|
||||||
|
|
||||||
@ -40,10 +39,7 @@ An Android clock [下载](#直接下载)
|
|||||||
|
|
||||||
(注:未手动 则闹铃结束后进入计时模式)
|
(注:未手动 则闹铃结束后进入计时模式)
|
||||||
|
|
||||||
### 自定界面样式示例
|
### 详细状态
|
||||||
<img src="/screenshot/device-theme.png" width="768" height="382"/>
|
|
||||||
|
|
||||||
### 更多功能
|
|
||||||
|
|
||||||
<img src="/screenshot/device-adv.png" width="768" height="382"/>
|
<img src="/screenshot/device-adv.png" width="768" height="382"/>
|
||||||
|
|
||||||
@ -51,27 +47,21 @@ An Android clock [下载](#直接下载)
|
|||||||
|
|
||||||
实心马 单击->设置背景色
|
实心马 单击->设置背景色
|
||||||
|
|
||||||
空心马1 单击->改变当前的前景色 长按-->设置1号位的前景色 (注:此为启动时的前景应用色)
|
空心马1 单击->改变当前的前景色 长按-->设置1号位的前景色
|
||||||
|
|
||||||
空心马2 单击->改变当前的前景色 长按-->设置2号位的前景色 (注:此也为背景动画的应用色)
|
空心马2 单击->改变当前的前景色 长按-->设置2号位的前景色
|
||||||
|
|
||||||
图片 单击->背景图显隐 长按 -->重新选择背景图
|
图片 单击->背景图显隐 长按 -->重新选择背景图
|
||||||
|
|
||||||
设置 单击->进入[更多设置页]()
|
|
||||||
|
|
||||||
时间 长按-->返回[普通状态](#普通状态)
|
|
||||||
|
|
||||||
|
时钟 单击->数字/模似切换
|
||||||
|
|
||||||
|
设置 单击->进入[系统设置]()
|
||||||
|
|
||||||
### 全屏精简模式
|
### 全屏精简模式
|
||||||
|
|
||||||
<img src="/screenshot/device-full.png" width="768" height="382"/>
|
<img src="/screenshot/device-full.png" width="768" height="382"/>
|
||||||
|
|
||||||
锁 单击->退出全屏模式,返回先前的状态
|
定时显 长按->隐去自已
|
||||||
|
|
||||||
时间 长按-->即进入[模拟时钟模式](#模拟时钟模式)
|
|
||||||
|
|
||||||
定时显 长按->隐去自已
|
|
||||||
|
|
||||||
左滑:改变背景动画
|
左滑:改变背景动画
|
||||||
右滑:改变字本
|
右滑:改变字本
|
||||||
@ -81,20 +71,13 @@ An Android clock [下载](#直接下载)
|
|||||||
|
|
||||||
<img src="/screenshot/device-full-clock.png" width="768" height="382"/>
|
<img src="/screenshot/device-full-clock.png" width="768" height="382"/>
|
||||||
|
|
||||||
锁 单击->退出全屏模式,返回先前的状态
|
时钟 长按-->进入[定制设置]
|
||||||
|
|
||||||
时钟 长按-->返回[全屏精简模式](#全屏精简模式)
|
|
||||||
|
|
||||||
左滑:改变背景动画
|
左滑:改变背景动画
|
||||||
右滑:改变走钟样式
|
|
||||||
双击:改变指针样式
|
|
||||||
|
|
||||||
------
|
右滑:改变样式
|
||||||
|
|
||||||
其它在设置页设置
|
双击:界面(详细-全屏)
|
||||||
|
|
||||||
|
|
||||||
<img src="/screenshot/demonstrate.gif" width="320" height="568"/>
|
|
||||||
|
|
||||||
|
|
||||||
6.0系统以下,可以用 近身感应锁屏。 在屏锁状态下无效
|
6.0系统以下,可以用 近身感应锁屏。 在屏锁状态下无效
|
||||||
@ -104,11 +87,11 @@ An Android clock [下载](#直接下载)
|
|||||||
|
|
||||||
### 直接下载:
|
### 直接下载:
|
||||||
|
|
||||||
[城通网盘](https://u19673462.ctfile.com/fs/19673462-357507198)
|
[城通网盘](https://u19673462.ctfile.com/fs/19673462-388092692)
|
||||||
|
|
||||||
[百度网盘](https://pan.baidu.com/s/1KC7vzUa7jQkAAbNrmBqvTQ) 提取码: pacy
|
[百度网盘](https://pan.baidu.com/s/1Uc8hdapVkAG1Zj8rFBsYfQ) 提取码: xfsj
|
||||||
|
|
||||||
[Download APK](https://gitee.com/51danju/workclock/raw/master/workclock.apk)
|
[Download APK](https://gitee.com/51danju/workclock/raw/master/workclock20190717.apk)
|
||||||
|
|
||||||
SourceCode:[WorkClock](https://gitee.com/51danju/workclock)
|
SourceCode:[WorkClock](https://gitee.com/51danju/workclock)
|
||||||
|
|
||||||
|
BIN
app/src/main/assets/test.3gp
Normal file
BIN
app/src/main/assets/test.3gp
Normal file
Binary file not shown.
@ -8,10 +8,8 @@ public class Constants {
|
|||||||
public final static int TALKING_HOURS=2;
|
public final static int TALKING_HOURS=2;
|
||||||
public final static int TALKING_NO_REPORT=3;
|
public final static int TALKING_NO_REPORT=3;
|
||||||
public final static String SHARE_PERFERENCE_FILE="share_perference.conf";
|
public final static String SHARE_PERFERENCE_FILE="share_perference.conf";
|
||||||
public final static String SHARE_PERFERENCE_FILE1="share_perference1.conf";
|
|
||||||
public final static String SHARE_PERFERENCE_FILE2="share_perference2.conf";
|
|
||||||
public final static int SUCCESS_CODE=0;
|
public final static int SUCCESS_CODE=0;
|
||||||
public final static int FAIL_CODE=-1;
|
public final static int FAIL_CODE=-1;
|
||||||
public final static int TYPE_TRIGGER_AUTO_OFF=4;
|
|
||||||
public final static int TYPE_TRIGGER_MANUAL =5;
|
public final static String APP_MEMO="小提示: ←动画 →字体 ↑↓亮度 双指_字体大小 双击_切屏 长按_参数设置";
|
||||||
}
|
}
|
@ -165,8 +165,17 @@ public class FamousQuotesManager {
|
|||||||
"民之难治,以其智多。故以智治国,国之贼。不以智治国,国之福。——《道德经》第六十五章"
|
"民之难治,以其智多。故以智治国,国之贼。不以智治国,国之福。——《道德经》第六十五章"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static final String[] APP_MEMOS=new String[]{
|
||||||
|
Constants.APP_MEMO,
|
||||||
|
"你可以长按「日期」来切换「界面主题」.",
|
||||||
|
"单击「星期几」可以快速切换「秒显」,长按则可以切换「时制」.",
|
||||||
|
"记着如怕乱触,可以使用「锁屏」.",
|
||||||
|
"前背景颜色可在「马头」切换,你也可以长按来改变它的设置,如果要彩虹字,则长按时间在参数设置里",
|
||||||
|
"注意哦,每个字体的大小在不同的模式下都不一样,可各自设置来保证美观,系统会记注每次改变."
|
||||||
|
};
|
||||||
|
|
||||||
public static String roundAutoQuotes(){
|
public static String roundAutoQuotes(){
|
||||||
int index=new java.util.Random().nextInt(4);
|
int index=new java.util.Random().nextInt(5);
|
||||||
switch (index){
|
switch (index){
|
||||||
case 1:
|
case 1:
|
||||||
return roundTangShi();
|
return roundTangShi();
|
||||||
@ -174,8 +183,10 @@ public class FamousQuotesManager {
|
|||||||
return roundLaoZi();
|
return roundLaoZi();
|
||||||
case 3:
|
case 3:
|
||||||
return roundKonZi();
|
return roundKonZi();
|
||||||
default:
|
case 4:
|
||||||
return roundFamousQuotes();
|
return roundFamousQuotes();
|
||||||
|
default:
|
||||||
|
return roundAppMemo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +206,13 @@ public class FamousQuotesManager {
|
|||||||
return roundFamousQuotes(POETRY_OF_THE_TANG_DYNASTY);
|
return roundFamousQuotes(POETRY_OF_THE_TANG_DYNASTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String roundAppMemo(){
|
||||||
|
return roundFamousQuotes(APP_MEMOS);
|
||||||
|
}
|
||||||
|
|
||||||
public static String roundFamousQuotes(String[] arrays){
|
public static String roundFamousQuotes(String[] arrays){
|
||||||
int index=new java.util.Random().nextInt(arrays.length);
|
int index=new java.util.Random().nextInt(arrays.length);
|
||||||
return arrays[index];
|
return arrays[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package clock.socoolby.com.clock;
|
|||||||
|
|
||||||
import com.openbravo.data.basic.BasicException;
|
import com.openbravo.data.basic.BasicException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
||||||
@ -10,6 +9,8 @@ import e.odbo.data.dao.EntityManager;
|
|||||||
|
|
||||||
public class FontManager {
|
public class FontManager {
|
||||||
|
|
||||||
|
public static final TimeFontStyle DEFAULT_FONT_STYLE =new TimeFontStyle("ds_digi",140,150,160,200);
|
||||||
|
|
||||||
private List<TimeFontStyle> fontStyleList;
|
private List<TimeFontStyle> fontStyleList;
|
||||||
|
|
||||||
private TimeFontStyle currentFontStyle;
|
private TimeFontStyle currentFontStyle;
|
||||||
@ -20,10 +21,8 @@ public class FontManager {
|
|||||||
|
|
||||||
public FontManager(EntityManager entityManager) {
|
public FontManager(EntityManager entityManager) {
|
||||||
this.entityManager=entityManager;
|
this.entityManager=entityManager;
|
||||||
//initTimeFontStyle();
|
|
||||||
loadForDB();
|
loadForDB();
|
||||||
currentFontIndex=0;
|
setCurrentFontName("ds_digi");
|
||||||
currentFontStyle=fontStyleList.get(currentFontIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadForDB(){
|
private void loadForDB(){
|
||||||
@ -36,10 +35,9 @@ public class FontManager {
|
|||||||
fontStyleList.add(DEFAULT_FONT_STYLE);
|
fontStyleList.add(DEFAULT_FONT_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final TimeFontStyle DEFAULT_FONT_STYLE =new TimeFontStyle("ds_digi",140,150,160,200);
|
|
||||||
|
|
||||||
public int getCurrentFontSize(boolean isFullScreen,boolean isDisplaySecond){
|
public int getCurrentFontSize(boolean isFullScreen,boolean isDisplaySecond){
|
||||||
int fontSize=currentFontStyle.displaySecond;
|
int fontSize;
|
||||||
if(isFullScreen){
|
if(isFullScreen){
|
||||||
if(isDisplaySecond) {
|
if(isDisplaySecond) {
|
||||||
fontSize=currentFontStyle.displaySecondOnFull;
|
fontSize=currentFontStyle.displaySecondOnFull;
|
||||||
@ -57,7 +55,7 @@ public class FontManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxFontSize(boolean isDisplaySecond){
|
public int getMaxFontSize(boolean isDisplaySecond){
|
||||||
int fontSize=currentFontStyle.displaySecond;
|
int fontSize;
|
||||||
if(isDisplaySecond) {
|
if(isDisplaySecond) {
|
||||||
fontSize=currentFontStyle.displaySecondOnFull;
|
fontSize=currentFontStyle.displaySecondOnFull;
|
||||||
}else{
|
}else{
|
||||||
@ -91,6 +89,14 @@ public class FontManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TimeFontStyle getFontStyleByName(String name){
|
||||||
|
for(TimeFontStyle entry:fontStyleList)
|
||||||
|
if (entry.name.equalsIgnoreCase(name)) {
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateCurrentFontSize(boolean isFullScreen,boolean isDisplaySecond,int newFontSize){
|
public void updateCurrentFontSize(boolean isFullScreen,boolean isDisplaySecond,int newFontSize){
|
||||||
if(isFullScreen){
|
if(isFullScreen){
|
||||||
if(isDisplaySecond) {
|
if(isDisplaySecond) {
|
||||||
@ -112,6 +118,30 @@ public class FontManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateFontSize(String fontName,boolean isFullScreen,boolean isDisplaySecond,int newFontSize){
|
||||||
|
TimeFontStyle timeFontStyle=getFontStyleByName(fontName);
|
||||||
|
if(timeFontStyle==null)
|
||||||
|
return;
|
||||||
|
if(isFullScreen){
|
||||||
|
if(isDisplaySecond) {
|
||||||
|
timeFontStyle.displaySecondOnFull=newFontSize;
|
||||||
|
}else{
|
||||||
|
timeFontStyle.noDisplaySecondOnFull=newFontSize;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(isDisplaySecond) {
|
||||||
|
timeFontStyle.displaySecond=newFontSize;
|
||||||
|
}else{
|
||||||
|
timeFontStyle.noDisplaySecond=newFontSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
entityManager.update(timeFontStyle);
|
||||||
|
} catch (BasicException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addCoustomFontStyle(List<TimeFontStyle> coustomFontStyleList){
|
public void addCoustomFontStyle(List<TimeFontStyle> coustomFontStyleList){
|
||||||
this.fontStyleList.addAll(coustomFontStyleList);
|
this.fontStyleList.addAll(coustomFontStyleList);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import androidx.lifecycle.Observer;
|
|||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
@ -17,6 +18,7 @@ import android.provider.Settings;
|
|||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@ -41,7 +43,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import clock.socoolby.com.clock.alter.AlterManager;
|
import clock.socoolby.com.clock.alter.AlterManager;
|
||||||
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
||||||
import clock.socoolby.com.clock.fragment.SystemAppConfigFragment;
|
import clock.socoolby.com.clock.fragment.houranimator.HourVideoFragment;
|
||||||
|
import clock.socoolby.com.clock.fragment.system.SystemAppConfigFragment;
|
||||||
import clock.socoolby.com.clock.fragment.handup.AbstractHandUpFragment;
|
import clock.socoolby.com.clock.fragment.handup.AbstractHandUpFragment;
|
||||||
import clock.socoolby.com.clock.fragment.handup.AlterFragmentFactory;
|
import clock.socoolby.com.clock.fragment.handup.AlterFragmentFactory;
|
||||||
import clock.socoolby.com.clock.fragment.digit.DigitClockConfigFragment;
|
import clock.socoolby.com.clock.fragment.digit.DigitClockConfigFragment;
|
||||||
@ -49,8 +52,8 @@ import clock.socoolby.com.clock.fragment.digit.DigitClockFragment;
|
|||||||
import clock.socoolby.com.clock.fragment.houranimator.HourAnimatorFactory;
|
import clock.socoolby.com.clock.fragment.houranimator.HourAnimatorFactory;
|
||||||
import clock.socoolby.com.clock.fragment.simulate.SimulateClockConfigFragment;
|
import clock.socoolby.com.clock.fragment.simulate.SimulateClockConfigFragment;
|
||||||
import clock.socoolby.com.clock.fragment.simulate.SimulateClockFragment;
|
import clock.socoolby.com.clock.fragment.simulate.SimulateClockFragment;
|
||||||
import clock.socoolby.com.clock.fragment.ThemeUIDefaultFragment;
|
import clock.socoolby.com.clock.fragment.theme.ThemeUIDefaultFragment;
|
||||||
import clock.socoolby.com.clock.fragment.ThemeUISampleFragment;
|
import clock.socoolby.com.clock.fragment.theme.ThemeUISampleFragment;
|
||||||
import clock.socoolby.com.clock.net.protocol.weather.WeatherResponse;
|
import clock.socoolby.com.clock.net.protocol.weather.WeatherResponse;
|
||||||
import clock.socoolby.com.clock.service.ProximityService;
|
import clock.socoolby.com.clock.service.ProximityService;
|
||||||
import clock.socoolby.com.clock.state.ClockModeEnum;
|
import clock.socoolby.com.clock.state.ClockModeEnum;
|
||||||
@ -66,7 +69,6 @@ import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
|||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
|
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.ClockFactory;
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.ClockFactory;
|
||||||
|
|
||||||
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.FULLSCREEN;
|
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.FULLSCREEN;
|
||||||
@ -76,22 +78,18 @@ import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.SETTING;
|
|||||||
public class MainActivity extends AppCompatActivity implements android.view.GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener, GestureDetector.OnDoubleTapListener {
|
public class MainActivity extends AppCompatActivity implements android.view.GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener, GestureDetector.OnDoubleTapListener {
|
||||||
private final static String TAG = MainActivity.class.getSimpleName();
|
private final static String TAG = MainActivity.class.getSimpleName();
|
||||||
|
|
||||||
private final static int SETTING_REQUEST_CODE = 100;
|
|
||||||
|
|
||||||
//背景动画
|
//背景动画
|
||||||
private AnimatorView animatorView;
|
private AnimatorView animatorView;
|
||||||
|
|
||||||
private I_Animator backGroundAnimator;
|
private I_Animator backGroundAnimator;
|
||||||
|
|
||||||
|
private final static int ANIMATOR_TEXTLED = 80;
|
||||||
private final static int ANIMATOR_TEXTLED=80;
|
|
||||||
|
|
||||||
private FrameLayout themeUIContainer;
|
private FrameLayout themeUIContainer;
|
||||||
|
|
||||||
//背景图相关
|
//背景图相关
|
||||||
private ImageView tv_background_image;
|
private ImageView tv_background_image;
|
||||||
|
|
||||||
|
|
||||||
// 定义手势检测器实例
|
// 定义手势检测器实例
|
||||||
GestureDetector detector;
|
GestureDetector detector;
|
||||||
ScaleGestureDetector scaleGestureDetector;
|
ScaleGestureDetector scaleGestureDetector;
|
||||||
@ -106,7 +104,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
private ClockStateMachine clockStateMachine;
|
private ClockStateMachine clockStateMachine;
|
||||||
|
|
||||||
Intent proximityServiceIntent=null;
|
Intent proximityServiceIntent = null;
|
||||||
FontManager fontManager;
|
FontManager fontManager;
|
||||||
|
|
||||||
GlobalViewModel globalViewModel;
|
GlobalViewModel globalViewModel;
|
||||||
@ -124,10 +122,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
public void setWeather(WeatherResponse weather) {
|
public void setWeather(WeatherResponse weather) {
|
||||||
if (weather == null)
|
if (weather == null)
|
||||||
return;
|
return;
|
||||||
Log.d(TAG,"setWeather...");
|
Log.d(TAG, "setWeather...");
|
||||||
this.weatherAdape= weather;
|
this.weatherAdape = weather;
|
||||||
if (weather.getTodayWeather() != null)
|
if (weather.getTodayWeather() != null)
|
||||||
themeUIViewModel.getWeatherDescription().setValue(weather.getTodayWeather().weather+"/"+weather.getTodayWeather().temperature);
|
themeUIViewModel.getWeatherDescription().setValue(weather.getTodayWeather().weather + "/" + weather.getTodayWeather().temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,110 +134,117 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
//Log.d(TAG,"onCreate...");
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
themeUIContainer = findViewById(R.id.main_background);
|
themeUIContainer = findViewById(R.id.main_background);
|
||||||
tv_background_image=findViewById(R.id.tv_background_image);
|
tv_background_image = findViewById(R.id.tv_background_image);
|
||||||
|
|
||||||
animatorView=findViewById(R.id.tv_background_animatorview);
|
animatorView = findViewById(R.id.tv_background_animatorview);
|
||||||
|
|
||||||
if(PermissionUtils.isGranted("android.permission.WAKE_LOCK","android.permission.DEVICE_POWER")) {
|
if (PermissionUtils.isGranted("android.permission.WAKE_LOCK", "android.permission.DEVICE_POWER")) {
|
||||||
PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE);
|
||||||
wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK |powerManager.ON_AFTER_RELEASE, "Clock");
|
wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK | powerManager.ON_AFTER_RELEASE, "Clock");
|
||||||
localWakeLock = powerManager.newWakeLock(32, "MyPower");
|
localWakeLock = powerManager.newWakeLock(32, "MyPower");
|
||||||
}else
|
} else
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
//创建手势检测器
|
//创建手势检测器
|
||||||
detector = new GestureDetector(this, this);
|
detector = new GestureDetector(this, this);
|
||||||
detector.setOnDoubleTapListener(this);
|
detector.setOnDoubleTapListener(this);
|
||||||
|
|
||||||
scaleGestureDetector=new ScaleGestureDetector(this,this);
|
scaleGestureDetector = new ScaleGestureDetector(this, this);
|
||||||
|
|
||||||
ClockApplication.getInstance().setMainActivity(this);
|
ClockApplication.getInstance().setMainActivity(this);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
testSetup();
|
||||||
|
|
||||||
//ClockApplication.valueOf().getBusinessService().checkUpdate();
|
//ClockApplication.valueOf().getBusinessService().checkUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPowerManagerDisable(){
|
private boolean isPowerManagerDisable() {
|
||||||
return wakeLock==null;
|
return wakeLock == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpProximityService(){
|
private void setUpProximityService() {
|
||||||
if(isPowerManagerDisable())
|
if (isPowerManagerDisable())
|
||||||
return;
|
return;
|
||||||
try{
|
try {
|
||||||
if(isScreenLock()){
|
if (isScreenLock()) {
|
||||||
stopService(proximityServiceIntent);
|
stopService(proximityServiceIntent);
|
||||||
}else {
|
} else {
|
||||||
if (model.isTriggerScreen()) {
|
if (model.isTriggerScreen()) {
|
||||||
startService(proximityServiceIntent);
|
startService(proximityServiceIntent);
|
||||||
} else {
|
} else {
|
||||||
stopService(proximityServiceIntent);
|
stopService(proximityServiceIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void onRequestPermissions(int reqCode,String ...permissions){
|
private void onRequestPermissions(int reqCode, String... permissions) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (!PermissionUtils.isGranted(permissions)) {
|
if (!PermissionUtils.isGranted(permissions)) {
|
||||||
ActivityCompat.requestPermissions(this,
|
ActivityCompat.requestPermissions(this,
|
||||||
permissions,
|
permissions,
|
||||||
reqCode);
|
reqCode);
|
||||||
}else {
|
} else {
|
||||||
Toast.makeText(this,"权限已申请",Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "权限已申请", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
model = ((ClockApplication)getApplication()).getModel();
|
model = ((ClockApplication) getApplication()).getModel();
|
||||||
|
|
||||||
Log.d(TAG, "init model:" + model.toString());
|
Log.d(TAG, "init model:" + model.toString());
|
||||||
|
|
||||||
proximityServiceIntent = new Intent(this, ProximityService.class);
|
proximityServiceIntent = new Intent(this, ProximityService.class);
|
||||||
|
|
||||||
fontManager=new FontManager(ClockApplication.getInstance().getEntityManager());
|
fontManager = new FontManager(ClockApplication.getInstance().getEntityManager());
|
||||||
|
|
||||||
animatorManager=new AnimatorManager();
|
animatorManager = new AnimatorManager();
|
||||||
|
|
||||||
ViewModelFactory viewModelFactory=new ViewModelFactory(model);
|
ViewModelFactory viewModelFactory = new ViewModelFactory(model);
|
||||||
globalViewModel= ViewModelProviders.of(MainActivity.this, viewModelFactory).get(GlobalViewModel.class);
|
globalViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(GlobalViewModel.class);
|
||||||
digitViewModel= ViewModelProviders.of(MainActivity.this, viewModelFactory).get(DigitViewModel.class);
|
digitViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(DigitViewModel.class);
|
||||||
simulateViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(SimulateViewModel.class);
|
simulateViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(SimulateViewModel.class);
|
||||||
themeUIViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
|
themeUIViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
|
||||||
alterViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
|
alterViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
|
||||||
|
|
||||||
alterManager=new AlterManager(model.getStartHourPowerTime(),model.getStopHourPowerTime(),globalViewModel,ClockApplication.getInstance().getEntityManager());
|
alterManager = new AlterManager(model.getStartHourPowerTime(), model.getStopHourPowerTime(), globalViewModel, ClockApplication.getInstance().getEntityManager());
|
||||||
|
|
||||||
clockStateMachine=new ClockStateMachine(alterManager,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel,alterViewModel);
|
clockStateMachine = new ClockStateMachine(alterManager, globalViewModel, digitViewModel, simulateViewModel, themeUIViewModel, alterViewModel);
|
||||||
|
|
||||||
setUpProximityService();
|
setUpProximityService();
|
||||||
|
|
||||||
bindViewModel();
|
bindViewModel();
|
||||||
|
|
||||||
themeUIManager=new ThemeUIManager(ClockApplication.getInstance().getEntityManager(),model);
|
themeUIManager = new ThemeUIManager(ClockApplication.getInstance().getEntityManager(), model,fontManager);
|
||||||
|
|
||||||
testSetup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int daily=30;
|
//这里对第一次启动
|
||||||
|
private void firstStartSetup(){
|
||||||
|
model.setFirstStart(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int daily = 30;
|
||||||
|
|
||||||
private void testSetup() {
|
private void testSetup() {
|
||||||
|
|
||||||
globalViewModel.getHourAlterTypeName().setValue(FishAnimator.NAME);
|
//model.setFirstStart(true);
|
||||||
|
|
||||||
//model.setBootStart(true);
|
//model.setBootStart(true);
|
||||||
|
|
||||||
//globalViewModel.getHandUpTypeName().setValue(HandUpSelect123Fragment.NAME);
|
//globalViewModel.getHandUpTypeName().setValue(HandUpSelect123Fragment.NAME);
|
||||||
|
|
||||||
/*Observer<Boolean> timeChange= new Observer<Boolean>() {
|
/*globalViewModel.getHourAlterTypeName().setValue(HourVideoFragment.NAME);
|
||||||
|
Observer<Boolean> timeChange= new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean aBoolean) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
daily--;
|
daily--;
|
||||||
@ -266,17 +271,18 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
fontManager.addCoustomFontStyle(new TimeFontStyle("BONX-TubeBold",110,120,130,150));
|
//fontManager.addCoustomFontStyle(new TimeFontStyle("BONX-TubeBold", 110, 120, 130, 150));
|
||||||
fontManager.addCoustomFontStyle(new TimeFontStyle("BONX-TubeBoldReverse",110,120,130,150));
|
//fontManager.addCoustomFontStyle(new TimeFontStyle("BONX-TubeBoldReverse", 110, 120, 130, 150));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void bindViewModel(){
|
private void bindViewModel() {
|
||||||
|
|
||||||
globalViewModel.getClockInterfaceTypeEnum().observe(this, new Observer<ClockInterfaceTypeEnum>() {
|
globalViewModel.getClockInterfaceTypeEnum().observe(this, new Observer<ClockInterfaceTypeEnum>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(ClockInterfaceTypeEnum clockInterfaceTypeEnum) {
|
public void onChanged(ClockInterfaceTypeEnum clockInterfaceTypeEnum) {
|
||||||
switch (clockInterfaceTypeEnum){
|
Log.d(TAG,"comming in clockInterfaceTypeEnum change observe type:"+clockInterfaceTypeEnum.name());
|
||||||
|
switch (clockInterfaceTypeEnum) {
|
||||||
case Digit:
|
case Digit:
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DigitClockFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DigitClockFragment()).commit();
|
||||||
break;
|
break;
|
||||||
@ -290,21 +296,22 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
globalViewModel.getClockModeEnum().observe(this, new Observer<ClockModeEnum>() {
|
globalViewModel.getClockModeEnum().observe(this, new Observer<ClockModeEnum>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(ClockModeEnum clockModeEnum) {
|
public void onChanged(ClockModeEnum clockModeEnum) {
|
||||||
switch(clockModeEnum){
|
switch (clockModeEnum) {
|
||||||
case HANDUP:
|
case HANDUP:
|
||||||
AbstractHandUpFragment alterFragment= AlterFragmentFactory.build(globalViewModel.getHandUpTypeName().getValue(),clockStateMachine);
|
closeAllConfigFragment();
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, alterFragment).commit();
|
AbstractHandUpFragment alterFragment = AlterFragmentFactory.build(globalViewModel.getHandUpTypeName().getValue(), clockStateMachine);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, alterFragment).addToBackStack(null).commit();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
|
getSupportFragmentManager().popBackStack();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
themeUIViewModel.getThemeName().observe(this, new Observer<String>() {
|
themeUIViewModel.getThemeName().observe(this, new Observer<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(String s) {
|
public void onChanged(String s) {
|
||||||
switch (s){
|
switch (s) {
|
||||||
case ThemeUISampleFragment.THEME_NAME:
|
case ThemeUISampleFragment.THEME_NAME:
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new ThemeUISampleFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new ThemeUISampleFragment()).commit();
|
||||||
break;
|
break;
|
||||||
@ -317,14 +324,14 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
globalViewModel.getBackgroundImageVisable().observe(this, new Observer<Boolean>() {
|
globalViewModel.getBackgroundImageVisable().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean visible) {
|
public void onChanged(Boolean visible) {
|
||||||
tv_background_image.setVisibility(visible?View.VISIBLE:View.GONE);
|
tv_background_image.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
globalViewModel.getBackgroundImageUri().observe(this, new Observer<Uri>() {
|
globalViewModel.getBackgroundImageUri().observe(this, new Observer<Uri>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Uri uri) {
|
public void onChanged(Uri uri) {
|
||||||
if(uri==null) {
|
if (uri == null) {
|
||||||
tv_background_image.setVisibility(View.GONE);
|
tv_background_image.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -355,7 +362,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
globalViewModel.getBackgroundAnimatorName().observe(this, new Observer<String>() {
|
globalViewModel.getBackgroundAnimatorName().observe(this, new Observer<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(String s) {
|
public void onChanged(String s) {
|
||||||
changeBackGroundAnimator(s,globalViewModel.getBackgroundAnimatorRandomColor());
|
changeBackGroundAnimator(s, globalViewModel.getBackgroundAnimatorRandomColor());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -384,21 +391,21 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
digitViewModel.getTimeFontStyle().observe(this, new Observer<TimeFontStyle>() {
|
digitViewModel.getTimeFontStyle().observe(this, new Observer<TimeFontStyle>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(TimeFontStyle timeFontStyle) {
|
public void onChanged(TimeFontStyle timeFontStyle) {
|
||||||
digitViewModel.setTimeFontStyleSize(fontManager.getCurrentFontSize(themeUIViewModel.getClockUITypeEnum().getValue()==FULLSCREEN,model.isDisplaySecond()));
|
digitViewModel.setTimeFontStyleSize(fontManager.getCurrentFontSize(themeUIViewModel.getClockUITypeEnum().getValue() == FULLSCREEN, model.isDisplaySecond()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
themeUIViewModel.getClockUITypeEnum().observe(this, new Observer<ClockThemeUITypeEnum>() {
|
themeUIViewModel.getClockUITypeEnum().observe(this, new Observer<ClockThemeUITypeEnum>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(ClockThemeUITypeEnum clockThemeUITypeEnum) {
|
public void onChanged(ClockThemeUITypeEnum clockThemeUITypeEnum) {
|
||||||
int fontSize=0;
|
int fontSize = 0;
|
||||||
boolean displaySecond=model.isDisplaySecond();
|
boolean displaySecond = model.isDisplaySecond();
|
||||||
switch (clockThemeUITypeEnum){
|
switch (clockThemeUITypeEnum) {
|
||||||
case FULLSCREEN:
|
case FULLSCREEN:
|
||||||
fontSize=fontManager.getCurrentFontSize(true,displaySecond);
|
fontSize = fontManager.getCurrentFontSize(true, displaySecond);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fontSize=fontManager.getCurrentFontSize(false,displaySecond);
|
fontSize = fontManager.getCurrentFontSize(false, displaySecond);
|
||||||
}
|
}
|
||||||
digitViewModel.setTimeFontStyleSize(fontSize);
|
digitViewModel.setTimeFontStyleSize(fontSize);
|
||||||
}
|
}
|
||||||
@ -407,35 +414,42 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
digitViewModel.getDisplaySecond().observe(this, new Observer<Boolean>() {
|
digitViewModel.getDisplaySecond().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean aBoolean) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
digitViewModel.setTimeFontStyleSize(fontManager.getCurrentFontSize(themeUIViewModel.getClockUITypeEnum().getValue()==FULLSCREEN,aBoolean));
|
digitViewModel.setTimeFontStyleSize(fontManager.getCurrentFontSize(themeUIViewModel.getClockUITypeEnum().getValue() == FULLSCREEN, aBoolean));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
globalViewModel.getTimeHourAnimatorStarting().observe(this, new Observer<Boolean>() {
|
globalViewModel.getTimeHourAnimatorStarting().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean starting) {
|
public void onChanged(Boolean starting) {
|
||||||
Log.d(TAG, "on hour animator changed: "+starting);
|
Log.d(TAG, "on hour animator changed: " + starting);
|
||||||
if(!HourAnimatorFactory.isHourAnimator(globalViewModel.getHourAlterTypeName().getValue()))
|
if (!HourAnimatorFactory.isHourAnimator(globalViewModel.getHourAlterTypeName().getValue()))
|
||||||
return;
|
return;
|
||||||
if(starting)
|
if (starting)
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(globalViewModel.getHourAlterTypeName().getValue(),globalViewModel.getTime_hour().getValue())).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(globalViewModel.getHourAlterTypeName().getValue(), globalViewModel.getTime_hour().getValue())).addToBackStack(null).commit();
|
||||||
else
|
else
|
||||||
globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
|
getSupportFragmentManager().popBackStack();
|
||||||
|
//globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void closeAllConfigFragment(){
|
||||||
|
getSupportFragmentManager().popBackStack();
|
||||||
|
}
|
||||||
|
|
||||||
//将该Activity上的触碰事件交给GestureDetector处理
|
//将该Activity上的触碰事件交给GestureDetector处理
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent me)
|
public boolean onTouchEvent(MotionEvent me) {
|
||||||
{
|
if (globalViewModel.getAppConfig())
|
||||||
if(globalViewModel.getAppConfig())
|
return true;
|
||||||
return false;
|
|
||||||
if(me.getPointerCount()>1)
|
boolean res = scaleGestureDetector.onTouchEvent(me);
|
||||||
return scaleGestureDetector.onTouchEvent(me);
|
if (!scaleGestureDetector.isInProgress()) {
|
||||||
return detector.onTouchEvent(me);
|
res = detector.onTouchEvent(me);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,17 +457,16 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
//Log.i(TAG, "onDestroy....");
|
//Log.i(TAG, "onDestroy....");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if(clockStateMachine!=null)
|
if (clockStateMachine != null)
|
||||||
clockStateMachine.onDestory();
|
clockStateMachine.onDestory();
|
||||||
try {
|
try {
|
||||||
if (model.isTriggerScreen())
|
if (model.isTriggerScreen())
|
||||||
stopService(proximityServiceIntent);
|
stopService(proximityServiceIntent);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(backGroundAnimator!=null)
|
if (backGroundAnimator != null)
|
||||||
backGroundAnimator.stop();
|
backGroundAnimator.stop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -463,27 +476,35 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
//Log.i(TAG, "onDestroy....");
|
//Log.i(TAG, "onDestroy....");
|
||||||
super.onResume();
|
super.onResume();
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
||||||
if(!isPowerManagerDisable())
|
if (!isPowerManagerDisable())
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
if(backGroundAnimator!=null)
|
if (backGroundAnimator != null)
|
||||||
backGroundAnimator.start();
|
backGroundAnimator.start();
|
||||||
clockStateMachine.start();
|
clockStateMachine.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if(model.isFirstStart())
|
||||||
|
firstStartSetup();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
//Log.d(TAG,"onPause..");
|
//Log.d(TAG,"onPause..");
|
||||||
if(!isPowerManagerDisable())
|
if (!isPowerManagerDisable())
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
if(backGroundAnimator!=null)
|
if (backGroundAnimator != null)
|
||||||
backGroundAnimator.stop();
|
backGroundAnimator.stop();
|
||||||
clockStateMachine.stop();
|
clockStateMachine.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configBackGroundImage(){
|
public void configBackGroundImage() {
|
||||||
PictureSelector.create(MainActivity.this)
|
PictureSelector.create(MainActivity.this)
|
||||||
.openGallery(PictureMimeType.ofImage())
|
.openGallery(PictureMimeType.ofImage())
|
||||||
|
.isCamera(false)
|
||||||
.imageSpanCount(4)
|
.imageSpanCount(4)
|
||||||
.forResult(PictureConfig.CHOOSE_REQUEST);
|
.forResult(PictureConfig.CHOOSE_REQUEST);
|
||||||
}
|
}
|
||||||
@ -492,68 +513,70 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
|
List<LocalMedia> selectList;
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case PictureConfig.CHOOSE_REQUEST:
|
case PictureConfig.CHOOSE_REQUEST:
|
||||||
// 图片、视频、音频选择结果回调
|
// 图片、视频、音频选择结果回调
|
||||||
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
|
selectList = PictureSelector.obtainMultipleResult(data);
|
||||||
// 例如 LocalMedia 里面返回三种path
|
// 例如 LocalMedia 里面返回三种path
|
||||||
// 1.media.getPath(); 为原图path
|
// 1.media.getPath(); 为原图path
|
||||||
// 2.media.getCutPath();为裁剪后path,需判断media.isCut();是否为true 注意:音视频除外
|
// 2.media.getCutPath();为裁剪后path,需判断media.isCut();是否为true 注意:音视频除外
|
||||||
// 3.media.getCompressPath();为压缩后path,需判断media.isCompressed();是否为true 注意:音视频除外
|
// 3.media.getCompressPath();为压缩后path,需判断media.isCompressed();是否为true 注意:音视频除外
|
||||||
// 如果裁剪并压缩了,以取压缩路径为准,因为是先裁剪后压缩的
|
// 如果裁剪并压缩了,以取压缩路径为准,因为是先裁剪后压缩的
|
||||||
|
|
||||||
globalViewModel.getBackgroundImageUri().setValue(Uri.parse(selectList.get(0).getPath()));
|
globalViewModel.setBackgroundImageUri(Uri.parse(selectList.get(0).getPath()));
|
||||||
globalViewModel.getBackgroundImageVisable().setValue(true);
|
globalViewModel.getBackgroundImageVisable().setValue(true);
|
||||||
break;
|
break;
|
||||||
case SETTING_REQUEST_CODE:
|
case PictureConfig.TYPE_VIDEO:
|
||||||
init();
|
selectList = PictureSelector.obtainMultipleResult(data);
|
||||||
|
model.setTimeHourVideoPath(selectList.get(0).getPath());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setBackGroundColor(Integer color){
|
protected void setBackGroundColor(Integer color) {
|
||||||
if(null==color)
|
if (null == color)
|
||||||
return;
|
return;
|
||||||
themeUIContainer.setBackgroundColor(color);
|
themeUIContainer.setBackgroundColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextBackGroundAnimator(){
|
public void nextBackGroundAnimator() {
|
||||||
boolean randomColor=globalViewModel.getBackgroundAnimatorRandomColor();
|
boolean randomColor = globalViewModel.getBackgroundAnimatorRandomColor();
|
||||||
if(!randomColor&&backGroundAnimator!=null) {
|
if (!randomColor && backGroundAnimator != null) {
|
||||||
globalViewModel.setBackgroundAnimatorRandomColor(true);
|
globalViewModel.setBackgroundAnimatorRandomColor(true);
|
||||||
backGroundAnimator.setRandColor(true);
|
backGroundAnimator.setRandColor(true);
|
||||||
animatorView.setAnimator(backGroundAnimator);
|
animatorView.setAnimator(backGroundAnimator);
|
||||||
}else {
|
} else {
|
||||||
globalViewModel.setBackgroundAnimatorRandomColor(false);
|
globalViewModel.setBackgroundAnimatorRandomColor(false);
|
||||||
globalViewModel.setBackgroundAnimatorName(animatorManager.next());
|
globalViewModel.setBackgroundAnimatorName(animatorManager.next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeBackGroundAnimator(String animatorName,boolean randomColor){
|
public void changeBackGroundAnimator(String animatorName, boolean randomColor) {
|
||||||
backGroundAnimator= animatorManager.configByName(animatorName);
|
backGroundAnimator = animatorManager.configByName(animatorName);
|
||||||
if(backGroundAnimator!=null) {
|
if (backGroundAnimator != null) {
|
||||||
backGroundAnimator.init(animatorView.getContext(),animatorView);
|
backGroundAnimator.init(animatorView.getContext(), animatorView);
|
||||||
backGroundAnimator.setRandColor(randomColor);
|
backGroundAnimator.setRandColor(randomColor);
|
||||||
}
|
}
|
||||||
animatorView.setAnimator(backGroundAnimator);
|
animatorView.setAnimator(backGroundAnimator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeBackGroudAnimatorColor(int color){
|
public void changeBackGroudAnimatorColor(int color) {
|
||||||
animatorView.setColor(color);
|
animatorView.setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if(isScreenLock())
|
if (isScreenLock())
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if(globalViewModel.getAppConfig()) {
|
if (globalViewModel.getAppConfig()) {
|
||||||
getSupportFragmentManager().popBackStack();
|
getSupportFragmentManager().popBackStack();
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(!isFullScreen()){
|
if (!isFullScreen()) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setIcon(android.R.drawable.ic_dialog_info);
|
builder.setIcon(android.R.drawable.ic_dialog_info);
|
||||||
builder.setTitle("温馨提示");
|
builder.setTitle("温馨提示");
|
||||||
@ -561,10 +584,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
builder.setCancelable(true);
|
builder.setCancelable(true);
|
||||||
|
|
||||||
builder.setPositiveButton("确定", (dialog, which) -> {
|
builder.setPositiveButton("确定", (dialog, which) -> {
|
||||||
MainActivity.this.finish();
|
MainActivity.this.finish();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton("取消", (dialog, which) -> {
|
builder.setNegativeButton("取消", (dialog, which) -> {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
@ -576,9 +599,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setup(){
|
public void setup() {
|
||||||
//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();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SystemAppConfigFragment(model)).addToBackStack(null).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,12 +613,12 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isScreenLock(){
|
private boolean isScreenLock() {
|
||||||
return globalViewModel.getSrceenLock().getValue();
|
return globalViewModel.getSrceenLock().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFullScreen(){
|
private boolean isFullScreen() {
|
||||||
return themeUIViewModel.getClockUITypeEnum().getValue()== FULLSCREEN;
|
return themeUIViewModel.getClockUITypeEnum().getValue() == FULLSCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -624,95 +645,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
showConfigThemeUI();
|
showConfigThemeUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeThemeUI(){
|
private void showConfigThemeUI() {
|
||||||
if(!isPowerManagerDisable())
|
if (globalViewModel.getClockModeEnum().getValue() != ClockModeEnum.NORMAL)
|
||||||
localWakeLock.isHeld();
|
return;
|
||||||
switch (globalViewModel.getClockInterfaceTypeEnum().getValue()){
|
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(isScreenLock()&&!isFullScreen())
|
|
||||||
return true;
|
|
||||||
Log.d(TAG,"onFling");
|
|
||||||
int brightness=globalViewModel.getBrightness().getValue();
|
|
||||||
if (e2.getY() - e1.getY() < -200) { // 从上至下
|
|
||||||
Log.d(TAG, "change brightness +10");
|
|
||||||
brightness = brightness + 10;
|
|
||||||
if (brightness >= 255){
|
|
||||||
Toast.makeText(this,"最大亮度了",Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
globalViewModel.getBrightness().setValue(brightness);
|
|
||||||
return true;
|
|
||||||
}else if (e2.getY() - e1.getY() >200) { // 从下至上
|
|
||||||
Log.d(TAG,"change brightness -10");
|
|
||||||
brightness=brightness-10;
|
|
||||||
if(brightness<=0) {
|
|
||||||
Toast.makeText(this,"最小亮度了",Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
globalViewModel.getBrightness().setValue(brightness);
|
|
||||||
return true;
|
|
||||||
}else if (e2.getX() - e1.getX() > 200) { // 从左向右滑动(左进右出)
|
|
||||||
Log.d(TAG,"left->right");
|
|
||||||
if(globalViewModel.getClockInterfaceTypeEnum().getValue()== ClockInterfaceTypeEnum.Simulate){
|
|
||||||
simulateViewModel.setClockTypeName(ClockFactory.nextSimulateClockName(simulateViewModel.getClockTypeName().getValue()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
digitViewModel.setTimeFontStyle(fontManager.nextFont());
|
|
||||||
return true;
|
|
||||||
} else if (e2.getX() - e1.getX() < -200) { // 从右向左滑动(右进左出)
|
|
||||||
nextBackGroundAnimator();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//boolean isShowAdvConfig=false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onDoubleTap(MotionEvent e) {
|
|
||||||
changeThemeUI();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void showConfigThemeUI(){
|
|
||||||
if(globalViewModel.getClockModeEnum().getValue()!=ClockModeEnum.NORMAL)
|
|
||||||
return ;
|
|
||||||
switch (globalViewModel.getClockInterfaceTypeEnum().getValue()){
|
|
||||||
case Digit:
|
case Digit:
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment(themeUIManager)).addToBackStack(null).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment(themeUIManager)).addToBackStack(null).commit();
|
||||||
break;
|
break;
|
||||||
@ -722,40 +658,134 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void changeThemeUI() {
|
||||||
|
if (!isPowerManagerDisable())
|
||||||
|
localWakeLock.isHeld();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer flingWidth;
|
||||||
|
Integer flingHeight;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float v, float v1) {
|
||||||
|
if (isScreenLock() && !isFullScreen())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Log.d(TAG, "onFling");
|
||||||
|
|
||||||
|
int brightness = globalViewModel.getBrightness().getValue();
|
||||||
|
|
||||||
|
if(flingWidth==null)
|
||||||
|
calcFilingFlag();
|
||||||
|
|
||||||
|
if (e2.getY() - e1.getY() < -flingHeight) { // 从上至下
|
||||||
|
Log.d(TAG, "change brightness +10");
|
||||||
|
brightness = brightness + 10;
|
||||||
|
if (brightness >= 255) {
|
||||||
|
Toast.makeText(this, "最大亮度了", Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
globalViewModel.getBrightness().setValue(brightness);
|
||||||
|
return true;
|
||||||
|
} else if (e2.getY() - e1.getY() > flingHeight) { // 从下至上
|
||||||
|
Log.d(TAG, "change brightness -10");
|
||||||
|
brightness = brightness - 10;
|
||||||
|
if (brightness <= 0) {
|
||||||
|
Toast.makeText(this, "最小亮度了", Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
globalViewModel.getBrightness().setValue(brightness);
|
||||||
|
return true;
|
||||||
|
} else if (e2.getX() - e1.getX() > flingWidth) { // 从左向右滑动(左进右出)
|
||||||
|
Log.d(TAG, "left->right");
|
||||||
|
if (globalViewModel.getClockInterfaceTypeEnum().getValue() == ClockInterfaceTypeEnum.Simulate) {
|
||||||
|
simulateViewModel.setClockTypeName(ClockFactory.nextSimulateClockName(simulateViewModel.getClockTypeName().getValue()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
digitViewModel.setTimeFontStyle(fontManager.nextFont());
|
||||||
|
return true;
|
||||||
|
} else if (e2.getX() - e1.getX() < -flingWidth) { // 从右向左滑动(右进左出)
|
||||||
|
nextBackGroundAnimator();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onDoubleTap(MotionEvent e) {
|
||||||
|
changeThemeUI();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTapEvent(MotionEvent e) {
|
public boolean onDoubleTapEvent(MotionEvent e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onScale(ScaleGestureDetector detector) {
|
|
||||||
float span=detector.getCurrentSpan();
|
|
||||||
Log.d(TAG,"onScale span:"+span);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
float scaleSpan=0;
|
|
||||||
|
|
||||||
|
float scaleSpan = 0;
|
||||||
|
int currentFontSize;
|
||||||
|
//int maxFontSize;
|
||||||
@Override
|
@Override
|
||||||
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
public boolean onScaleBegin(ScaleGestureDetector detector) {
|
||||||
Log.d(TAG,"onScaleBegin ");
|
Log.d(TAG, "onScaleBegin ");
|
||||||
scaleSpan=detector.getCurrentSpan();
|
scaleSpan = detector.getCurrentSpan();
|
||||||
|
currentFontSize=digitViewModel.getTimeFontStyleSize().getValue();
|
||||||
|
//maxFontSize = fontManager.getMaxFontSize(model.isDisplaySecond());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScaleEnd(ScaleGestureDetector detector) {
|
public boolean onScale(ScaleGestureDetector detector) {
|
||||||
//float fontScale = getResources().getDisplayMetrics().scaledDensity;
|
|
||||||
float span=detector.getCurrentSpan()-scaleSpan;
|
|
||||||
int step=new Float(span/30).intValue();
|
|
||||||
int maxFontSize=fontManager.getMaxFontSize(model.isDisplaySecond());
|
|
||||||
int currentFontSize=digitViewModel.getTimeFontStyleSize().getValue();
|
|
||||||
currentFontSize=currentFontSize+step;
|
|
||||||
|
|
||||||
Log.d(TAG,"onScaleEnd span:"+span+"\t step:"+step+"\tcurrent text size"+currentFontSize+"\t max text size:"+maxFontSize+"\t");
|
float span = detector.getCurrentSpan() - scaleSpan;
|
||||||
|
int step = new Float(span / 30).intValue();
|
||||||
|
|
||||||
|
currentFontSize = currentFontSize + step;
|
||||||
|
|
||||||
|
Log.d(TAG, "onScaleEnd span:" + span + "\t step:" + step + "\tcurrent text size" + currentFontSize);
|
||||||
|
|
||||||
fontManager.updateCurrentFontSize(isFullScreen(),model.isDisplaySecond(),currentFontSize);
|
|
||||||
digitViewModel.setTimeFontStyleSize(currentFontSize);
|
digitViewModel.setTimeFontStyleSize(currentFontSize);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScaleEnd(ScaleGestureDetector detector) {
|
||||||
|
fontManager.updateCurrentFontSize(isFullScreen(), model.isDisplaySecond(), currentFontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -786,12 +816,12 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
return systemBrightness;
|
return systemBrightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getnum(int num1,int num2){
|
public String getnum(int num1, int num2) {
|
||||||
NumberFormat numberFormat = NumberFormat.getInstance();
|
NumberFormat numberFormat = NumberFormat.getInstance();
|
||||||
// 设置精确到小数点后0位
|
// 设置精确到小数点后0位
|
||||||
numberFormat.setMaximumFractionDigits(0);
|
numberFormat.setMaximumFractionDigits(0);
|
||||||
String result = numberFormat.format((float) num1 / (float) num2 * 100);
|
String result = numberFormat.format((float) num1 / (float) num2 * 100);
|
||||||
return result+"%";
|
return result + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClockStateMachine getClockStateMachine() {
|
public ClockStateMachine getClockStateMachine() {
|
||||||
@ -802,4 +832,15 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
public AlterManager getAlterManager() {
|
public AlterManager getAlterManager() {
|
||||||
return alterManager;
|
return alterManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void calcFilingFlag() {
|
||||||
|
Point outSize=new Point();
|
||||||
|
WindowManager windowManager = getWindowManager();
|
||||||
|
Display display = windowManager.getDefaultDisplay();
|
||||||
|
display.getSize(outSize);
|
||||||
|
flingWidth=outSize.x/3;
|
||||||
|
flingHeight =outSize.y/3;
|
||||||
|
//Log.d(TAG,"calc filing flag flingWidth:"+flingWidth+"\tflingHeight"+flingHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,19 @@ import com.openbravo.data.basic.BasicException;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.dao.base.ThemeUI;
|
import clock.socoolby.com.clock.dao.base.ThemeUI;
|
||||||
import clock.socoolby.com.clock.model.DigitPerferenceModel;
|
import clock.socoolby.com.clock.model.DigitPerferenceModel;
|
||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
import clock.socoolby.com.clock.model.SimulatePerferenceModel;
|
import clock.socoolby.com.clock.model.SimulatePerferenceModel;
|
||||||
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
||||||
|
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
||||||
import e.odbo.data.dao.EntityManager;
|
import e.odbo.data.dao.EntityManager;
|
||||||
import e.odbo.data.dsl.query.QBF;
|
import e.odbo.data.dsl.query.QBF;
|
||||||
|
|
||||||
|
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.FULLSCREEN;
|
||||||
|
|
||||||
public class ThemeUIManager{
|
public class ThemeUIManager{
|
||||||
|
|
||||||
public static final String TAG = ThemeUIManager.class.getSimpleName();
|
public static final String TAG = ThemeUIManager.class.getSimpleName();
|
||||||
@ -24,11 +28,14 @@ public class ThemeUIManager{
|
|||||||
|
|
||||||
SharePerferenceModel model;
|
SharePerferenceModel model;
|
||||||
|
|
||||||
|
FontManager fontManager;
|
||||||
|
|
||||||
private String tempThemeStr=null;
|
private String tempThemeStr=null;
|
||||||
|
|
||||||
public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model) {
|
public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model,FontManager fontManager) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.model=model;
|
this.model=model;
|
||||||
|
this.fontManager=fontManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadDigitThemeFromDB(String name) throws BasicException {
|
public void loadDigitThemeFromDB(String name) throws BasicException {
|
||||||
@ -75,6 +82,7 @@ public class ThemeUIManager{
|
|||||||
ThemeUI themeUI=findThemeUIFromDB(name,ClockInterfaceTypeEnum.Digit.code);
|
ThemeUI themeUI=findThemeUIFromDB(name,ClockInterfaceTypeEnum.Digit.code);
|
||||||
if(themeUI==null){
|
if(themeUI==null){
|
||||||
themeUI=new ThemeUI();
|
themeUI=new ThemeUI();
|
||||||
|
themeUI.setId(UUID.randomUUID().toString());
|
||||||
themeUI.setName(name);
|
themeUI.setName(name);
|
||||||
themeUI.setClockType(ClockInterfaceTypeEnum.Digit.code);
|
themeUI.setClockType(ClockInterfaceTypeEnum.Digit.code);
|
||||||
themeUI.setConfigText(makeSaveDigitThemeString(model.getDigitPerferenceModel()));
|
themeUI.setConfigText(makeSaveDigitThemeString(model.getDigitPerferenceModel()));
|
||||||
@ -100,6 +108,7 @@ public class ThemeUIManager{
|
|||||||
ThemeUI themeUI=findThemeUIFromDB(name,ClockInterfaceTypeEnum.Simulate.code);
|
ThemeUI themeUI=findThemeUIFromDB(name,ClockInterfaceTypeEnum.Simulate.code);
|
||||||
if(themeUI==null){
|
if(themeUI==null){
|
||||||
themeUI=new ThemeUI();
|
themeUI=new ThemeUI();
|
||||||
|
themeUI.setId(UUID.randomUUID().toString());
|
||||||
themeUI.setName(name);
|
themeUI.setName(name);
|
||||||
themeUI.setClockType(ClockInterfaceTypeEnum.Simulate.code);
|
themeUI.setClockType(ClockInterfaceTypeEnum.Simulate.code);
|
||||||
themeUI.setConfigText(makeSaveSimulateThemeString(model.getSimulatePerferenceModel()));
|
themeUI.setConfigText(makeSaveSimulateThemeString(model.getSimulatePerferenceModel()));
|
||||||
@ -154,4 +163,20 @@ public class ThemeUIManager{
|
|||||||
loadSimulateTheme(tempThemeStr);
|
loadSimulateTheme(tempThemeStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadThemeFromNet(ThemeUI netTheme)throws BasicException{
|
||||||
|
if(netTheme==null)
|
||||||
|
return;
|
||||||
|
int clockType=netTheme.getClockType();
|
||||||
|
if(clockType==ClockInterfaceTypeEnum.Digit.code) {
|
||||||
|
loadDigitTheme(netTheme.getConfigText());
|
||||||
|
fontManager.updateFontSize(model.getFontName(),isFullScreen(), model.isDisplaySecond(), model.getFontStyleSize());
|
||||||
|
}else if(clockType==ClockInterfaceTypeEnum.Simulate.code)
|
||||||
|
loadSimulateTheme(netTheme.getConfigText());
|
||||||
|
model.setClockInterfaceType(clockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFullScreen() {
|
||||||
|
return ClockThemeUITypeEnum.valueOf(model.getThemeUIType()) == FULLSCREEN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import e.odbo.data.model.DataBase;
|
|||||||
import e.odbo.data.model.Table;
|
import e.odbo.data.model.Table;
|
||||||
import e.odbo.data.model.TableData;
|
import e.odbo.data.model.TableData;
|
||||||
import e.odbo.data.model.smaple.PK;
|
import e.odbo.data.model.smaple.PK;
|
||||||
import e.odbo.data.model.smaple.TimeLogAble;
|
|
||||||
|
|
||||||
public class WorkClockDatabase extends DataBase {
|
public class WorkClockDatabase extends DataBase {
|
||||||
public WorkClockDatabase() {
|
public WorkClockDatabase() {
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
||||||
|
|
||||||
|
public abstract class AbstractAnimatorFragment extends Fragment {
|
||||||
|
|
||||||
|
protected GlobalViewModel globalViewModel;
|
||||||
|
|
||||||
|
protected AnimatorView animatorView;
|
||||||
|
|
||||||
|
protected I_Animator animator;
|
||||||
|
|
||||||
|
public AbstractAnimatorFragment(I_Animator animator) {
|
||||||
|
this.animator = animator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void initAnimatorView(AnimatorView animatorView){
|
||||||
|
this.animatorView=animatorView;
|
||||||
|
animator.init(getActivity(),animatorView);
|
||||||
|
animatorView.setAnimator(animator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
animatorView.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
animatorView.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void bindViewModel();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.graphics.SurfaceTexture;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Surface;
|
||||||
|
import android.view.TextureView;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
|
import clock.socoolby.com.clock.utils.Player;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
|
|
||||||
|
public abstract class AbstractVideoFragment extends Fragment {
|
||||||
|
protected String videoFileName;
|
||||||
|
|
||||||
|
protected MediaPlayer mediaPlayer;
|
||||||
|
|
||||||
|
protected int fileLocal=0;//0-》自定,1-》assets
|
||||||
|
|
||||||
|
public AbstractVideoFragment(String videoFileName) {
|
||||||
|
this.videoFileName = videoFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractVideoFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Player.getInstance().setPlayAble(false);
|
||||||
|
try {
|
||||||
|
if(fileLocal==1) {
|
||||||
|
AssetFileDescriptor fd = getActivity().getAssets().openFd(videoFileName);
|
||||||
|
mediaPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
|
||||||
|
}else
|
||||||
|
mediaPlayer.setDataSource(videoFileName);
|
||||||
|
mediaPlayer.prepare();
|
||||||
|
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||||
|
@Override
|
||||||
|
public void onCompletion(MediaPlayer mp) {
|
||||||
|
mp.seekTo(0);
|
||||||
|
mp.stop();
|
||||||
|
onPlayCompletion();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mediaPlayer.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initMediaPlay(TextureView textureView){
|
||||||
|
mediaPlayer=new MediaPlayer();
|
||||||
|
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||||
|
textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
|
||||||
|
@Override
|
||||||
|
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
|
||||||
|
// SurfaceTexture准备就绪
|
||||||
|
mediaPlayer.setSurface(new Surface(surface));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
|
||||||
|
// SurfaceTexture缓冲大小变化
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
|
||||||
|
// SurfaceTexture即将被销毁
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
|
||||||
|
// SurfaceTexture通过updateImage更新
|
||||||
|
}
|
||||||
|
});
|
||||||
|
textureView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
textureViewClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void onPlayCompletion();
|
||||||
|
|
||||||
|
protected void textureViewClick(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
mediaPlayer.pause();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if(mediaPlayer.isPlaying())
|
||||||
|
mediaPlayer.stop();
|
||||||
|
mediaPlayer.release();
|
||||||
|
Player.getInstance().setPlayAble(true);
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,7 @@ import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
|||||||
import clock.socoolby.com.clock.utils.DialogUtils;
|
import clock.socoolby.com.clock.utils.DialogUtils;
|
||||||
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
import clock.socoolby.com.clock.widget.textview.ShadowTypeEnum;
|
import clock.socoolby.com.clock.widget.textview.ShadowTypeEnum;
|
||||||
import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
|
import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
|
||||||
@ -47,7 +48,7 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
|
|
||||||
DigitViewModel digitViewModel;
|
DigitViewModel digitViewModel;
|
||||||
GlobalViewModel globalViewModel;
|
GlobalViewModel globalViewModel;
|
||||||
|
ThemeUIViewModel themeUIViewModel;
|
||||||
ThemeUIManager themeUIManager;
|
ThemeUIManager themeUIManager;
|
||||||
|
|
||||||
@BindView(R.id.tv_hourSystem12)
|
@BindView(R.id.tv_hourSystem12)
|
||||||
@ -146,6 +147,7 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||||
digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
|
digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
|
||||||
|
themeUIViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(ThemeUIViewModel.class);
|
||||||
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
|
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Digit.code);
|
||||||
globalViewModel.setAppConfig(true);
|
globalViewModel.setAppConfig(true);
|
||||||
}
|
}
|
||||||
@ -164,7 +166,8 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
view.setOnLongClickListener(new View.OnLongClickListener() {
|
view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
getFragmentManager().popBackStack();
|
//getFragmentManager().popBackStack();
|
||||||
|
themeUIViewModel.loadFromModel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -28,6 +29,7 @@ import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
|
|||||||
* create an instance of this fragment.
|
* create an instance of this fragment.
|
||||||
*/
|
*/
|
||||||
public class DigitClockFragment extends Fragment {
|
public class DigitClockFragment extends Fragment {
|
||||||
|
public static final String TAG=DigitClockFragment.class.getName();
|
||||||
|
|
||||||
public DigitClockFragment() {
|
public DigitClockFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -41,6 +43,7 @@ public class DigitClockFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Log.d(TAG,"onCreate..");
|
||||||
digitViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
|
digitViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
|
||||||
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
package clock.socoolby.com.clock.fragment.houranimator;
|
package clock.socoolby.com.clock.fragment.houranimator;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FerrisWheelAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.FerrisWheelAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.WindmillAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.WindmillAnimator;
|
||||||
|
|
||||||
public final class HourAnimatorFactory {
|
public final class HourAnimatorFactory {
|
||||||
|
public static final String DEFAULT="default";
|
||||||
|
|
||||||
public static boolean isHourAnimator(String typeName){
|
public static boolean isHourAnimator(String typeName){
|
||||||
return !"default".equalsIgnoreCase(typeName);
|
return !DEFAULT.equalsIgnoreCase(typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HourAnimatorFragment builder(String typeName,int hour){
|
public static Fragment builder(String typeName, int hour){
|
||||||
I_Animator animator=null;
|
I_Animator animator=null;
|
||||||
switch (typeName){
|
switch (typeName){
|
||||||
case FerrisWheelAnimator.NAME:
|
case FerrisWheelAnimator.NAME:
|
||||||
@ -18,6 +22,8 @@ public final class HourAnimatorFactory {
|
|||||||
case FishAnimator.NAME:
|
case FishAnimator.NAME:
|
||||||
animator=new FishAnimator(hour>12?hour-12:hour);
|
animator=new FishAnimator(hour>12?hour-12:hour);
|
||||||
break;
|
break;
|
||||||
|
case HourVideoFragment.NAME:
|
||||||
|
return new HourVideoFragment(hour);
|
||||||
default:
|
default:
|
||||||
animator=new WindmillAnimator(hour>12?hour-12:hour);
|
animator=new WindmillAnimator(hour>12?hour-12:hour);
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,32 @@
|
|||||||
package clock.socoolby.com.clock.fragment.houranimator;
|
package clock.socoolby.com.clock.fragment.houranimator;
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.ClockApplication;
|
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.fragment.AbstractAnimatorFragment;
|
||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link Fragment} subclass.
|
* A simple {@link Fragment} subclass.
|
||||||
*/
|
*/
|
||||||
public class HourAnimatorFragment extends Fragment {
|
public class HourAnimatorFragment extends AbstractAnimatorFragment {
|
||||||
|
|
||||||
GlobalViewModel globalViewModel;
|
|
||||||
|
|
||||||
AnimatorView animatorView;
|
|
||||||
|
|
||||||
private int animatorDialy;
|
private int animatorDialy;
|
||||||
|
|
||||||
I_Animator hourAnimator;
|
|
||||||
|
|
||||||
Observer<Boolean> heartbeatObserver;
|
Observer<Boolean> heartbeatObserver;
|
||||||
|
|
||||||
public HourAnimatorFragment(I_Animator hourAnimator) {
|
public HourAnimatorFragment(I_Animator hourAnimator) {
|
||||||
this.hourAnimator=hourAnimator;
|
super(hourAnimator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
|
||||||
|
|
||||||
heartbeatObserver=new Observer<Boolean>() {
|
heartbeatObserver=new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean aBoolean) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
@ -62,11 +46,9 @@ public class HourAnimatorFragment extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view=inflater.inflate(R.layout.fragment_hour_animator, container, false);
|
View view=inflater.inflate(R.layout.fragment_hour_animator, container, false);
|
||||||
animatorView=view.findViewById(R.id.tv_hour_animatorview);
|
initAnimatorView(view.findViewById(R.id.tv_hour_animatorview));
|
||||||
bindViewModel();
|
bindViewModel();
|
||||||
Log.d("hourAnimator fragment","on create animator view width:"+animatorView.getWidth());
|
//Log.d("animator fragment","on create animator view width:"+animatorView.getWidth());
|
||||||
hourAnimator.init(getActivity(),animatorView);
|
|
||||||
animatorView.setAnimator(hourAnimator);
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +57,6 @@ public class HourAnimatorFragment extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
globalViewModel.getHeartbeat().observe(getActivity(),heartbeatObserver);
|
globalViewModel.getHeartbeat().observe(getActivity(),heartbeatObserver);
|
||||||
animatorView.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,12 +64,10 @@ public class HourAnimatorFragment extends Fragment {
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
globalViewModel.getHeartbeat().removeObserver(heartbeatObserver);
|
globalViewModel.getHeartbeat().removeObserver(heartbeatObserver);
|
||||||
animatorView.pause();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindViewModel(){
|
protected void bindViewModel(){
|
||||||
animatorDialy=globalViewModel.getTimeHourAnimatordialy().getValue();
|
animatorDialy=globalViewModel.getTimeHourAnimatordialy().getValue();
|
||||||
|
|
||||||
globalViewModel.getForegroundColor().observe(getActivity(), new Observer<Integer>() {
|
globalViewModel.getForegroundColor().observe(getActivity(), new Observer<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Integer integer) {
|
public void onChanged(Integer integer) {
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment.houranimator;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
|
import clock.socoolby.com.clock.R;
|
||||||
|
import clock.socoolby.com.clock.fragment.AbstractVideoFragment;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
|
|
||||||
|
public class HourVideoFragment extends AbstractVideoFragment {
|
||||||
|
|
||||||
|
public static final String NAME="video";
|
||||||
|
|
||||||
|
protected int hour;
|
||||||
|
|
||||||
|
protected GlobalViewModel globalViewModel;
|
||||||
|
|
||||||
|
public HourVideoFragment(int hour) {
|
||||||
|
super();
|
||||||
|
this.hour=hour;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
globalViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
View view= inflater.inflate(R.layout.fragment_hour_video,container,false);
|
||||||
|
initMediaPlay(view.findViewById(R.id.tv_hour_video));
|
||||||
|
loadForModel();
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadForModel(){
|
||||||
|
videoFileName= globalViewModel.getTimeHourVideoPath();
|
||||||
|
if(videoFileName==null||videoFileName.isEmpty()){
|
||||||
|
this.videoFileName="test.3gp";
|
||||||
|
this.fileLocal=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPlayCompletion() {
|
||||||
|
globalViewModel.setTimeHourAnimatorStarting(false);
|
||||||
|
//getActivity().onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,7 @@ import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
|||||||
import clock.socoolby.com.clock.utils.DialogUtils;
|
import clock.socoolby.com.clock.utils.DialogUtils;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.DefaultPointer;
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.DefaultPointer;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafPointer;
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafPointer;
|
||||||
@ -45,8 +46,11 @@ public class SimulateClockConfigFragment extends Fragment {
|
|||||||
|
|
||||||
ThemeUIManager themeUIManager;
|
ThemeUIManager themeUIManager;
|
||||||
|
|
||||||
|
|
||||||
SimulateViewModel simulateViewModel;
|
SimulateViewModel simulateViewModel;
|
||||||
GlobalViewModel globalViewModel;
|
GlobalViewModel globalViewModel;
|
||||||
|
ThemeUIViewModel themeUIViewModel;
|
||||||
|
|
||||||
@BindView(R.id.tv_simulate_color_pointer)
|
@BindView(R.id.tv_simulate_color_pointer)
|
||||||
Button tvSimulateColorPointer;
|
Button tvSimulateColorPointer;
|
||||||
@BindView(R.id.tv_simulate_color_scale)
|
@BindView(R.id.tv_simulate_color_scale)
|
||||||
@ -111,6 +115,7 @@ public class SimulateClockConfigFragment extends Fragment {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
|
||||||
simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class);
|
simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(SimulateViewModel.class);
|
||||||
|
themeUIViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(ThemeUIViewModel.class);
|
||||||
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code);
|
themeUIManager.saveTempThemeUI(ClockInterfaceTypeEnum.Simulate.code);
|
||||||
globalViewModel.setAppConfig(true);
|
globalViewModel.setAppConfig(true);
|
||||||
}
|
}
|
||||||
@ -129,7 +134,8 @@ public class SimulateClockConfigFragment extends Fragment {
|
|||||||
view.setOnLongClickListener(new View.OnLongClickListener() {
|
view.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
getFragmentManager().popBackStack();
|
//getFragmentManager().popBackStack();
|
||||||
|
themeUIViewModel.loadFromModel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -278,7 +284,6 @@ public class SimulateClockConfigFragment extends Fragment {
|
|||||||
String styleName = "simulate_style_" + order;
|
String styleName = "simulate_style_" + order;
|
||||||
try {
|
try {
|
||||||
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code, styleName)) {
|
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code, styleName)) {
|
||||||
|
|
||||||
themeUIManager.loadSimulateThemeFromDB(styleName);
|
themeUIManager.loadSimulateThemeFromDB(styleName);
|
||||||
reloadViewModel();
|
reloadViewModel();
|
||||||
} else {
|
} else {
|
||||||
@ -314,7 +319,8 @@ public class SimulateClockConfigFragment extends Fragment {
|
|||||||
|
|
||||||
private void reloadViewModel(){
|
private void reloadViewModel(){
|
||||||
globalViewModel.loadFromModel();
|
globalViewModel.loadFromModel();
|
||||||
simulateViewModel.loadFromModel();
|
//simulateViewModel.loadFromModel();
|
||||||
|
//loadForViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindViewModel() {
|
private void bindViewModel() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package clock.socoolby.com.clock.fragment;
|
package clock.socoolby.com.clock.fragment.system;
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@ -18,16 +18,23 @@ import android.widget.RadioGroup;
|
|||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import com.luck.picture.lib.PictureSelector;
|
||||||
|
import com.luck.picture.lib.config.PictureConfig;
|
||||||
|
import com.luck.picture.lib.config.PictureMimeType;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.AboutActivity;
|
import clock.socoolby.com.clock.AboutActivity;
|
||||||
import clock.socoolby.com.clock.ActivateAdmin;
|
import clock.socoolby.com.clock.ActivateAdmin;
|
||||||
import clock.socoolby.com.clock.ClockApplication;
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
import clock.socoolby.com.clock.Constants;
|
import clock.socoolby.com.clock.Constants;
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
|
import clock.socoolby.com.clock.fragment.houranimator.HourAnimatorFactory;
|
||||||
|
import clock.socoolby.com.clock.fragment.houranimator.HourVideoFragment;
|
||||||
import clock.socoolby.com.clock.model.DateModel;
|
import clock.socoolby.com.clock.model.DateModel;
|
||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
import clock.socoolby.com.clock.utils.FuncUnit;
|
import clock.socoolby.com.clock.utils.FuncUnit;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
|
||||||
import clock.socoolby.com.clock.widget.wheelview.WheelView;
|
import clock.socoolby.com.clock.widget.wheelview.WheelView;
|
||||||
import clock.socoolby.com.clock.widget.wheelview.adapters.ArrayWheelAdapter;
|
import clock.socoolby.com.clock.widget.wheelview.adapters.ArrayWheelAdapter;
|
||||||
|
|
||||||
@ -53,6 +60,16 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
Button btn_about;
|
Button btn_about;
|
||||||
Button btn_save;
|
Button btn_save;
|
||||||
|
|
||||||
|
RadioGroup rg_clock_hour_animator_group;
|
||||||
|
RadioButton rg_clock_hour_animator_null;
|
||||||
|
RadioButton rg_clock_hour_animator_flash;
|
||||||
|
RadioButton rg_clock_hour_video;
|
||||||
|
|
||||||
|
Button btn_clock_hour_video;
|
||||||
|
|
||||||
|
|
||||||
|
CheckBox cb_boot_start;
|
||||||
|
|
||||||
private SharePerferenceModel model;
|
private SharePerferenceModel model;
|
||||||
|
|
||||||
public SystemAppConfigFragment(SharePerferenceModel model) {
|
public SystemAppConfigFragment(SharePerferenceModel model) {
|
||||||
@ -82,8 +99,32 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
et_city =themeRootView.findViewById(R.id.et_city);
|
et_city =themeRootView.findViewById(R.id.et_city);
|
||||||
et_description = themeRootView.findViewById(R.id.et_description);
|
et_description = themeRootView.findViewById(R.id.et_description);
|
||||||
|
|
||||||
|
rg_clock_hour_animator_group=themeRootView.findViewById(R.id.rg_clock_hour_animator_group);
|
||||||
|
rg_clock_hour_animator_null=themeRootView.findViewById(R.id.rg_clock_hour_animator_null);
|
||||||
|
rg_clock_hour_animator_flash=themeRootView.findViewById(R.id.rg_clock_hour_animator_flash);
|
||||||
|
rg_clock_hour_video=themeRootView.findViewById(R.id.rg_clock_hour_video);
|
||||||
|
btn_clock_hour_video=themeRootView.findViewById(R.id.btn_clock_hour_video);
|
||||||
|
|
||||||
|
|
||||||
|
cb_boot_start=themeRootView.findViewById(R.id.cb_boot_start);
|
||||||
|
|
||||||
cb_tick = themeRootView.findViewById(R.id.cb_tick);
|
cb_tick = themeRootView.findViewById(R.id.cb_tick);
|
||||||
|
cb_trigger_screen = themeRootView.findViewById(R.id.cb_trigger_screen);
|
||||||
|
btn_uninstall = themeRootView.findViewById(R.id.btn_uninstall);
|
||||||
|
btn_about = themeRootView.findViewById(R.id.btn_about);
|
||||||
|
btn_save= themeRootView.findViewById(R.id.btn_save);
|
||||||
|
|
||||||
|
loadDataFromModel();
|
||||||
|
|
||||||
|
btn_about.setOnClickListener(this);
|
||||||
|
btn_uninstall.setOnClickListener(this);
|
||||||
|
btn_save.setOnClickListener(this);
|
||||||
|
cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
model.setTriggerScreen(isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cb_tick.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
cb_tick.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -92,37 +133,39 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cb_trigger_screen = themeRootView.findViewById(R.id.cb_trigger_screen);
|
cb_boot_start.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
|
||||||
cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
model.setTriggerScreen(isChecked);
|
model.setBootStart(isChecked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btn_uninstall = themeRootView.findViewById(R.id.btn_uninstall);
|
rg_clock_hour_animator_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
btn_uninstall.setOnClickListener(this);
|
@Override
|
||||||
btn_about = themeRootView.findViewById(R.id.btn_about);
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
btn_about.setOnClickListener(this);
|
btn_clock_hour_video.setVisibility(View.GONE);
|
||||||
|
switch (checkedId){
|
||||||
|
case R.id.rg_clock_hour_animator_null:
|
||||||
|
model.setTimeHourAlterTypeName(HourAnimatorFactory.DEFAULT);
|
||||||
|
break;
|
||||||
|
case R.id.rg_clock_hour_animator_flash:
|
||||||
|
model.setTimeHourAlterTypeName(FishAnimator.NAME);
|
||||||
|
break;
|
||||||
|
case R.id.rg_clock_hour_video:
|
||||||
|
model.setTimeHourAlterTypeName(HourVideoFragment.NAME);
|
||||||
|
btn_clock_hour_video.setVisibility(View.VISIBLE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
btn_save= themeRootView.findViewById(R.id.btn_save);
|
btn_clock_hour_video.setOnClickListener(this);
|
||||||
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<String> timeAdpater = new ArrayWheelAdapter<String>(getContext(), listTime);
|
ArrayWheelAdapter<String> timeAdpater = new ArrayWheelAdapter<String>(getContext(), listTime);
|
||||||
weel_startTime.setViewAdapter(timeAdpater);
|
weel_startTime.setViewAdapter(timeAdpater);
|
||||||
ArrayWheelAdapter<String> durationAdapter = new ArrayWheelAdapter<String>(getContext(), listTime);
|
ArrayWheelAdapter<String> durationAdapter = new ArrayWheelAdapter<String>(getContext(), listTime);
|
||||||
weel_stopTime.setViewAdapter(durationAdapter);
|
weel_stopTime.setViewAdapter(durationAdapter);
|
||||||
|
|
||||||
loadDataFromModel();
|
|
||||||
|
|
||||||
rg_taking_clock.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
rg_taking_clock.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(RadioGroup radioGroup, int index) {
|
public void onCheckedChanged(RadioGroup radioGroup, int index) {
|
||||||
@ -143,7 +186,6 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return themeRootView;
|
return themeRootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +196,14 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadDataFromModel() {
|
private void loadDataFromModel() {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
int startTimeIndex = indexOfTimeString(String.format("%02d:%02d", model.getStartHourPowerTime().getHour(), model.getStartHourPowerTime().getMinute()));
|
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()));
|
int stopTimeIndex = indexOfTimeString(String.format("%02d:%02d", model.getStopHourPowerTime().getHour(), model.getStopHourPowerTime().getMinute()));
|
||||||
weel_startTime.setCurrentItem(startTimeIndex);
|
weel_startTime.setCurrentItem(startTimeIndex);
|
||||||
@ -176,6 +226,23 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
}
|
}
|
||||||
et_city.setText(model.getCity());
|
et_city.setText(model.getCity());
|
||||||
et_description.setText(model.getDescription());
|
et_description.setText(model.getDescription());
|
||||||
|
|
||||||
|
cb_boot_start.setChecked(model.isBootStart());
|
||||||
|
|
||||||
|
btn_clock_hour_video.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
switch (model.getTimeHourAlterTypeName()){
|
||||||
|
case FishAnimator.NAME:
|
||||||
|
rg_clock_hour_animator_flash.setChecked(true);
|
||||||
|
break;
|
||||||
|
case HourVideoFragment.NAME:
|
||||||
|
btn_clock_hour_video.setVisibility(View.VISIBLE);
|
||||||
|
rg_clock_hour_video.setChecked(true);
|
||||||
|
btn_clock_hour_video.setText(model.getTimeHourVideoPath());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rg_clock_hour_animator_null.setChecked(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveToModel() {
|
private void saveToModel() {
|
||||||
@ -230,6 +297,18 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
|
|||||||
saveToModel();
|
saveToModel();
|
||||||
getFragmentManager().popBackStack();
|
getFragmentManager().popBackStack();
|
||||||
break;
|
break;
|
||||||
|
case R.id.btn_clock_hour_video:
|
||||||
|
configHourVideo();
|
||||||
|
btn_clock_hour_video.setText(model.getTimeHourVideoPath());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void configHourVideo() {
|
||||||
|
PictureSelector.create(getActivity())
|
||||||
|
.openGallery(PictureMimeType.ofVideo())
|
||||||
|
.isCamera(false)
|
||||||
|
.imageSpanCount(4)
|
||||||
|
.forResult(PictureConfig.TYPE_VIDEO);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package clock.socoolby.com.clock.fragment;
|
package clock.socoolby.com.clock.fragment.theme;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -23,7 +23,6 @@ import clock.socoolby.com.clock.ClockApplication;
|
|||||||
import clock.socoolby.com.clock.FamousQuotesManager;
|
import clock.socoolby.com.clock.FamousQuotesManager;
|
||||||
import clock.socoolby.com.clock.MainActivity;
|
import clock.socoolby.com.clock.MainActivity;
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
import clock.socoolby.com.clock.SettingActivity;
|
|
||||||
import clock.socoolby.com.clock.model.DateModel;
|
import clock.socoolby.com.clock.model.DateModel;
|
||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
import clock.socoolby.com.clock.pop.CalendarPopup;
|
import clock.socoolby.com.clock.pop.CalendarPopup;
|
||||||
@ -32,7 +31,6 @@ import clock.socoolby.com.clock.pop.TimeSetupMinPopup;
|
|||||||
import clock.socoolby.com.clock.pop.TimeSetupPopup;
|
import clock.socoolby.com.clock.pop.TimeSetupPopup;
|
||||||
import clock.socoolby.com.clock.pop.WeatherPopup;
|
import clock.socoolby.com.clock.pop.WeatherPopup;
|
||||||
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
||||||
import clock.socoolby.com.clock.state.ClockStateMachine;
|
|
||||||
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
||||||
import clock.socoolby.com.clock.state.ClockTimeTypeEnum;
|
import clock.socoolby.com.clock.state.ClockTimeTypeEnum;
|
||||||
import clock.socoolby.com.clock.viewmodel.AlterViewModel;
|
import clock.socoolby.com.clock.viewmodel.AlterViewModel;
|
||||||
@ -68,7 +66,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
private ImageButton tv_foreground_color2;
|
private ImageButton tv_foreground_color2;
|
||||||
|
|
||||||
private TextView tv_hand_time;
|
private TextView tv_hand_time;
|
||||||
//private boolean hand_time_visable=true;
|
|
||||||
private ImageButton tv_screen_lock;
|
private ImageButton tv_screen_lock;
|
||||||
|
|
||||||
ColorPickerPop colorPickerDialog;
|
ColorPickerPop colorPickerDialog;
|
||||||
@ -142,8 +140,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
if (isScreenLock())
|
if (isScreenLock())
|
||||||
return true;
|
return true;
|
||||||
model.setHourSystem12(!model.isHourSystem12());
|
globalViewModel.setHourSystem12(!model.isHourSystem12());
|
||||||
globalViewModel.setHourSystem12(model.isHourSystem12());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -333,6 +330,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean handUpAbla) {
|
public void onChanged(Boolean handUpAbla) {
|
||||||
if(handUpAbla) {
|
if(handUpAbla) {
|
||||||
|
globalViewModel.getHandUpTime().setValue(model.getHandUpTime());
|
||||||
tv_handup.setColorFilter(globalViewModel.getForegroundColor().getValue());
|
tv_handup.setColorFilter(globalViewModel.getForegroundColor().getValue());
|
||||||
tv_hand_time.setVisibility(View.VISIBLE);
|
tv_hand_time.setVisibility(View.VISIBLE);
|
||||||
}else{
|
}else{
|
||||||
@ -398,22 +396,15 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
return globalViewModel.getHandUpAble().getValue();
|
return globalViewModel.getHandUpAble().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateHourSystem() {
|
|
||||||
if (model.isHourSystem12())
|
|
||||||
tv_hours_system.setVisibility(View.VISIBLE);
|
|
||||||
else
|
|
||||||
tv_hours_system.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeSetupPopup handUpTimePopup1;
|
//TimeSetupPopup handUpTimePopup1;
|
||||||
|
|
||||||
private void setupHandUpTime() {
|
private void setupHandUpTime() {
|
||||||
int saveHandUpTime=model.getHandUpTime();
|
int saveHandUpTime=model.getHandUpTime();
|
||||||
int hour=0;
|
int hour=0;
|
||||||
int minute=0;
|
int minute=0;
|
||||||
if(handUpTimePopup1==null) {
|
TimeSetupPopup handUpTimePopup1 = new TimeSetupPopup();
|
||||||
handUpTimePopup1 = new TimeSetupPopup(mainActivity);
|
handUpTimePopup1.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
|
||||||
handUpTimePopup1.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(int hour, int minute, Uri uri, String s, String hundUpStyle) {
|
public void onChanged(int hour, int minute, Uri uri, String s, String hundUpStyle) {
|
||||||
if (hour == 0 && minute == 0) {
|
if (hour == 0 && minute == 0) {
|
||||||
@ -429,13 +420,13 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if(saveHandUpTime>0){
|
if(saveHandUpTime>0){
|
||||||
hour=saveHandUpTime/60;
|
hour=saveHandUpTime/60;
|
||||||
minute=saveHandUpTime-hour*60;
|
minute=saveHandUpTime-hour*60;
|
||||||
}
|
}
|
||||||
|
Log.d(TAG, "switch HandUpTime:" + saveHandUpTime+"\thour:"+hour+"\tminute:"+minute);
|
||||||
handUpTimePopup1.init(hour,minute,globalViewModel.getHandUpTypeName().getValue(),alterViewModel.getHandUpMusic().getValue(),alterViewModel.getHandUpMusicName().getValue());
|
handUpTimePopup1.init(hour,minute,globalViewModel.getHandUpTypeName().getValue(),alterViewModel.getHandUpMusic().getValue(),alterViewModel.getHandUpMusicName().getValue());
|
||||||
handUpTimePopup1.showNow(getFragmentManager(),"test");
|
handUpTimePopup1.showNow(getFragmentManager(),null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTempHandUpTime() {
|
private void setupTempHandUpTime() {
|
||||||
@ -489,6 +480,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
}else{
|
}else{
|
||||||
handUpAbla=!handUpAbla;
|
handUpAbla=!handUpAbla;
|
||||||
globalViewModel.setHandUpAble(handUpAbla);
|
globalViewModel.setHandUpAble(handUpAbla);
|
||||||
|
themeUIViewModel.setDescription(FamousQuotesManager.roundAutoQuotes());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.tv_hand_time:
|
case R.id.tv_hand_time:
|
||||||
@ -660,13 +652,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
return themeUIViewModel.getClockUITypeEnum().getValue()==ClockThemeUITypeEnum.FULLSCREEN;
|
return themeUIViewModel.getClockUITypeEnum().getValue()==ClockThemeUITypeEnum.FULLSCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configThemeUITypeWithNoFullScreen(){
|
|
||||||
if(globalViewModel.getClockInterfaceTypeEnum().getValue()==ClockInterfaceTypeEnum.Digit)
|
|
||||||
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.NORMAL);
|
|
||||||
else
|
|
||||||
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.SETTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void screenLock(boolean locked) {
|
public void screenLock(boolean locked) {
|
||||||
tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);
|
tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);
|
@ -1,4 +1,4 @@
|
|||||||
package clock.socoolby.com.clock.fragment;
|
package clock.socoolby.com.clock.fragment.theme;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
|
|
||||||
@ -12,7 +12,6 @@ public class ThemeUIDefaultFragment extends AbstractThemeUIFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void changeThemeTypeCheck() {
|
void changeThemeTypeCheck() {
|
||||||
themeUIViewModel.getThemeName().setValue(ThemeUISampleFragment.THEME_NAME);
|
themeUIViewModel.setThemeName(ThemeUISampleFragment.THEME_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package clock.socoolby.com.clock.fragment;
|
package clock.socoolby.com.clock.fragment.theme;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
|
|
||||||
@ -12,6 +12,6 @@ public class ThemeUISampleFragment extends AbstractThemeUIFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void changeThemeTypeCheck() {
|
void changeThemeTypeCheck() {
|
||||||
themeUIViewModel.getThemeName().setValue(ThemeUIDefaultFragment.THEME_NAME);
|
themeUIViewModel.setThemeName(ThemeUIDefaultFragment.THEME_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,10 @@ public class DigitPerferenceModel {
|
|||||||
protected final static String KEY_FONT_NAME = "key_font_name";
|
protected final static String KEY_FONT_NAME = "key_font_name";
|
||||||
protected String fontName="default";
|
protected String fontName="default";
|
||||||
|
|
||||||
|
protected final static String KEY_FONT_STYLE_SIZE = "key_font_style_size";
|
||||||
|
protected Integer fontStyleSize =100;
|
||||||
|
|
||||||
|
|
||||||
protected final static String KEY_IS_LINEARGRADIENT_ABLE="key_time_text_is_linearGradient_able";
|
protected final static String KEY_IS_LINEARGRADIENT_ABLE="key_time_text_is_linearGradient_able";
|
||||||
protected boolean linearGradientAble = false;
|
protected boolean linearGradientAble = false;
|
||||||
|
|
||||||
@ -43,7 +47,7 @@ public class DigitPerferenceModel {
|
|||||||
protected Integer charBackgroundBorderDividerStrokeWidth=10;
|
protected Integer charBackgroundBorderDividerStrokeWidth=10;
|
||||||
|
|
||||||
protected final static String KEY_TIME_TEXT_BASELINE_DOWN= "key_time_text_baseline_down";
|
protected final static String KEY_TIME_TEXT_BASELINE_DOWN= "key_time_text_baseline_down";
|
||||||
protected Integer baseLineDown=0;
|
protected Integer baseLineDown=13;
|
||||||
|
|
||||||
protected final static String KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE= "key_time_text_subscript_font_scale";
|
protected final static String KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE= "key_time_text_subscript_font_scale";
|
||||||
protected Integer subscriptFontScale=40;
|
protected Integer subscriptFontScale=40;
|
||||||
@ -63,11 +67,12 @@ public class DigitPerferenceModel {
|
|||||||
shadowType=jsonObject.optInt(KEY_TIME_TEXT_SHADOW_TYPE,0);
|
shadowType=jsonObject.optInt(KEY_TIME_TEXT_SHADOW_TYPE,0);
|
||||||
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
|
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
|
||||||
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
|
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
|
||||||
|
fontStyleSize =jsonObject.optInt(KEY_FONT_STYLE_SIZE,100);
|
||||||
displaySecond = jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND,false);
|
displaySecond = jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND,false);
|
||||||
timeTextSecondSubscript=jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,true);
|
timeTextSecondSubscript=jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,true);
|
||||||
charBackgroundBorder=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER,false);
|
charBackgroundBorder=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER,false);
|
||||||
charBackgroundBorderColor=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_COLOR, Color.BLACK);
|
charBackgroundBorderColor=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_COLOR, Color.BLACK);
|
||||||
baseLineDown=jsonObject.optInt(KEY_TIME_TEXT_BASELINE_DOWN,0);
|
baseLineDown=jsonObject.optInt(KEY_TIME_TEXT_BASELINE_DOWN,13);
|
||||||
charBackgroundBorderDividerColor=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_COLOR, Color.BLACK);
|
charBackgroundBorderDividerColor=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_COLOR, Color.BLACK);
|
||||||
charBackgroundBorderDividerStrokeWidth=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_STROKE_WIDTH, 10);
|
charBackgroundBorderDividerStrokeWidth=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_STROKE_WIDTH, 10);
|
||||||
subscriptFontScale=jsonObject.optInt(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE, 40);
|
subscriptFontScale=jsonObject.optInt(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE, 40);
|
||||||
@ -83,6 +88,7 @@ public class DigitPerferenceModel {
|
|||||||
jsonObject.put(KEY_TIME_TEXT_SHADOW_TYPE,shadowType);
|
jsonObject.put(KEY_TIME_TEXT_SHADOW_TYPE,shadowType);
|
||||||
jsonObject.put(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,timeTextCharAnimatorType);
|
jsonObject.put(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,timeTextCharAnimatorType);
|
||||||
jsonObject.put(KEY_FONT_NAME,fontName);
|
jsonObject.put(KEY_FONT_NAME,fontName);
|
||||||
|
jsonObject.put(KEY_FONT_STYLE_SIZE, fontStyleSize);
|
||||||
jsonObject.put(KEY_IS_DISPLAY_SECOND, displaySecond);
|
jsonObject.put(KEY_IS_DISPLAY_SECOND, displaySecond);
|
||||||
jsonObject.put(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,timeTextSecondSubscript);
|
jsonObject.put(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,timeTextSecondSubscript);
|
||||||
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER,charBackgroundBorder);
|
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER,charBackgroundBorder);
|
||||||
@ -245,4 +251,12 @@ public class DigitPerferenceModel {
|
|||||||
public void setCharBackgroundBorderWithDoubble(boolean charBackgroundBorderWithDoubble) {
|
public void setCharBackgroundBorderWithDoubble(boolean charBackgroundBorderWithDoubble) {
|
||||||
this.charBackgroundBorderWithDoubble = charBackgroundBorderWithDoubble;
|
this.charBackgroundBorderWithDoubble = charBackgroundBorderWithDoubble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getFontStyleSize() {
|
||||||
|
return fontStyleSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFontStyleSize(Integer fontStyleSize) {
|
||||||
|
this.fontStyleSize = fontStyleSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.ClockApplication;
|
|
||||||
import clock.socoolby.com.clock.Constants;
|
import clock.socoolby.com.clock.Constants;
|
||||||
import clock.socoolby.com.clock.R;
|
|
||||||
import clock.socoolby.com.clock.utils.FileUtils;
|
import clock.socoolby.com.clock.utils.FileUtils;
|
||||||
|
|
||||||
public class SharePerferenceModel implements Serializable {
|
public class SharePerferenceModel implements Serializable {
|
||||||
@ -21,6 +19,9 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
|
|
||||||
public static final int DEFAULT_COLOR=Color.rgb(255, 255, 255);
|
public static final int DEFAULT_COLOR=Color.rgb(255, 255, 255);
|
||||||
|
|
||||||
|
protected boolean firstStart = true;
|
||||||
|
protected final static String KEY_FIRST_START = "key_first_start";
|
||||||
|
|
||||||
protected int typeHourPower = Constants.TALKING_HALF_AN_HOUR;
|
protected int typeHourPower = Constants.TALKING_HALF_AN_HOUR;
|
||||||
protected final static String KEY_TYPE_HOUR_POWER = "key_type_hour_power";
|
protected final static String KEY_TYPE_HOUR_POWER = "key_type_hour_power";
|
||||||
|
|
||||||
@ -44,6 +45,10 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
protected final static String KEY_TIME_HOUR_ALTER_DIALY= "key_time_hour_alter_dialy";
|
protected final static String KEY_TIME_HOUR_ALTER_DIALY= "key_time_hour_alter_dialy";
|
||||||
protected Integer timeHourAlterDialy=20;
|
protected Integer timeHourAlterDialy=20;
|
||||||
|
|
||||||
|
protected final static String KEY_TIME_HOUR_VIDEO_PATH= "key_time_hour_video_path";
|
||||||
|
protected String timeHourVideoPath="";
|
||||||
|
|
||||||
|
|
||||||
protected final static String KEY_CITY = "key_city";
|
protected final static String KEY_CITY = "key_city";
|
||||||
protected String mCity="jinhua";
|
protected String mCity="jinhua";
|
||||||
|
|
||||||
@ -76,6 +81,7 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
protected final static String KEY_BACKGROUND_IMAGE="key_background_image";
|
protected final static String KEY_BACKGROUND_IMAGE="key_background_image";
|
||||||
protected String backgroundImage="";
|
protected String backgroundImage="";
|
||||||
|
|
||||||
|
|
||||||
protected final static String KEY_BACKGROUND_ANIMATOR="key_background_animator";
|
protected final static String KEY_BACKGROUND_ANIMATOR="key_background_animator";
|
||||||
protected String backgroundAnimatorName="";
|
protected String backgroundAnimatorName="";
|
||||||
|
|
||||||
@ -207,6 +213,8 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
if(mDescription.isEmpty())
|
||||||
|
return Constants.APP_MEMO;
|
||||||
return mDescription;
|
return mDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,12 +226,13 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
protected void fromJsonString(String jsonString) {
|
protected void fromJsonString(String jsonString) {
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(jsonString);
|
JSONObject jsonObject = new JSONObject(jsonString);
|
||||||
|
firstStart=jsonObject.optBoolean(KEY_FIRST_START,true);
|
||||||
typeHourPower = jsonObject.getInt(KEY_TYPE_HOUR_POWER);
|
typeHourPower = jsonObject.getInt(KEY_TYPE_HOUR_POWER);
|
||||||
|
|
||||||
tickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND);
|
tickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND);
|
||||||
triggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,true);
|
triggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,true);
|
||||||
mCity = jsonObject.optString(KEY_CITY,"jinhua");
|
mCity = jsonObject.optString(KEY_CITY,"jinhua");
|
||||||
mDescription = jsonObject.optString(KEY_DESCRPTION, ClockApplication.getContext().getResources().getString(R.string.always_zuo_never_die));
|
mDescription = jsonObject.optString(KEY_DESCRPTION, "");
|
||||||
startHourPowerTime = new DateModel();
|
startHourPowerTime = new DateModel();
|
||||||
startHourPowerTime.setDataString(jsonObject.getString(KEY_START_POWER));
|
startHourPowerTime.setDataString(jsonObject.getString(KEY_START_POWER));
|
||||||
stopHourPowerTime = new DateModel();
|
stopHourPowerTime = new DateModel();
|
||||||
@ -232,6 +241,8 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
timeHourAlterTypeName=jsonObject.optString(KEY_TIME_HOUR_ALTER_TYPE_NAME,"default");
|
timeHourAlterTypeName=jsonObject.optString(KEY_TIME_HOUR_ALTER_TYPE_NAME,"default");
|
||||||
timeHourAlterDialy=jsonObject.optInt(KEY_TIME_HOUR_ALTER_DIALY,20);
|
timeHourAlterDialy=jsonObject.optInt(KEY_TIME_HOUR_ALTER_DIALY,20);
|
||||||
|
|
||||||
|
timeHourVideoPath=jsonObject.optString(KEY_TIME_HOUR_VIDEO_PATH,"");
|
||||||
|
|
||||||
handUpAble=jsonObject.optBoolean(KEY_IS_HANDUP_ABLE,false);
|
handUpAble=jsonObject.optBoolean(KEY_IS_HANDUP_ABLE,false);
|
||||||
handUpTime=jsonObject.optInt(KEY_HANDUP_TIME,-1);
|
handUpTime=jsonObject.optInt(KEY_HANDUP_TIME,-1);
|
||||||
handUpMusic=jsonObject.optString(KEY_HANDUP_MUSIC,"");
|
handUpMusic=jsonObject.optString(KEY_HANDUP_MUSIC,"");
|
||||||
@ -267,6 +278,7 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
protected String toJsonString() {
|
protected String toJsonString() {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
try {
|
try {
|
||||||
|
jsonObject.put(KEY_FIRST_START,firstStart);
|
||||||
jsonObject.put(KEY_TYPE_HOUR_POWER, typeHourPower);
|
jsonObject.put(KEY_TYPE_HOUR_POWER, typeHourPower);
|
||||||
|
|
||||||
jsonObject.put(KEY_IS_TICK_SOUND, tickSound);
|
jsonObject.put(KEY_IS_TICK_SOUND, tickSound);
|
||||||
@ -295,6 +307,7 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
|
|
||||||
jsonObject.put(KEY_TIME_HOUR_ALTER_TYPE_NAME,timeHourAlterTypeName);
|
jsonObject.put(KEY_TIME_HOUR_ALTER_TYPE_NAME,timeHourAlterTypeName);
|
||||||
jsonObject.put(KEY_TIME_HOUR_ALTER_DIALY,timeHourAlterDialy);
|
jsonObject.put(KEY_TIME_HOUR_ALTER_DIALY,timeHourAlterDialy);
|
||||||
|
jsonObject.put(KEY_TIME_HOUR_VIDEO_PATH,timeHourVideoPath);
|
||||||
|
|
||||||
digitPerferenceModel.toJsonString(jsonObject);
|
digitPerferenceModel.toJsonString(jsonObject);
|
||||||
|
|
||||||
@ -518,6 +531,7 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
|
|
||||||
public void setTimeHourAlterTypeName(String timeHourAlterTypeName) {
|
public void setTimeHourAlterTypeName(String timeHourAlterTypeName) {
|
||||||
this.timeHourAlterTypeName = timeHourAlterTypeName;
|
this.timeHourAlterTypeName = timeHourAlterTypeName;
|
||||||
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getTimeHourAlterDialy() {
|
public Integer getTimeHourAlterDialy() {
|
||||||
@ -529,6 +543,14 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
dirtySave();
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTimeHourVideoPath() {
|
||||||
|
return timeHourVideoPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeHourVideoPath(String timeHourVideoPath) {
|
||||||
|
this.timeHourVideoPath = timeHourVideoPath;
|
||||||
|
}
|
||||||
|
|
||||||
//digit
|
//digit
|
||||||
|
|
||||||
public Integer[] getTimeColorsArray() {
|
public Integer[] getTimeColorsArray() {
|
||||||
@ -786,4 +808,21 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
digitPerferenceModel.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble);
|
digitPerferenceModel.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble);
|
||||||
dirtySave();
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getFontStyleSize() {
|
||||||
|
return digitPerferenceModel.getFontStyleSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFontStyleSize(Integer fontStyleSize) {
|
||||||
|
digitPerferenceModel.setFontStyleSize(fontStyleSize);
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFirstStart() {
|
||||||
|
return firstStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstStart(boolean firstStart) {
|
||||||
|
this.firstStart = firstStart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,10 @@ public class CalendarPopup extends DialogFragment implements CalendarView.OnCale
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initTestData() {
|
||||||
int year = mCalendarView.getCurYear();
|
int year = mCalendarView.getCurYear();
|
||||||
int month = mCalendarView.getCurMonth();
|
int month = mCalendarView.getCurMonth();
|
||||||
|
|
||||||
|
@ -60,20 +60,16 @@ public class TimeSetupMinPopup extends BasePopupWindow {
|
|||||||
|
|
||||||
mHourSeekbar.setCurProcess(hour);
|
mHourSeekbar.setCurProcess(hour);
|
||||||
mMinuteSeekbar.setCurProcess(minute);
|
mMinuteSeekbar.setCurProcess(minute);
|
||||||
mMinuteSeekbar.setMaxProcess(60);
|
|
||||||
mHourSeekbar.setMaxProcess(120);
|
|
||||||
|
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(int hour, int minute) {
|
public void init(int hour, int minute) {
|
||||||
|
this.hour=hour;
|
||||||
|
this.minute=minute;
|
||||||
if(mHourSeekbar!=null) {
|
if(mHourSeekbar!=null) {
|
||||||
mHourSeekbar.setCurProcess(hour);
|
mHourSeekbar.setCurProcess(hour);
|
||||||
mMinuteSeekbar.setCurProcess(minute);
|
mMinuteSeekbar.setCurProcess(minute);
|
||||||
}else{
|
|
||||||
this.hour=hour;
|
|
||||||
this.minute=minute;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package clock.socoolby.com.clock.pop;
|
package clock.socoolby.com.clock.pop;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -28,6 +29,9 @@ import xyz.aprildown.ultimatemusicpicker.MusicPickerListener;
|
|||||||
import xyz.aprildown.ultimatemusicpicker.UltimateMusicPicker;
|
import xyz.aprildown.ultimatemusicpicker.UltimateMusicPicker;
|
||||||
|
|
||||||
public class TimeSetupPopup extends DialogFragment implements MusicPickerListener {
|
public class TimeSetupPopup extends DialogFragment implements MusicPickerListener {
|
||||||
|
|
||||||
|
public static final String TAG=TimeSetupPopup.class.getName();
|
||||||
|
|
||||||
private CircleSeekBar mHourSeekbar;
|
private CircleSeekBar mHourSeekbar;
|
||||||
|
|
||||||
private CircleSeekBar mMinuteSeekbar;
|
private CircleSeekBar mMinuteSeekbar;
|
||||||
@ -42,8 +46,6 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
|
|||||||
|
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
MainActivity activity;
|
|
||||||
|
|
||||||
Button musicSelect;
|
Button musicSelect;
|
||||||
|
|
||||||
ImageView back;
|
ImageView back;
|
||||||
@ -59,10 +61,6 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
|
|||||||
ImageView ok;
|
ImageView ok;
|
||||||
|
|
||||||
|
|
||||||
public TimeSetupPopup(MainActivity activity) {
|
|
||||||
this.activity=activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
@ -71,6 +69,8 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
|
|||||||
mMinuteSeekbar = (CircleSeekBar) content.findViewById(R.id.seek_minute);
|
mMinuteSeekbar = (CircleSeekBar) content.findViewById(R.id.seek_minute);
|
||||||
mTextView = (TextView)content.findViewById(R.id.seek_time);
|
mTextView = (TextView)content.findViewById(R.id.seek_time);
|
||||||
|
|
||||||
|
mTextView.setTextColor(Color.YELLOW);
|
||||||
|
|
||||||
musicSelect=content.findViewById(R.id.tv_handup_time_select_Music);
|
musicSelect=content.findViewById(R.id.tv_handup_time_select_Music);
|
||||||
|
|
||||||
back=content.findViewById(R.id.tv_handup_time_back);
|
back=content.findViewById(R.id.tv_handup_time_back);
|
||||||
@ -103,37 +103,25 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
|
|||||||
mHourSeekbar.setOnSeekBarChangeListener(new CircleSeekBar.OnSeekBarChangeListener() {
|
mHourSeekbar.setOnSeekBarChangeListener(new CircleSeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(CircleSeekBar seekbar, int curValue) {
|
public void onChanged(CircleSeekBar seekbar, int curValue) {
|
||||||
changeText(curValue, mMinuteSeekbar.getCurProcess());
|
hour=curValue;
|
||||||
|
changeText(hour,minute);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mHourSeekbar.fillInside();
|
|
||||||
|
|
||||||
mMinuteSeekbar.setOnSeekBarChangeListener(new CircleSeekBar.OnSeekBarChangeListener() {
|
mMinuteSeekbar.setOnSeekBarChangeListener(new CircleSeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(CircleSeekBar seekbar, int curValue) {
|
public void onChanged(CircleSeekBar seekbar, int curValue) {
|
||||||
changeText(mHourSeekbar.getCurProcess(), curValue);
|
minute=curValue;
|
||||||
|
changeText(hour,minute);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mHourSeekbar.setCurProcess(hour);
|
|
||||||
mMinuteSeekbar.setCurProcess(minute);
|
|
||||||
mMinuteSeekbar.setMaxProcess(60);
|
|
||||||
mHourSeekbar.setMaxProcess(120);
|
|
||||||
|
|
||||||
handUpAlterTypeGroup=content.findViewById(R.id.tv_huad_up_style_group);
|
handUpAlterTypeGroup=content.findViewById(R.id.tv_huad_up_style_group);
|
||||||
|
|
||||||
handUpAlterTypeDefault=content.findViewById(R.id.tv_huad_up_style_default);
|
handUpAlterTypeDefault=content.findViewById(R.id.tv_huad_up_style_default);
|
||||||
|
|
||||||
handUpAlterTypeSelect=content.findViewById(R.id.tv_huad_up_style_select);
|
handUpAlterTypeSelect=content.findViewById(R.id.tv_huad_up_style_select);
|
||||||
|
|
||||||
switch (handUpAlterType){
|
|
||||||
case HandUpSelect123Fragment.NAME:
|
|
||||||
handUpAlterTypeSelect.setChecked(true);
|
|
||||||
break;
|
|
||||||
case HandUpDefaultFragment.NAME:
|
|
||||||
handUpAlterTypeDefault.setChecked(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
handUpAlterTypeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
handUpAlterTypeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
@ -147,11 +135,27 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
musicSelect.setText(s);
|
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Log.d(TAG,"onResume hour:"+hour+"\tminute:"+minute);
|
||||||
|
mHourSeekbar.fillInside();
|
||||||
|
mHourSeekbar.setCurProcess(hour);
|
||||||
|
mMinuteSeekbar.setCurProcess(minute);
|
||||||
|
//changeText(hour,minute);
|
||||||
|
musicSelect.setText(s);
|
||||||
|
switch (handUpAlterType){
|
||||||
|
case HandUpSelect123Fragment.NAME:
|
||||||
|
handUpAlterTypeSelect.setChecked(true);
|
||||||
|
break;
|
||||||
|
case HandUpDefaultFragment.NAME:
|
||||||
|
handUpAlterTypeDefault.setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
@ -163,22 +167,14 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
|
|||||||
|
|
||||||
|
|
||||||
public void init(int hour, int minute,String handUpAlterType,Uri musicUri,String musicName) {
|
public void init(int hour, int minute,String handUpAlterType,Uri musicUri,String musicName) {
|
||||||
if(mHourSeekbar!=null) {
|
this.hour=hour;
|
||||||
mHourSeekbar.setCurProcess(hour);
|
this.minute=minute;
|
||||||
mMinuteSeekbar.setCurProcess(minute);
|
|
||||||
}else{
|
|
||||||
this.hour=hour;
|
|
||||||
this.minute=minute;
|
|
||||||
}
|
|
||||||
this.s=musicName;
|
this.s=musicName;
|
||||||
this.uri=musicUri;
|
this.uri=musicUri;
|
||||||
this.handUpAlterType=handUpAlterType;
|
this.handUpAlterType=handUpAlterType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeText(int hour, int minute) {
|
private void changeText(int hour, int minute) {
|
||||||
this.hour=hour;
|
|
||||||
this.minute=minute;
|
|
||||||
int day=hour/60;
|
int day=hour/60;
|
||||||
int inHour=hour;
|
int inHour=hour;
|
||||||
String hourStr="";
|
String hourStr="";
|
||||||
|
@ -24,6 +24,7 @@ import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
|||||||
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
||||||
|
|
||||||
|
import static clock.socoolby.com.clock.state.ClockModeEnum.HANDUP;
|
||||||
import static clock.socoolby.com.clock.state.ClockTimeTypeEnum.TIME;
|
import static clock.socoolby.com.clock.state.ClockTimeTypeEnum.TIME;
|
||||||
|
|
||||||
public class ClockStateMachine implements Handler.Callback{
|
public class ClockStateMachine implements Handler.Callback{
|
||||||
@ -92,8 +93,8 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case UPDATE_TIME:
|
case UPDATE_TIME:
|
||||||
updateTime();
|
|
||||||
checkHandUp();
|
checkHandUp();
|
||||||
|
updateTime();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -115,6 +116,7 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
case COUNTING:
|
case COUNTING:
|
||||||
countingDateTimeBase =new Date();
|
countingDateTimeBase =new Date();
|
||||||
}
|
}
|
||||||
|
updateDescription(model.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClockTimeTypeEnum getCurrentShowTimeType(){
|
public ClockTimeTypeEnum getCurrentShowTimeType(){
|
||||||
@ -126,29 +128,30 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
return globalViewModel.getClockModeEnum().getValue();
|
return globalViewModel.getClockModeEnum().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String timeString;
|
||||||
|
DateModel date;
|
||||||
private void updateTime() {
|
private void updateTime() {
|
||||||
heartbeat=!heartbeat;
|
heartbeat=!heartbeat;
|
||||||
DateModel date = new DateModel();
|
date= new DateModel();
|
||||||
globalViewModel.setHeartbeat(heartbeat);
|
globalViewModel.setHeartbeat(heartbeat);
|
||||||
String timeString=null;
|
|
||||||
switch (getCurrentModeEnum()){
|
switch (getCurrentModeEnum()){
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
switch (showTimeType){
|
switch (showTimeType){
|
||||||
case COUNTING:
|
case COUNTING:
|
||||||
DateModel temp=new DateModel(countingDateTimeBase);
|
DateModel temp=new DateModel(countingDateTimeBase);
|
||||||
timeString=temp.getTimeString(false);
|
digitViewModel.setTimeText(temp.getTimeString(false));
|
||||||
if (!model.isTickSound()) {
|
if (!model.isTickSound()) {
|
||||||
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
|
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COUNTING_DOWN:
|
case COUNTING_DOWN:
|
||||||
timeString=DateModel.getTimeFull(globalViewModel.getHandUpTime().getValue());
|
digitViewModel.setTimeText(DateModel.getTimeFull(globalViewModel.getHandUpTime().getValue()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
|
timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
|
||||||
|
digitViewModel.setTimeText(timeString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
digitViewModel.getTimeText().setValue(timeString);
|
|
||||||
break;
|
break;
|
||||||
case HANDUP:
|
case HANDUP:
|
||||||
break;
|
break;
|
||||||
@ -156,11 +159,10 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
if(countingDateTimeBase==null)
|
if(countingDateTimeBase==null)
|
||||||
countingDateTimeBase=new Date();
|
countingDateTimeBase=new Date();
|
||||||
DateModel temp=new DateModel(countingDateTimeBase);
|
DateModel temp=new DateModel(countingDateTimeBase);
|
||||||
timeString=temp.getTimeString(false);
|
digitViewModel.setTimeText(temp.getTimeString(false));
|
||||||
if (!model.isTickSound()) {
|
if (!model.isTickSound()) {
|
||||||
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
|
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
|
||||||
}
|
}
|
||||||
digitViewModel.getTimeText().setValue(timeString);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
updateDay(date);
|
updateDay(date);
|
||||||
@ -212,7 +214,7 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
|
|
||||||
|
|
||||||
private void reportTime(DateModel date) {
|
private void reportTime(DateModel date) {
|
||||||
if (globalViewModel.isTickSound()&&globalViewModel.getClockModeEnum().getValue()!=ClockModeEnum.HANDUP) {
|
if (globalViewModel.isTickSound()&&globalViewModel.getClockModeEnum().getValue()!= HANDUP) {
|
||||||
Player.getInstance().playTick(ClockApplication.getContext(),R.raw.tick2);
|
Player.getInstance().playTick(ClockApplication.getContext(),R.raw.tick2);
|
||||||
}
|
}
|
||||||
int year = date.getYear();
|
int year = date.getYear();
|
||||||
@ -282,11 +284,11 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
case NORMAL:
|
case NORMAL:
|
||||||
globalViewModel.getHandUpTime().setValue(handUpTime-1);
|
globalViewModel.getHandUpTime().setValue(handUpTime-1);
|
||||||
if (handUpTime <= 10&&handUpTime > 0)
|
if (handUpTime <= 10&&handUpTime > 0)
|
||||||
themeUIViewModel.setDescription("提醒时间倒计时: " + handUpTime);
|
updateDescription("提醒时间倒计时: " + handUpTime);
|
||||||
if (handUpTime == 0) {
|
if (handUpTime == 0) {
|
||||||
globalViewModel.getHandUpTime().setValue(model.getHandUpTime());
|
globalViewModel.getHandUpTime().setValue(model.getHandUpTime());
|
||||||
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.HANDUP);
|
globalViewModel.getClockModeEnum().setValue(HANDUP);
|
||||||
themeUIViewModel.setDescription(model.getDescription());
|
updateDescription(model.getDescription());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HANDUP:
|
case HANDUP:
|
||||||
@ -298,4 +300,8 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDescription(String desc){
|
||||||
|
themeUIViewModel.setDescription(desc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ public class Player {
|
|||||||
|
|
||||||
private boolean isReporttime = false;
|
private boolean isReporttime = false;
|
||||||
|
|
||||||
|
private boolean playAble=true;
|
||||||
|
|
||||||
public static Player getInstance() {
|
public static Player getInstance() {
|
||||||
if (playerInstance == null) {
|
if (playerInstance == null) {
|
||||||
synchronized (Player.class) {
|
synchronized (Player.class) {
|
||||||
@ -95,13 +97,16 @@ public class Player {
|
|||||||
});
|
});
|
||||||
mediaPlayer.start();
|
mediaPlayer.start();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
if(mediaPlayer!=null)
|
||||||
|
mediaPlayer.release();
|
||||||
mediaPlayer = null;
|
mediaPlayer = null;
|
||||||
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reportTime(Context activity, int year, int month, int day, int hour, int minute, int today) {
|
public void reportTime(Context activity, int year, int month, int day, int hour, int minute, int today) {
|
||||||
if (isReporttime)
|
Log.d(TAG,"go in report time playAble:"+playAble+"\tisReportime:"+isReporttime);
|
||||||
|
if (!playAble||isReporttime)
|
||||||
return;
|
return;
|
||||||
Log.d(TAG, String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today));
|
Log.d(TAG, String.format("reportTime Year:%d Month:%d Day:%d Hour:%d Minute:%d Today:%d", year, month, day, hour, minute, today));
|
||||||
LinkedList<Integer> playList = new LinkedList<Integer>();
|
LinkedList<Integer> playList = new LinkedList<Integer>();
|
||||||
@ -164,27 +169,28 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playTick(Context activity,int tick_type_id) {
|
public void playTick(Context activity,int tick_type_id) {
|
||||||
|
Log.d(TAG,"go in Play tick playable:"+playAble+"\tisReportime:"+isReporttime);
|
||||||
|
if (!playAble||isReporttime)
|
||||||
|
return;
|
||||||
if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext()))
|
if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext()))
|
||||||
return;
|
return;
|
||||||
if (!isReporttime) {
|
playSoundWithRawId(activity,tick_type_id);
|
||||||
playSoundWithRawId(activity,tick_type_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AssetFileDescriptor soundFile = null;
|
private AssetFileDescriptor soundFile = null;
|
||||||
private Map<Integer,AssetFileDescriptor> soundFileCache=new HashMap<>();
|
private Map<Integer,AssetFileDescriptor> soundFileCache=new HashMap<>();
|
||||||
|
|
||||||
public void playHandUp(Context activity){
|
public void playHandUp(Context activity){
|
||||||
|
Log.d(TAG,"go in Play hand up playable:"+playAble+"\tisReportime:"+isReporttime);
|
||||||
|
if (!playAble||isReporttime)
|
||||||
|
return;
|
||||||
if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext()))
|
if (!ScreenManager.isScreenOn() || ScreenManager.isApplicationBroughtToBackground(ClockApplication.getContext()))
|
||||||
return;
|
return;
|
||||||
if (!isReporttime) {
|
playSoundWithRawId(activity, R.raw.handup_didi);
|
||||||
playSoundWithRawId(activity, R.raw.handup_didi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void playSoundWithRawId(Context activity,int soundId){
|
public void playSoundWithRawId(Context activity,int soundId){
|
||||||
|
|
||||||
if (mediaPlayer == null)
|
if (mediaPlayer == null)
|
||||||
mediaPlayer = buildMediaPlayer();
|
mediaPlayer = buildMediaPlayer();
|
||||||
soundFile =soundFileCache.get(soundId);
|
soundFile =soundFileCache.get(soundId);
|
||||||
@ -206,19 +212,24 @@ public class Player {
|
|||||||
});
|
});
|
||||||
mediaPlayer.start();
|
mediaPlayer.start();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
if(mediaPlayer!=null)
|
||||||
|
mediaPlayer.release();
|
||||||
mediaPlayer = null;
|
mediaPlayer = null;
|
||||||
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MediaPlayer buildMediaPlayer() {
|
private static MediaPlayer buildMediaPlayer() {
|
||||||
MediaPlayer mediaPlayer = MediaPlayer.create(ClockApplication.getContext(), R.raw.tick);
|
MediaPlayer mediaPlayer = MediaPlayer.create(ClockApplication.getContext(), R.raw.tick);
|
||||||
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
return mediaPlayer;
|
return mediaPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isPlaying=false;
|
boolean isPlaying=false;
|
||||||
public void playRing(Context activity, Uri uri){
|
public void playRing(Context activity, Uri uri){
|
||||||
|
if(!playAble)
|
||||||
|
return;
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
mediaPlayer = buildMediaPlayer();
|
mediaPlayer = buildMediaPlayer();
|
||||||
isPlaying=false;
|
isPlaying=false;
|
||||||
@ -243,8 +254,11 @@ public class Player {
|
|||||||
isPlaying=true;
|
isPlaying=true;
|
||||||
mediaPlayer.start();
|
mediaPlayer.start();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
if(mediaPlayer!=null)
|
||||||
|
mediaPlayer.release();
|
||||||
mediaPlayer = null;
|
mediaPlayer = null;
|
||||||
isPlaying=false;
|
isPlaying=false;
|
||||||
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,4 +269,18 @@ public class Player {
|
|||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPlayAble() {
|
||||||
|
return playAble;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayAble(boolean playAble) {
|
||||||
|
Log.d(TAG,"set Play able:"+playAble);
|
||||||
|
this.playAble = playAble;
|
||||||
|
if(!playAble&&mediaPlayer!=null){
|
||||||
|
resert();
|
||||||
|
mediaPlayer.release();
|
||||||
|
mediaPlayer=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class DigitViewModel extends ViewModel {
|
|||||||
shadowType.setValue(ShadowTypeEnum.valueOf(model.getShadowType()));
|
shadowType.setValue(ShadowTypeEnum.valueOf(model.getShadowType()));
|
||||||
timeCharAnimatorType.setValue(CharAnimatorEnum.valueOf(model.getTimeTextCharAnimatorType()));
|
timeCharAnimatorType.setValue(CharAnimatorEnum.valueOf(model.getTimeTextCharAnimatorType()));
|
||||||
baseLineDown.setValue(model.getBaseLineDown());
|
baseLineDown.setValue(model.getBaseLineDown());
|
||||||
timeFontStyleSize.setValue(100);
|
timeFontStyleSize.setValue(model.getFontStyleSize());
|
||||||
timeFontName.setValue(model.getFontName());
|
timeFontName.setValue(model.getFontName());
|
||||||
secondSubscript.setValue(model.isTimeTextSecondSubscript());
|
secondSubscript.setValue(model.isTimeTextSecondSubscript());
|
||||||
charBackgroundBorder.setValue(model.isCharBackgroundBorder());
|
charBackgroundBorder.setValue(model.isCharBackgroundBorder());
|
||||||
@ -148,6 +148,7 @@ public class DigitViewModel extends ViewModel {
|
|||||||
|
|
||||||
public void setTimeFontStyleSize(Integer timeFontStyleSize) {
|
public void setTimeFontStyleSize(Integer timeFontStyleSize) {
|
||||||
this.timeFontStyleSize.setValue(timeFontStyleSize);
|
this.timeFontStyleSize.setValue(timeFontStyleSize);
|
||||||
|
//model.setFontStyleSize(timeFontStyleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShadowType(ShadowTypeEnum shadowType) {
|
public void setShadowType(ShadowTypeEnum shadowType) {
|
||||||
|
@ -17,13 +17,13 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<Integer> foregroundColor=new MutableLiveData<>();
|
private MutableLiveData<Integer> foregroundColor=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Uri> backgroundImageUri=new MutableLiveData<>();
|
private MutableLiveData<Uri> backgroundImageUri=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<String> backgroundAnimatorName=new MutableLiveData<>();
|
private MutableLiveData<String> backgroundAnimatorName=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Integer> backgroundAnimatorColor=new MutableLiveData<>();
|
private MutableLiveData<Integer> backgroundAnimatorColor=new MutableLiveData<>();
|
||||||
|
|
||||||
private Boolean backgroundAnimatorRandomColor=false;
|
private Boolean backgroundAnimatorRandomColor=false;
|
||||||
|
|
||||||
private MutableLiveData<ClockInterfaceTypeEnum> clockInterfaceTypeEnum =new MutableLiveData<>();
|
private MutableLiveData<ClockInterfaceTypeEnum> clockInterfaceTypeEnum =new MutableLiveData<>();
|
||||||
|
|
||||||
@ -31,14 +31,14 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<Boolean> backgroundImageVisable=new MutableLiveData<>();
|
private MutableLiveData<Boolean> backgroundImageVisable=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Boolean> autoFullScreen=new MutableLiveData<>();
|
private MutableLiveData<Boolean> autoFullScreen=new MutableLiveData<>();
|
||||||
|
|
||||||
//system
|
//system
|
||||||
private Boolean tickSound=false;
|
private Boolean tickSound=false;
|
||||||
|
|
||||||
private Boolean appConfig=false;
|
private Boolean appConfig=false;
|
||||||
|
|
||||||
private MutableLiveData<String> mCity=new MutableLiveData<>();
|
private MutableLiveData<String> mCity=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Integer> brightness=new MutableLiveData<>();
|
private MutableLiveData<Integer> brightness=new MutableLiveData<>();
|
||||||
|
|
||||||
@ -51,12 +51,13 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<String> handUpTypeName=new MutableLiveData<>();
|
private MutableLiveData<String> handUpTypeName=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<String> hourAlterTypeName=new MutableLiveData<>();
|
private MutableLiveData<String> hourAlterTypeName=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Boolean> timeHourAnimatorStarting =new MutableLiveData<>();
|
private MutableLiveData<Boolean> timeHourAnimatorStarting =new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Integer> timeHourAnimatordialy=new MutableLiveData<>();
|
private MutableLiveData<Integer> timeHourAnimatordialy=new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
//state
|
//state
|
||||||
private MutableLiveData<ClockModeEnum> clockModeEnum=new MutableLiveData<>();
|
private MutableLiveData<ClockModeEnum> clockModeEnum=new MutableLiveData<>();
|
||||||
|
|
||||||
@ -64,20 +65,26 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<Integer> time_hour=new MutableLiveData<>();
|
private MutableLiveData<Integer> time_hour=new MutableLiveData<>();
|
||||||
|
|
||||||
private MutableLiveData<Date> time_day=new MutableLiveData<>();
|
private MutableLiveData<Date> time_day=new MutableLiveData<>();
|
||||||
|
|
||||||
SharePerferenceModel model;
|
SharePerferenceModel model;
|
||||||
|
|
||||||
public GlobalViewModel(SharePerferenceModel model) {
|
public GlobalViewModel(SharePerferenceModel model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
init();
|
||||||
loadFromModel();
|
loadFromModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromModel(){
|
private void init(){
|
||||||
srceenLock.setValue(false);
|
srceenLock.setValue(false);
|
||||||
brightness.setValue(100);
|
brightness.setValue(100);
|
||||||
heartbeat.setValue(true);
|
heartbeat.setValue(true);
|
||||||
|
appConfig=false;
|
||||||
|
clockModeEnum.setValue(ClockModeEnum.NORMAL);
|
||||||
|
timeHourAnimatorStarting.setValue(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFromModel(){
|
||||||
mCity.setValue(model.getCity());
|
mCity.setValue(model.getCity());
|
||||||
backgroundColor.setValue(model.getBackgroundColor());
|
backgroundColor.setValue(model.getBackgroundColor());
|
||||||
foregroundColor.setValue(model.getForegroundColor());
|
foregroundColor.setValue(model.getForegroundColor());
|
||||||
@ -88,28 +95,16 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
backgroundAnimatorName.setValue(model.getBackgroundAnimatorName());
|
backgroundAnimatorName.setValue(model.getBackgroundAnimatorName());
|
||||||
backgroundAnimatorColor.setValue(model.getForegroundColor1());
|
backgroundAnimatorColor.setValue(model.getForegroundColor1());
|
||||||
backgroundAnimatorRandomColor=model.isBackgroundAnimatorRandomColor();
|
backgroundAnimatorRandomColor=model.isBackgroundAnimatorRandomColor();
|
||||||
|
|
||||||
clockInterfaceTypeEnum.setValue(ClockInterfaceTypeEnum.valueOf(model.getClockInterfaceType()));
|
clockInterfaceTypeEnum.setValue(ClockInterfaceTypeEnum.valueOf(model.getClockInterfaceType()));
|
||||||
|
|
||||||
autoFullScreen.setValue(model.isAutoFullscreen());
|
autoFullScreen.setValue(model.isAutoFullscreen());
|
||||||
|
|
||||||
clockModeEnum.setValue(ClockModeEnum.NORMAL);
|
|
||||||
|
|
||||||
handUpAble.setValue(model.isHandUpAble());
|
handUpAble.setValue(model.isHandUpAble());
|
||||||
handUpTime.setValue(model.getHandUpTime());
|
handUpTime.setValue(model.getHandUpTime());
|
||||||
handUpTypeName.setValue(model.getHandUpTypeName());
|
handUpTypeName.setValue(model.getHandUpTypeName());
|
||||||
|
|
||||||
hourSystem12.setValue(model.isHourSystem12());
|
hourSystem12.setValue(model.isHourSystem12());
|
||||||
|
|
||||||
hourAlterTypeName.setValue(model.getTimeHourAlterTypeName());
|
hourAlterTypeName.setValue(model.getTimeHourAlterTypeName());
|
||||||
|
|
||||||
time_hour.setValue(new Date().getHours());
|
time_hour.setValue(new Date().getHours());
|
||||||
|
|
||||||
timeHourAnimatorStarting.setValue(false);
|
|
||||||
|
|
||||||
timeHourAnimatordialy.setValue(model.getTimeHourAlterDialy());
|
timeHourAnimatordialy.setValue(model.getTimeHourAlterDialy());
|
||||||
|
|
||||||
appConfig=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<String> getCity() {
|
public MutableLiveData<String> getCity() {
|
||||||
@ -189,6 +184,11 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
return handUpAble;
|
return handUpAble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHandUpTime(Integer handUpTime) {
|
||||||
|
this.handUpTime.setValue(handUpTime);
|
||||||
|
//model.setHandUpTime(handUpTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCity(String mCity) {
|
public void setCity(String mCity) {
|
||||||
this.mCity.setValue(mCity);
|
this.mCity.setValue(mCity);
|
||||||
@ -207,6 +207,7 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
public void setBackgroundImageUri(Uri backgroundImageUri) {
|
public void setBackgroundImageUri(Uri backgroundImageUri) {
|
||||||
this.backgroundImageUri.setValue(backgroundImageUri);
|
this.backgroundImageUri.setValue(backgroundImageUri);
|
||||||
|
model.setBackgroundImage(backgroundImageUri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackgroundAnimatorName(String backgroundAnimatorName) {
|
public void setBackgroundAnimatorName(String backgroundAnimatorName) {
|
||||||
@ -271,10 +272,6 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
model.setAutoFullscreen(autoFullScreen);
|
model.setAutoFullscreen(autoFullScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHandUpTime(Integer handUpTime) {
|
|
||||||
this.handUpTime.setValue(handUpTime);
|
|
||||||
//model.setHandUpTime(handUpTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHandUpAble(Boolean handUpAble) {
|
public void setHandUpAble(Boolean handUpAble) {
|
||||||
this.handUpAble.setValue(handUpAble);
|
this.handUpAble.setValue(handUpAble);
|
||||||
@ -331,4 +328,8 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
public void setAppConfig(Boolean appConfig) {
|
public void setAppConfig(Boolean appConfig) {
|
||||||
this.appConfig = appConfig;
|
this.appConfig = appConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTimeHourVideoPath(){
|
||||||
|
return model.getTimeHourVideoPath();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class ThemeUIViewModel extends ViewModel {
|
|||||||
loadFromModel();
|
loadFromModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadFromModel(){
|
public void loadFromModel(){
|
||||||
description.setValue(model.getDescription());
|
description.setValue(model.getDescription());
|
||||||
|
|
||||||
themeName.setValue(model.getThemeName());
|
themeName.setValue(model.getThemeName());
|
||||||
@ -42,6 +42,10 @@ public class ThemeUIViewModel extends ViewModel {
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description.setValue(description);
|
||||||
|
}
|
||||||
|
|
||||||
public MutableLiveData<ClockThemeUITypeEnum> getClockUITypeEnum() {
|
public MutableLiveData<ClockThemeUITypeEnum> getClockUITypeEnum() {
|
||||||
return clockUITypeEnum;
|
return clockUITypeEnum;
|
||||||
}
|
}
|
||||||
@ -67,10 +71,6 @@ public class ThemeUIViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description.setValue(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClockUITypeEnum(ClockThemeUITypeEnum clockUITypeEnum) {
|
public void setClockUITypeEnum(ClockThemeUITypeEnum clockUITypeEnum) {
|
||||||
this.clockUITypeEnum.setValue(clockUITypeEnum);
|
this.clockUITypeEnum.setValue(clockUITypeEnum);
|
||||||
model.setThemeUIType(clockUITypeEnum.code);
|
model.setThemeUIType(clockUITypeEnum.code);
|
||||||
|
@ -78,6 +78,8 @@ public class AnimatorView extends View {
|
|||||||
if(animator!=null) {
|
if(animator!=null) {
|
||||||
animator.setColor(color);
|
animator.setColor(color);
|
||||||
animator.start();
|
animator.start();
|
||||||
|
}else{
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import clock.socoolby.com.clock.widget.textview.charanimator.Up2DownCharAnimator
|
|||||||
public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
||||||
public static final String Tag = DigitTextView.class.getSimpleName();
|
public static final String Tag = DigitTextView.class.getSimpleName();
|
||||||
|
|
||||||
float baseLineDown = 0;
|
float baseLineDownScale = 0;
|
||||||
|
|
||||||
private LinearGradient mLinearGradient;
|
private LinearGradient mLinearGradient;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBaseLineDown(float baseLineDown) {
|
public void setBaseLineDown(float baseLineDown) {
|
||||||
this.baseLineDown =getHeight()/2*(-baseLineDown/100);
|
this.baseLineDownScale =baseLineDown;
|
||||||
layoutReflushAble=true;
|
layoutReflushAble=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,6 +254,8 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
textSubscriptSpan = textSubscriptSpan + subscriptCharWidth * 2;
|
textSubscriptSpan = textSubscriptSpan + subscriptCharWidth * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
layoutReflushAble=false;
|
layoutReflushAble=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +284,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
layoutReflush(textToDraw);
|
layoutReflush(textToDraw);
|
||||||
|
|
||||||
startX = (getWidth() - textWidth - textSubscriptSpan) / 2;
|
startX = (getWidth() - textWidth - textSubscriptSpan) / 2;
|
||||||
startY = (getHeight() + textBodyHight) / 2+baseLineDown;
|
startY = (getHeight() + textBodyHight) / 2+getHeight()/2*(-baseLineDownScale /100);
|
||||||
|
|
||||||
for (int i = 0; i < textLength; i++) {
|
for (int i = 0; i < textLength; i++) {
|
||||||
charStr = String.valueOf(textToDraw.charAt(i));
|
charStr = String.valueOf(textToDraw.charAt(i));
|
||||||
|
14
app/src/main/res/layout/fragment_hour_video.xml
Normal file
14
app/src/main/res/layout/fragment_hour_video.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".fragment.houranimator.HourAnimatorFragment">
|
||||||
|
|
||||||
|
<TextureView
|
||||||
|
android:id="@+id/tv_hour_video"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
@ -48,13 +48,61 @@
|
|||||||
android:text="@string/no_report" />
|
android:text="@string/no_report" />
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/tv_clock_hour_animator_setting"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/rg_talking_clock"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_clock_hour_animator_text"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="整点动画"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rg_clock_hour_animator_group"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_below="@+id/tv_clock_hour_animator_text">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rg_clock_hour_animator_null"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="不设置" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rg_clock_hour_animator_flash"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="游鱼" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rg_clock_hour_video"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="视频" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_clock_hour_video"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/rg_clock_hour_animator_group"
|
||||||
|
android:text="" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_except"
|
android:id="@+id/tv_except"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_below="@+id/rg_talking_clock"
|
android:layout_below="@+id/tv_clock_hour_animator_setting"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:text="@string/except" />
|
android:text="@string/except" />
|
||||||
|
|
||||||
@ -78,6 +126,7 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_tick_title"
|
android:id="@+id/tv_tick_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -109,11 +158,26 @@
|
|||||||
android:text="@string/trigger_screen_on_off" />
|
android:text="@string/trigger_screen_on_off" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_weather_title"
|
android:id="@+id/tv_boot_start_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/cb_trigger_screen"
|
android:layout_below="@+id/cb_trigger_screen"
|
||||||
android:layout_marginTop="@dimen/setting_margin_top"
|
android:layout_marginTop="@dimen/setting_margin_top"
|
||||||
|
android:text="开机启动设置" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cb_boot_start"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/tv_boot_start_text"
|
||||||
|
android:text="开启" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_weather_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/cb_boot_start"
|
||||||
|
android:layout_marginTop="@dimen/setting_margin_top"
|
||||||
android:text="@string/weather_citiyname" />
|
android:text="@string/weather_citiyname" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
@ -16,33 +16,30 @@
|
|||||||
android:id="@+id/seek_hour"
|
android:id="@+id/seek_hour"
|
||||||
android:layout_width="300dp"
|
android:layout_width="300dp"
|
||||||
android:layout_height="300dp"
|
android:layout_height="300dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_centerVertical="true"
|
app:wheel_max_process="120"
|
||||||
app:wheel_max_process="59"
|
|
||||||
app:wheel_unreached_width="32dp" />
|
app:wheel_unreached_width="32dp" />
|
||||||
|
|
||||||
<io.feeeei.circleseekbar.CircleSeekBar
|
<io.feeeei.circleseekbar.CircleSeekBar
|
||||||
android:id="@+id/seek_minute"
|
android:id="@+id/seek_minute"
|
||||||
android:layout_width="236dp"
|
android:layout_width="236dp"
|
||||||
android:layout_height="236dp"
|
android:layout_height="236dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_centerVertical="true"
|
app:wheel_max_process="59"
|
||||||
app:wheel_max_process="11"
|
|
||||||
app:wheel_pointer_color="@color/colorPrimaryDark"
|
app:wheel_pointer_color="@color/colorPrimaryDark"
|
||||||
app:wheel_pointer_radius="8dp"
|
app:wheel_pointer_radius="8dp"
|
||||||
app:wheel_reached_color="@color/colorAccent"
|
app:wheel_reached_color="@color/colorAccent"
|
||||||
app:wheel_reached_width="32dp"
|
app:wheel_reached_width="32dp"
|
||||||
app:wheel_unreached_color="@color/colorPrimary" />
|
app:wheel_unreached_color="@color/colorPrimary" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/seek_time"
|
android:id="@+id/seek_time"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="100dp"
|
android:layout_height="100dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerInParent="true"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="18sp" />
|
android:textSize="22sp" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
android:layout_width="300dp"
|
android:layout_width="300dp"
|
||||||
android:layout_height="300dp"
|
android:layout_height="300dp"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
app:wheel_max_process="59"
|
app:wheel_max_process="120"
|
||||||
app:wheel_unreached_width="32dp" />
|
app:wheel_unreached_width="32dp" />
|
||||||
|
|
||||||
<io.feeeei.circleseekbar.CircleSeekBar
|
<io.feeeei.circleseekbar.CircleSeekBar
|
||||||
@ -19,7 +19,7 @@
|
|||||||
android:layout_width="236dp"
|
android:layout_width="236dp"
|
||||||
android:layout_height="236dp"
|
android:layout_height="236dp"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
app:wheel_max_process="11"
|
app:wheel_max_process="59"
|
||||||
app:wheel_pointer_color="@color/colorPrimaryDark"
|
app:wheel_pointer_color="@color/colorPrimaryDark"
|
||||||
app:wheel_pointer_radius="8dp"
|
app:wheel_pointer_radius="8dp"
|
||||||
app:wheel_reached_color="@color/colorAccent"
|
app:wheel_reached_color="@color/colorAccent"
|
||||||
|
BIN
workclock.apk
BIN
workclock.apk
Binary file not shown.
BIN
workclock20190717.apk
Normal file
BIN
workclock20190717.apk
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user