1
0
mirror of https://gitee.com/51danju/workclock.git synced 2025-06-28 13:12:48 +08:00

增加视频Fragment,更新app

This commit is contained in:
wushunlian 2019-07-17 11:18:00 +08:00
parent 07061787eb
commit 73c347f021
38 changed files with 1022 additions and 475 deletions

View File

@ -1,7 +1,6 @@
# WorkClock
An Android clock [下载](#直接下载)
<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"/>
@ -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"/>
锁 单击->退出全屏模式,返回先前的状态
时间 长按-->即进入[模拟时钟模式](#模拟时钟模式)
定时显 长按->隐去自已
定时显 长按->隐去自已
左滑:改变背景动画
右滑:改变字本
@ -81,20 +71,13 @@ An Android clock [下载](#直接下载)
<img src="/screenshot/device-full-clock.png" width="768" height="382"/>
锁 单击->退出全屏模式,返回先前的状态
时钟 长按-->返回[全屏精简模式](#全屏精简模式)
时钟 长按-->进入[定制设置]
左滑:改变背景动画
右滑:改变走钟样式
双击:改变指针样式
------
右滑:改变样式
其它在设置页设置
<img src="/screenshot/demonstrate.gif" width="320" height="568"/>
双击:界面(详细-全屏)
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)

Binary file not shown.

View File

@ -8,10 +8,8 @@ public class Constants {
public final static int TALKING_HOURS=2;
public final static int TALKING_NO_REPORT=3;
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 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="小提示: ←动画 →字体 ↑↓亮度 双指_字体大小 双击_切屏 长按_参数设置";
}

View File

@ -165,8 +165,17 @@ public class FamousQuotesManager {
"民之难治,以其智多。故以智治国,国之贼。不以智治国,国之福。——《道德经》第六十五章"
};
public static final String[] APP_MEMOS=new String[]{
Constants.APP_MEMO,
"你可以长按「日期」来切换「界面主题」.",
"单击「星期几」可以快速切换「秒显」,长按则可以切换「时制」.",
"记着如怕乱触,可以使用「锁屏」.",
"前背景颜色可在「马头」切换,你也可以长按来改变它的设置,如果要彩虹字,则长按时间在参数设置里",
"注意哦,每个字体的大小在不同的模式下都不一样,可各自设置来保证美观,系统会记注每次改变."
};
public static String roundAutoQuotes(){
int index=new java.util.Random().nextInt(4);
int index=new java.util.Random().nextInt(5);
switch (index){
case 1:
return roundTangShi();
@ -174,8 +183,10 @@ public class FamousQuotesManager {
return roundLaoZi();
case 3:
return roundKonZi();
default:
case 4:
return roundFamousQuotes();
default:
return roundAppMemo();
}
}
@ -195,8 +206,13 @@ public class FamousQuotesManager {
return roundFamousQuotes(POETRY_OF_THE_TANG_DYNASTY);
}
public static String roundAppMemo(){
return roundFamousQuotes(APP_MEMOS);
}
public static String roundFamousQuotes(String[] arrays){
int index=new java.util.Random().nextInt(arrays.length);
return arrays[index];
}
}

View File

@ -2,7 +2,6 @@ package clock.socoolby.com.clock;
import com.openbravo.data.basic.BasicException;
import java.util.ArrayList;
import java.util.List;
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
@ -10,6 +9,8 @@ import e.odbo.data.dao.EntityManager;
public class FontManager {
public static final TimeFontStyle DEFAULT_FONT_STYLE =new TimeFontStyle("ds_digi",140,150,160,200);
private List<TimeFontStyle> fontStyleList;
private TimeFontStyle currentFontStyle;
@ -20,10 +21,8 @@ public class FontManager {
public FontManager(EntityManager entityManager) {
this.entityManager=entityManager;
//initTimeFontStyle();
loadForDB();
currentFontIndex=0;
currentFontStyle=fontStyleList.get(currentFontIndex);
setCurrentFontName("ds_digi");
}
private void loadForDB(){
@ -36,10 +35,9 @@ public class FontManager {
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){
int fontSize=currentFontStyle.displaySecond;
int fontSize;
if(isFullScreen){
if(isDisplaySecond) {
fontSize=currentFontStyle.displaySecondOnFull;
@ -57,7 +55,7 @@ public class FontManager {
}
public int getMaxFontSize(boolean isDisplaySecond){
int fontSize=currentFontStyle.displaySecond;
int fontSize;
if(isDisplaySecond) {
fontSize=currentFontStyle.displaySecondOnFull;
}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){
if(isFullScreen){
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){
this.fontStyleList.addAll(coustomFontStyleList);
}

View File

@ -9,6 +9,7 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
@ -17,6 +18,7 @@ import android.provider.Settings;
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
@ -41,7 +43,8 @@ import java.util.List;
import clock.socoolby.com.clock.alter.AlterManager;
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
import clock.socoolby.com.clock.fragment.SystemAppConfigFragment;
import clock.socoolby.com.clock.fragment.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.AlterFragmentFactory;
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.simulate.SimulateClockConfigFragment;
import clock.socoolby.com.clock.fragment.simulate.SimulateClockFragment;
import clock.socoolby.com.clock.fragment.ThemeUIDefaultFragment;
import clock.socoolby.com.clock.fragment.ThemeUISampleFragment;
import clock.socoolby.com.clock.fragment.theme.ThemeUIDefaultFragment;
import clock.socoolby.com.clock.fragment.theme.ThemeUISampleFragment;
import clock.socoolby.com.clock.net.protocol.weather.WeatherResponse;
import clock.socoolby.com.clock.service.ProximityService;
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.widget.animatorview.AnimatorView;
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 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 {
private final static String TAG = MainActivity.class.getSimpleName();
private final static int SETTING_REQUEST_CODE = 100;
//背景动画
private AnimatorView animatorView;
private I_Animator backGroundAnimator;
private final static int ANIMATOR_TEXTLED=80;
private final static int ANIMATOR_TEXTLED = 80;
private FrameLayout themeUIContainer;
//背景图相关
private ImageView tv_background_image;
// 定义手势检测器实例
GestureDetector detector;
ScaleGestureDetector scaleGestureDetector;
@ -106,7 +104,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
private ClockStateMachine clockStateMachine;
Intent proximityServiceIntent=null;
Intent proximityServiceIntent = null;
FontManager fontManager;
GlobalViewModel globalViewModel;
@ -124,10 +122,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
public void setWeather(WeatherResponse weather) {
if (weather == null)
return;
Log.d(TAG,"setWeather...");
this.weatherAdape= weather;
Log.d(TAG, "setWeather...");
this.weatherAdape = weather;
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) {
super.onCreate(savedInstanceState);
//Log.d(TAG,"onCreate...");
setContentView(R.layout.activity_main);
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);
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");
}else
} else
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//创建手势检测器
detector = new GestureDetector(this, this);
detector.setOnDoubleTapListener(this);
scaleGestureDetector=new ScaleGestureDetector(this,this);
scaleGestureDetector = new ScaleGestureDetector(this, this);
ClockApplication.getInstance().setMainActivity(this);
init();
testSetup();
//ClockApplication.valueOf().getBusinessService().checkUpdate();
}
private boolean isPowerManagerDisable(){
return wakeLock==null;
private boolean isPowerManagerDisable() {
return wakeLock == null;
}
private void setUpProximityService(){
if(isPowerManagerDisable())
private void setUpProximityService() {
if (isPowerManagerDisable())
return;
try{
if(isScreenLock()){
stopService(proximityServiceIntent);
}else {
try {
if (isScreenLock()) {
stopService(proximityServiceIntent);
} else {
if (model.isTriggerScreen()) {
startService(proximityServiceIntent);
} else {
stopService(proximityServiceIntent);
}
}
}catch (Exception e){
}
} catch (Exception e) {
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 (!PermissionUtils.isGranted(permissions)) {
ActivityCompat.requestPermissions(this,
permissions,
reqCode);
}else {
Toast.makeText(this,"权限已申请",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "权限已申请", Toast.LENGTH_LONG).show();
}
}
}
private void init() {
model = ((ClockApplication)getApplication()).getModel();
model = ((ClockApplication) getApplication()).getModel();
Log.d(TAG, "init model:" + model.toString());
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);
globalViewModel= ViewModelProviders.of(MainActivity.this, viewModelFactory).get(GlobalViewModel.class);
digitViewModel= ViewModelProviders.of(MainActivity.this, viewModelFactory).get(DigitViewModel.class);
simulateViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(SimulateViewModel.class);
themeUIViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
alterViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
ViewModelFactory viewModelFactory = new ViewModelFactory(model);
globalViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(GlobalViewModel.class);
digitViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(DigitViewModel.class);
simulateViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(SimulateViewModel.class);
themeUIViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
alterViewModel = ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
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();
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() {
globalViewModel.getHourAlterTypeName().setValue(FishAnimator.NAME);
//model.setFirstStart(true);
//model.setBootStart(true);
//globalViewModel.getHandUpTypeName().setValue(HandUpSelect123Fragment.NAME);
/*Observer<Boolean> timeChange= new Observer<Boolean>() {
/*globalViewModel.getHourAlterTypeName().setValue(HourVideoFragment.NAME);
Observer<Boolean> timeChange= new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
daily--;
@ -266,17 +271,18 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
e.printStackTrace();
}*/
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-TubeBold", 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>() {
@Override
public void onChanged(ClockInterfaceTypeEnum clockInterfaceTypeEnum) {
switch (clockInterfaceTypeEnum){
Log.d(TAG,"comming in clockInterfaceTypeEnum change observe type:"+clockInterfaceTypeEnum.name());
switch (clockInterfaceTypeEnum) {
case Digit:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new DigitClockFragment()).commit();
break;
@ -290,21 +296,22 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
globalViewModel.getClockModeEnum().observe(this, new Observer<ClockModeEnum>() {
@Override
public void onChanged(ClockModeEnum clockModeEnum) {
switch(clockModeEnum){
switch (clockModeEnum) {
case HANDUP:
AbstractHandUpFragment alterFragment= AlterFragmentFactory.build(globalViewModel.getHandUpTypeName().getValue(),clockStateMachine);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, alterFragment).commit();
closeAllConfigFragment();
AbstractHandUpFragment alterFragment = AlterFragmentFactory.build(globalViewModel.getHandUpTypeName().getValue(), clockStateMachine);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, alterFragment).addToBackStack(null).commit();
break;
default:
globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
};
getSupportFragmentManager().popBackStack();
}
}
});
themeUIViewModel.getThemeName().observe(this, new Observer<String>() {
@Override
public void onChanged(String s) {
switch (s){
switch (s) {
case ThemeUISampleFragment.THEME_NAME:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new ThemeUISampleFragment()).commit();
break;
@ -317,14 +324,14 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
globalViewModel.getBackgroundImageVisable().observe(this, new Observer<Boolean>() {
@Override
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>() {
@Override
public void onChanged(Uri uri) {
if(uri==null) {
if (uri == null) {
tv_background_image.setVisibility(View.GONE);
return;
}
@ -355,7 +362,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
globalViewModel.getBackgroundAnimatorName().observe(this, new Observer<String>() {
@Override
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>() {
@Override
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>() {
@Override
public void onChanged(ClockThemeUITypeEnum clockThemeUITypeEnum) {
int fontSize=0;
boolean displaySecond=model.isDisplaySecond();
switch (clockThemeUITypeEnum){
int fontSize = 0;
boolean displaySecond = model.isDisplaySecond();
switch (clockThemeUITypeEnum) {
case FULLSCREEN:
fontSize=fontManager.getCurrentFontSize(true,displaySecond);
fontSize = fontManager.getCurrentFontSize(true, displaySecond);
break;
default:
fontSize=fontManager.getCurrentFontSize(false,displaySecond);
fontSize = fontManager.getCurrentFontSize(false, displaySecond);
}
digitViewModel.setTimeFontStyleSize(fontSize);
}
@ -407,35 +414,42 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
digitViewModel.getDisplaySecond().observe(this, new Observer<Boolean>() {
@Override
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>() {
@Override
public void onChanged(Boolean starting) {
Log.d(TAG, "on hour animator changed: "+starting);
if(!HourAnimatorFactory.isHourAnimator(globalViewModel.getHourAlterTypeName().getValue()))
Log.d(TAG, "on hour animator changed: " + starting);
if (!HourAnimatorFactory.isHourAnimator(globalViewModel.getHourAlterTypeName().getValue()))
return;
if(starting)
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(globalViewModel.getHourAlterTypeName().getValue(),globalViewModel.getTime_hour().getValue())).commit();
if (starting)
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, HourAnimatorFactory.builder(globalViewModel.getHourAlterTypeName().getValue(), globalViewModel.getTime_hour().getValue())).addToBackStack(null).commit();
else
globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
getSupportFragmentManager().popBackStack();
//globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
}
});
}
private void closeAllConfigFragment(){
getSupportFragmentManager().popBackStack();
}
//将该Activity上的触碰事件交给GestureDetector处理
@Override
public boolean onTouchEvent(MotionEvent me)
{
if(globalViewModel.getAppConfig())
return false;
if(me.getPointerCount()>1)
return scaleGestureDetector.onTouchEvent(me);
return detector.onTouchEvent(me);
public boolean onTouchEvent(MotionEvent me) {
if (globalViewModel.getAppConfig())
return true;
boolean res = scaleGestureDetector.onTouchEvent(me);
if (!scaleGestureDetector.isInProgress()) {
res = detector.onTouchEvent(me);
}
return res;
}
@ -443,17 +457,16 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
public void onDestroy() {
//Log.i(TAG, "onDestroy....");
super.onDestroy();
if(clockStateMachine!=null)
clockStateMachine.onDestory();
if (clockStateMachine != null)
clockStateMachine.onDestory();
try {
if (model.isTriggerScreen())
stopService(proximityServiceIntent);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
if(backGroundAnimator!=null)
if (backGroundAnimator != null)
backGroundAnimator.stop();
}
@ -463,27 +476,35 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
//Log.i(TAG, "onDestroy....");
super.onResume();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
if(!isPowerManagerDisable())
if (!isPowerManagerDisable())
wakeLock.acquire();
if(backGroundAnimator!=null)
if (backGroundAnimator != null)
backGroundAnimator.start();
clockStateMachine.start();
}
@Override
protected void onStart() {
super.onStart();
if(model.isFirstStart())
firstStartSetup();
}
@Override
protected void onPause() {
super.onPause();
//Log.d(TAG,"onPause..");
if(!isPowerManagerDisable())
if (!isPowerManagerDisable())
wakeLock.release();
if(backGroundAnimator!=null)
if (backGroundAnimator != null)
backGroundAnimator.stop();
clockStateMachine.stop();
}
public void configBackGroundImage(){
public void configBackGroundImage() {
PictureSelector.create(MainActivity.this)
.openGallery(PictureMimeType.ofImage())
.isCamera(false)
.imageSpanCount(4)
.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) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
List<LocalMedia> selectList;
switch (requestCode) {
case PictureConfig.CHOOSE_REQUEST:
// 图片视频音频选择结果回调
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
selectList = PictureSelector.obtainMultipleResult(data);
// 例如 LocalMedia 里面返回三种path
// 1.media.getPath(); 为原图path
// 2.media.getCutPath();为裁剪后path需判断media.isCut();是否为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);
break;
case SETTING_REQUEST_CODE:
init();
case PictureConfig.TYPE_VIDEO:
selectList = PictureSelector.obtainMultipleResult(data);
model.setTimeHourVideoPath(selectList.get(0).getPath());
break;
}
}
}
protected void setBackGroundColor(Integer color){
if(null==color)
protected void setBackGroundColor(Integer color) {
if (null == color)
return;
themeUIContainer.setBackgroundColor(color);
}
public void nextBackGroundAnimator(){
boolean randomColor=globalViewModel.getBackgroundAnimatorRandomColor();
if(!randomColor&&backGroundAnimator!=null) {
public void nextBackGroundAnimator() {
boolean randomColor = globalViewModel.getBackgroundAnimatorRandomColor();
if (!randomColor && backGroundAnimator != null) {
globalViewModel.setBackgroundAnimatorRandomColor(true);
backGroundAnimator.setRandColor(true);
animatorView.setAnimator(backGroundAnimator);
}else {
} else {
globalViewModel.setBackgroundAnimatorRandomColor(false);
globalViewModel.setBackgroundAnimatorName(animatorManager.next());
}
}
public void changeBackGroundAnimator(String animatorName,boolean randomColor){
backGroundAnimator= animatorManager.configByName(animatorName);
if(backGroundAnimator!=null) {
backGroundAnimator.init(animatorView.getContext(),animatorView);
public void changeBackGroundAnimator(String animatorName, boolean randomColor) {
backGroundAnimator = animatorManager.configByName(animatorName);
if (backGroundAnimator != null) {
backGroundAnimator.init(animatorView.getContext(), animatorView);
backGroundAnimator.setRandColor(randomColor);
}
animatorView.setAnimator(backGroundAnimator);
}
public void changeBackGroudAnimatorColor(int color){
public void changeBackGroudAnimatorColor(int color) {
animatorView.setColor(color);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(isScreenLock())
if (isScreenLock())
return super.onKeyDown(keyCode, event);
if (keyCode == KeyEvent.KEYCODE_BACK) {
if(globalViewModel.getAppConfig()) {
if (globalViewModel.getAppConfig()) {
getSupportFragmentManager().popBackStack();
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
return true;
}
if(!isFullScreen()){
if (!isFullScreen()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setTitle("温馨提示");
@ -561,10 +584,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
builder.setCancelable(true);
builder.setPositiveButton("确定", (dialog, which) -> {
MainActivity.this.finish();
MainActivity.this.finish();
});
builder.setNegativeButton("取消", (dialog, which) -> {
dialog.dismiss();
dialog.dismiss();
});
builder.create().show();
}
@ -576,9 +599,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
return super.onKeyDown(keyCode, event);
}
public void setup(){
//Intent intent = new Intent(this, SettingActivity.class);
//startActivityForResult(intent, SETTING_REQUEST_CODE);
public void setup() {
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();
}
private boolean isFullScreen(){
return themeUIViewModel.getClockUITypeEnum().getValue()== FULLSCREEN;
private boolean isFullScreen() {
return themeUIViewModel.getClockUITypeEnum().getValue() == FULLSCREEN;
}
@Override
@ -624,95 +645,10 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
showConfigThemeUI();
}
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();
}
@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()){
private void showConfigThemeUI() {
if (globalViewModel.getClockModeEnum().getValue() != ClockModeEnum.NORMAL)
return;
switch (globalViewModel.getClockInterfaceTypeEnum().getValue()) {
case Digit:
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment(themeUIManager)).addToBackStack(null).commit();
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
public boolean onDoubleTapEvent(MotionEvent e) {
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
public boolean onScaleBegin(ScaleGestureDetector detector) {
Log.d(TAG,"onScaleBegin ");
scaleSpan=detector.getCurrentSpan();
Log.d(TAG, "onScaleBegin ");
scaleSpan = detector.getCurrentSpan();
currentFontSize=digitViewModel.getTimeFontStyleSize().getValue();
//maxFontSize = fontManager.getMaxFontSize(model.isDisplaySecond());
return true;
}
@Override
public void onScaleEnd(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;
public boolean onScale(ScaleGestureDetector detector) {
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);
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;
}
public String getnum(int num1,int num2){
public String getnum(int num1, int num2) {
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后0位
numberFormat.setMaximumFractionDigits(0);
String result = numberFormat.format((float) num1 / (float) num2 * 100);
return result+"%";
return result + "%";
}
public ClockStateMachine getClockStateMachine() {
@ -802,4 +832,15 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
public AlterManager getAlterManager() {
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);
}
}

View File

@ -7,15 +7,19 @@ import com.openbravo.data.basic.BasicException;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import java.util.UUID;
import clock.socoolby.com.clock.dao.base.ThemeUI;
import clock.socoolby.com.clock.model.DigitPerferenceModel;
import clock.socoolby.com.clock.model.SharePerferenceModel;
import clock.socoolby.com.clock.model.SimulatePerferenceModel;
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
import e.odbo.data.dao.EntityManager;
import e.odbo.data.dsl.query.QBF;
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.FULLSCREEN;
public class ThemeUIManager{
public static final String TAG = ThemeUIManager.class.getSimpleName();
@ -24,11 +28,14 @@ public class ThemeUIManager{
SharePerferenceModel model;
FontManager fontManager;
private String tempThemeStr=null;
public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model) {
public ThemeUIManager(EntityManager entityManager,SharePerferenceModel model,FontManager fontManager) {
this.entityManager = entityManager;
this.model=model;
this.fontManager=fontManager;
}
public void loadDigitThemeFromDB(String name) throws BasicException {
@ -75,6 +82,7 @@ public class ThemeUIManager{
ThemeUI themeUI=findThemeUIFromDB(name,ClockInterfaceTypeEnum.Digit.code);
if(themeUI==null){
themeUI=new ThemeUI();
themeUI.setId(UUID.randomUUID().toString());
themeUI.setName(name);
themeUI.setClockType(ClockInterfaceTypeEnum.Digit.code);
themeUI.setConfigText(makeSaveDigitThemeString(model.getDigitPerferenceModel()));
@ -100,6 +108,7 @@ public class ThemeUIManager{
ThemeUI themeUI=findThemeUIFromDB(name,ClockInterfaceTypeEnum.Simulate.code);
if(themeUI==null){
themeUI=new ThemeUI();
themeUI.setId(UUID.randomUUID().toString());
themeUI.setName(name);
themeUI.setClockType(ClockInterfaceTypeEnum.Simulate.code);
themeUI.setConfigText(makeSaveSimulateThemeString(model.getSimulatePerferenceModel()));
@ -154,4 +163,20 @@ public class ThemeUIManager{
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;
}
}

View File

@ -7,7 +7,6 @@ import e.odbo.data.model.DataBase;
import e.odbo.data.model.Table;
import e.odbo.data.model.TableData;
import e.odbo.data.model.smaple.PK;
import e.odbo.data.model.smaple.TimeLogAble;
public class WorkClockDatabase extends DataBase {
public WorkClockDatabase() {

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -35,6 +35,7 @@ import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
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.widget.textview.ShadowTypeEnum;
import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
@ -47,7 +48,7 @@ public class DigitClockConfigFragment extends Fragment {
DigitViewModel digitViewModel;
GlobalViewModel globalViewModel;
ThemeUIViewModel themeUIViewModel;
ThemeUIManager themeUIManager;
@BindView(R.id.tv_hourSystem12)
@ -146,6 +147,7 @@ public class DigitClockConfigFragment extends Fragment {
super.onCreate(savedInstanceState);
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.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);
globalViewModel.setAppConfig(true);
}
@ -164,7 +166,8 @@ public class DigitClockConfigFragment extends Fragment {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
getFragmentManager().popBackStack();
//getFragmentManager().popBackStack();
themeUIViewModel.loadFromModel();
return true;
}
});

View File

@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -28,6 +29,7 @@ import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
* create an instance of this fragment.
*/
public class DigitClockFragment extends Fragment {
public static final String TAG=DigitClockFragment.class.getName();
public DigitClockFragment() {
// Required empty public constructor
@ -41,6 +43,7 @@ public class DigitClockFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"onCreate..");
digitViewModel= ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(DigitViewModel.class);
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
}

View File

@ -1,16 +1,20 @@
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.animator.FerrisWheelAnimator;
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
import clock.socoolby.com.clock.widget.animatorview.animator.WindmillAnimator;
public final class HourAnimatorFactory {
public static final String DEFAULT="default";
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;
switch (typeName){
case FerrisWheelAnimator.NAME:
@ -18,6 +22,8 @@ public final class HourAnimatorFactory {
case FishAnimator.NAME:
animator=new FishAnimator(hour>12?hour-12:hour);
break;
case HourVideoFragment.NAME:
return new HourVideoFragment(hour);
default:
animator=new WindmillAnimator(hour>12?hour-12:hour);
}

View File

@ -1,48 +1,32 @@
package clock.socoolby.com.clock.fragment.houranimator;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.R;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
import clock.socoolby.com.clock.fragment.AbstractAnimatorFragment;
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
/**
* A simple {@link Fragment} subclass.
*/
public class HourAnimatorFragment extends Fragment {
GlobalViewModel globalViewModel;
AnimatorView animatorView;
public class HourAnimatorFragment extends AbstractAnimatorFragment {
private int animatorDialy;
I_Animator hourAnimator;
Observer<Boolean> heartbeatObserver;
public HourAnimatorFragment(I_Animator hourAnimator) {
this.hourAnimator=hourAnimator;
super(hourAnimator);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
globalViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.class);
heartbeatObserver=new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
@ -62,11 +46,9 @@ public class HourAnimatorFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
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();
Log.d("hourAnimator fragment","on create animator view width:"+animatorView.getWidth());
hourAnimator.init(getActivity(),animatorView);
animatorView.setAnimator(hourAnimator);
//Log.d("animator fragment","on create animator view width:"+animatorView.getWidth());
return view;
}
@ -75,7 +57,6 @@ public class HourAnimatorFragment extends Fragment {
public void onResume() {
super.onResume();
globalViewModel.getHeartbeat().observe(getActivity(),heartbeatObserver);
animatorView.start();
}
@ -83,12 +64,10 @@ public class HourAnimatorFragment extends Fragment {
public void onPause() {
super.onPause();
globalViewModel.getHeartbeat().removeObserver(heartbeatObserver);
animatorView.pause();
}
private void bindViewModel(){
protected void bindViewModel(){
animatorDialy=globalViewModel.getTimeHourAnimatordialy().getValue();
globalViewModel.getForegroundColor().observe(getActivity(), new Observer<Integer>() {
@Override
public void onChanged(Integer integer) {

View File

@ -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();
}
}

View File

@ -28,6 +28,7 @@ import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
import clock.socoolby.com.clock.utils.DialogUtils;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
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.widget.animatorview.animator.clockanimator.pointer.DefaultPointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafPointer;
@ -45,8 +46,11 @@ public class SimulateClockConfigFragment extends Fragment {
ThemeUIManager themeUIManager;
SimulateViewModel simulateViewModel;
GlobalViewModel globalViewModel;
ThemeUIViewModel themeUIViewModel;
@BindView(R.id.tv_simulate_color_pointer)
Button tvSimulateColorPointer;
@BindView(R.id.tv_simulate_color_scale)
@ -111,6 +115,7 @@ public class SimulateClockConfigFragment extends Fragment {
super.onCreate(savedInstanceState);
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(GlobalViewModel.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);
globalViewModel.setAppConfig(true);
}
@ -129,7 +134,8 @@ public class SimulateClockConfigFragment extends Fragment {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
getFragmentManager().popBackStack();
//getFragmentManager().popBackStack();
themeUIViewModel.loadFromModel();
return true;
}
});
@ -278,7 +284,6 @@ public class SimulateClockConfigFragment extends Fragment {
String styleName = "simulate_style_" + order;
try {
if (themeUIManager.exitsThemeUIStyle(ClockInterfaceTypeEnum.Simulate.code, styleName)) {
themeUIManager.loadSimulateThemeFromDB(styleName);
reloadViewModel();
} else {
@ -314,7 +319,8 @@ public class SimulateClockConfigFragment extends Fragment {
private void reloadViewModel(){
globalViewModel.loadFromModel();
simulateViewModel.loadFromModel();
//simulateViewModel.loadFromModel();
//loadForViewModel();
}
private void bindViewModel() {

View File

@ -1,4 +1,4 @@
package clock.socoolby.com.clock.fragment;
package clock.socoolby.com.clock.fragment.system;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
@ -18,16 +18,23 @@ import android.widget.RadioGroup;
import androidx.fragment.app.Fragment;
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.ActivateAdmin;
import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.Constants;
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.SharePerferenceModel;
import clock.socoolby.com.clock.utils.FuncUnit;
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
import clock.socoolby.com.clock.widget.wheelview.WheelView;
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_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;
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_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_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() {
@Override
@ -92,37 +133,39 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
}
});
cb_trigger_screen = themeRootView.findViewById(R.id.cb_trigger_screen);
cb_trigger_screen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
cb_boot_start.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
model.setTriggerScreen(isChecked);
model.setBootStart(isChecked);
}
});
btn_uninstall = themeRootView.findViewById(R.id.btn_uninstall);
btn_uninstall.setOnClickListener(this);
btn_about = themeRootView.findViewById(R.id.btn_about);
btn_about.setOnClickListener(this);
rg_clock_hour_animator_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
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_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;
}
btn_clock_hour_video.setOnClickListener(this);
ArrayWheelAdapter<String> timeAdpater = new ArrayWheelAdapter<String>(getContext(), listTime);
weel_startTime.setViewAdapter(timeAdpater);
ArrayWheelAdapter<String> durationAdapter = new ArrayWheelAdapter<String>(getContext(), listTime);
weel_stopTime.setViewAdapter(durationAdapter);
loadDataFromModel();
rg_taking_clock.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int index) {
@ -143,7 +186,6 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
}
});
return themeRootView;
}
@ -154,6 +196,14 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
}
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 stopTimeIndex = indexOfTimeString(String.format("%02d:%02d", model.getStopHourPowerTime().getHour(), model.getStopHourPowerTime().getMinute()));
weel_startTime.setCurrentItem(startTimeIndex);
@ -176,6 +226,23 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
}
et_city.setText(model.getCity());
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() {
@ -230,6 +297,18 @@ public class SystemAppConfigFragment extends Fragment implements View.OnClickLi
saveToModel();
getFragmentManager().popBackStack();
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);
}
}

View File

@ -1,4 +1,4 @@
package clock.socoolby.com.clock.fragment;
package clock.socoolby.com.clock.fragment.theme;
import android.annotation.TargetApi;
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.MainActivity;
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.SharePerferenceModel;
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.WeatherPopup;
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.ClockTimeTypeEnum;
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 TextView tv_hand_time;
//private boolean hand_time_visable=true;
private ImageButton tv_screen_lock;
ColorPickerPop colorPickerDialog;
@ -142,8 +140,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
public boolean onLongClick(View v) {
if (isScreenLock())
return true;
model.setHourSystem12(!model.isHourSystem12());
globalViewModel.setHourSystem12(model.isHourSystem12());
globalViewModel.setHourSystem12(!model.isHourSystem12());
return true;
}
});
@ -333,6 +330,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
@Override
public void onChanged(Boolean handUpAbla) {
if(handUpAbla) {
globalViewModel.getHandUpTime().setValue(model.getHandUpTime());
tv_handup.setColorFilter(globalViewModel.getForegroundColor().getValue());
tv_hand_time.setVisibility(View.VISIBLE);
}else{
@ -398,22 +396,15 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
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() {
int saveHandUpTime=model.getHandUpTime();
int hour=0;
int minute=0;
if(handUpTimePopup1==null) {
handUpTimePopup1 = new TimeSetupPopup(mainActivity);
handUpTimePopup1.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
TimeSetupPopup handUpTimePopup1 = new TimeSetupPopup();
handUpTimePopup1.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
@Override
public void onChanged(int hour, int minute, Uri uri, String s, String hundUpStyle) {
if (hour == 0 && minute == 0) {
@ -429,13 +420,13 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
}
}
});
}
if(saveHandUpTime>0){
hour=saveHandUpTime/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.showNow(getFragmentManager(),"test");
handUpTimePopup1.showNow(getFragmentManager(),null);
}
private void setupTempHandUpTime() {
@ -489,6 +480,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
}else{
handUpAbla=!handUpAbla;
globalViewModel.setHandUpAble(handUpAbla);
themeUIViewModel.setDescription(FamousQuotesManager.roundAutoQuotes());
}
break;
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;
}
public void configThemeUITypeWithNoFullScreen(){
if(globalViewModel.getClockInterfaceTypeEnum().getValue()==ClockInterfaceTypeEnum.Digit)
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.NORMAL);
else
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.SETTING);
}
public void screenLock(boolean locked) {
tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);

View File

@ -1,4 +1,4 @@
package clock.socoolby.com.clock.fragment;
package clock.socoolby.com.clock.fragment.theme;
import clock.socoolby.com.clock.R;
@ -12,7 +12,6 @@ public class ThemeUIDefaultFragment extends AbstractThemeUIFragment {
@Override
void changeThemeTypeCheck() {
themeUIViewModel.getThemeName().setValue(ThemeUISampleFragment.THEME_NAME);
themeUIViewModel.setThemeName(ThemeUISampleFragment.THEME_NAME);
}
}

View File

@ -1,4 +1,4 @@
package clock.socoolby.com.clock.fragment;
package clock.socoolby.com.clock.fragment.theme;
import clock.socoolby.com.clock.R;
@ -12,6 +12,6 @@ public class ThemeUISampleFragment extends AbstractThemeUIFragment {
@Override
void changeThemeTypeCheck() {
themeUIViewModel.getThemeName().setValue(ThemeUIDefaultFragment.THEME_NAME);
themeUIViewModel.setThemeName(ThemeUIDefaultFragment.THEME_NAME);
}
}

View File

@ -9,6 +9,10 @@ public class DigitPerferenceModel {
protected final static String KEY_FONT_NAME = "key_font_name";
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 boolean linearGradientAble = false;
@ -43,7 +47,7 @@ public class DigitPerferenceModel {
protected Integer charBackgroundBorderDividerStrokeWidth=10;
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 Integer subscriptFontScale=40;
@ -63,11 +67,12 @@ public class DigitPerferenceModel {
shadowType=jsonObject.optInt(KEY_TIME_TEXT_SHADOW_TYPE,0);
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
fontStyleSize =jsonObject.optInt(KEY_FONT_STYLE_SIZE,100);
displaySecond = jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND,false);
timeTextSecondSubscript=jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,true);
charBackgroundBorder=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER,false);
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);
charBackgroundBorderDividerStrokeWidth=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_DIVIDER_STROKE_WIDTH, 10);
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_CHAR_ANIMATOR_TYPE,timeTextCharAnimatorType);
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_SUBSCRIPT,timeTextSecondSubscript);
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER,charBackgroundBorder);
@ -245,4 +251,12 @@ public class DigitPerferenceModel {
public void setCharBackgroundBorderWithDoubble(boolean charBackgroundBorderWithDoubble) {
this.charBackgroundBorderWithDoubble = charBackgroundBorderWithDoubble;
}
public Integer getFontStyleSize() {
return fontStyleSize;
}
public void setFontStyleSize(Integer fontStyleSize) {
this.fontStyleSize = fontStyleSize;
}
}

View File

@ -10,9 +10,7 @@ import java.io.Serializable;
import java.util.Timer;
import java.util.TimerTask;
import clock.socoolby.com.clock.ClockApplication;
import clock.socoolby.com.clock.Constants;
import clock.socoolby.com.clock.R;
import clock.socoolby.com.clock.utils.FileUtils;
public class SharePerferenceModel implements Serializable {
@ -21,6 +19,9 @@ public class SharePerferenceModel implements Serializable {
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 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 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 String mCity="jinhua";
@ -76,6 +81,7 @@ public class SharePerferenceModel implements Serializable {
protected final static String KEY_BACKGROUND_IMAGE="key_background_image";
protected String backgroundImage="";
protected final static String KEY_BACKGROUND_ANIMATOR="key_background_animator";
protected String backgroundAnimatorName="";
@ -207,6 +213,8 @@ public class SharePerferenceModel implements Serializable {
}
public String getDescription() {
if(mDescription.isEmpty())
return Constants.APP_MEMO;
return mDescription;
}
@ -218,12 +226,13 @@ public class SharePerferenceModel implements Serializable {
protected void fromJsonString(String jsonString) {
try {
JSONObject jsonObject = new JSONObject(jsonString);
firstStart=jsonObject.optBoolean(KEY_FIRST_START,true);
typeHourPower = jsonObject.getInt(KEY_TYPE_HOUR_POWER);
tickSound = jsonObject.getBoolean(KEY_IS_TICK_SOUND);
triggerScreen =jsonObject.optBoolean(KEY_IS_TRIGGER_SCREEN,true);
mCity = jsonObject.optString(KEY_CITY,"jinhua");
mDescription = jsonObject.optString(KEY_DESCRPTION, ClockApplication.getContext().getResources().getString(R.string.always_zuo_never_die));
mDescription = jsonObject.optString(KEY_DESCRPTION, "");
startHourPowerTime = new DateModel();
startHourPowerTime.setDataString(jsonObject.getString(KEY_START_POWER));
stopHourPowerTime = new DateModel();
@ -232,6 +241,8 @@ public class SharePerferenceModel implements Serializable {
timeHourAlterTypeName=jsonObject.optString(KEY_TIME_HOUR_ALTER_TYPE_NAME,"default");
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);
handUpTime=jsonObject.optInt(KEY_HANDUP_TIME,-1);
handUpMusic=jsonObject.optString(KEY_HANDUP_MUSIC,"");
@ -267,6 +278,7 @@ public class SharePerferenceModel implements Serializable {
protected String toJsonString() {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put(KEY_FIRST_START,firstStart);
jsonObject.put(KEY_TYPE_HOUR_POWER, typeHourPower);
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_DIALY,timeHourAlterDialy);
jsonObject.put(KEY_TIME_HOUR_VIDEO_PATH,timeHourVideoPath);
digitPerferenceModel.toJsonString(jsonObject);
@ -518,6 +531,7 @@ public class SharePerferenceModel implements Serializable {
public void setTimeHourAlterTypeName(String timeHourAlterTypeName) {
this.timeHourAlterTypeName = timeHourAlterTypeName;
dirtySave();
}
public Integer getTimeHourAlterDialy() {
@ -529,6 +543,14 @@ public class SharePerferenceModel implements Serializable {
dirtySave();
}
public String getTimeHourVideoPath() {
return timeHourVideoPath;
}
public void setTimeHourVideoPath(String timeHourVideoPath) {
this.timeHourVideoPath = timeHourVideoPath;
}
//digit
public Integer[] getTimeColorsArray() {
@ -786,4 +808,21 @@ public class SharePerferenceModel implements Serializable {
digitPerferenceModel.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble);
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;
}
}

View File

@ -137,6 +137,10 @@ public class CalendarPopup extends DialogFragment implements CalendarView.OnCale
}
protected void initData() {
}
protected void initTestData() {
int year = mCalendarView.getCurYear();
int month = mCalendarView.getCurMonth();

View File

@ -60,20 +60,16 @@ public class TimeSetupMinPopup extends BasePopupWindow {
mHourSeekbar.setCurProcess(hour);
mMinuteSeekbar.setCurProcess(minute);
mMinuteSeekbar.setMaxProcess(60);
mHourSeekbar.setMaxProcess(120);
return content;
}
public void init(int hour, int minute) {
this.hour=hour;
this.minute=minute;
if(mHourSeekbar!=null) {
mHourSeekbar.setCurProcess(hour);
mMinuteSeekbar.setCurProcess(minute);
}else{
this.hour=hour;
this.minute=minute;
}
}

View File

@ -1,5 +1,6 @@
package clock.socoolby.com.clock.pop;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
@ -28,6 +29,9 @@ import xyz.aprildown.ultimatemusicpicker.MusicPickerListener;
import xyz.aprildown.ultimatemusicpicker.UltimateMusicPicker;
public class TimeSetupPopup extends DialogFragment implements MusicPickerListener {
public static final String TAG=TimeSetupPopup.class.getName();
private CircleSeekBar mHourSeekbar;
private CircleSeekBar mMinuteSeekbar;
@ -42,8 +46,6 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
String s;
MainActivity activity;
Button musicSelect;
ImageView back;
@ -59,10 +61,6 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
ImageView ok;
public TimeSetupPopup(MainActivity activity) {
this.activity=activity;
}
@Nullable
@Override
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);
mTextView = (TextView)content.findViewById(R.id.seek_time);
mTextView.setTextColor(Color.YELLOW);
musicSelect=content.findViewById(R.id.tv_handup_time_select_Music);
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() {
@Override
public void onChanged(CircleSeekBar seekbar, int curValue) {
changeText(curValue, mMinuteSeekbar.getCurProcess());
hour=curValue;
changeText(hour,minute);
}
});
mHourSeekbar.fillInside();
mMinuteSeekbar.setOnSeekBarChangeListener(new CircleSeekBar.OnSeekBarChangeListener() {
@Override
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);
handUpAlterTypeDefault=content.findViewById(R.id.tv_huad_up_style_default);
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() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
@ -147,11 +135,27 @@ public class TimeSetupPopup extends DialogFragment implements MusicPickerListene
}
});
musicSelect.setText(s);
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
public void onActivityCreated(Bundle savedInstanceState) {
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) {
if(mHourSeekbar!=null) {
mHourSeekbar.setCurProcess(hour);
mMinuteSeekbar.setCurProcess(minute);
}else{
this.hour=hour;
this.minute=minute;
}
this.hour=hour;
this.minute=minute;
this.s=musicName;
this.uri=musicUri;
this.handUpAlterType=handUpAlterType;
}
private void changeText(int hour, int minute) {
this.hour=hour;
this.minute=minute;
int day=hour/60;
int inHour=hour;
String hourStr="";

View File

@ -24,6 +24,7 @@ import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
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;
public class ClockStateMachine implements Handler.Callback{
@ -92,8 +93,8 @@ public class ClockStateMachine implements Handler.Callback{
public boolean handleMessage(Message msg) {
switch (msg.what) {
case UPDATE_TIME:
updateTime();
checkHandUp();
updateTime();
break;
}
return true;
@ -115,6 +116,7 @@ public class ClockStateMachine implements Handler.Callback{
case COUNTING:
countingDateTimeBase =new Date();
}
updateDescription(model.getDescription());
}
public ClockTimeTypeEnum getCurrentShowTimeType(){
@ -126,29 +128,30 @@ public class ClockStateMachine implements Handler.Callback{
return globalViewModel.getClockModeEnum().getValue();
}
String timeString;
DateModel date;
private void updateTime() {
heartbeat=!heartbeat;
DateModel date = new DateModel();
date= new DateModel();
globalViewModel.setHeartbeat(heartbeat);
String timeString=null;
switch (getCurrentModeEnum()){
case NORMAL:
switch (showTimeType){
case COUNTING:
DateModel temp=new DateModel(countingDateTimeBase);
timeString=temp.getTimeString(false);
digitViewModel.setTimeText(temp.getTimeString(false));
if (!model.isTickSound()) {
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
}
break;
case COUNTING_DOWN:
timeString=DateModel.getTimeFull(globalViewModel.getHandUpTime().getValue());
digitViewModel.setTimeText(DateModel.getTimeFull(globalViewModel.getHandUpTime().getValue()));
break;
default:
timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
digitViewModel.setTimeText(timeString);
break;
}
digitViewModel.getTimeText().setValue(timeString);
break;
case HANDUP:
break;
@ -156,11 +159,10 @@ public class ClockStateMachine implements Handler.Callback{
if(countingDateTimeBase==null)
countingDateTimeBase=new Date();
DateModel temp=new DateModel(countingDateTimeBase);
timeString=temp.getTimeString(false);
digitViewModel.setTimeText(temp.getTimeString(false));
if (!model.isTickSound()) {
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
}
digitViewModel.getTimeText().setValue(timeString);
break;
}
updateDay(date);
@ -212,7 +214,7 @@ public class ClockStateMachine implements Handler.Callback{
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);
}
int year = date.getYear();
@ -282,11 +284,11 @@ public class ClockStateMachine implements Handler.Callback{
case NORMAL:
globalViewModel.getHandUpTime().setValue(handUpTime-1);
if (handUpTime <= 10&&handUpTime > 0)
themeUIViewModel.setDescription("提醒时间倒计时: " + handUpTime);
updateDescription("提醒时间倒计时: " + handUpTime);
if (handUpTime == 0) {
globalViewModel.getHandUpTime().setValue(model.getHandUpTime());
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.HANDUP);
themeUIViewModel.setDescription(model.getDescription());
globalViewModel.getClockModeEnum().setValue(HANDUP);
updateDescription(model.getDescription());
}
break;
case HANDUP:
@ -298,4 +300,8 @@ public class ClockStateMachine implements Handler.Callback{
break;
}
}
private void updateDescription(String desc){
themeUIViewModel.setDescription(desc);
}
}

View File

@ -26,6 +26,8 @@ public class Player {
private boolean isReporttime = false;
private boolean playAble=true;
public static Player getInstance() {
if (playerInstance == null) {
synchronized (Player.class) {
@ -95,13 +97,16 @@ public class Player {
});
mediaPlayer.start();
} catch (IOException ioe) {
if(mediaPlayer!=null)
mediaPlayer.release();
mediaPlayer = null;
ioe.printStackTrace();
}
}
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;
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>();
@ -164,27 +169,28 @@ public class Player {
}
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()))
return;
if (!isReporttime) {
playSoundWithRawId(activity,tick_type_id);
}
playSoundWithRawId(activity,tick_type_id);
}
private AssetFileDescriptor soundFile = null;
private Map<Integer,AssetFileDescriptor> soundFileCache=new HashMap<>();
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()))
return;
if (!isReporttime) {
playSoundWithRawId(activity, R.raw.handup_didi);
}
playSoundWithRawId(activity, R.raw.handup_didi);
}
public void playSoundWithRawId(Context activity,int soundId){
if (mediaPlayer == null)
mediaPlayer = buildMediaPlayer();
soundFile =soundFileCache.get(soundId);
@ -206,19 +212,24 @@ public class Player {
});
mediaPlayer.start();
} catch (IOException ioe) {
if(mediaPlayer!=null)
mediaPlayer.release();
mediaPlayer = null;
ioe.printStackTrace();
}
}
private static MediaPlayer buildMediaPlayer() {
MediaPlayer mediaPlayer = MediaPlayer.create(ClockApplication.getContext(), R.raw.tick);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
return mediaPlayer;
}
boolean isPlaying=false;
public void playRing(Context activity, Uri uri){
if(!playAble)
return;
if (mediaPlayer == null) {
mediaPlayer = buildMediaPlayer();
isPlaying=false;
@ -243,8 +254,11 @@ public class Player {
isPlaying=true;
mediaPlayer.start();
} catch (IOException ioe) {
if(mediaPlayer!=null)
mediaPlayer.release();
mediaPlayer = null;
isPlaying=false;
ioe.printStackTrace();
}
}
@ -255,4 +269,18 @@ public class Player {
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;
}
}
}

View File

@ -64,7 +64,7 @@ public class DigitViewModel extends ViewModel {
shadowType.setValue(ShadowTypeEnum.valueOf(model.getShadowType()));
timeCharAnimatorType.setValue(CharAnimatorEnum.valueOf(model.getTimeTextCharAnimatorType()));
baseLineDown.setValue(model.getBaseLineDown());
timeFontStyleSize.setValue(100);
timeFontStyleSize.setValue(model.getFontStyleSize());
timeFontName.setValue(model.getFontName());
secondSubscript.setValue(model.isTimeTextSecondSubscript());
charBackgroundBorder.setValue(model.isCharBackgroundBorder());
@ -148,6 +148,7 @@ public class DigitViewModel extends ViewModel {
public void setTimeFontStyleSize(Integer timeFontStyleSize) {
this.timeFontStyleSize.setValue(timeFontStyleSize);
//model.setFontStyleSize(timeFontStyleSize);
}
public void setShadowType(ShadowTypeEnum shadowType) {

View File

@ -17,13 +17,13 @@ public class GlobalViewModel extends ViewModel {
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 Boolean backgroundAnimatorRandomColor=false;
private Boolean backgroundAnimatorRandomColor=false;
private MutableLiveData<ClockInterfaceTypeEnum> clockInterfaceTypeEnum =new MutableLiveData<>();
@ -31,14 +31,14 @@ public class GlobalViewModel extends ViewModel {
private MutableLiveData<Boolean> backgroundImageVisable=new MutableLiveData<>();
private MutableLiveData<Boolean> autoFullScreen=new MutableLiveData<>();
private MutableLiveData<Boolean> autoFullScreen=new MutableLiveData<>();
//system
private Boolean tickSound=false;
private Boolean appConfig=false;
private MutableLiveData<String> mCity=new MutableLiveData<>();
private MutableLiveData<String> mCity=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> hourAlterTypeName=new MutableLiveData<>();
private MutableLiveData<String> hourAlterTypeName=new MutableLiveData<>();
private MutableLiveData<Boolean> timeHourAnimatorStarting =new MutableLiveData<>();
private MutableLiveData<Integer> timeHourAnimatordialy=new MutableLiveData<>();
//state
private MutableLiveData<ClockModeEnum> clockModeEnum=new MutableLiveData<>();
@ -64,20 +65,26 @@ public class GlobalViewModel extends ViewModel {
private MutableLiveData<Integer> time_hour=new MutableLiveData<>();
private MutableLiveData<Date> time_day=new MutableLiveData<>();
private MutableLiveData<Date> time_day=new MutableLiveData<>();
SharePerferenceModel model;
public GlobalViewModel(SharePerferenceModel model) {
this.model = model;
init();
loadFromModel();
}
public void loadFromModel(){
private void init(){
srceenLock.setValue(false);
brightness.setValue(100);
heartbeat.setValue(true);
appConfig=false;
clockModeEnum.setValue(ClockModeEnum.NORMAL);
timeHourAnimatorStarting.setValue(false);
}
public void loadFromModel(){
mCity.setValue(model.getCity());
backgroundColor.setValue(model.getBackgroundColor());
foregroundColor.setValue(model.getForegroundColor());
@ -88,28 +95,16 @@ public class GlobalViewModel extends ViewModel {
backgroundAnimatorName.setValue(model.getBackgroundAnimatorName());
backgroundAnimatorColor.setValue(model.getForegroundColor1());
backgroundAnimatorRandomColor=model.isBackgroundAnimatorRandomColor();
clockInterfaceTypeEnum.setValue(ClockInterfaceTypeEnum.valueOf(model.getClockInterfaceType()));
autoFullScreen.setValue(model.isAutoFullscreen());
clockModeEnum.setValue(ClockModeEnum.NORMAL);
handUpAble.setValue(model.isHandUpAble());
handUpTime.setValue(model.getHandUpTime());
handUpTypeName.setValue(model.getHandUpTypeName());
hourSystem12.setValue(model.isHourSystem12());
hourAlterTypeName.setValue(model.getTimeHourAlterTypeName());
time_hour.setValue(new Date().getHours());
timeHourAnimatorStarting.setValue(false);
timeHourAnimatordialy.setValue(model.getTimeHourAlterDialy());
appConfig=false;
}
public MutableLiveData<String> getCity() {
@ -189,6 +184,11 @@ public class GlobalViewModel extends ViewModel {
return handUpAble;
}
public void setHandUpTime(Integer handUpTime) {
this.handUpTime.setValue(handUpTime);
//model.setHandUpTime(handUpTime);
}
public void setCity(String mCity) {
this.mCity.setValue(mCity);
@ -207,6 +207,7 @@ public class GlobalViewModel extends ViewModel {
public void setBackgroundImageUri(Uri backgroundImageUri) {
this.backgroundImageUri.setValue(backgroundImageUri);
model.setBackgroundImage(backgroundImageUri.toString());
}
public void setBackgroundAnimatorName(String backgroundAnimatorName) {
@ -271,10 +272,6 @@ public class GlobalViewModel extends ViewModel {
model.setAutoFullscreen(autoFullScreen);
}
public void setHandUpTime(Integer handUpTime) {
this.handUpTime.setValue(handUpTime);
//model.setHandUpTime(handUpTime);
}
public void setHandUpAble(Boolean handUpAble) {
this.handUpAble.setValue(handUpAble);
@ -331,4 +328,8 @@ public class GlobalViewModel extends ViewModel {
public void setAppConfig(Boolean appConfig) {
this.appConfig = appConfig;
}
public String getTimeHourVideoPath(){
return model.getTimeHourVideoPath();
}
}

View File

@ -29,7 +29,7 @@ public class ThemeUIViewModel extends ViewModel {
loadFromModel();
}
private void loadFromModel(){
public void loadFromModel(){
description.setValue(model.getDescription());
themeName.setValue(model.getThemeName());
@ -42,6 +42,10 @@ public class ThemeUIViewModel extends ViewModel {
return description;
}
public void setDescription(String description) {
this.description.setValue(description);
}
public MutableLiveData<ClockThemeUITypeEnum> getClockUITypeEnum() {
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) {
this.clockUITypeEnum.setValue(clockUITypeEnum);
model.setThemeUIType(clockUITypeEnum.code);

View File

@ -78,6 +78,8 @@ public class AnimatorView extends View {
if(animator!=null) {
animator.setColor(color);
animator.start();
}else{
invalidate();
}
}

View File

@ -29,7 +29,7 @@ import clock.socoolby.com.clock.widget.textview.charanimator.Up2DownCharAnimator
public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
public static final String Tag = DigitTextView.class.getSimpleName();
float baseLineDown = 0;
float baseLineDownScale = 0;
private LinearGradient mLinearGradient;
@ -116,7 +116,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
}
public void setBaseLineDown(float baseLineDown) {
this.baseLineDown =getHeight()/2*(-baseLineDown/100);
this.baseLineDownScale =baseLineDown;
layoutReflushAble=true;
}
@ -254,6 +254,8 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
textSubscriptSpan = textSubscriptSpan + subscriptCharWidth * 2;
}
layoutReflushAble=false;
}
@ -282,7 +284,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
layoutReflush(textToDraw);
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++) {
charStr = String.valueOf(textToDraw.charAt(i));

View 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>

View File

@ -48,13 +48,61 @@
android:text="@string/no_report" />
</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
android:id="@+id/tv_except"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="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:text="@string/except" />
@ -78,6 +126,7 @@
</RelativeLayout>
<TextView
android:id="@+id/tv_tick_title"
android:layout_width="match_parent"
@ -109,11 +158,26 @@
android:text="@string/trigger_screen_on_off" />
<TextView
android:id="@+id/tv_weather_title"
android:id="@+id/tv_boot_start_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cb_trigger_screen"
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" />
<EditText

View File

@ -16,33 +16,30 @@
android:id="@+id/seek_hour"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:wheel_max_process="59"
android:layout_centerInParent="true"
app:wheel_max_process="120"
app:wheel_unreached_width="32dp" />
<io.feeeei.circleseekbar.CircleSeekBar
android:id="@+id/seek_minute"
android:layout_width="236dp"
android:layout_height="236dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
app:wheel_max_process="11"
android:layout_centerInParent="true"
app:wheel_max_process="59"
app:wheel_pointer_color="@color/colorPrimaryDark"
app:wheel_pointer_radius="8dp"
app:wheel_reached_color="@color/colorAccent"
app:wheel_reached_width="32dp"
app:wheel_unreached_color="@color/colorPrimary" />
<TextView
android:id="@+id/seek_time"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:gravity="center"
android:textSize="18sp" />
android:textSize="22sp" />
</RelativeLayout>
<ImageView

View File

@ -11,7 +11,7 @@
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
app:wheel_max_process="59"
app:wheel_max_process="120"
app:wheel_unreached_width="32dp" />
<io.feeeei.circleseekbar.CircleSeekBar
@ -19,7 +19,7 @@
android:layout_width="236dp"
android:layout_height="236dp"
android:layout_centerInParent="true"
app:wheel_max_process="11"
app:wheel_max_process="59"
app:wheel_pointer_color="@color/colorPrimaryDark"
app:wheel_pointer_radius="8dp"
app:wheel_reached_color="@color/colorAccent"

Binary file not shown.

BIN
workclock20190717.apk Normal file

Binary file not shown.