mirror of
https://gitee.com/51danju/workclock.git
synced 2025-06-19 17:02:41 +08:00
增加时钟详细设置界面
This commit is contained in:
parent
5d7da6d793
commit
b04b7d043a
@ -20,8 +20,8 @@ android {
|
|||||||
productFlavors {
|
productFlavors {
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = '1.7'
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = '1.7'
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
exclude 'META-INF/DEPENDENCIES'
|
exclude 'META-INF/DEPENDENCIES'
|
||||||
@ -67,4 +67,7 @@ dependencies {
|
|||||||
implementation 'org.sqldroid:sqldroid:1.1.0-rc1'
|
implementation 'org.sqldroid:sqldroid:1.1.0-rc1'
|
||||||
|
|
||||||
implementation "com.github.DeweyReed:UltimateMusicPicker:2.0.4"
|
implementation "com.github.DeweyReed:UltimateMusicPicker:2.0.4"
|
||||||
|
|
||||||
|
implementation 'com.jakewharton:butterknife:10.1.0'
|
||||||
|
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import clock.socoolby.com.clock.alter.AlterManager;
|
import clock.socoolby.com.clock.alter.AlterManager;
|
||||||
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
||||||
|
import clock.socoolby.com.clock.fragment.AlterFragment;
|
||||||
|
import clock.socoolby.com.clock.fragment.DigitClockConfigFragment;
|
||||||
import clock.socoolby.com.clock.fragment.DigitClockFragment;
|
import clock.socoolby.com.clock.fragment.DigitClockFragment;
|
||||||
|
import clock.socoolby.com.clock.fragment.SimulateClockConfigFragment;
|
||||||
import clock.socoolby.com.clock.fragment.SimulateClockFragment;
|
import clock.socoolby.com.clock.fragment.SimulateClockFragment;
|
||||||
|
import clock.socoolby.com.clock.fragment.ThemeUIDefaultFragment;
|
||||||
|
import clock.socoolby.com.clock.fragment.ThemeUISampleFragment;
|
||||||
import clock.socoolby.com.clock.protocol.WeatherResponse;
|
import clock.socoolby.com.clock.protocol.WeatherResponse;
|
||||||
import clock.socoolby.com.clock.service.ProximityService;
|
import clock.socoolby.com.clock.service.ProximityService;
|
||||||
|
import clock.socoolby.com.clock.state.ClockModeEnum;
|
||||||
import clock.socoolby.com.clock.state.ClockStateMachine;
|
import clock.socoolby.com.clock.state.ClockStateMachine;
|
||||||
import clock.socoolby.com.clock.state.ClockTimeTypeEnum;
|
import clock.socoolby.com.clock.state.ClockTimeTypeEnum;
|
||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
@ -68,6 +74,7 @@ import clock.socoolby.com.clock.widget.animatorview.animator.PhaserBallAnimator;
|
|||||||
import clock.socoolby.com.clock.widget.animatorview.animator.SawtoothAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.SawtoothAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.Wave3DAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.Wave3DAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.CircleTwoClock;
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.CircleTwoClock;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.ClockFactory;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.textanimator.EZLedAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.textanimator.EZLedAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FireAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.FireAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FireworkAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.FireworkAnimator;
|
||||||
@ -115,7 +122,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
private PowerManager.WakeLock localWakeLock = null;
|
private PowerManager.WakeLock localWakeLock = null;
|
||||||
|
|
||||||
|
|
||||||
WeatherResponse weatherAdape;
|
public WeatherResponse weatherAdape;
|
||||||
|
|
||||||
private ClockTimeTypeEnum showTimeType=ClockTimeTypeEnum.TIME;
|
private ClockTimeTypeEnum showTimeType=ClockTimeTypeEnum.TIME;
|
||||||
|
|
||||||
@ -132,7 +139,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
AlterManager alterManager;
|
AlterManager alterManager;
|
||||||
|
|
||||||
ThemeUIManager themeUIManager;
|
//ThemeUIManager themeUIManager;
|
||||||
|
|
||||||
public void setWeather(WeatherResponse weather) {
|
public void setWeather(WeatherResponse weather) {
|
||||||
if (weather == null)
|
if (weather == null)
|
||||||
@ -238,13 +245,13 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
themeUIViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
|
themeUIViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(ThemeUIViewModel.class);
|
||||||
alterViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
|
alterViewModel=ViewModelProviders.of(MainActivity.this, viewModelFactory).get(AlterViewModel.class);
|
||||||
|
|
||||||
clockStateMachine=new ClockStateMachine(alterManager,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel);
|
clockStateMachine=new ClockStateMachine(alterManager,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel,alterViewModel);
|
||||||
|
|
||||||
setUpProximityService();
|
setUpProximityService();
|
||||||
|
|
||||||
bindViewModel();
|
bindViewModel();
|
||||||
|
|
||||||
themeUIManager=new ThemeUIManager(this,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel);
|
//themeUIManager=new ThemeUIManager(this,globalViewModel,digitViewModel,simulateViewModel,themeUIViewModel);
|
||||||
|
|
||||||
digitViewModel.getTimeFontStyle().setValue(fontManager.getCurrentFontStyle());
|
digitViewModel.getTimeFontStyle().setValue(fontManager.getCurrentFontStyle());
|
||||||
|
|
||||||
@ -267,6 +274,33 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
globalViewModel.getClockModeEnum().observe(this, new Observer<ClockModeEnum>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(ClockModeEnum clockModeEnum) {
|
||||||
|
switch(clockModeEnum){
|
||||||
|
case HANDUP:
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AlterFragment(clockStateMachine)).commit();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
globalViewModel.getClockInterfaceTypeEnum().setValue(globalViewModel.getClockInterfaceTypeEnum().getValue());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
themeUIViewModel.getThemeName().observe(this, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(String s) {
|
||||||
|
switch (s){
|
||||||
|
case ThemeUISampleFragment.THEME_NAME:
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new ThemeUISampleFragment()).commit();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new ThemeUIDefaultFragment()).commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
globalViewModel.getBackgroundImageVisable().observe(this, new Observer<Boolean>() {
|
globalViewModel.getBackgroundImageVisable().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean visible) {
|
public void onChanged(Boolean visible) {
|
||||||
@ -887,7 +921,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
if (e2.getX() - e1.getX() > 120) { // 从左向右滑动(左进右出)
|
if (e2.getX() - e1.getX() > 120) { // 从左向右滑动(左进右出)
|
||||||
Log.d(TAG,"left->right");
|
Log.d(TAG,"left->right");
|
||||||
if(globalViewModel.getClockInterfaceTypeEnum().getValue()== ClockInterfaceTypeEnum.Simulate){
|
if(globalViewModel.getClockInterfaceTypeEnum().getValue()== ClockInterfaceTypeEnum.Simulate){
|
||||||
simulateViewModel.setClockTypeName(CircleTwoClock.TYPE_CIRCLE_TWO);
|
simulateViewModel.setClockTypeName(ClockFactory.nextSimulateClockName(simulateViewModel.getClockTypeName().getValue()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
digitViewModel.setTimeFontStyle(fontManager.nextFont());
|
digitViewModel.setTimeFontStyle(fontManager.nextFont());
|
||||||
@ -900,21 +934,35 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTapConfirmed(MotionEvent e) {
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isShowAdvConfig=false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onDoubleTap(MotionEvent e) {
|
public boolean onDoubleTap(MotionEvent e) {
|
||||||
/*if(!isArtificialHiddle) {
|
if(globalViewModel.getClockModeEnum().getValue()!=ClockModeEnum.NORMAL)
|
||||||
tv_time.setLinearGradientRandom(!tv_time.isLinearGradientAble());
|
|
||||||
return true;
|
|
||||||
}else if(clockAnimator!=null){
|
|
||||||
clockAnimator.randPointer();
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
return false;
|
return false;
|
||||||
|
switch (globalViewModel.getClockInterfaceTypeEnum().getValue()){
|
||||||
|
case Digit:
|
||||||
|
if(!isShowAdvConfig)
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new DigitClockConfigFragment()).addToBackStack(null).commit();
|
||||||
|
else
|
||||||
|
getSupportFragmentManager().popBackStack();
|
||||||
|
isShowAdvConfig=!isShowAdvConfig;
|
||||||
|
break;
|
||||||
|
case Simulate:
|
||||||
|
if(!isShowAdvConfig)
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_config_container, new SimulateClockConfigFragment()).addToBackStack(null).commit();
|
||||||
|
else
|
||||||
|
getSupportFragmentManager().popBackStack();
|
||||||
|
isShowAdvConfig=!isShowAdvConfig;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -994,4 +1042,8 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
String result = numberFormat.format((float) num1 / (float) num2 * 100);
|
String result = numberFormat.format((float) num1 / (float) num2 * 100);
|
||||||
return result+"%";
|
return result+"%";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClockStateMachine getClockStateMachine() {
|
||||||
|
return clockStateMachine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,16 @@ import java.util.Timer;
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
||||||
|
import clock.socoolby.com.clock.model.DateModel;
|
||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
import clock.socoolby.com.clock.pop.CalendarPopup;
|
import clock.socoolby.com.clock.pop.CalendarPopup;
|
||||||
import clock.socoolby.com.clock.pop.ColorPickerPop;
|
import clock.socoolby.com.clock.pop.ColorPickerPop;
|
||||||
import clock.socoolby.com.clock.pop.TimeSetupPopup;
|
import clock.socoolby.com.clock.pop.TimeSetupPopup;
|
||||||
import clock.socoolby.com.clock.pop.WeatherPopup;
|
import clock.socoolby.com.clock.pop.WeatherPopup;
|
||||||
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
||||||
|
import clock.socoolby.com.clock.state.ClockStateMachine;
|
||||||
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
||||||
|
import clock.socoolby.com.clock.state.ClockTimeTypeEnum;
|
||||||
import clock.socoolby.com.clock.utils.FontUtils;
|
import clock.socoolby.com.clock.utils.FontUtils;
|
||||||
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
@ -77,13 +80,14 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
|
|
||||||
private boolean autoFullScreen=false;
|
private boolean autoFullScreen=false;
|
||||||
|
|
||||||
|
|
||||||
private int runDelaySecond=10000;
|
private int runDelaySecond=10000;
|
||||||
|
|
||||||
private boolean running=false;
|
private boolean running=false;
|
||||||
|
|
||||||
Timer timer=null;
|
Timer timer=null;
|
||||||
|
|
||||||
|
ClockStateMachine clockStateMachine;
|
||||||
|
|
||||||
private void autoFullScreenCheck(){
|
private void autoFullScreenCheck(){
|
||||||
if(!autoFullScreen)
|
if(!autoFullScreen)
|
||||||
return;
|
return;
|
||||||
@ -112,6 +116,7 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
this.mainActivity = mainActivity;
|
this.mainActivity = mainActivity;
|
||||||
this.model = ClockApplication.getInstance().getModel();
|
this.model = ClockApplication.getInstance().getModel();
|
||||||
|
|
||||||
|
this.clockStateMachine=mainActivity.getClockStateMachine();
|
||||||
bindViewModel();
|
bindViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +164,28 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
globalViewModel.getHandUpAble().observe(mainActivity, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Boolean handUpAbla) {
|
||||||
|
if(handUpAbla) {
|
||||||
|
tv_handup.setColorFilter(globalViewModel.getForegroundColor().getValue());
|
||||||
|
tv_hand_time.setVisibility(View.VISIBLE);
|
||||||
|
}else{
|
||||||
|
tv_handup.setColorFilter(R.color.colorPrimaryDark);
|
||||||
|
tv_hand_time.setVisibility(View.GONE);
|
||||||
|
if(clockStateMachine.getCurrentShowTimeType()== ClockTimeTypeEnum.COUNTING_DOWN)
|
||||||
|
clockStateMachine.setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getHandUpTime().observe(mainActivity, new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Integer handUpTime) {
|
||||||
|
tv_hand_time.setText(DateModel.getTime(handUpTime));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
themeUIViewModel.getHand_time_visable().observe(mainActivity, new Observer<Boolean>() {
|
themeUIViewModel.getHand_time_visable().observe(mainActivity, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean aBoolean) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
@ -268,7 +295,9 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
if (isScreenLock())
|
if (isScreenLock())
|
||||||
return true;
|
return true;
|
||||||
model.setHourSystem12(!model.isHourSystem12());
|
model.setHourSystem12(!model.isHourSystem12());
|
||||||
updateHourSystem();
|
globalViewModel.setHourSystem12(model.isHourSystem12());
|
||||||
|
if(model.isHourSystem12())
|
||||||
|
globalViewModel.setTime_hour(globalViewModel.getTime_hour().getValue());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -290,12 +319,7 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
tv_break.setOnLongClickListener(new View.OnLongClickListener() {
|
tv_break.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
/*if(handUpAbla){
|
clockStateMachine.handUpCountingDownCheck();
|
||||||
if(showTimeType==ShowTimeType.COUNTING_DOWN)
|
|
||||||
setCurrentShowTimeType(ShowTimeType.TIME);
|
|
||||||
else
|
|
||||||
setCurrentShowTimeType(ShowTimeType.COUNTING_DOWN);
|
|
||||||
}*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -394,18 +418,6 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
tv_screen_lock = themeRootView.findViewById(R.id.tv_screen_lock);
|
tv_screen_lock = themeRootView.findViewById(R.id.tv_screen_lock);
|
||||||
tv_screen_lock.setOnClickListener(this);
|
tv_screen_lock.setOnClickListener(this);
|
||||||
|
|
||||||
/*tv_screen_lock.setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
if(!isFullScreen()){
|
|
||||||
screenLock(true);
|
|
||||||
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.FULLSCREEN);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
tv_descript.init(mainActivity, false);
|
tv_descript.init(mainActivity, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,39 +436,23 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
tv_hours_system.setVisibility(View.GONE);
|
tv_hours_system.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//handUp
|
|
||||||
private void upHandStatic() {
|
|
||||||
/*if(handUpAbla) {
|
|
||||||
if(foregroundColor!=null)
|
|
||||||
this.tv_handup.setColorFilter(foregroundColor);
|
|
||||||
hand_time_visable=true;
|
|
||||||
this.tv_hand_time.setVisibility(View.VISIBLE);
|
|
||||||
}else{
|
|
||||||
this.tv_handup.setColorFilter(R.color.colorPrimaryDark);
|
|
||||||
this.tv_hand_time.setVisibility(View.GONE);
|
|
||||||
if(showTimeType==ShowTimeType.COUNTING_DOWN)
|
|
||||||
setCurrentShowTimeType(ShowTimeType.TIME);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupHandUpTime() {
|
private void setupHandUpTime() {
|
||||||
/*int saveHandUpTime=model.getHandUpTime();
|
int saveHandUpTime=model.getHandUpTime();
|
||||||
int hour=0;
|
int hour=0;
|
||||||
int minute=0;
|
int minute=0;
|
||||||
if(handUpTimePopup==null) {
|
if(handUpTimePopup==null) {
|
||||||
handUpTimePopup = new TimeSetupPopup(this);
|
handUpTimePopup = new TimeSetupPopup(mainActivity);
|
||||||
handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
|
handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(int hour, int minute) {
|
public void onChanged(int hour, int minute) {
|
||||||
model.setHandUpTime(hour*60+minute);
|
|
||||||
handUpAbla=true;
|
|
||||||
if(hour==0&&minute==0) {
|
if(hour==0&&minute==0) {
|
||||||
handUpAbla = false;
|
|
||||||
model.setHandUpTime(-1);
|
model.setHandUpTime(-1);
|
||||||
|
globalViewModel.setHandUpAble(false);
|
||||||
|
}else{
|
||||||
|
model.setHandUpTime(hour*60+minute);
|
||||||
|
globalViewModel.setHandUpTime(hour*60+minute);
|
||||||
|
globalViewModel.setHandUpAble(true);
|
||||||
}
|
}
|
||||||
saveData();
|
|
||||||
resetHandUpTime();
|
|
||||||
upHandStatic();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -465,7 +461,7 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
minute=saveHandUpTime-hour*60;
|
minute=saveHandUpTime-hour*60;
|
||||||
}
|
}
|
||||||
handUpTimePopup.init(hour,minute);
|
handUpTimePopup.init(hour,minute);
|
||||||
handUpTimePopup.showPopupWindow();*/
|
handUpTimePopup.showPopupWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTempHandUpTime() {
|
private void setupTempHandUpTime() {
|
||||||
@ -488,12 +484,6 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
handUpAbla=true;*/
|
handUpAbla=true;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetHandUpTime() {
|
|
||||||
/*this.handUpTime = model.getHandUpTime();
|
|
||||||
Log.d(TAG,"reset handUp time:"+handUpTime);
|
|
||||||
setDiscriptForModel();*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//Discript
|
//Discript
|
||||||
private void setDiscript(String disp) {
|
private void setDiscript(String disp) {
|
||||||
tv_descript.setText(disp);
|
tv_descript.setText(disp);
|
||||||
@ -518,14 +508,14 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
mainActivity.setup();
|
mainActivity.setup();
|
||||||
break;
|
break;
|
||||||
case R.id.tv_hand:
|
case R.id.tv_hand:
|
||||||
/*if(!handUpAbla&&handUpTime<0) {
|
int handUpTime=model.getHandUpTime();
|
||||||
|
boolean handUpAbla=isHandUpAble();
|
||||||
|
if(!handUpAbla&&handUpTime<0) {
|
||||||
setupHandUpTime();
|
setupHandUpTime();
|
||||||
}else{
|
}else{
|
||||||
handUpAbla=!handUpAbla;
|
handUpAbla=!handUpAbla;
|
||||||
upHandStatic();
|
globalViewModel.setHandUpAble(handUpAbla);
|
||||||
resetHandUpTime();
|
}
|
||||||
switchMode(MODE_NORMAL);
|
|
||||||
}*/
|
|
||||||
break;
|
break;
|
||||||
case R.id.tv_hand_time:
|
case R.id.tv_hand_time:
|
||||||
setupTempHandUpTime();
|
setupTempHandUpTime();
|
||||||
@ -546,18 +536,11 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
weatherPopup.showPopupWindow();
|
weatherPopup.showPopupWindow();
|
||||||
break;
|
break;
|
||||||
case R.id.tv_screen_lock:
|
case R.id.tv_screen_lock:
|
||||||
/*if(isFullScreen()) {
|
|
||||||
configThemeUITypeWithNoFullScreen();
|
|
||||||
}*/
|
|
||||||
globalViewModel.setSrceenLock(!isScreenLock());
|
globalViewModel.setSrceenLock(!isScreenLock());
|
||||||
screenLock(!isScreenLock());
|
screenLock(!isScreenLock());
|
||||||
break;
|
break;
|
||||||
case R.id.tv_break:
|
case R.id.tv_break:
|
||||||
/*if(showTimeType!= ClockTimeTypeEnum.COUNTING){
|
clockStateMachine.countingCheck();
|
||||||
setCurrentShowTimeType(ClockTimeTypeEnum.COUNTING);
|
|
||||||
}else{
|
|
||||||
setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
|
|
||||||
}*/
|
|
||||||
break;
|
break;
|
||||||
case R.id.tv_descript:
|
case R.id.tv_descript:
|
||||||
setDiscript(SettingActivity.roundAutoQuotes());
|
setDiscript(SettingActivity.roundAutoQuotes());
|
||||||
@ -696,7 +679,6 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isFullScreen(){
|
private boolean isFullScreen(){
|
||||||
return themeUIViewModel.getClockUITypeEnum().getValue()==ClockThemeUITypeEnum.FULLSCREEN;
|
return themeUIViewModel.getClockUITypeEnum().getValue()==ClockThemeUITypeEnum.FULLSCREEN;
|
||||||
}
|
}
|
||||||
@ -708,9 +690,6 @@ public class ThemeUIManager implements View.OnClickListener {
|
|||||||
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.SETTING);
|
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.SETTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reflushFontStyle(TimeFontStyle fontStyle) {
|
|
||||||
FontUtils.getInstance().replaceFontFromAsset(tv_date, "fonts/" + fontStyle.name + ".ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void screenLock(boolean locked) {
|
public void screenLock(boolean locked) {
|
||||||
tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);
|
tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);
|
||||||
|
@ -0,0 +1,670 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
|
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;
|
||||||
|
import clock.socoolby.com.clock.pop.ColorPickerPop;
|
||||||
|
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.DigitViewModel;
|
||||||
|
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.textview.AutoScrollTextView;
|
||||||
|
|
||||||
|
public abstract class AbstractThemeUIFragment extends Fragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
public static final String TAG= AbstractThemeUIFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
public int layoutId;
|
||||||
|
|
||||||
|
private TextView tv_date;
|
||||||
|
private TextView tv_day;
|
||||||
|
private TextView tv_weather;
|
||||||
|
private AutoScrollTextView tv_descript;
|
||||||
|
private ImageButton tv_setting;
|
||||||
|
private ImageButton tv_handup;
|
||||||
|
|
||||||
|
private ImageButton tv_hours_system;
|
||||||
|
private ImageButton tv_background_image_hand;
|
||||||
|
private ImageButton tv_break;
|
||||||
|
|
||||||
|
private ImageButton tv_clock_interface;
|
||||||
|
|
||||||
|
//颜色相关
|
||||||
|
private ImageButton tv_background_color;
|
||||||
|
private ImageButton tv_foreground_color;
|
||||||
|
private ImageButton tv_foreground_color1;
|
||||||
|
|
||||||
|
private TextView tv_hand_time;
|
||||||
|
//private boolean hand_time_visable=true;
|
||||||
|
private ImageButton tv_screen_lock;
|
||||||
|
|
||||||
|
ColorPickerPop colorPickerDialog;
|
||||||
|
TimeSetupPopup handUpTimePopup;
|
||||||
|
CalendarPopup calendarPopup;
|
||||||
|
WeatherPopup weatherPopup;
|
||||||
|
|
||||||
|
GlobalViewModel globalViewModel;
|
||||||
|
DigitViewModel digitViewModel;
|
||||||
|
SimulateViewModel simulateViewModel;
|
||||||
|
ThemeUIViewModel themeUIViewModel;
|
||||||
|
|
||||||
|
MainActivity mainActivity;
|
||||||
|
|
||||||
|
public AbstractThemeUIFragment(int layoutId){
|
||||||
|
this.layoutId=layoutId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
this.globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(GlobalViewModel.class);
|
||||||
|
this.digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(DigitViewModel.class);
|
||||||
|
this.simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(SimulateViewModel.class);
|
||||||
|
this.themeUIViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(ThemeUIViewModel.class);
|
||||||
|
this.mainActivity = (MainActivity)getActivity();
|
||||||
|
this.model = ClockApplication.getInstance().getModel();
|
||||||
|
this.clockStateMachine=mainActivity.getClockStateMachine();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View themeRootView=inflater.inflate(layoutId, container, false);
|
||||||
|
|
||||||
|
tv_background_image_hand = themeRootView.findViewById(R.id.tv_background_image_hand);
|
||||||
|
tv_background_image_hand.setOnClickListener(this);
|
||||||
|
tv_background_image_hand.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
mainActivity.configBackGroundImage();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_date = themeRootView.findViewById(R.id.tv_date);
|
||||||
|
tv_date.setOnClickListener(this);
|
||||||
|
tv_date.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
changeThemeTypeCheck();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_day = themeRootView.findViewById(R.id.tv_day);
|
||||||
|
tv_day.setOnClickListener(this);
|
||||||
|
tv_day.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (isScreenLock())
|
||||||
|
return true;
|
||||||
|
model.setHourSystem12(!model.isHourSystem12());
|
||||||
|
globalViewModel.setHourSystem12(model.isHourSystem12());
|
||||||
|
if(model.isHourSystem12())
|
||||||
|
globalViewModel.setTime_hour(globalViewModel.getTime_hour().getValue());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_weather = themeRootView.findViewById(R.id.tv_weather);
|
||||||
|
tv_weather.setOnClickListener(this);
|
||||||
|
tv_descript = themeRootView.findViewById(R.id.tv_descript);
|
||||||
|
tv_descript.setOnClickListener(this);
|
||||||
|
tv_descript.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
//changeBackGroundAnimator(ANIMATOR_TEXTLED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_break = themeRootView.findViewById(R.id.tv_break);
|
||||||
|
tv_break.setOnClickListener(this);
|
||||||
|
tv_break.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
clockStateMachine.handUpCountingDownCheck();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_handup = themeRootView.findViewById(R.id.tv_hand);
|
||||||
|
tv_handup.setOnClickListener(this);
|
||||||
|
tv_handup.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
if (isScreenLock())
|
||||||
|
return true;
|
||||||
|
setupHandUpTime();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tv_hand_time = themeRootView.findViewById(R.id.tv_hand_time);
|
||||||
|
tv_hand_time.setOnClickListener(this);
|
||||||
|
tv_hand_time.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
//hand_time_visable=false;
|
||||||
|
tv_hand_time.setVisibility(View.GONE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_hours_system = themeRootView.findViewById(R.id.tv_hours_system);
|
||||||
|
|
||||||
|
tv_background_color = themeRootView.findViewById(R.id.tv_background_color);
|
||||||
|
tv_background_color.setOnClickListener(this);
|
||||||
|
|
||||||
|
tv_foreground_color = themeRootView.findViewById(R.id.tv_foreground_color);
|
||||||
|
tv_foreground_color.setOnClickListener(this);
|
||||||
|
tv_foreground_color.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (isScreenLock())
|
||||||
|
return true;
|
||||||
|
if (colorPickerDialog == null)
|
||||||
|
colorPickerDialog = new ColorPickerPop(getActivity());
|
||||||
|
|
||||||
|
colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
model.setForegroundColor(color);
|
||||||
|
globalViewModel.setForegroundColor(color);
|
||||||
|
tv_foreground_color.setColorFilter(color);
|
||||||
|
autoFullScreenCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerDialog.show(model.getForegroundColor());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_foreground_color1 = themeRootView.findViewById(R.id.tv_foreground_color1);
|
||||||
|
tv_foreground_color1.setOnClickListener(this);
|
||||||
|
tv_foreground_color1.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (isScreenLock())
|
||||||
|
return true;
|
||||||
|
if (colorPickerDialog == null)
|
||||||
|
colorPickerDialog = new ColorPickerPop(getActivity());
|
||||||
|
|
||||||
|
colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
model.setForegroundColor1(color);
|
||||||
|
globalViewModel.setForegroundColor(color);
|
||||||
|
tv_foreground_color1.setColorFilter(color);
|
||||||
|
autoFullScreenCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerDialog.show(model.getForegroundColor1());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tv_clock_interface = themeRootView.findViewById(R.id.tv_clock_interface);
|
||||||
|
tv_clock_interface.setOnClickListener(this);
|
||||||
|
|
||||||
|
|
||||||
|
tv_setting = themeRootView.findViewById(R.id.tv_setting);
|
||||||
|
tv_setting.setOnClickListener(this);
|
||||||
|
|
||||||
|
|
||||||
|
tv_screen_lock = themeRootView.findViewById(R.id.tv_screen_lock);
|
||||||
|
tv_screen_lock.setOnClickListener(this);
|
||||||
|
|
||||||
|
//tv_descript.init(mainActivity, false);
|
||||||
|
bindViewModel();
|
||||||
|
return themeRootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SharePerferenceModel model;
|
||||||
|
|
||||||
|
private boolean autoFullScreen=false;
|
||||||
|
|
||||||
|
private int runDelaySecond=10000;
|
||||||
|
|
||||||
|
private boolean running=false;
|
||||||
|
|
||||||
|
Timer timer=null;
|
||||||
|
|
||||||
|
ClockStateMachine clockStateMachine;
|
||||||
|
|
||||||
|
private void autoFullScreenCheck(){
|
||||||
|
if(!autoFullScreen)
|
||||||
|
return;
|
||||||
|
if(timer==null)
|
||||||
|
timer = new Timer();
|
||||||
|
if(running){
|
||||||
|
timer.cancel();
|
||||||
|
}
|
||||||
|
running=true;
|
||||||
|
Log.d("themeUiManager","autoFullScreen task created ...");
|
||||||
|
timer.schedule(new TimerTask() {
|
||||||
|
public void run() {
|
||||||
|
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.FULLSCREEN);
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
}, runDelaySecond);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
abstract void changeThemeTypeCheck();
|
||||||
|
|
||||||
|
private void bindViewModel() {
|
||||||
|
|
||||||
|
/*themeUIViewModel.getThemeName().observe(mainActivity, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(String s) {
|
||||||
|
switchThemeType(s);
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
|
||||||
|
themeUIViewModel.getClockUITypeEnum().observe(mainActivity, new Observer<ClockThemeUITypeEnum>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(ClockThemeUITypeEnum uiTypeEnum) {
|
||||||
|
switchMode(uiTypeEnum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getHourSystem12().observe(mainActivity, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Boolean aBoolean) {
|
||||||
|
tv_hours_system.setVisibility(aBoolean ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getTime_hour().observe(mainActivity, new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Integer integer) {
|
||||||
|
tv_hours_system.setImageResource(integer > 12 ? R.drawable.ic_pm : R.drawable.ic_am);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
themeUIViewModel.getDescription().observe(mainActivity, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(String s) {
|
||||||
|
setDiscript(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getForegroundColor().observe(mainActivity, new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Integer integer) {
|
||||||
|
setForegroundColor(integer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getHandUpAble().observe(mainActivity, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Boolean handUpAbla) {
|
||||||
|
if(handUpAbla) {
|
||||||
|
tv_handup.setColorFilter(globalViewModel.getForegroundColor().getValue());
|
||||||
|
tv_hand_time.setVisibility(View.VISIBLE);
|
||||||
|
}else{
|
||||||
|
tv_handup.setColorFilter(R.color.colorPrimaryDark);
|
||||||
|
tv_hand_time.setVisibility(View.GONE);
|
||||||
|
if(clockStateMachine.getCurrentShowTimeType()== ClockTimeTypeEnum.COUNTING_DOWN)
|
||||||
|
clockStateMachine.setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getHandUpTime().observe(mainActivity, new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Integer handUpTime) {
|
||||||
|
tv_hand_time.setText(DateModel.getTime(handUpTime));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
themeUIViewModel.getHand_time_visable().observe(mainActivity, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Boolean aBoolean) {
|
||||||
|
tv_hand_time.setVisibility(aBoolean ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
themeUIViewModel.getWeatherDescription().observe(mainActivity, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(String s) {
|
||||||
|
tv_weather.setText(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
themeUIViewModel.getWeekDescription().observe(mainActivity, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(String s) {
|
||||||
|
tv_date.setText(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
themeUIViewModel.getDayDescription().observe(mainActivity, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(String s) {
|
||||||
|
tv_day.setText(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateColorSettingButtunColor(){
|
||||||
|
tv_foreground_color.setColorFilter(model.getForegroundColor());
|
||||||
|
tv_foreground_color1.setColorFilter(model.getForegroundColor1());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isScreenLock() {
|
||||||
|
return globalViewModel.getSrceenLock().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHandUpAble() {
|
||||||
|
return globalViewModel.getHandUpAble().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateHourSystem() {
|
||||||
|
if (model.isHourSystem12())
|
||||||
|
tv_hours_system.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tv_hours_system.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupHandUpTime() {
|
||||||
|
int saveHandUpTime=model.getHandUpTime();
|
||||||
|
int hour=0;
|
||||||
|
int minute=0;
|
||||||
|
if(handUpTimePopup==null) {
|
||||||
|
handUpTimePopup = new TimeSetupPopup(mainActivity);
|
||||||
|
handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(int hour, int minute) {
|
||||||
|
if(hour==0&&minute==0) {
|
||||||
|
model.setHandUpTime(-1);
|
||||||
|
globalViewModel.setHandUpAble(false);
|
||||||
|
}else{
|
||||||
|
model.setHandUpTime(hour*60+minute);
|
||||||
|
globalViewModel.setHandUpTime(hour*60+minute);
|
||||||
|
globalViewModel.setHandUpAble(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(saveHandUpTime>0){
|
||||||
|
hour=saveHandUpTime/60;
|
||||||
|
minute=saveHandUpTime-hour*60;
|
||||||
|
}
|
||||||
|
handUpTimePopup.init(hour,minute);
|
||||||
|
handUpTimePopup.showPopupWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupTempHandUpTime() {
|
||||||
|
/*handUpAbla=false;
|
||||||
|
int hour=0;
|
||||||
|
int minute=0;
|
||||||
|
if(handUpTimePopup==null) {
|
||||||
|
handUpTimePopup = new TimeSetupPopup(this);
|
||||||
|
handUpTimePopup.setOnSeekBarChangeListener(new TimeSetupPopup.OnTimeChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(int hour, int minute) {
|
||||||
|
handUpTime=hour*60+minute;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
hour=handUpTime/60;
|
||||||
|
minute=handUpTime-hour*60;
|
||||||
|
handUpTimePopup.init(hour,minute);
|
||||||
|
handUpTimePopup.showPopupWindow();
|
||||||
|
handUpAbla=true;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//Discript
|
||||||
|
private void setDiscript(String disp) {
|
||||||
|
tv_descript.setText(disp);
|
||||||
|
tv_descript.startScrollIfAble();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDiscriptForModel() {
|
||||||
|
String dis = model.getDescription();
|
||||||
|
if (dis == null || dis.isEmpty())
|
||||||
|
dis = SettingActivity.roundFamousQuotes();
|
||||||
|
setDiscript(dis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (isScreenLock() && view.getId() != R.id.tv_screen_lock && view.getId() != R.id.tv_handup_image) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (view.getId()) {
|
||||||
|
case R.id.tv_setting:
|
||||||
|
mainActivity.setup();
|
||||||
|
break;
|
||||||
|
case R.id.tv_hand:
|
||||||
|
int handUpTime=model.getHandUpTime();
|
||||||
|
boolean handUpAbla=isHandUpAble();
|
||||||
|
if(!handUpAbla&&handUpTime<0) {
|
||||||
|
setupHandUpTime();
|
||||||
|
}else{
|
||||||
|
handUpAbla=!handUpAbla;
|
||||||
|
globalViewModel.setHandUpAble(handUpAbla);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.tv_hand_time:
|
||||||
|
setupTempHandUpTime();
|
||||||
|
break;
|
||||||
|
case R.id.tv_day:
|
||||||
|
digitViewModel.setDisplaySecond(!model.isDisplaySecond());
|
||||||
|
break;
|
||||||
|
case R.id.tv_date:
|
||||||
|
if (calendarPopup == null)
|
||||||
|
calendarPopup = new CalendarPopup(mainActivity);
|
||||||
|
calendarPopup.showPopupWindow();
|
||||||
|
calendarPopup.setCurrentDay();
|
||||||
|
break;
|
||||||
|
case R.id.tv_weather:
|
||||||
|
if (weatherPopup == null)
|
||||||
|
weatherPopup = new WeatherPopup(mainActivity);
|
||||||
|
weatherPopup.init(mainActivity.weatherAdape.getWeatherList(), model.getCity() + " PM2.5 : " + mainActivity.weatherAdape.getmPM25());
|
||||||
|
weatherPopup.showPopupWindow();
|
||||||
|
break;
|
||||||
|
case R.id.tv_screen_lock:
|
||||||
|
globalViewModel.setSrceenLock(!isScreenLock());
|
||||||
|
screenLock(!isScreenLock());
|
||||||
|
break;
|
||||||
|
case R.id.tv_break:
|
||||||
|
clockStateMachine.countingCheck();
|
||||||
|
break;
|
||||||
|
case R.id.tv_descript:
|
||||||
|
setDiscript(SettingActivity.roundAutoQuotes());
|
||||||
|
break;
|
||||||
|
case R.id.tv_background_color:
|
||||||
|
if (colorPickerDialog == null)
|
||||||
|
colorPickerDialog = new ColorPickerPop(mainActivity);
|
||||||
|
|
||||||
|
colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
globalViewModel.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerDialog.show(model.getBackgroundColor());
|
||||||
|
break;
|
||||||
|
case R.id.tv_background_image_hand:
|
||||||
|
if (globalViewModel.getBackgroundImageUri().getValue() == null)
|
||||||
|
mainActivity.configBackGroundImage();
|
||||||
|
else
|
||||||
|
globalViewModel.setBackgroundImageVisable(!globalViewModel.getBackgroundImageVisable().getValue());
|
||||||
|
break;
|
||||||
|
case R.id.tv_foreground_color:
|
||||||
|
globalViewModel.setForegroundColor(model.getForegroundColor());
|
||||||
|
break;
|
||||||
|
case R.id.tv_foreground_color1:
|
||||||
|
globalViewModel.setForegroundColor(model.getForegroundColor1());
|
||||||
|
break;
|
||||||
|
case R.id.tv_clock_interface:
|
||||||
|
changeClockInterface();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
autoFullScreenCheck();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void changeClockInterface() {
|
||||||
|
ClockInterfaceTypeEnum currentClockInterface = globalViewModel.getClockInterfaceTypeEnum().getValue();
|
||||||
|
switch (currentClockInterface) {
|
||||||
|
case Digit:
|
||||||
|
currentClockInterface = ClockInterfaceTypeEnum.Simulate;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
currentClockInterface = ClockInterfaceTypeEnum.Digit;
|
||||||
|
}
|
||||||
|
globalViewModel.setClockInterfaceTypeEnum(currentClockInterface);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setForegroundColor(Integer color) {
|
||||||
|
tv_date.setTextColor(color);
|
||||||
|
tv_day.setTextColor(color);
|
||||||
|
tv_weather.setTextColor(color);
|
||||||
|
tv_descript.setTextColor(color);
|
||||||
|
|
||||||
|
tv_handup.setColorFilter(color);
|
||||||
|
tv_screen_lock.setColorFilter(color);
|
||||||
|
tv_setting.setColorFilter(color);
|
||||||
|
tv_background_color.setColorFilter(color);
|
||||||
|
tv_hand_time.setTextColor(color);
|
||||||
|
tv_hours_system.setColorFilter(color);
|
||||||
|
tv_background_image_hand.setColorFilter(color);
|
||||||
|
|
||||||
|
tv_break.setColorFilter(color);
|
||||||
|
|
||||||
|
tv_clock_interface.setColorFilter(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void switchMode(ClockThemeUITypeEnum mode) {
|
||||||
|
Log.d(TAG, "switch mode to:" + mode);
|
||||||
|
switch (mode) {
|
||||||
|
case FULLSCREEN:
|
||||||
|
tv_date.setVisibility(View.GONE);
|
||||||
|
tv_day.setVisibility(View.GONE);
|
||||||
|
tv_weather.setVisibility(View.GONE);
|
||||||
|
tv_descript.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_handup.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_setting.setVisibility(View.GONE);
|
||||||
|
tv_background_color.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_background_color.setVisibility(View.GONE);
|
||||||
|
tv_foreground_color.setVisibility(View.GONE);
|
||||||
|
tv_foreground_color1.setVisibility(View.GONE);
|
||||||
|
tv_background_image_hand.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_break.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_clock_interface.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_screen_lock.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
case NORMAL:
|
||||||
|
tv_date.setVisibility(View.VISIBLE);
|
||||||
|
tv_day.setVisibility(View.VISIBLE);
|
||||||
|
tv_weather.setVisibility(View.VISIBLE);
|
||||||
|
tv_descript.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
tv_handup.setVisibility(View.VISIBLE);
|
||||||
|
tv_break.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
tv_setting.setVisibility(View.GONE);
|
||||||
|
tv_background_color.setVisibility(View.GONE);
|
||||||
|
tv_foreground_color.setVisibility(View.GONE);
|
||||||
|
tv_foreground_color1.setVisibility(View.GONE);
|
||||||
|
tv_background_image_hand.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_clock_interface.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
tv_screen_lock.setVisibility(View.VISIBLE);
|
||||||
|
break;
|
||||||
|
case SETTING:
|
||||||
|
tv_date.setVisibility(View.VISIBLE);
|
||||||
|
tv_day.setVisibility(View.VISIBLE);
|
||||||
|
tv_weather.setVisibility(View.VISIBLE);
|
||||||
|
tv_descript.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
tv_handup.setVisibility(View.VISIBLE);
|
||||||
|
tv_break.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
tv_setting.setVisibility(View.VISIBLE);
|
||||||
|
tv_background_color.setVisibility(View.VISIBLE);
|
||||||
|
tv_foreground_color.setVisibility(View.VISIBLE);
|
||||||
|
tv_foreground_color1.setVisibility(View.VISIBLE);
|
||||||
|
tv_background_image_hand.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
tv_clock_interface.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
tv_screen_lock.setVisibility(View.VISIBLE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFullScreen(){
|
||||||
|
return themeUIViewModel.getClockUITypeEnum().getValue()==ClockThemeUITypeEnum.FULLSCREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configThemeUITypeWithNoFullScreen(){
|
||||||
|
if(globalViewModel.getClockInterfaceTypeEnum().getValue()==ClockInterfaceTypeEnum.Digit)
|
||||||
|
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.NORMAL);
|
||||||
|
else
|
||||||
|
themeUIViewModel.setClockUITypeEnum(ClockThemeUITypeEnum.SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void screenLock(boolean locked) {
|
||||||
|
tv_screen_lock.setImageResource(locked ? R.drawable.ic_screen_lock : R.drawable.ic_screen_unlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import clock.socoolby.com.clock.ClockApplication;
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
import clock.socoolby.com.clock.state.ClockModeEnum;
|
import clock.socoolby.com.clock.state.ClockStateMachine;
|
||||||
|
import clock.socoolby.com.clock.utils.Player;
|
||||||
import clock.socoolby.com.clock.viewmodel.AlterViewModel;
|
import clock.socoolby.com.clock.viewmodel.AlterViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
@ -29,10 +30,15 @@ public class AlterFragment extends Fragment {
|
|||||||
GlobalViewModel globalViewModel;
|
GlobalViewModel globalViewModel;
|
||||||
AlterViewModel alterViewModel;
|
AlterViewModel alterViewModel;
|
||||||
|
|
||||||
|
ClockStateMachine clockStateMachine;
|
||||||
|
|
||||||
private TextView tv_handup_text;
|
private TextView tv_handup_text;
|
||||||
|
|
||||||
public AlterFragment() {
|
private int handUPDialy=0;
|
||||||
// Required empty public constructor
|
|
||||||
|
|
||||||
|
public AlterFragment(ClockStateMachine clockStateMachine) {
|
||||||
|
this.clockStateMachine=clockStateMachine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -43,6 +49,11 @@ public class AlterFragment extends Fragment {
|
|||||||
alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(AlterViewModel.class);
|
alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(),ClockApplication.getInstance().getEntityManager())).get(AlterViewModel.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@ -59,24 +70,36 @@ public class AlterFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bindViewModel(){
|
private void bindViewModel(){
|
||||||
alterViewModel.getHandUpDescription().observe(this, new Observer<String>() {
|
alterViewModel.getHandUPDialy().observe(this, new Observer<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(String s) {
|
public void onChanged(Integer integer) {
|
||||||
tv_handup_text.setText(s);
|
handUPDialy=integer;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
globalViewModel.getHandUpTime().observe(this, new Observer<Integer>() {
|
globalViewModel.getHeartbeat().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Integer time) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
if(time==0)
|
handUPDialy--;
|
||||||
|
tv_handup_text.setText("hand up ! \t"+handUPDialy);
|
||||||
|
if(handUPDialy==0)
|
||||||
endHandUp(false);
|
endHandUp(false);
|
||||||
|
else
|
||||||
|
Player.getInstance().playHandUp(ClockApplication.getContext());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
globalViewModel.getForegroundColor().observe(this, new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Integer integer) {
|
||||||
|
tv_handup_text.setTextColor(integer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void endHandUp(boolean userCheck){
|
private void endHandUp(boolean userCheck){
|
||||||
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.NORMAL);
|
clockStateMachine.stopHandUp(userCheck);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,352 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.Unbinder;
|
||||||
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
|
import clock.socoolby.com.clock.R;
|
||||||
|
import clock.socoolby.com.clock.pop.ColorPickerPop;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
|
import clock.socoolby.com.clock.widget.textview.ShadowTypeEnum;
|
||||||
|
import clock.socoolby.com.clock.widget.textview.charanimator.CharAnimatorEnum;
|
||||||
|
|
||||||
|
public class DigitClockConfigFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String TAG = SimulateClockFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
public static final String NAME = "simulateClockConfig";
|
||||||
|
|
||||||
|
DigitViewModel digitViewModel;
|
||||||
|
GlobalViewModel globalViewModel;
|
||||||
|
|
||||||
|
@BindView(R.id.tv_hourSystem12)
|
||||||
|
RadioButton tvHourSystem12;
|
||||||
|
@BindView(R.id.tv_hourSystem24)
|
||||||
|
RadioButton tvHourSystem24;
|
||||||
|
@BindView(R.id.tv_hourSystem_group)
|
||||||
|
RadioGroup tvHourSystemGroup;
|
||||||
|
@BindView(R.id.tv_secoundShow)
|
||||||
|
CheckBox tvSecoundShow;
|
||||||
|
@BindView(R.id.text_style_group1)
|
||||||
|
LinearLayout textStyleGroup1;
|
||||||
|
@BindView(R.id.textView3)
|
||||||
|
TextView textView3;
|
||||||
|
@BindView(R.id.tv_textStyle_numal)
|
||||||
|
RadioButton tvTextStyleNumal;
|
||||||
|
@BindView(R.id.tv_textStyle_shadow)
|
||||||
|
RadioButton tvTextStyleShadow;
|
||||||
|
@BindView(R.id.tv_textStyle_relief)
|
||||||
|
RadioButton tvTextStyleRelief;
|
||||||
|
@BindView(R.id.tv_textStyle_group)
|
||||||
|
RadioGroup tvTextStyleGroup;
|
||||||
|
@BindView(R.id.tv_textStyle_reflect)
|
||||||
|
CheckBox tvTextStyleReflect;
|
||||||
|
@BindView(R.id.text_style_group2)
|
||||||
|
LinearLayout textStyleGroup2;
|
||||||
|
@BindView(R.id.tv_textAnim_down)
|
||||||
|
RadioButton tvTextAnimDown;
|
||||||
|
@BindView(R.id.tv_textAnim_up)
|
||||||
|
RadioButton tvTextAnimUp;
|
||||||
|
@BindView(R.id.tv_textAnim_downflit)
|
||||||
|
RadioButton tvTextAnimDownflit;
|
||||||
|
@BindView(R.id.tv_textAnim_upflat)
|
||||||
|
RadioButton tvTextAnimUpflat;
|
||||||
|
@BindView(R.id.tv_textAnim_group)
|
||||||
|
RadioGroup tvTextAnimGroup;
|
||||||
|
@BindView(R.id.text_style_group3)
|
||||||
|
LinearLayout textStyleGroup3;
|
||||||
|
@BindView(R.id.tv_textAnim_numal)
|
||||||
|
RadioButton tvTextAnimNumal;
|
||||||
|
@BindView(R.id.textView2)
|
||||||
|
CheckBox textView2;
|
||||||
|
@BindView(R.id.button4)
|
||||||
|
Button button4;
|
||||||
|
@BindView(R.id.button5)
|
||||||
|
Button button5;
|
||||||
|
@BindView(R.id.button6)
|
||||||
|
Button button6;
|
||||||
|
@BindView(R.id.button7)
|
||||||
|
Button button7;
|
||||||
|
@BindView(R.id.button8)
|
||||||
|
Button button8;
|
||||||
|
@BindView(R.id.text_style_group4)
|
||||||
|
LinearLayout textStyleGroup4;
|
||||||
|
@BindView(R.id.textView)
|
||||||
|
TextView textView;
|
||||||
|
@BindView(R.id.editText)
|
||||||
|
TextView textView1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(), ClockApplication.getInstance().getEntityManager())).get(GlobalViewModel.class);
|
||||||
|
digitViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(), ClockApplication.getInstance().getEntityManager())).get(DigitViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Unbinder unbinder;
|
||||||
|
|
||||||
|
private ColorPickerPop colorPickerDialog;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_digit_config, container, false);
|
||||||
|
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
|
||||||
|
loadForViewModel();
|
||||||
|
|
||||||
|
tvHourSystemGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
|
switch (checkedId) {
|
||||||
|
case R.id.tv_hourSystem12:
|
||||||
|
globalViewModel.setHourSystem12(tvHourSystem12.isChecked());
|
||||||
|
break;
|
||||||
|
case R.id.tv_hourSystem24:
|
||||||
|
globalViewModel.setHourSystem12(tvHourSystem12.isChecked());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
tvTextStyleGroup.setOnCheckedChangeListener((RadioGroup group, int checkedId) -> {
|
||||||
|
ShadowTypeEnum shadowTypeEnum = ShadowTypeEnum.NOSETUP;
|
||||||
|
switch (checkedId) {
|
||||||
|
case R.id.tv_textStyle_numal:
|
||||||
|
shadowTypeEnum = ShadowTypeEnum.NOSETUP;
|
||||||
|
break;
|
||||||
|
case R.id.tv_textStyle_shadow:
|
||||||
|
shadowTypeEnum = ShadowTypeEnum.SHADOW;
|
||||||
|
break;
|
||||||
|
case R.id.tv_textStyle_relief:
|
||||||
|
shadowTypeEnum = ShadowTypeEnum.RELIEF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
digitViewModel.setShadowType(shadowTypeEnum);
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSecoundShow.setOnCheckedChangeListener((group, checkedId) ->
|
||||||
|
{
|
||||||
|
digitViewModel.setDisplaySecond(group.isChecked());
|
||||||
|
});
|
||||||
|
|
||||||
|
tvTextStyleReflect.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
digitViewModel.setReflectedAble(group.isChecked());
|
||||||
|
});
|
||||||
|
|
||||||
|
tvTextAnimGroup.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
CharAnimatorEnum charAnimatorEnum = CharAnimatorEnum.NOSETUP;
|
||||||
|
switch (checkedId) {
|
||||||
|
case R.id.tv_textAnim_down:
|
||||||
|
charAnimatorEnum = CharAnimatorEnum.UP2DOWN;
|
||||||
|
break;
|
||||||
|
case R.id.tv_textAnim_up:
|
||||||
|
charAnimatorEnum = CharAnimatorEnum.DOWN2UP;
|
||||||
|
break;
|
||||||
|
case R.id.tv_textAnim_downflit:
|
||||||
|
charAnimatorEnum = CharAnimatorEnum.Marquee3D_Down;
|
||||||
|
break;
|
||||||
|
case R.id.tv_textAnim_upflat:
|
||||||
|
charAnimatorEnum = CharAnimatorEnum.Marquee3D_Up;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (charAnimatorEnum != CharAnimatorEnum.NOSETUP)
|
||||||
|
if (digitViewModel.getDisplaySecond().getValue())
|
||||||
|
digitViewModel.setTimeText("88:88:88");
|
||||||
|
else
|
||||||
|
digitViewModel.setTimeText("88:88");
|
||||||
|
digitViewModel.setTimeCharAnimatorType(charAnimatorEnum);
|
||||||
|
});
|
||||||
|
|
||||||
|
textView2.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
digitViewModel.setLinearGradientAble(textView2.isChecked());
|
||||||
|
});
|
||||||
|
|
||||||
|
button4.setOnClickListener(view1 ->
|
||||||
|
changeGradientColor(button4, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
button5.setOnClickListener((view1) -> {
|
||||||
|
changeGradientColor(button5, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
button6.setOnClickListener(view1 -> {
|
||||||
|
changeGradientColor(button6, 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
button7.setOnClickListener((view1) -> {
|
||||||
|
changeGradientColor(button7, 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
button8.setOnClickListener((view1) -> {
|
||||||
|
changeGradientColor(button8, 4);
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeGradientColor(Button view, int order) {
|
||||||
|
if (colorPickerDialog == null)
|
||||||
|
colorPickerDialog = new ColorPickerPop(getActivity());
|
||||||
|
|
||||||
|
colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
confColors[order] = color;
|
||||||
|
digitViewModel.setTimeLinearGradientColorsArray(confColors);
|
||||||
|
view.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerDialog.show(confColors[order]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onDestroyView中进行解绑操作
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer[] defGradientColorsArray = new Integer[]{Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK};
|
||||||
|
Integer[] confColors;
|
||||||
|
|
||||||
|
private void loadForViewModel() {
|
||||||
|
|
||||||
|
if (globalViewModel.getHourSystem12().getValue())
|
||||||
|
tvHourSystem12.setChecked(true);
|
||||||
|
else
|
||||||
|
tvHourSystem24.setChecked(true);
|
||||||
|
|
||||||
|
|
||||||
|
tvSecoundShow.setChecked(digitViewModel.getDisplaySecond().getValue());
|
||||||
|
|
||||||
|
|
||||||
|
switch (digitViewModel.getShadowType().getValue()) {
|
||||||
|
case NOSETUP:
|
||||||
|
tvTextStyleNumal.setChecked(true);
|
||||||
|
break;
|
||||||
|
case RELIEF:
|
||||||
|
tvTextStyleRelief.setChecked(true);
|
||||||
|
break;
|
||||||
|
case SHADOW:
|
||||||
|
tvTextStyleShadow.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tvTextStyleReflect.setChecked(digitViewModel.getReflectedAble().getValue());
|
||||||
|
|
||||||
|
switch (digitViewModel.getTimeCharAnimatorType().getValue()) {
|
||||||
|
case NOSETUP:
|
||||||
|
tvTextAnimNumal.setChecked(true);
|
||||||
|
break;
|
||||||
|
case UP2DOWN:
|
||||||
|
tvTextAnimDown.setChecked(true);
|
||||||
|
break;
|
||||||
|
case DOWN2UP:
|
||||||
|
tvTextAnimUp.setChecked(true);
|
||||||
|
break;
|
||||||
|
case Marquee3D_Down:
|
||||||
|
tvTextAnimDownflit.setChecked(true);
|
||||||
|
break;
|
||||||
|
case Marquee3D_Up:
|
||||||
|
tvTextAnimUpflat.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
textView2.setChecked(digitViewModel.getLinearGradientAble().getValue());
|
||||||
|
|
||||||
|
confColors = digitViewModel.getTimeLinearGradientColorsArray().getValue();
|
||||||
|
|
||||||
|
if (confColors == null)
|
||||||
|
confColors = defGradientColorsArray;
|
||||||
|
|
||||||
|
button4.setBackgroundColor(confColors[0]);
|
||||||
|
button5.setBackgroundColor(confColors[1]);
|
||||||
|
button6.setBackgroundColor(confColors[2]);
|
||||||
|
button7.setBackgroundColor(confColors[3]);
|
||||||
|
button8.setBackgroundColor(confColors[4]);
|
||||||
|
|
||||||
|
|
||||||
|
digitViewModel.getLinearGradientAble().observe(this, (able) -> {
|
||||||
|
button4.setClickable(able);
|
||||||
|
button5.setClickable(able);
|
||||||
|
button6.setClickable(able);
|
||||||
|
button7.setClickable(able);
|
||||||
|
button8.setClickable(able);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
setTextColor(globalViewModel.getForegroundColor().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setTextColor(int color) {
|
||||||
|
|
||||||
|
tvHourSystem12.setTextColor(color);
|
||||||
|
|
||||||
|
tvHourSystem24.setTextColor(color);
|
||||||
|
|
||||||
|
tvSecoundShow.setTextColor(color);
|
||||||
|
|
||||||
|
textView3.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextStyleNumal.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextStyleShadow.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextStyleRelief.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextStyleReflect.setTextColor(color);
|
||||||
|
|
||||||
|
|
||||||
|
tvTextAnimDown.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextAnimUp.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextAnimDownflit.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextAnimUpflat.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextAnimNumal.setTextColor(color);
|
||||||
|
|
||||||
|
textView2.setTextColor(color);
|
||||||
|
textView1.setTextColor(color);
|
||||||
|
textView.setTextColor(color);
|
||||||
|
|
||||||
|
button4.setTextColor(color);
|
||||||
|
button5.setTextColor(color);
|
||||||
|
button6.setTextColor(color);
|
||||||
|
button7.setTextColor(color);
|
||||||
|
button8.setTextColor(color);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -87,7 +87,7 @@ public class DigitClockFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onChanged(Integer[] integers) {
|
public void onChanged(Integer[] integers) {
|
||||||
if(integers==null) {
|
if(integers==null) {
|
||||||
tv_time.setLinearGradientAble(false);
|
tv_time.setLinearGradientColors(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int[] toInts=new int[integers.length];
|
int[] toInts=new int[integers.length];
|
||||||
|
@ -0,0 +1,239 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.Unbinder;
|
||||||
|
import clock.socoolby.com.clock.ClockApplication;
|
||||||
|
import clock.socoolby.com.clock.R;
|
||||||
|
import clock.socoolby.com.clock.pop.ColorPickerPop;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.DefaultPointer;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafPointer;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafTwoPointer;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.SecondTailPointer;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.SwordPointer;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.TrianglePointer;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.TwoStepPointer;
|
||||||
|
|
||||||
|
public class SimulateClockConfigFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String TAG = SimulateClockFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
public static final String NAME = "simulateClockConfig";
|
||||||
|
|
||||||
|
SimulateViewModel simulateViewModel;
|
||||||
|
GlobalViewModel globalViewModel;
|
||||||
|
@BindView(R.id.tv_simulate_color_pointer)
|
||||||
|
Button tvSimulateColorPointer;
|
||||||
|
@BindView(R.id.tv_simulate_color_scale)
|
||||||
|
Button tvSimulateColorScale;
|
||||||
|
@BindView(R.id.tv_simulate_color_scalep_particularly)
|
||||||
|
Button tvSimulateColorScalepParticularly;
|
||||||
|
@BindView(R.id.tv_simulate_color_text)
|
||||||
|
Button tvSimulateColorText;
|
||||||
|
@BindView(R.id.tv_simulate_color_outline)
|
||||||
|
Button tvSimulateColorOutline;
|
||||||
|
@BindView(R.id.textView4)
|
||||||
|
TextView textView4;
|
||||||
|
@BindView(R.id.tv_simulate_text_show_hide)
|
||||||
|
RadioButton tvSimulateTextShowHide;
|
||||||
|
@BindView(R.id.tv_simulate_text_show_all)
|
||||||
|
RadioButton tvSimulateTextShowAll;
|
||||||
|
@BindView(R.id.tv_simulate_text_show_four)
|
||||||
|
RadioButton tvSimulateTextShowFour;
|
||||||
|
@BindView(R.id.tv_simulate_text_show_group)
|
||||||
|
RadioGroup tvSimulateTextShowGroup;
|
||||||
|
@BindView(R.id.textView5)
|
||||||
|
TextView textView5;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_1)
|
||||||
|
Button tvSimulatePointerStyle1;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_2)
|
||||||
|
Button tvSimulatePointerStyle2;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_3)
|
||||||
|
Button tvSimulatePointerStyle3;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_4)
|
||||||
|
Button tvSimulatePointerStyle4;
|
||||||
|
@BindView(R.id.pointer_list)
|
||||||
|
ScrollView pointerList;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_0)
|
||||||
|
Button tvSimulatePointerStyle0;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_5)
|
||||||
|
Button tvSimulatePointerStyle5;
|
||||||
|
@BindView(R.id.tv_simulate_pointer_style_6)
|
||||||
|
Button tvSimulatePointerStyle6;
|
||||||
|
@BindView(R.id.tv_simulate_color_pointer_second)
|
||||||
|
Button tvSimulateColorPointerSecond;
|
||||||
|
|
||||||
|
private Unbinder unbinder;
|
||||||
|
|
||||||
|
private ColorPickerPop colorPickerDialog;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
globalViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(), ClockApplication.getInstance().getEntityManager())).get(GlobalViewModel.class);
|
||||||
|
simulateViewModel = ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel(), ClockApplication.getInstance().getEntityManager())).get(SimulateViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_simulate_config, container, false);
|
||||||
|
unbinder = ButterKnife.bind(this, view);
|
||||||
|
|
||||||
|
bindViewModel();
|
||||||
|
|
||||||
|
tvSimulateTextShowGroup.setOnCheckedChangeListener((view1, checkId) -> {
|
||||||
|
switch (checkId) {
|
||||||
|
case R.id.tv_simulate_text_show_hide:
|
||||||
|
break;
|
||||||
|
case R.id.tv_simulate_text_show_all:
|
||||||
|
break;
|
||||||
|
case R.id.tv_simulate_text_show_four:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSimulatePointerStyle0.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(DefaultPointer.TYPE_NAME));
|
||||||
|
tvSimulatePointerStyle1.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(LeafPointer.TYPE_LEAF));
|
||||||
|
tvSimulatePointerStyle2.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(LeafTwoPointer.TYPE_LEAF_TWO));
|
||||||
|
tvSimulatePointerStyle3.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(SecondTailPointer.TYPE_SECOND_TAIL));
|
||||||
|
tvSimulatePointerStyle4.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(SwordPointer.TYPE_SWORD_POINTER));
|
||||||
|
tvSimulatePointerStyle5.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(TrianglePointer.TYPE_TRIANGLE_POINTER));
|
||||||
|
tvSimulatePointerStyle6.setOnClickListener((e) -> simulateViewModel.setPointerTypeName(TwoStepPointer.TYPE_TWO_STEP_POINTER));
|
||||||
|
|
||||||
|
|
||||||
|
tvSimulateColorPointer.setOnClickListener((view1) -> {
|
||||||
|
colorSelect(simulateViewModel.getSimulateClockColorPointer().getValue(),
|
||||||
|
new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
simulateViewModel.setSimulateClockColorPointer(color);
|
||||||
|
view1.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSimulateColorPointerSecond.setOnClickListener((view1) -> {
|
||||||
|
colorSelect(simulateViewModel.getSimulateClockColorPointerSecond().getValue(),
|
||||||
|
new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
simulateViewModel.setSimulateClockColorPointerSecond(color);
|
||||||
|
view1.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSimulateColorScale.setOnClickListener((view1) -> {
|
||||||
|
colorSelect(simulateViewModel.getSimulateClockColorScale().getValue(),
|
||||||
|
new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
simulateViewModel.setSimulateClockColorScale(color);
|
||||||
|
view1.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSimulateColorScalepParticularly.setOnClickListener((view1) -> {
|
||||||
|
colorSelect(simulateViewModel.getSimulateClockColorScaleParticularly().getValue(),
|
||||||
|
new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
simulateViewModel.setSimulateClockColorScaleParticularly(color);
|
||||||
|
view1.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSimulateColorOutline.setOnClickListener((view1) -> {
|
||||||
|
colorSelect(simulateViewModel.getSimulateClockColorOutLine().getValue(),
|
||||||
|
new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
simulateViewModel.setSimulateClockColorOutLine(color);
|
||||||
|
view1.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tvSimulateColorText.setOnClickListener((view1) -> {
|
||||||
|
colorSelect(simulateViewModel.getSimulateClockColorText().getValue(),
|
||||||
|
new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
simulateViewModel.setSimulateClockColorText(color);
|
||||||
|
view1.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void colorSelect(int defColor, ColorPickerPop.OnColorListener listener){
|
||||||
|
if (colorPickerDialog == null)
|
||||||
|
colorPickerDialog = new ColorPickerPop(getActivity());
|
||||||
|
colorPickerDialog.setOnColorChangeListenter(listener);
|
||||||
|
colorPickerDialog.show(defColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void bindViewModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onDestroyView中进行解绑操作
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unbinder.unbind();
|
||||||
|
}
|
||||||
|
}
|
@ -69,18 +69,15 @@ public class SimulateClockFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if(clockAnimator!=null){
|
|
||||||
clockAnimator.start();
|
clockAnimator.start();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if(clockAnimator!=null){
|
|
||||||
clockAnimator.stop();
|
clockAnimator.stop();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void bindViewModel(){
|
private void bindViewModel(){
|
||||||
simulateViewModel.getClockTypeName().observe(this, new Observer<String>() {
|
simulateViewModel.getClockTypeName().observe(this, new Observer<String>() {
|
||||||
@ -103,44 +100,30 @@ public class SimulateClockFragment extends Fragment {
|
|||||||
clockAnimator.setColor(integer);
|
clockAnimator.setColor(integer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
simulateViewModel.getSimulateClockColorOutLine().observe(this,color->clockAnimator.setmClockColor(color));
|
||||||
|
|
||||||
|
simulateViewModel.getSimulateClockColorPointer().observe(this,color->clockAnimator.setmClockColorPointer(color));
|
||||||
|
|
||||||
|
simulateViewModel.getSimulateClockColorPointerSecond().observe(this,color->clockAnimator.setPointerSecondColor(color));
|
||||||
|
|
||||||
|
simulateViewModel.getSimulateClockColorScale().observe(this,color->clockAnimator.setmColorDefaultScale(color));
|
||||||
|
|
||||||
|
simulateViewModel.getSimulateClockColorScaleParticularly().observe(this,color->clockAnimator.setmColorParticularyScale(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClockAnimator clockAnimator=null;
|
ClockAnimator clockAnimator=null;
|
||||||
private void changeFullScreenClock(int index) {
|
|
||||||
Log.d(TAG,"changeFullScreenClock index:"+index);
|
|
||||||
|
|
||||||
clockAnimator.setColor(globalViewModel.getForegroundColor().getValue());
|
|
||||||
|
|
||||||
switch (index) {
|
|
||||||
case 1:
|
|
||||||
clockAnimator.setClock(new SquareClock());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
clockAnimator.setClock(new OvalClock());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
clockAnimator.setClock(new CircleTwoClock());
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
clockAnimator.setClock(new HexagonalClock());
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
clockAnimator.setClock(new HelixClock());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
clockAnimator.setClock(new CircleClock());
|
|
||||||
}
|
|
||||||
clockView.setAnimator(clockAnimator);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setFullScreenClock(String clockStyle,String pointerStyle){
|
private void setFullScreenClock(String clockStyle,String pointerStyle){
|
||||||
setClockStyle(clockStyle);
|
setClockStyle(clockStyle);
|
||||||
setClockPointer(pointerStyle);
|
setClockPointer(pointerStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractClock clock;
|
||||||
|
|
||||||
private void setClockStyle(String clockStyle){
|
private void setClockStyle(String clockStyle){
|
||||||
clockAnimator.setColor(globalViewModel.getForegroundColor().getValue());
|
clockAnimator.setColor(globalViewModel.getForegroundColor().getValue());
|
||||||
AbstractClock clock= ClockFactory.build(clockStyle);
|
clock= ClockFactory.build(clockStyle);
|
||||||
clockAnimator.setClock(clock);
|
clockAnimator.setClock(clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import clock.socoolby.com.clock.R;
|
||||||
|
|
||||||
|
public class ThemeUIDefaultFragment extends AbstractThemeUIFragment {
|
||||||
|
|
||||||
|
public static final String THEME_NAME="default";
|
||||||
|
|
||||||
|
public ThemeUIDefaultFragment() {
|
||||||
|
super(R.layout.theme_default);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void changeThemeTypeCheck() {
|
||||||
|
themeUIViewModel.getThemeName().setValue(ThemeUISampleFragment.THEME_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package clock.socoolby.com.clock.fragment;
|
||||||
|
|
||||||
|
import clock.socoolby.com.clock.R;
|
||||||
|
|
||||||
|
public class ThemeUISampleFragment extends AbstractThemeUIFragment {
|
||||||
|
|
||||||
|
public static final String THEME_NAME="sample";
|
||||||
|
|
||||||
|
public ThemeUISampleFragment() {
|
||||||
|
super(R.layout.theme_sample);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void changeThemeTypeCheck() {
|
||||||
|
themeUIViewModel.getThemeName().setValue(ThemeUIDefaultFragment.THEME_NAME);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@ import clock.socoolby.com.clock.ClockApplication;
|
|||||||
import clock.socoolby.com.clock.Constants;
|
import clock.socoolby.com.clock.Constants;
|
||||||
import clock.socoolby.com.clock.R;
|
import clock.socoolby.com.clock.R;
|
||||||
import clock.socoolby.com.clock.utils.FileUtils;
|
import clock.socoolby.com.clock.utils.FileUtils;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.SimulateTextShowTypeEnum;
|
||||||
|
|
||||||
public class SharePerferenceModel implements Serializable {
|
public class SharePerferenceModel implements Serializable {
|
||||||
|
|
||||||
@ -65,6 +66,9 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
protected final static String KEY_HANDUP_MUSIC ="key_handup_music";
|
protected final static String KEY_HANDUP_MUSIC ="key_handup_music";
|
||||||
protected String handUpMusic = "";
|
protected String handUpMusic = "";
|
||||||
|
|
||||||
|
protected final static String KEY_HANDUP_DIALY="key_handup_dialy";
|
||||||
|
protected Integer handUpDialy=60;
|
||||||
|
|
||||||
protected final static String KEY_BACKGROUND_COLOR="key_background_color";
|
protected final static String KEY_BACKGROUND_COLOR="key_background_color";
|
||||||
protected Integer backgroundColor=Color.rgb(0, 0, 0);
|
protected Integer backgroundColor=Color.rgb(0, 0, 0);
|
||||||
|
|
||||||
@ -114,6 +118,28 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
protected final static String KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME="key_simulate_clock_pointer_type_name";
|
protected final static String KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME="key_simulate_clock_pointer_type_name";
|
||||||
protected String simulateClockPointerTypeName;
|
protected String simulateClockPointerTypeName;
|
||||||
|
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_COLOR_SCALE="key_simulate_clock_color_scale";
|
||||||
|
protected Integer simulateClockColorScale;
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_COLOR_SCALE_PARTICULARLY="key_simulate_clock_color_scale_particularly";
|
||||||
|
protected Integer simulateClockColorScaleParticularly;
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_COLOR_TEXT="key_simulate_clock_color_text";
|
||||||
|
protected Integer simulateClockColorText;
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_COLOR_POINTER="key_simulate_clock_color_pointer";
|
||||||
|
protected Integer simulateClockColorPointer;
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_COLOR_POINTER_SECOND="key_simulate_clock_color_pointer_second";
|
||||||
|
protected Integer simulateClockColorPointerSecond;
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_COLOR_OUTLINE="key_simulate_clock_color_outLine";
|
||||||
|
protected Integer simulateClockColorOutLine;
|
||||||
|
|
||||||
|
protected final static String KEY_SIMULATE_CLOCK_TEXT_SHOW_TYPE="key_simulate_clock_text_show_type";
|
||||||
|
protected Integer simulateClockTextShowType;
|
||||||
|
|
||||||
//ui
|
//ui
|
||||||
protected final static String KEY_UI_CLOCK_INTERFACE_TYPE ="key_ui_clock_interface_type";
|
protected final static String KEY_UI_CLOCK_INTERFACE_TYPE ="key_ui_clock_interface_type";
|
||||||
protected int clockInterfaceType;
|
protected int clockInterfaceType;
|
||||||
@ -293,6 +319,7 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
handUpAble=jsonObject.optBoolean(KEY_IS_HANDUP_ABLE,false);
|
handUpAble=jsonObject.optBoolean(KEY_IS_HANDUP_ABLE,false);
|
||||||
handUpTime=jsonObject.optInt(KEY_HANDUP_TIME,-1);
|
handUpTime=jsonObject.optInt(KEY_HANDUP_TIME,-1);
|
||||||
handUpMusic=jsonObject.optString(KEY_HANDUP_MUSIC,"");
|
handUpMusic=jsonObject.optString(KEY_HANDUP_MUSIC,"");
|
||||||
|
handUpDialy=jsonObject.optInt(KEY_HANDUP_DIALY,60);
|
||||||
|
|
||||||
backgroundColor=jsonObject.optInt(KEY_BACKGROUND_COLOR,Color.rgb(0, 0, 0));
|
backgroundColor=jsonObject.optInt(KEY_BACKGROUND_COLOR,Color.rgb(0, 0, 0));
|
||||||
backgroundImage=jsonObject.optString(KEY_BACKGROUND_IMAGE,"");
|
backgroundImage=jsonObject.optString(KEY_BACKGROUND_IMAGE,"");
|
||||||
@ -311,9 +338,15 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
|
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
|
||||||
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
|
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
|
||||||
|
|
||||||
|
|
||||||
simulateClockTypeName=jsonObject.optString(KEY_SIMULATE_CLOCK_TYPE_NAME,"default");
|
simulateClockTypeName=jsonObject.optString(KEY_SIMULATE_CLOCK_TYPE_NAME,"default");
|
||||||
simulateClockPointerTypeName=jsonObject.optString(KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME,"default");
|
simulateClockPointerTypeName=jsonObject.optString(KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME,"default");
|
||||||
|
simulateClockColorScale=jsonObject.optInt(KEY_SIMULATE_CLOCK_COLOR_SCALE,Color.rgb(255, 255, 255));
|
||||||
|
simulateClockColorScaleParticularly=jsonObject.optInt(KEY_SIMULATE_CLOCK_COLOR_SCALE_PARTICULARLY,Color.rgb(255, 255, 255));
|
||||||
|
simulateClockColorText=jsonObject.optInt(KEY_SIMULATE_CLOCK_COLOR_TEXT,Color.rgb(255, 255, 255));
|
||||||
|
simulateClockColorOutLine=jsonObject.optInt(KEY_SIMULATE_CLOCK_COLOR_OUTLINE,Color.rgb(255, 255, 255));
|
||||||
|
simulateClockTextShowType=jsonObject.optInt(KEY_SIMULATE_CLOCK_TEXT_SHOW_TYPE,0);
|
||||||
|
simulateClockColorPointer=jsonObject.optInt(KEY_SIMULATE_CLOCK_COLOR_POINTER,Color.rgb(255, 255, 255));
|
||||||
|
simulateClockColorPointerSecond=jsonObject.optInt(KEY_SIMULATE_CLOCK_COLOR_POINTER_SECOND,Color.rgb(255, 255, 255));
|
||||||
|
|
||||||
themeName=jsonObject.optString(KEY_THEME_UI_NAME,"default");
|
themeName=jsonObject.optString(KEY_THEME_UI_NAME,"default");
|
||||||
|
|
||||||
@ -345,7 +378,10 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
jsonObject.put(KEY_DISPLAYVIEW_WEATHER, weatherLocation.toString());
|
jsonObject.put(KEY_DISPLAYVIEW_WEATHER, weatherLocation.toString());
|
||||||
jsonObject.put(KEY_DISPLAYVIEW_DESCRIPTION, descriptionLocation.toString());
|
jsonObject.put(KEY_DISPLAYVIEW_DESCRIPTION, descriptionLocation.toString());
|
||||||
jsonObject.put(KEY_FONT_INDEX, fontIndex);
|
jsonObject.put(KEY_FONT_INDEX, fontIndex);
|
||||||
|
|
||||||
jsonObject.put(KEY_HANDUP_TIME,handUpTime);
|
jsonObject.put(KEY_HANDUP_TIME,handUpTime);
|
||||||
|
jsonObject.put(KEY_HANDUP_DIALY,handUpDialy);
|
||||||
|
|
||||||
jsonObject.put(KEY_IS_HANDUP_ABLE,handUpAble);
|
jsonObject.put(KEY_IS_HANDUP_ABLE,handUpAble);
|
||||||
jsonObject.put(KEY_HANDUP_MUSIC,handUpMusic);
|
jsonObject.put(KEY_HANDUP_MUSIC,handUpMusic);
|
||||||
jsonObject.put(KEY_BACKGROUND_COLOR,backgroundColor);
|
jsonObject.put(KEY_BACKGROUND_COLOR,backgroundColor);
|
||||||
@ -368,6 +404,14 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
jsonObject.put(KEY_SIMULATE_CLOCK_TYPE_NAME,simulateClockTypeName);
|
jsonObject.put(KEY_SIMULATE_CLOCK_TYPE_NAME,simulateClockTypeName);
|
||||||
jsonObject.put(KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME,simulateClockPointerTypeName);
|
jsonObject.put(KEY_SIMULATE_CLOCK_POINTER_TYPE_NAME,simulateClockPointerTypeName);
|
||||||
|
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_COLOR_SCALE,simulateClockColorScale);
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_COLOR_SCALE_PARTICULARLY,simulateClockColorScaleParticularly);
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_COLOR_TEXT,simulateClockColorText);
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_COLOR_OUTLINE,simulateClockColorOutLine);
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_TEXT_SHOW_TYPE,simulateClockTextShowType);
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_COLOR_POINTER,simulateClockColorPointer);
|
||||||
|
jsonObject.put(KEY_SIMULATE_CLOCK_COLOR_POINTER_SECOND,simulateClockColorPointerSecond);
|
||||||
|
|
||||||
jsonObject.put(KEY_THEME_UI_NAME,themeName);
|
jsonObject.put(KEY_THEME_UI_NAME,themeName);
|
||||||
|
|
||||||
jsonObject.put(KEY_UI_CLOCK_INTERFACE_TYPE, clockInterfaceType);
|
jsonObject.put(KEY_UI_CLOCK_INTERFACE_TYPE, clockInterfaceType);
|
||||||
@ -526,6 +570,15 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
dirtySave();
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getHandUpDialy() {
|
||||||
|
return handUpDialy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHandUpDialy(Integer handUpDialy) {
|
||||||
|
this.handUpDialy = handUpDialy;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
public String getBackgroundImage() {
|
public String getBackgroundImage() {
|
||||||
return backgroundImage;
|
return backgroundImage;
|
||||||
}
|
}
|
||||||
@ -662,4 +715,68 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
this.autoFullscreen = autoFullscreen;
|
this.autoFullscreen = autoFullscreen;
|
||||||
dirtySave();
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getSimulateClockColorScale() {
|
||||||
|
return simulateClockColorScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorScale(Integer simulateClockColorScale) {
|
||||||
|
this.simulateClockColorScale = simulateClockColorScale;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSimulateClockColorScaleParticularly() {
|
||||||
|
return simulateClockColorScaleParticularly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorScaleParticularly(Integer simulateClockColorScaleParticularly) {
|
||||||
|
this.simulateClockColorScaleParticularly = simulateClockColorScaleParticularly;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSimulateClockColorText() {
|
||||||
|
return simulateClockColorText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorText(Integer simulateClockColorText) {
|
||||||
|
this.simulateClockColorText = simulateClockColorText;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSimulateClockColorOutLine() {
|
||||||
|
return simulateClockColorOutLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorOutLine(Integer simulateClockColorOutLine) {
|
||||||
|
this.simulateClockColorOutLine = simulateClockColorOutLine;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSimulateClockTextShowType() {
|
||||||
|
return simulateClockTextShowType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockTextShowType(Integer simulateClockTextShowType) {
|
||||||
|
this.simulateClockTextShowType = simulateClockTextShowType;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSimulateClockColorPointer() {
|
||||||
|
return simulateClockColorPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorPointer(Integer simulateClockColorPointer) {
|
||||||
|
this.simulateClockColorPointer = simulateClockColorPointer;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSimulateClockColorPointerSecond() {
|
||||||
|
return simulateClockColorPointerSecond;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorPointerSecond(Integer simulateClockColorPointerSecond) {
|
||||||
|
this.simulateClockColorPointerSecond = simulateClockColorPointerSecond;
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.haibin.calendarview.LunarCalendarManager;
|
import com.haibin.calendarview.LunarCalendarManager;
|
||||||
|
|
||||||
|
import java.sql.Time;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
@ -18,11 +19,14 @@ import clock.socoolby.com.clock.model.DateModel;
|
|||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
import clock.socoolby.com.clock.utils.Player;
|
import clock.socoolby.com.clock.utils.Player;
|
||||||
import clock.socoolby.com.clock.utils.ScreenManager;
|
import clock.socoolby.com.clock.utils.ScreenManager;
|
||||||
|
import clock.socoolby.com.clock.viewmodel.AlterViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
import clock.socoolby.com.clock.viewmodel.DigitViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
import clock.socoolby.com.clock.viewmodel.GlobalViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
import clock.socoolby.com.clock.viewmodel.SimulateViewModel;
|
||||||
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
||||||
|
|
||||||
|
import static clock.socoolby.com.clock.state.ClockTimeTypeEnum.TIME;
|
||||||
|
|
||||||
public class ClockStateMachine implements Handler.Callback{
|
public class ClockStateMachine implements Handler.Callback{
|
||||||
|
|
||||||
public static final String TAG=ClockStateMachine.class.getSimpleName();
|
public static final String TAG=ClockStateMachine.class.getSimpleName();
|
||||||
@ -31,6 +35,7 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
DigitViewModel digitViewModel;
|
DigitViewModel digitViewModel;
|
||||||
SimulateViewModel simulateViewModel;
|
SimulateViewModel simulateViewModel;
|
||||||
ThemeUIViewModel themeUIViewModel;
|
ThemeUIViewModel themeUIViewModel;
|
||||||
|
AlterViewModel alterViewModel;
|
||||||
|
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
@ -45,16 +50,18 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
|
|
||||||
boolean heartbeat=false;
|
boolean heartbeat=false;
|
||||||
|
|
||||||
ClockTimeTypeEnum showTimeType=ClockTimeTypeEnum.TIME;
|
ClockTimeTypeEnum showTimeType= TIME;
|
||||||
|
|
||||||
public ClockStateMachine(AlterManager alterManager,GlobalViewModel globalViewModel, DigitViewModel digitViewModel, SimulateViewModel simulateViewModel,ThemeUIViewModel themeUIViewModel) {
|
public ClockStateMachine(AlterManager alterManager,GlobalViewModel globalViewModel, DigitViewModel digitViewModel, SimulateViewModel simulateViewModel,ThemeUIViewModel themeUIViewModel,AlterViewModel alterViewModel) {
|
||||||
this.globalViewModel = globalViewModel;
|
this.globalViewModel = globalViewModel;
|
||||||
this.digitViewModel = digitViewModel;
|
this.digitViewModel = digitViewModel;
|
||||||
this.simulateViewModel = simulateViewModel;
|
this.simulateViewModel = simulateViewModel;
|
||||||
this.alterManager = alterManager;
|
this.alterManager = alterManager;
|
||||||
|
this.alterViewModel=alterViewModel;
|
||||||
this.themeUIViewModel=themeUIViewModel;
|
this.themeUIViewModel=themeUIViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start(){
|
public void start(){
|
||||||
LunarCalendarManager.init(ClockApplication.getContext());
|
LunarCalendarManager.init(ClockApplication.getContext());
|
||||||
model=ClockApplication.getInstance().getModel();
|
model=ClockApplication.getInstance().getModel();
|
||||||
@ -73,8 +80,6 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
timer.schedule(timerTask, 1000, 1000);
|
timer.schedule(timerTask, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
@ -87,49 +92,32 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentShowTimeType(ClockTimeTypeEnum type){
|
public void setCurrentShowTimeType(ClockTimeTypeEnum type){
|
||||||
|
if(getCurrentModeEnum()==ClockModeEnum.HANDUP)
|
||||||
|
stopHandUp(true);
|
||||||
|
else if(getCurrentModeEnum()==ClockModeEnum.DELAY)
|
||||||
|
stopHandUpDelay();
|
||||||
|
this.showTimeType=type;
|
||||||
|
countingDateTimeBase=null;
|
||||||
switch (type){
|
switch (type){
|
||||||
case COUNTING:
|
case COUNTING:
|
||||||
countingDateTimeBase =new Date();
|
countingDateTimeBase =new Date();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int handUPDialy=60;
|
public ClockTimeTypeEnum getCurrentShowTimeType(){
|
||||||
|
return showTimeType;
|
||||||
private void checkHandUp(){
|
|
||||||
/*if(!handUpAbla) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//Log.d(TAG,"checkHandUp..\thandUPDialy:"+handUPDialy+" \thandUpTime:"+handUpTime+"\thandUpAble:"+handUpAbla);
|
|
||||||
if(mMode==MODE_HANDUP) {
|
|
||||||
tv_handup_image.setText("hand up:"+handUPDialy);
|
|
||||||
handUPDialy--;
|
|
||||||
if(handUPDialy==0) {
|
|
||||||
switchMode(MODE_NORMAL);
|
|
||||||
if(!isArtificialHiddle&&showTimeType==ShowTimeType.TIME){
|
|
||||||
setCurrentShowTimeType(ShowTimeType.COUNTING);
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
Player.valueOf().playHandUp(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handUpTime--;
|
|
||||||
if(hand_time_visable)
|
|
||||||
tv_hand_time.setText(DateModel.getTime(handUpTime));
|
|
||||||
if (handUpTime <= 10&&handUpTime > 0)
|
|
||||||
setDiscript("提醒时间倒计时: " + handUpTime);
|
|
||||||
if (handUpTime == 0) {
|
|
||||||
handUPDialy = 60;
|
|
||||||
resetHandUpTime();
|
|
||||||
switchMode(MODE_HANDUP);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ClockModeEnum getCurrentModeEnum(){
|
||||||
|
return globalViewModel.getClockModeEnum().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateTime() {
|
private void updateTime() {
|
||||||
heartbeat=!heartbeat;
|
heartbeat=!heartbeat;
|
||||||
DateModel date = new DateModel();
|
DateModel date = new DateModel();
|
||||||
String timeString=null;
|
String timeString=null;
|
||||||
switch (globalViewModel.getClockModeEnum().getValue()){
|
switch (getCurrentModeEnum()){
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
switch (showTimeType){
|
switch (showTimeType){
|
||||||
case COUNTING:
|
case COUNTING:
|
||||||
@ -140,7 +128,7 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COUNTING_DOWN:
|
case COUNTING_DOWN:
|
||||||
//timeString=DateModel.getTimeFull(handUpTime);
|
timeString=DateModel.getTimeFull(globalViewModel.getHandUpTime().getValue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
|
timeString = model.isDisplaySecond() ? date.getTimeString(model.isHourSystem12()) : date.getShortTimeString(heartbeat,model.isHourSystem12());
|
||||||
@ -149,10 +137,15 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
digitViewModel.getTimeText().setValue(timeString);
|
digitViewModel.getTimeText().setValue(timeString);
|
||||||
break;
|
break;
|
||||||
case HANDUP:
|
case HANDUP:
|
||||||
|
globalViewModel.setHeartbeat(heartbeat);
|
||||||
break;
|
break;
|
||||||
case DELAY:
|
case DELAY:
|
||||||
|
DateModel temp=new DateModel(countingDateTimeBase);
|
||||||
|
timeString=temp.getTimeString(false);
|
||||||
|
if (!model.isTickSound()) {
|
||||||
|
Player.getInstance().playTick(ClockApplication.getContext(), R.raw.tick2);
|
||||||
|
}
|
||||||
|
digitViewModel.getTimeText().setValue(timeString);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
reportTime(date);
|
reportTime(date);
|
||||||
@ -224,4 +217,64 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
public void onDestory() {
|
public void onDestory() {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//handUp
|
||||||
|
public void stopHandUp(boolean userCheckStop){
|
||||||
|
if(!userCheckStop&&showTimeType==TIME){
|
||||||
|
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.DELAY);
|
||||||
|
}else
|
||||||
|
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopHandUpDelay(){
|
||||||
|
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handUpCountingDownCheck(){
|
||||||
|
if(isHandUpAbla()){
|
||||||
|
if(showTimeType==ClockTimeTypeEnum.COUNTING_DOWN)
|
||||||
|
setCurrentShowTimeType(TIME);
|
||||||
|
else
|
||||||
|
setCurrentShowTimeType(ClockTimeTypeEnum.COUNTING_DOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void countingCheck(){
|
||||||
|
if(showTimeType!= ClockTimeTypeEnum.COUNTING){
|
||||||
|
setCurrentShowTimeType(ClockTimeTypeEnum.COUNTING);
|
||||||
|
}else{
|
||||||
|
setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isHandUpAbla(){
|
||||||
|
return globalViewModel.getHandUpAble().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkHandUp(){
|
||||||
|
if(!isHandUpAbla()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int handUpTime=globalViewModel.getHandUpTime().getValue();
|
||||||
|
switch (getCurrentModeEnum()) {
|
||||||
|
case NORMAL:
|
||||||
|
globalViewModel.getHandUpTime().setValue(handUpTime-1);
|
||||||
|
if (handUpTime <= 10&&handUpTime > 0)
|
||||||
|
themeUIViewModel.setDescription("提醒时间倒计时: " + handUpTime);
|
||||||
|
if (handUpTime == 0) {
|
||||||
|
globalViewModel.getHandUpTime().setValue(model.getHandUpTime());
|
||||||
|
globalViewModel.getClockModeEnum().setValue(ClockModeEnum.HANDUP);
|
||||||
|
themeUIViewModel.setDescription(model.getDescription());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HANDUP:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case DELAY:
|
||||||
|
if(countingDateTimeBase==null)
|
||||||
|
countingDateTimeBase =new Date();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ public class AlterViewModel extends ViewModel {
|
|||||||
private MutableLiveData<Integer> handUPDialy=new MutableLiveData<>();
|
private MutableLiveData<Integer> handUPDialy=new MutableLiveData<>();
|
||||||
|
|
||||||
//alter handUp UI
|
//alter handUp UI
|
||||||
private MutableLiveData<String> handUpDescription=new MutableLiveData<>();
|
|
||||||
|
|
||||||
SharePerferenceModel model;
|
SharePerferenceModel model;
|
||||||
|
|
||||||
@ -25,20 +24,16 @@ public class AlterViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromModel(){
|
public void loadFromModel(){
|
||||||
|
|
||||||
String handUpMusicString=model.getHandUpMusic();
|
String handUpMusicString=model.getHandUpMusic();
|
||||||
Uri musicUri=handUpMusicString.isEmpty()?null:Uri.parse(handUpMusicString);
|
Uri musicUri=handUpMusicString.isEmpty()?null:Uri.parse(handUpMusicString);
|
||||||
handUpMusic.setValue(musicUri);
|
handUpMusic.setValue(musicUri);
|
||||||
|
handUPDialy.setValue(model.getHandUpDialy());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<Uri> getHandUpMusic() {
|
public MutableLiveData<Uri> getHandUpMusic() {
|
||||||
return handUpMusic;
|
return handUpMusic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<String> getHandUpDescription() {
|
|
||||||
return handUpDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MutableLiveData<Integer> getHandUPDialy() {
|
public MutableLiveData<Integer> getHandUPDialy() {
|
||||||
return handUPDialy;
|
return handUPDialy;
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,9 @@ public class DigitViewModel extends ViewModel {
|
|||||||
model.setTimeColorsArray(timeLinearGradientColorsArray);
|
model.setTimeColorsArray(timeLinearGradientColorsArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReflectedAble(MutableLiveData<Boolean> reflectedAble) {
|
public void setReflectedAble(Boolean reflectedAble) {
|
||||||
this.reflectedAble = reflectedAble;
|
this.reflectedAble.setValue(reflectedAble);
|
||||||
|
model.setReflectedAble(reflectedAble);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeFontStyleSize(Integer timeFontStyleSize) {
|
public void setTimeFontStyleSize(Integer timeFontStyleSize) {
|
||||||
|
@ -40,6 +40,8 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<Integer> brightness=new MutableLiveData<>();
|
private MutableLiveData<Integer> brightness=new MutableLiveData<>();
|
||||||
|
|
||||||
|
public MutableLiveData<Boolean> heartbeat=new MutableLiveData();
|
||||||
|
|
||||||
//alter handUp
|
//alter handUp
|
||||||
private MutableLiveData<Integer> handUpTime=new MutableLiveData<>();
|
private MutableLiveData<Integer> handUpTime=new MutableLiveData<>();
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
public void loadFromModel(){
|
public void loadFromModel(){
|
||||||
srceenLock.setValue(false);
|
srceenLock.setValue(false);
|
||||||
brightness.setValue(100);
|
brightness.setValue(100);
|
||||||
|
heartbeat.setValue(true);
|
||||||
|
|
||||||
mCity.setValue(model.getCity());
|
mCity.setValue(model.getCity());
|
||||||
backgroundColor.setValue(model.getBackgroundColor());
|
backgroundColor.setValue(model.getBackgroundColor());
|
||||||
@ -85,6 +88,8 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
handUpAble.setValue(model.isHandUpAble());
|
handUpAble.setValue(model.isHandUpAble());
|
||||||
handUpTime.setValue(model.getHandUpTime());
|
handUpTime.setValue(model.getHandUpTime());
|
||||||
|
|
||||||
|
hourSystem12.setValue(model.isHourSystem12());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<String> getCity() {
|
public MutableLiveData<String> getCity() {
|
||||||
@ -164,6 +169,7 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
return handUpAble;
|
return handUpAble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCity(String mCity) {
|
public void setCity(String mCity) {
|
||||||
this.mCity.setValue(mCity);
|
this.mCity.setValue(mCity);
|
||||||
model.setCity(mCity);
|
model.setCity(mCity);
|
||||||
@ -246,11 +252,19 @@ public class GlobalViewModel extends ViewModel {
|
|||||||
|
|
||||||
public void setHandUpTime(Integer handUpTime) {
|
public void setHandUpTime(Integer handUpTime) {
|
||||||
this.handUpTime.setValue(handUpTime);
|
this.handUpTime.setValue(handUpTime);
|
||||||
model.setHandUpTime(handUpTime);
|
//model.setHandUpTime(handUpTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHandUpAble(Boolean handUpAble) {
|
public void setHandUpAble(Boolean handUpAble) {
|
||||||
this.handUpAble.setValue(handUpAble);
|
this.handUpAble.setValue(handUpAble);
|
||||||
model.setHandUpAble(handUpAble);
|
model.setHandUpAble(handUpAble);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Boolean> getHeartbeat() {
|
||||||
|
return heartbeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeartbeat(Boolean heartbeat) {
|
||||||
|
this.heartbeat.setValue(heartbeat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
|
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.SimulateTextShowTypeEnum;
|
||||||
|
|
||||||
public class SimulateViewModel extends ViewModel {
|
public class SimulateViewModel extends ViewModel {
|
||||||
|
|
||||||
@ -11,6 +12,18 @@ public class SimulateViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<String> pointerTypeName=new MutableLiveData<>();
|
private MutableLiveData<String> pointerTypeName=new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<Integer> simulateClockColorScale=new MutableLiveData<>();
|
||||||
|
private MutableLiveData<Integer> simulateClockColorScaleParticularly=new MutableLiveData<>();
|
||||||
|
private MutableLiveData<Integer> simulateClockColorText=new MutableLiveData<>();
|
||||||
|
private MutableLiveData<Integer> simulateClockColorOutLine=new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<Integer> simulateClockColorPointer=new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<Integer> simulateClockColorPointerSecond=new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<SimulateTextShowTypeEnum> simulateClockTextShowType=new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
SharePerferenceModel model;
|
SharePerferenceModel model;
|
||||||
|
|
||||||
public SimulateViewModel(SharePerferenceModel model) {
|
public SimulateViewModel(SharePerferenceModel model) {
|
||||||
@ -21,6 +34,14 @@ public class SimulateViewModel extends ViewModel {
|
|||||||
private void loadFromModel(){
|
private void loadFromModel(){
|
||||||
clockTypeName.setValue(model.getSimulateClockTypeName());
|
clockTypeName.setValue(model.getSimulateClockTypeName());
|
||||||
pointerTypeName.setValue(model.getSimulateClockPointerTypeName());
|
pointerTypeName.setValue(model.getSimulateClockPointerTypeName());
|
||||||
|
|
||||||
|
simulateClockColorScale.setValue(model.getSimulateClockColorScale());
|
||||||
|
simulateClockColorScaleParticularly.setValue(model.getSimulateClockColorScaleParticularly());
|
||||||
|
simulateClockColorText.setValue(model.getSimulateClockColorText());
|
||||||
|
simulateClockColorOutLine.setValue(model.getSimulateClockColorOutLine());
|
||||||
|
simulateClockTextShowType.setValue(SimulateTextShowTypeEnum.valueOf(model.getSimulateClockTextShowType()));
|
||||||
|
simulateClockColorPointer.setValue(model.getSimulateClockColorPointer());
|
||||||
|
simulateClockColorPointerSecond.setValue(model.getSimulateClockColorPointerSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<String> getClockTypeName() {
|
public MutableLiveData<String> getClockTypeName() {
|
||||||
@ -40,4 +61,68 @@ public class SimulateViewModel extends ViewModel {
|
|||||||
this.pointerTypeName.setValue(pointerTypeName);
|
this.pointerTypeName.setValue(pointerTypeName);
|
||||||
model.setSimulateClockPointerTypeName(pointerTypeName);
|
model.setSimulateClockPointerTypeName(pointerTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSimulateClockColorScale() {
|
||||||
|
return simulateClockColorScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorScale(Integer simulateClockColorScale) {
|
||||||
|
this.simulateClockColorScale.setValue(simulateClockColorScale);
|
||||||
|
model.setSimulateClockColorScale(simulateClockColorScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSimulateClockColorScaleParticularly() {
|
||||||
|
return simulateClockColorScaleParticularly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorScaleParticularly(Integer simulateClockColorScaleParticularly) {
|
||||||
|
this.simulateClockColorScaleParticularly.setValue(simulateClockColorScaleParticularly);
|
||||||
|
model.setSimulateClockColorScaleParticularly(simulateClockColorScaleParticularly);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSimulateClockColorText() {
|
||||||
|
return simulateClockColorText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorText(Integer simulateClockColorText) {
|
||||||
|
this.simulateClockColorText.setValue(simulateClockColorText);
|
||||||
|
model.setSimulateClockColorText(simulateClockColorText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSimulateClockColorOutLine() {
|
||||||
|
return simulateClockColorOutLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorOutLine(Integer simulateClockColorOutLine) {
|
||||||
|
this.simulateClockColorOutLine.setValue(simulateClockColorOutLine);
|
||||||
|
model.setSimulateClockColorOutLine(simulateClockColorOutLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<SimulateTextShowTypeEnum> getSimulateClockTextShowType() {
|
||||||
|
return simulateClockTextShowType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockTextShowType(SimulateTextShowTypeEnum simulateClockTextShowType) {
|
||||||
|
this.simulateClockTextShowType.setValue(simulateClockTextShowType);
|
||||||
|
model.setSimulateClockTextShowType(simulateClockTextShowType.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSimulateClockColorPointer() {
|
||||||
|
return simulateClockColorPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorPointer(Integer simulateClockColorPointer) {
|
||||||
|
this.simulateClockColorPointer.setValue(simulateClockColorPointer);
|
||||||
|
model.setSimulateClockColorPointer(simulateClockColorPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getSimulateClockColorPointerSecond() {
|
||||||
|
return simulateClockColorPointerSecond;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateClockColorPointerSecond(Integer simulateClockColorPointerSecond) {
|
||||||
|
this.simulateClockColorPointerSecond.setValue(simulateClockColorPointerSecond);
|
||||||
|
model.setSimulateClockColorPointerSecond(simulateClockColorPointerSecond);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,12 @@ public class ClockAnimator extends AbstractAnimator<AbstractClock> {
|
|||||||
|
|
||||||
AbstractClock clock;
|
AbstractClock clock;
|
||||||
|
|
||||||
|
// 时钟颜色、默认刻度颜色、时刻度颜色
|
||||||
|
protected int mClockColor=Color.BLACK, mColorDefaultScale=Color.BLACK, mColorParticularyScale=Color.BLACK,textColor=Color.BLACK,mClockColorPointer=Color.BLACK,pointerSecondColor=Color.BLACK;
|
||||||
|
|
||||||
public ClockAnimator() {
|
public ClockAnimator() {
|
||||||
super(DYNAMIC_QUANTITY);
|
super(DYNAMIC_QUANTITY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +46,16 @@ public class ClockAnimator extends AbstractAnimator<AbstractClock> {
|
|||||||
list.clear();
|
list.clear();
|
||||||
this.clock=clock1;
|
this.clock=clock1;
|
||||||
int minHigh=Math.min(width,height);
|
int minHigh=Math.min(width,height);
|
||||||
clock.init(width,height,width/2,height/2,minHigh/2,color,color);
|
clock.init(width,height,width/2,height/2,minHigh/2,color,textColor);
|
||||||
|
|
||||||
|
clock.setPointerSecondColor(pointerSecondColor);
|
||||||
|
clock.setmColorDefaultScale(mColorDefaultScale);
|
||||||
|
clock.setmColorParticularyScale(mColorParticularyScale);
|
||||||
|
clock.setTextColor(textColor);
|
||||||
|
clock.setmClockColorPointer(mClockColorPointer);
|
||||||
|
clock.setPointerSecondColor(pointerSecondColor);
|
||||||
|
clock.setmClockColor(mClockColor);
|
||||||
|
|
||||||
list.add(clock);
|
list.add(clock);
|
||||||
Log.d("clock","set clock type: "+clock1.typeName()+"\t color:"+ color);
|
Log.d("clock","set clock type: "+clock1.typeName()+"\t color:"+ color);
|
||||||
}
|
}
|
||||||
@ -57,38 +70,37 @@ public class ClockAnimator extends AbstractAnimator<AbstractClock> {
|
|||||||
super.onSizeChanged(w, h, oldw, oldh);
|
super.onSizeChanged(w, h, oldw, oldh);
|
||||||
if(clock!=null) {
|
if(clock!=null) {
|
||||||
int minHigh=Math.min(width,height);
|
int minHigh=Math.min(width,height);
|
||||||
clock.init(width, height, width / 2, height / 2, minHigh / 2, color, color);
|
clock.init(width, height, width / 2, height / 2, minHigh / 2, color, textColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int randPointerIndex=1;
|
public void setmClockColor(int mClockColor) {
|
||||||
public void randPointer(){
|
this.mClockColor = mClockColor;
|
||||||
if(clock==null)
|
clock.setmClockColor(mClockColor);
|
||||||
return;
|
|
||||||
if(randPointerIndex>6)
|
|
||||||
randPointerIndex=0;
|
|
||||||
switch (randPointerIndex){
|
|
||||||
case 1:
|
|
||||||
clock.setPointer(new SecondTailPointer());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
clock.setPointer(new TrianglePointer());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
clock.setPointer(new SwordPointer());
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
clock.setPointer(new TwoStepPointer());
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
clock.setPointer(new LeafPointer());
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
clock.setPointer(new LeafTwoPointer());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
clock.setPointer(new DefaultPointer());
|
|
||||||
}
|
}
|
||||||
randPointerIndex++;
|
|
||||||
|
public void setmColorDefaultScale(int mColorDefaultScale) {
|
||||||
|
this.mColorDefaultScale = mColorDefaultScale;
|
||||||
|
clock.setmColorDefaultScale(mColorDefaultScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmColorParticularyScale(int mColorParticularyScale) {
|
||||||
|
this.mColorParticularyScale = mColorParticularyScale;
|
||||||
|
clock.setmColorParticularyScale(mColorParticularyScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(int textColor) {
|
||||||
|
this.textColor = textColor;
|
||||||
|
clock.setTextColor(textColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmClockColorPointer(int mClockColorPointer) {
|
||||||
|
this.mClockColorPointer = mClockColorPointer;
|
||||||
|
clock.setmClockColorPointer(mClockColorPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointerSecondColor(int pointerSecondColor) {
|
||||||
|
this.pointerSecondColor = pointerSecondColor;
|
||||||
|
clock.setPointerSecondColor(pointerSecondColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,13 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
protected int mH, mM, mS;
|
protected int mH, mM, mS;
|
||||||
|
|
||||||
// 时钟颜色、默认刻度颜色、时刻度颜色
|
// 时钟颜色、默认刻度颜色、时刻度颜色
|
||||||
protected int mClockColor, mColorDefaultScale, mColorParticularyScale,textColor;
|
protected int mClockColor, mColorDefaultScale, mColorParticularyScale,textColor,mClockColorPointer,pointerSecondColor;
|
||||||
|
|
||||||
I_Pointer pointer;
|
I_Pointer pointer;
|
||||||
|
|
||||||
|
SimulateTextShowTypeEnum simulateTextShowTypeEnum=SimulateTextShowTypeEnum.FOUR;
|
||||||
|
|
||||||
|
|
||||||
public AbstractClock() {
|
public AbstractClock() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -55,6 +58,8 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
private void init() {
|
private void init() {
|
||||||
mColorDefaultScale = mClockColor;
|
mColorDefaultScale = mClockColor;
|
||||||
mColorParticularyScale = mClockColor;
|
mColorParticularyScale = mClockColor;
|
||||||
|
mClockColorPointer=mClockColor;
|
||||||
|
pointerSecondColor=mClockColor;
|
||||||
|
|
||||||
mDefaultPaint = new Paint();
|
mDefaultPaint = new Paint();
|
||||||
mDefaultPaint.setAntiAlias(true);
|
mDefaultPaint.setAntiAlias(true);
|
||||||
@ -64,7 +69,7 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
mTextPaint.setStrokeWidth(mDefaultScaleWidth / 2);
|
mTextPaint.setStrokeWidth(mDefaultScaleWidth / 2);
|
||||||
mTextPaint.setTextSize(mParticularlyScaleWidth * 4);
|
mTextPaint.setTextSize(mParticularlyScaleWidth * 4);
|
||||||
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
mTextPaint.setColor(textColor);
|
//mTextPaint.setColor(textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +94,8 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
|
|
||||||
public void setPointer(I_Pointer pointer){
|
public void setPointer(I_Pointer pointer){
|
||||||
this.pointer=pointer;
|
this.pointer=pointer;
|
||||||
pointer.init(mRadius,mClockColor);
|
pointer.init(mRadius,mClockColorPointer);
|
||||||
|
pointer.setColorSecond(pointerSecondColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,6 +104,64 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
pointer.init(mRadius,mClockColor);
|
pointer.init(mRadius,mClockColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getmColorDefaultScale() {
|
||||||
|
return mColorDefaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmColorDefaultScale(int mColorDefaultScale) {
|
||||||
|
this.mColorDefaultScale = mColorDefaultScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getmColorParticularyScale() {
|
||||||
|
return mColorParticularyScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmColorParticularyScale(int mColorParticularyScale) {
|
||||||
|
this.mColorParticularyScale = mColorParticularyScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextColor() {
|
||||||
|
return textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(int textColor) {
|
||||||
|
this.textColor = textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getmClockColor() {
|
||||||
|
return mClockColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmClockColor(int mClockColor) {
|
||||||
|
this.mClockColor = mClockColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getmClockColorPointer() {
|
||||||
|
return mClockColorPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmClockColorPointer(int mClockColorPointer) {
|
||||||
|
this.mClockColorPointer = mClockColorPointer;
|
||||||
|
pointer.setmPointerColor(mClockColorPointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPointerSecondColor() {
|
||||||
|
return pointerSecondColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointerSecondColor(int pointerSecondColor) {
|
||||||
|
this.pointerSecondColor = pointerSecondColor;
|
||||||
|
pointer.setColorSecond(pointerSecondColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimulateTextShowTypeEnum getSimulateTextShowTypeEnum() {
|
||||||
|
return simulateTextShowTypeEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSimulateTextShowTypeEnum(SimulateTextShowTypeEnum simulateTextShowTypeEnum) {
|
||||||
|
this.simulateTextShowTypeEnum = simulateTextShowTypeEnum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前系统时间
|
* 获取当前系统时间
|
||||||
*/
|
*/
|
||||||
@ -124,11 +188,15 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
|
|
||||||
|
|
||||||
public void onDraw(Canvas canvas, Paint mPaint) {
|
public void onDraw(Canvas canvas, Paint mPaint) {
|
||||||
|
|
||||||
drawBorder(canvas);
|
drawBorder(canvas);
|
||||||
|
|
||||||
drawOrnament(canvas);
|
drawOrnament(canvas);
|
||||||
// 坐标原点移动到View 中心
|
// 坐标原点移动到View 中心
|
||||||
canvas.translate(mCenterX, mCenterY);
|
canvas.translate(mCenterX, mCenterY);
|
||||||
|
mPaint.setColor(textColor);
|
||||||
drawText(canvas);
|
drawText(canvas);
|
||||||
|
mPaint.setColor(mClockColorPointer);
|
||||||
pointer.drawPointer(canvas,mH,mM,mS,mPaint);
|
pointer.drawPointer(canvas,mH,mM,mS,mPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +289,7 @@ public abstract class AbstractClock implements I_AnimatorEntry {
|
|||||||
fontWidth = mTextPaint.measureText(h);
|
fontWidth = mTextPaint.measureText(h);
|
||||||
// y轴坐标为: -(半径-特殊刻度长度-特殊刻度宽度(作为间距)-文字长度/2(绘制原点在文字横向中心))
|
// y轴坐标为: -(半径-特殊刻度长度-特殊刻度宽度(作为间距)-文字长度/2(绘制原点在文字横向中心))
|
||||||
y = -(mRadius - mParticularlyScaleLength - mParticularlyScaleWidth - (fontWidth / 2));
|
y = -(mRadius - mParticularlyScaleLength - mParticularlyScaleWidth - (fontWidth / 2));
|
||||||
|
|
||||||
canvas.drawText(h, y, 0 + offsetY, mTextPaint);
|
canvas.drawText(h, y, 0 + offsetY, mTextPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,4 +31,26 @@ public class ClockFactory {
|
|||||||
}
|
}
|
||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String[] CLOCKS_ARRAY=new String[]{
|
||||||
|
CircleClock.TYPE_CIRCLE,
|
||||||
|
CircleTwoClock.TYPE_CIRCLE_TWO,
|
||||||
|
HelixClock.TYPE_HELIX,
|
||||||
|
HexagonalClock.TYPE_HEXAGONAL,
|
||||||
|
OctagonalClock.TYPE_OCTAGONAL,
|
||||||
|
OvalClock.TYPE_OVAL,
|
||||||
|
SquareClock.TYPE_SQUARE
|
||||||
|
};
|
||||||
|
|
||||||
|
public static String nextSimulateClockName(String currentName){
|
||||||
|
int order=0;
|
||||||
|
for(int i=0;i<CLOCKS_ARRAY.length;i++)
|
||||||
|
if(CLOCKS_ARRAY[i].equalsIgnoreCase(currentName))
|
||||||
|
order=i;
|
||||||
|
order++;
|
||||||
|
if(order==CLOCKS_ARRAY.length)
|
||||||
|
order=0;
|
||||||
|
return CLOCKS_ARRAY[order];
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,8 @@ public interface I_Pointer {
|
|||||||
void drawPointer(Canvas canvas, int mH,int mM,int mS, Paint mPointerPaint);
|
void drawPointer(Canvas canvas, int mH,int mM,int mS, Paint mPointerPaint);
|
||||||
|
|
||||||
String typeName();
|
String typeName();
|
||||||
|
|
||||||
|
void setmPointerColor(int mClockColor);
|
||||||
|
|
||||||
|
void setColorSecond(int colorSecond);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package clock.socoolby.com.clock.widget.animatorview.animator.clockanimator;
|
||||||
|
|
||||||
|
public enum SimulateTextShowTypeEnum {
|
||||||
|
FULL(0),FOUR(1),HIDD(2);
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
|
||||||
|
SimulateTextShowTypeEnum(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SimulateTextShowTypeEnum valueOf(int code){
|
||||||
|
switch (code){
|
||||||
|
case 1:
|
||||||
|
return FOUR;
|
||||||
|
case 2:
|
||||||
|
return HIDD;
|
||||||
|
default:
|
||||||
|
return FULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package clock.socoolby.com.clock.widget.animatorview.animator.clockanimator;
|
package clock.socoolby.com.clock.widget.animatorview.animator.clockanimator;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
|
||||||
|
|
||||||
//方型
|
//方型
|
||||||
public class SquareClock extends AbstractClock {
|
public class SquareClock extends AbstractClock {
|
||||||
|
@ -40,9 +40,14 @@ public abstract class AbstractPointer implements I_Pointer {
|
|||||||
|
|
||||||
public void setmPointerColor(int color){
|
public void setmPointerColor(int color){
|
||||||
this.mClockColor=color;
|
this.mClockColor=color;
|
||||||
|
mColorHourPointer=mColorMinutePointer=mColorSecondPointer=color;
|
||||||
mPointerPaint.setColor(mClockColor);
|
mPointerPaint.setColor(mClockColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setColorSecond(int colorSecond) {
|
||||||
|
mColorSecondPointer=colorSecond;
|
||||||
|
}
|
||||||
|
|
||||||
public void initPointerLength(float mRadius){
|
public void initPointerLength(float mRadius){
|
||||||
/*
|
/*
|
||||||
|
@ -33,14 +33,17 @@ public class AutoScrollTextView extends androidx.appcompat.widget.AppCompatTextV
|
|||||||
|
|
||||||
public AutoScrollTextView(Context context) {
|
public AutoScrollTextView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
init(context,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoScrollTextView(Context context, AttributeSet attrs) {
|
public AutoScrollTextView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
init(context,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoScrollTextView(Context context, AttributeSet attrs, int defStyle) {
|
public AutoScrollTextView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
|
init(context,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Context context,boolean clickScroll)
|
public void init(Context context,boolean clickScroll)
|
||||||
|
@ -8,7 +8,6 @@ import android.graphics.Matrix;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.style.ReplacementSpan;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -33,7 +32,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
|
|
||||||
private ShadowTypeEnum shadowType=ShadowTypeEnum.NOSETUP;//0:不设置,1:阴影,2:浮雕
|
private ShadowTypeEnum shadowType=ShadowTypeEnum.NOSETUP;//0:不设置,1:阴影,2:浮雕
|
||||||
|
|
||||||
private int[] linearGradientColors;
|
private int[] linearGradientColors=null;
|
||||||
|
|
||||||
int textWidth=0;
|
int textWidth=0;
|
||||||
|
|
||||||
@ -55,15 +54,18 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
this.baseLineDown = baseLineDown;
|
this.baseLineDown = baseLineDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] pos = {0f,0.2f,0.4f,0.5f,0.6f,0.8f,1.0f};
|
float[] pos = {0.1f,0.3f,0.5f,0.7f,0.9f};
|
||||||
|
|
||||||
boolean isLinearGradientPosAble=false;
|
boolean isLinearGradientPosAble=false;
|
||||||
|
|
||||||
boolean isReflectedAble=false;
|
boolean isReflectedAble=false;
|
||||||
|
|
||||||
|
boolean linearGradientReCreate=false;
|
||||||
|
|
||||||
|
|
||||||
public void setLinearGradientRandom(boolean able){
|
public void setLinearGradientRandom(boolean able){
|
||||||
if(able){
|
if(able){
|
||||||
linearGradientColors= new int[]{roundColor(), roundColor(), roundColor(), roundColor(), roundColor(), roundColor(), roundColor()};
|
linearGradientColors= new int[]{roundColor(), roundColor(), roundColor(), roundColor(), roundColor()};
|
||||||
isLinearGradientPosAble=rand.nextBoolean();
|
isLinearGradientPosAble=rand.nextBoolean();
|
||||||
isReflectedAble=rand.nextBoolean();
|
isReflectedAble=rand.nextBoolean();
|
||||||
}
|
}
|
||||||
@ -73,23 +75,26 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
|
|
||||||
public void setLinearGradientAble(boolean able){
|
public void setLinearGradientAble(boolean able){
|
||||||
isLinearGradientAble=able;
|
isLinearGradientAble=able;
|
||||||
Paint mTextPaint=getPaint();
|
linearGradientReCreate=true;
|
||||||
if(isLinearGradientAble){
|
|
||||||
setLinearGradient(linearGradientColors);
|
|
||||||
}else{
|
|
||||||
mTextPaint.setShader(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLinearGradient(int[] colors){
|
public void setLinearGradient(int[] colors){
|
||||||
Paint mTextPaint=getPaint();
|
this.linearGradientColors=colors;
|
||||||
if(isLinearGradientPosAble&&colors.length==pos.length)
|
linearGradientReCreate=true;
|
||||||
mLinearGradient = new LinearGradient(0, 0, getWidth(), getHeight(), colors , pos, Shader.TileMode.CLAMP);
|
|
||||||
else
|
|
||||||
mLinearGradient = new LinearGradient(0, 0, getWidth(), 0,colors, null, Shader.TileMode.CLAMP);
|
|
||||||
mTextPaint.setShader(mLinearGradient);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkReCreate(){
|
||||||
|
mLinearGradient = null;
|
||||||
|
if(isLinearGradientAble)
|
||||||
|
//if(isLinearGradientPosAble&&linearGradientColors.length==pos.length)
|
||||||
|
mLinearGradient = new LinearGradient(0, 0, getWidth(), getHeight(), linearGradientColors , pos, Shader.TileMode.CLAMP);
|
||||||
|
//else
|
||||||
|
//mLinearGradient = new LinearGradient(0, 0, getWidth(), 0,linearGradientColors, null, Shader.TileMode.CLAMP);
|
||||||
|
getPaint().setShader(mLinearGradient);
|
||||||
|
linearGradientReCreate=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setShadowType(ShadowTypeEnum shadowType){
|
public void setShadowType(ShadowTypeEnum shadowType){
|
||||||
this.shadowType=shadowType;
|
this.shadowType=shadowType;
|
||||||
switch (shadowType){
|
switch (shadowType){
|
||||||
@ -98,7 +103,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
break;
|
break;
|
||||||
case RELIEF:
|
case RELIEF:
|
||||||
//setShadowLayer(1, 0.5f, 0.5f, Color.argb(200,204,204,204));//浮雕效果
|
//setShadowLayer(1, 0.5f, 0.5f, Color.argb(200,204,204,204));//浮雕效果
|
||||||
setShadowLayer(10, 0, 0, Color.parseColor("#FF4141"));//边缘模糊
|
setShadowLayer(12, 0, 1,Color.parseColor("#CC2b88f6"));//边缘模糊
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
setShadowLayer(0,0,0,getPaint().getColor());
|
setShadowLayer(0,0,0,getPaint().getColor());
|
||||||
@ -156,12 +161,25 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
|
|
||||||
private CharAnimatorEnum currentCharAnimatorType= CharAnimatorEnum.Marquee3D_Up;
|
private CharAnimatorEnum currentCharAnimatorType= CharAnimatorEnum.Marquee3D_Up;
|
||||||
|
|
||||||
|
AbstractCharAnimator charAnimator;
|
||||||
|
|
||||||
|
float startX,startY;
|
||||||
|
|
||||||
|
Paint smallCharPaint=null;
|
||||||
|
|
||||||
|
Paint mTextPaint;
|
||||||
|
|
||||||
|
float fontScale;
|
||||||
|
|
||||||
|
String charStr;
|
||||||
|
|
||||||
|
float centerY;
|
||||||
|
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
int color = getCurrentTextColor();
|
|
||||||
|
|
||||||
Paint mTextPaint=getPaint();
|
mTextPaint=getPaint();
|
||||||
|
|
||||||
mTextPaint.setColor(color);
|
mTextPaint.setColor(getCurrentTextColor());
|
||||||
|
|
||||||
CharSequence textToDraw=getText();
|
CharSequence textToDraw=getText();
|
||||||
|
|
||||||
@ -172,7 +190,6 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
textHight=-fm.descent - fm.ascent;
|
textHight=-fm.descent - fm.ascent;
|
||||||
smallTextHight=0;
|
smallTextHight=0;
|
||||||
smallCharWidth=0;
|
smallCharWidth=0;
|
||||||
Paint smallCharPaint=null;
|
|
||||||
|
|
||||||
textLength=textToDraw.length();
|
textLength=textToDraw.length();
|
||||||
textSmallSpan=0;
|
textSmallSpan=0;
|
||||||
@ -182,7 +199,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(textLength>7){
|
if(textLength>7){
|
||||||
float fontScale = getResources().getDisplayMetrics().scaledDensity;
|
fontScale = getResources().getDisplayMetrics().scaledDensity;
|
||||||
smallCharPaint = getCustomTextPaint(mTextPaint,mTextPaint.getTextSize()/fontScale*4/5);
|
smallCharPaint = getCustomTextPaint(mTextPaint,mTextPaint.getTextSize()/fontScale*4/5);
|
||||||
smallCharWidth=getCharWidth("8",smallCharPaint);
|
smallCharWidth=getCharWidth("8",smallCharPaint);
|
||||||
fm=smallCharPaint.getFontMetricsInt();
|
fm=smallCharPaint.getFontMetricsInt();
|
||||||
@ -190,19 +207,20 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
textSmallSpan=smallCharWidth*2;
|
textSmallSpan=smallCharWidth*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float startX=(getWidth()-textWidth-textSmallSpan)/2;
|
startX=(getWidth()-textWidth-textSmallSpan)/2;
|
||||||
float startY=(getHeight()+textHight)/2;
|
startY=(getHeight()+textHight)/2;
|
||||||
|
|
||||||
AbstractCharAnimator charAnimator;
|
if(linearGradientReCreate)
|
||||||
|
checkReCreate();
|
||||||
|
|
||||||
for(int i=0;i<textLength;i++){
|
for(int i=0;i<textLength;i++){
|
||||||
String c=String.valueOf(textToDraw.charAt(i));
|
charStr =String.valueOf(textToDraw.charAt(i));
|
||||||
if(i<5){
|
if(i<5){
|
||||||
if(i==2){
|
if(i==2){
|
||||||
canvas.drawText(c, startX, startY+baseLineDown, mTextPaint);
|
canvas.drawText(charStr, startX, startY+baseLineDown, mTextPaint);
|
||||||
startX+=flagCharwidth;
|
startX+=flagCharwidth;
|
||||||
}else{
|
}else{
|
||||||
int charWidth= getCharWidth(c,mTextPaint);
|
int charWidth= getCharWidth(charStr,mTextPaint);
|
||||||
if(currentCharAnimatorType!= CharAnimatorEnum.NOSETUP) {
|
if(currentCharAnimatorType!= CharAnimatorEnum.NOSETUP) {
|
||||||
charAnimator = charAnimatorHashMap.get(i);
|
charAnimator = charAnimatorHashMap.get(i);
|
||||||
if (charAnimator != null && !charAnimator.isCharAnimatorRuning()) {
|
if (charAnimator != null && !charAnimator.isCharAnimatorRuning()) {
|
||||||
@ -210,7 +228,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
charAnimator=null;
|
charAnimator=null;
|
||||||
}
|
}
|
||||||
if (charAnimator == null&&preString != null&&preString.length()==textToDraw.length() && textToDraw.charAt(i) != preString.charAt(i)) {
|
if (charAnimator == null&&preString != null&&preString.length()==textToDraw.length() && textToDraw.charAt(i) != preString.charAt(i)) {
|
||||||
charAnimator=createCharAnimator(String.valueOf(preString.charAt(i)), c, currentCharAnimatorType);
|
charAnimator=createCharAnimator(String.valueOf(preString.charAt(i)), charStr, currentCharAnimatorType);
|
||||||
charAnimatorHashMap.put(i, charAnimator);
|
charAnimatorHashMap.put(i, charAnimator);
|
||||||
}
|
}
|
||||||
if (charAnimator != null) {
|
if (charAnimator != null) {
|
||||||
@ -218,17 +236,17 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
//Log.d(Tag,"charAnimator index i:"+i+"\tanimator percent:");
|
//Log.d(Tag,"charAnimator index i:"+i+"\tanimator percent:");
|
||||||
invalidate();
|
invalidate();
|
||||||
}else
|
}else
|
||||||
drawChar(canvas, c, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
||||||
}else
|
}else
|
||||||
drawChar(canvas, c, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
||||||
startX+=baseCharWidth;
|
startX+=baseCharWidth;
|
||||||
}
|
}
|
||||||
}else if(i==5) {
|
}else if(i==5) {
|
||||||
startX+=smallCharWidth/2;
|
startX+=smallCharWidth/2;
|
||||||
} else {
|
} else {
|
||||||
float centerY=(getHeight()+smallTextHight)/2;
|
centerY=(getHeight()+smallTextHight)/2;
|
||||||
centerY=centerY+(startY-centerY)/2+smallCharPaint.getFontMetrics().descent;
|
centerY=centerY+(startY-centerY)/2+smallCharPaint.getFontMetrics().descent;
|
||||||
drawChar(canvas,c, startX, centerY+baseLineDown, smallCharPaint);
|
drawChar(canvas, charStr, startX, centerY+baseLineDown, smallCharPaint);
|
||||||
startX+=smallCharWidth;
|
startX+=smallCharWidth;
|
||||||
//Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textHight+"small text hight:"+smallTextHight);
|
//Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textHight+"small text hight:"+smallTextHight);
|
||||||
}
|
}
|
||||||
@ -242,20 +260,22 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
canvas.drawText(c, startX, startY, mTextPaint);
|
canvas.drawText(c, startX, startY, mTextPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Paint reflectedPaint;
|
||||||
|
Matrix matrix;
|
||||||
|
LinearGradient reflectedShader;
|
||||||
private void drawCharReflected(Canvas canvas,String c,float startX,float startY,Paint mTextPaint){
|
private void drawCharReflected(Canvas canvas,String c,float startX,float startY,Paint mTextPaint){
|
||||||
canvas.save();
|
canvas.save();
|
||||||
Paint paint = new Paint(mTextPaint);
|
reflectedPaint = new Paint(mTextPaint);
|
||||||
LinearGradient shader = new LinearGradient(startX,
|
reflectedShader = new LinearGradient(startX,
|
||||||
-startY, startX,
|
-startY, startX,
|
||||||
-startY-textHight*6/5,
|
-startY-textHight*6/5,
|
||||||
Color.BLACK, 0x00ffffff, Shader.TileMode.MIRROR);// 创建线性渐变LinearGradient对象
|
Color.BLACK, 0x00ffffff, Shader.TileMode.MIRROR);// 创建线性渐变LinearGradient对象
|
||||||
Matrix matrix = new Matrix();
|
matrix = new Matrix();
|
||||||
matrix.preScale(1, -1); // 实现图片的反转
|
matrix.preScale(1, -1); // 实现图片的反转
|
||||||
paint.setShader(shader); // 绘制
|
reflectedPaint.setShader(reflectedShader); // 绘制
|
||||||
paint.setAlpha(50);
|
reflectedPaint.setAlpha(50);
|
||||||
canvas.setMatrix(matrix);
|
canvas.setMatrix(matrix);
|
||||||
canvas.drawText(c, startX, -startY, paint);
|
canvas.drawText(c, startX, -startY, reflectedPaint);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,164 +298,12 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
return charAnimator;
|
return charAnimator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 使TextView中不同大小字体垂直居中
|
|
||||||
*/
|
|
||||||
public static class DigitSpan extends ReplacementSpan {
|
|
||||||
private int fontSizeSp; //字体大小sp
|
|
||||||
|
|
||||||
private float beseLineDown=0;
|
|
||||||
|
|
||||||
public DigitSpan(){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
|
|
||||||
|
|
||||||
String text1 = text.subSequence(start, end).toString();
|
|
||||||
//Log.d("DigitSpan","getSize text:"+text+"\tstart:"+start+"\tend:"+end+"\tsubStr:"+text1);
|
|
||||||
//Paint p = getCustomTextPaint(paint);
|
|
||||||
return (int) getCharWidth("8",paint)*text1.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
|
|
||||||
String text1 = text.subSequence(start, end).toString();
|
|
||||||
//Log.d("DigitSpan","draw text:"+text+"\tstart:"+start+"\tend:"+end+"\tsubStr:"+text1);
|
|
||||||
Paint p = getCustomTextPaint(paint);
|
|
||||||
Paint.FontMetricsInt fm = p.getFontMetricsInt();
|
|
||||||
int baseCharWitch= getCharWidth("8",paint);
|
|
||||||
int currentCharWidth,moveWidthX;
|
|
||||||
for(int i=0;i<text1.length();i++) {
|
|
||||||
String currentChar=String.valueOf(text1.charAt(i));
|
|
||||||
currentCharWidth= getCharWidth(currentChar,paint);
|
|
||||||
moveWidthX=baseCharWitch*i+(baseCharWitch-currentCharWidth)/2;
|
|
||||||
canvas.drawText(currentChar, x+moveWidthX, y - ((y + fm.descent + y + fm.ascent) / 2 - (bottom + top) / 2)+beseLineDown, p); //此处重新计算y坐标,使字体居中
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextPaint getCustomTextPaint(Paint srcPaint) {
|
|
||||||
TextPaint paint = new TextPaint(srcPaint);
|
|
||||||
//paint.setTextSize(ViewUtils.getSpPixel(mContext, fontSizeSp)); //设定字体大小, sp转换为px
|
|
||||||
return paint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBeseLineDown(float beseLineDown){
|
|
||||||
this.beseLineDown=beseLineDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DigitFlagSpan extends ReplacementSpan {
|
|
||||||
private float beseLineDown=0;
|
|
||||||
|
|
||||||
public DigitFlagSpan(){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
|
|
||||||
String text1 = text.subSequence(start, end).toString();
|
|
||||||
return (int) getCharWidth(":",paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
|
|
||||||
String text1 = text.subSequence(start, end).toString();
|
|
||||||
Paint.FontMetricsInt fm = paint.getFontMetricsInt();
|
|
||||||
canvas.drawText(text1, x, y - ((y + fm.descent + y + fm.ascent) / 2 - (bottom + top) / 2)+beseLineDown, paint); //此处重新计算y坐标,使字体居中
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBeseLineDown(float beseLineDown){
|
|
||||||
this.beseLineDown=beseLineDown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DigitSmallSpan extends ReplacementSpan {
|
|
||||||
private float fontSizeSp; //字体大小sp
|
|
||||||
private float beseLineDown=0;
|
|
||||||
|
|
||||||
public DigitSmallSpan(){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
|
|
||||||
|
|
||||||
String text1 = text.subSequence(start, end).toString();
|
|
||||||
//Log.d("DigitSpan","getSize text:"+text+"\tstart:"+start+"\tend:"+end+"\tsubStr:"+text1);
|
|
||||||
fontSizeSp=paint.getTextSize()/2;
|
|
||||||
Paint p = getCustomTextPaint(paint,fontSizeSp);
|
|
||||||
return (int) getCharWidth("8",p)*text1.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentCharWidth,moveWidthX;
|
|
||||||
String currentChar;
|
|
||||||
@Override
|
|
||||||
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
|
|
||||||
String text1 = text.subSequence(start, end).toString();
|
|
||||||
if(text1.length()<=1)
|
|
||||||
return;
|
|
||||||
//Log.d("DigitSpan","draw text:"+text+"\tstart:"+start+"\tend:"+end+"\tsubStr:"+text1);
|
|
||||||
Paint.FontMetricsInt fmBefor=paint.getFontMetricsInt();
|
|
||||||
Paint p = getCustomTextPaint(paint,fontSizeSp);
|
|
||||||
Paint.FontMetricsInt fm = p.getFontMetricsInt();
|
|
||||||
int baseCharWitch= getCharWidth("8",p);
|
|
||||||
for(int i=1;i<text1.length();i++) {
|
|
||||||
currentChar=String.valueOf(text1.charAt(i));
|
|
||||||
currentCharWidth= getCharWidth(currentChar,paint);
|
|
||||||
moveWidthX=baseCharWitch*i+(baseCharWitch-currentCharWidth)/2;
|
|
||||||
//canvas.drawText(currentChar, x+moveWidthX, bottom+fm.ascent, p); //此处重新计算y坐标,使字体居中
|
|
||||||
canvas.drawText(currentChar, x+moveWidthX, bottom-fmBefor.descent+beseLineDown, p); //此处重新计算y坐标,使字体居中
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setBeseLineDown(float beseLineDown){
|
|
||||||
this.beseLineDown=beseLineDown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static TextPaint getCustomTextPaint(Paint srcPaint,float fontSizeSp) {
|
private static TextPaint getCustomTextPaint(Paint srcPaint,float fontSizeSp) {
|
||||||
TextPaint paint = new TextPaint(srcPaint);
|
TextPaint paint = new TextPaint(srcPaint);
|
||||||
paint.setTextSize(fontSizeSp); //设定字体大小, sp转换为px
|
paint.setTextSize(fontSizeSp); //设定字体大小, sp转换为px
|
||||||
return paint;
|
return paint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class SuperSubSpan extends ReplacementSpan
|
|
||||||
{
|
|
||||||
|
|
||||||
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm)
|
|
||||||
{
|
|
||||||
text = text.subSequence(start, end);
|
|
||||||
String[] parts = text.toString().split(",");
|
|
||||||
Paint p = getSuperSubPaint(paint);
|
|
||||||
return (int) Math.max(p.measureText(parts[0]), p.measureText(parts[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static TextPaint getSuperSubPaint(Paint src)
|
|
||||||
{
|
|
||||||
TextPaint paint = new TextPaint(src);
|
|
||||||
paint.setTextSize(src.getTextSize() / 2.5f);
|
|
||||||
return paint;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
|
|
||||||
{
|
|
||||||
text = text.subSequence(start, end);
|
|
||||||
String[] parts = text.toString().split(",");
|
|
||||||
|
|
||||||
Paint p = getSuperSubPaint(paint);
|
|
||||||
|
|
||||||
float width1 = p.measureText(parts[0]);
|
|
||||||
float width2 = p.measureText(parts[1]);
|
|
||||||
float maxWidth = Math.max(width1, width2);
|
|
||||||
|
|
||||||
canvas.drawText(parts[0], x + (maxWidth - width1), y - (bottom - top) / 3f, p);
|
|
||||||
canvas.drawText(parts[1], x + (maxWidth - width2), y + (bottom - top) / 10f, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Random rand=new Random();
|
static Random rand=new Random();
|
||||||
public static int roundColor(){
|
public static int roundColor(){
|
||||||
int alpha = 200;
|
int alpha = 200;
|
||||||
|
@ -30,4 +30,10 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/fragment_config_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -14,7 +14,6 @@
|
|||||||
android:text='"hand up"'
|
android:text='"hand up"'
|
||||||
android:textColor="#fff"
|
android:textColor="#fff"
|
||||||
android:background="#00FFFFFF"
|
android:background="#00FFFFFF"
|
||||||
android:textSize="80sp"
|
android:textSize="80sp" />
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
225
app/src/main/res/layout/fragment_digit_config.xml
Normal file
225
app/src/main/res/layout/fragment_digit_config.xml
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#00FFFFFF"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_style_group1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/tv_hourSystem_group"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="时制" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_hourSystem12"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="12时制" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_hourSystem24"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="24时制" />
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/tv_secoundShow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="秒显" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_style_group2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_below="@id/text_style_group1"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/tv_textStyle_group"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="样式" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textStyle_numal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="普通" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textStyle_shadow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="阴影" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textStyle_relief"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="发光" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/tv_textStyle_reflect"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="倒影" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_style_group3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/editText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="textPersonName"
|
||||||
|
android:text="字符动画:" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/tv_textAnim_group"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textAnim_numal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="无" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textAnim_down"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="下滑" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textAnim_up"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="上滑" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textAnim_downflit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="下翻" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_textAnim_upflat"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="上翻" />
|
||||||
|
</RadioGroup>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_style_group4"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_above="@id/text_style_group3"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="彩虹字" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:text="头" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button5"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:text="《" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button6"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:text="中" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button7"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:text="》" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button8"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="尾" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
167
app/src/main/res/layout/fragment_simulate_config.xml
Normal file
167
app/src/main/res/layout/fragment_simulate_config.xml
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#00FFFFFF"
|
||||||
|
>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_toLeftOf="@id/pointer_list"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_color_pointer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="指针" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_color_pointer_second"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="秒针" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_color_scale"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="刻度" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_color_scalep_particularly"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="整点刻度" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_color_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="文字" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_color_outline"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="外盘" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:layout_toLeftOf="@id/pointer_list"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="文字显示" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/tv_simulate_text_show_group"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_simulate_text_show_hide"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="隐藏" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_simulate_text_show_all"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="全显" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/tv_simulate_text_show_four"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="四边" />
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/pointer_list"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginTop="15dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="指针样式" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_0"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="默认" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="样式一" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="样式二" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="样式三" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_4"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="样式四" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="样式五" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_simulate_pointer_style_6"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="样式六" />
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -10,7 +10,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
classpath 'com.android.tools.build:gradle:3.3.1'
|
||||||
classpath 'com.jakewharton:butterknife-gradle-plugin:10.0.0' //添加这一行
|
classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0' //添加这一行
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user