mirror of
https://gitee.com/51danju/workclock.git
synced 2025-06-12 13:54:03 +08:00
添加2字体,及更多自定义项
This commit is contained in:
parent
78e56b54ba
commit
ec64ecb921
@ -65,15 +65,7 @@ dependencies {
|
|||||||
// ViewModel and LiveData
|
// ViewModel and LiveData
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
|
||||||
|
|
||||||
implementation('com.gitee.51danju.e-odbo:e-odbo-jdbc:V1.0-beta.3')
|
implementation('com.gitee.51danju.e-odbo:e-odbo-jdbc:1.0-beta.13')
|
||||||
{
|
|
||||||
exclude(group: 'org.apache.logging.log4j', module: '*')
|
|
||||||
//exclude(group: 'org.apache.logging.log4j', module: 'log4j-core')
|
|
||||||
//exclude(group: 'org.apache.logging.log4j', module: 'log4j-api')
|
|
||||||
//exclude(group: 'org.apache.logging.log4j', module: 'log4j-jcl')
|
|
||||||
//exclude(group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl')
|
|
||||||
//exclude(group: 'org.slf4j', module: 'slf4j-api')
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation 'org.slf4j:slf4j-android:1.7.26'
|
implementation 'org.slf4j:slf4j-android:1.7.26'
|
||||||
//implementation 'com.github.tony19:logback-android-core:1.0.7-1'
|
//implementation 'com.github.tony19:logback-android-core:1.0.7-1'
|
||||||
|
BIN
app/src/main/assets/fonts/BONX-TubeBold.ttf
Normal file
BIN
app/src/main/assets/fonts/BONX-TubeBold.ttf
Normal file
Binary file not shown.
BIN
app/src/main/assets/fonts/BONX-TubeBoldReverse.ttf
Normal file
BIN
app/src/main/assets/fonts/BONX-TubeBoldReverse.ttf
Normal file
Binary file not shown.
@ -111,4 +111,12 @@ public class FontManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCoustomFontStyle(List<TimeFontStyle> coustomFontStyleList){
|
||||||
|
this.fontStyleList.addAll(coustomFontStyleList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCoustomFontStyle(TimeFontStyle coustomFontStyleList){
|
||||||
|
this.fontStyleList.add(coustomFontStyleList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ 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.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.model.SharePerferenceModel;
|
import clock.socoolby.com.clock.model.SharePerferenceModel;
|
||||||
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
import clock.socoolby.com.clock.state.ClockInterfaceTypeEnum;
|
||||||
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
import clock.socoolby.com.clock.state.ClockThemeUITypeEnum;
|
||||||
@ -66,30 +65,8 @@ import clock.socoolby.com.clock.viewmodel.ThemeUIViewModel;
|
|||||||
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
import clock.socoolby.com.clock.viewmodel.ViewModelFactory;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
|
import clock.socoolby.com.clock.widget.animatorview.AnimatorView;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
import clock.socoolby.com.clock.widget.animatorview.I_Animator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.AnimatorFactory;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.BubbleAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.BubbleCollisionAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.BubbleWhirlPoolAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.CarrouselAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.DotsLineAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
|
import clock.socoolby.com.clock.widget.animatorview.animator.FishAnimator;
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.MagicLineAnimator;
|
|
||||||
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.Wave3DAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.ClockFactory;
|
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.FireAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FireworkAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.FluorescenceAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.RainAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.SkyAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.SnowAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.StarFallAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.VorolayAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.WaterAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.WindmillAnimator;
|
|
||||||
import clock.socoolby.com.clock.widget.animatorview.animator.textanimator.EvaporateTextAnimator;
|
|
||||||
|
|
||||||
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.FULLSCREEN;
|
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.FULLSCREEN;
|
||||||
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.SETTING;
|
import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.SETTING;
|
||||||
@ -97,6 +74,7 @@ import static clock.socoolby.com.clock.state.ClockThemeUITypeEnum.SETTING;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements android.view.GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener, GestureDetector.OnDoubleTapListener {
|
public class MainActivity extends AppCompatActivity implements android.view.GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener, GestureDetector.OnDoubleTapListener {
|
||||||
private final static String TAG = MainActivity.class.getSimpleName();
|
private final static String TAG = MainActivity.class.getSimpleName();
|
||||||
|
|
||||||
private final static int SETTING_REQUEST_CODE = 100;
|
private final static int SETTING_REQUEST_CODE = 100;
|
||||||
|
|
||||||
//背景动画
|
//背景动画
|
||||||
@ -104,7 +82,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
private I_Animator backGroundAnimator;
|
private I_Animator backGroundAnimator;
|
||||||
|
|
||||||
private int currectAnimatorIndex=0;
|
|
||||||
|
|
||||||
private final static int ANIMATOR_TEXTLED=80;
|
private final static int ANIMATOR_TEXTLED=80;
|
||||||
|
|
||||||
@ -112,7 +89,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
//背景图相关
|
//背景图相关
|
||||||
private ImageView tv_background_image;
|
private ImageView tv_background_image;
|
||||||
private String imagePath=null;
|
|
||||||
|
|
||||||
// 定义手势检测器实例
|
// 定义手势检测器实例
|
||||||
GestureDetector detector;
|
GestureDetector detector;
|
||||||
@ -126,8 +103,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
public WeatherResponse weatherAdape;
|
public WeatherResponse weatherAdape;
|
||||||
|
|
||||||
private ClockTimeTypeEnum showTimeType=ClockTimeTypeEnum.TIME;
|
|
||||||
|
|
||||||
private ClockStateMachine clockStateMachine;
|
private ClockStateMachine clockStateMachine;
|
||||||
|
|
||||||
Intent proximityServiceIntent=null;
|
Intent proximityServiceIntent=null;
|
||||||
@ -258,8 +233,6 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
|
|
||||||
//digitViewModel.getTimeFontStyle().setValue(fontManager.getCurrentFontStyle());
|
//digitViewModel.getTimeFontStyle().setValue(fontManager.getCurrentFontStyle());
|
||||||
|
|
||||||
clockStateMachine.start();
|
|
||||||
|
|
||||||
themeUIManager=new ThemeUIManager(ClockApplication.getInstance().getEntityManager(),model);
|
themeUIManager=new ThemeUIManager(ClockApplication.getInstance().getEntityManager(),model);
|
||||||
|
|
||||||
testSetup();
|
testSetup();
|
||||||
@ -298,6 +271,9 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
} catch (BasicException e) {
|
} catch (BasicException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
fontManager.addCoustomFontStyle(new TimeFontStyle("BONX-TubeBold",110,120,130,150));
|
||||||
|
fontManager.addCoustomFontStyle(new TimeFontStyle("BONX-TubeBoldReverse",110,120,130,150));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -471,6 +447,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
//Log.i(TAG, "onDestroy....");
|
//Log.i(TAG, "onDestroy....");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
if(clockStateMachine!=null)
|
||||||
clockStateMachine.onDestory();
|
clockStateMachine.onDestory();
|
||||||
try {
|
try {
|
||||||
if (model.isTriggerScreen())
|
if (model.isTriggerScreen())
|
||||||
@ -494,6 +471,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
if(backGroundAnimator!=null)
|
if(backGroundAnimator!=null)
|
||||||
backGroundAnimator.start();
|
backGroundAnimator.start();
|
||||||
|
clockStateMachine.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -504,6 +482,7 @@ public class MainActivity extends AppCompatActivity implements android.view.Ges
|
|||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
if(backGroundAnimator!=null)
|
if(backGroundAnimator!=null)
|
||||||
backGroundAnimator.stop();
|
backGroundAnimator.stop();
|
||||||
|
clockStateMachine.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configBackGroundImage(){
|
public void configBackGroundImage(){
|
||||||
|
@ -80,9 +80,10 @@ public class WorkClockDatabase extends DataBase {
|
|||||||
.value("谁能许我扶桑花期", 110, 120, 130, 150)
|
.value("谁能许我扶桑花期", 110, 120, 130, 150)
|
||||||
.value("造字工房凌黑", 110, 120, 130, 150)
|
.value("造字工房凌黑", 110, 120, 130, 150)
|
||||||
.value("中国龙新草体", 110, 120, 130, 150)
|
.value("中国龙新草体", 110, 120, 130, 150)
|
||||||
.value("迷你简剪纸_0",110,120,130,150);
|
.value("迷你简剪纸_0",110,120,130,150)
|
||||||
|
.value("BONX-TubeBold",110,120,130,150)
|
||||||
|
.value("BONX-TubeBoldReverse",110,120,130,150)
|
||||||
|
;
|
||||||
addData(fontStyleInitData);
|
addData(fontStyleInitData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,9 +93,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
|
|
||||||
private Timer timer=null;
|
private Timer timer=null;
|
||||||
|
|
||||||
private ClockStateMachine clockStateMachine;
|
|
||||||
|
|
||||||
|
|
||||||
public AbstractThemeUIFragment(int layoutId){
|
public AbstractThemeUIFragment(int layoutId){
|
||||||
this.layoutId=layoutId;
|
this.layoutId=layoutId;
|
||||||
}
|
}
|
||||||
@ -110,7 +107,6 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
this.alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class);
|
this.alterViewModel=ViewModelProviders.of(getActivity(), new ViewModelFactory(ClockApplication.getInstance().getModel())).get(AlterViewModel.class);
|
||||||
this.mainActivity = (MainActivity)getActivity();
|
this.mainActivity = (MainActivity)getActivity();
|
||||||
this.model = ClockApplication.getInstance().getModel();
|
this.model = ClockApplication.getInstance().getModel();
|
||||||
this.clockStateMachine=mainActivity.getClockStateMachine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -168,7 +164,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
tv_break.setOnLongClickListener(new View.OnLongClickListener() {
|
tv_break.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
clockStateMachine.handUpCountingDownCheck();
|
mainActivity.getClockStateMachine().handUpCountingDownCheck();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -341,8 +337,8 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
}else{
|
}else{
|
||||||
tv_handup.setColorFilter(R.color.colorPrimaryDark);
|
tv_handup.setColorFilter(R.color.colorPrimaryDark);
|
||||||
tv_hand_time.setVisibility(View.GONE);
|
tv_hand_time.setVisibility(View.GONE);
|
||||||
if(clockStateMachine.getCurrentShowTimeType()== ClockTimeTypeEnum.COUNTING_DOWN)
|
if(mainActivity.getClockStateMachine().getCurrentShowTimeType()== ClockTimeTypeEnum.COUNTING_DOWN)
|
||||||
clockStateMachine.setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
|
mainActivity.getClockStateMachine().setCurrentShowTimeType(ClockTimeTypeEnum.TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -520,7 +516,7 @@ public abstract class AbstractThemeUIFragment extends Fragment implements View.O
|
|||||||
globalViewModel.setSrceenLock(!globalViewModel.getSrceenLock().getValue());
|
globalViewModel.setSrceenLock(!globalViewModel.getSrceenLock().getValue());
|
||||||
break;
|
break;
|
||||||
case R.id.tv_break:
|
case R.id.tv_break:
|
||||||
clockStateMachine.countingCheck();
|
mainActivity.getClockStateMachine().countingCheck();
|
||||||
break;
|
break;
|
||||||
case R.id.tv_descript:
|
case R.id.tv_descript:
|
||||||
setDiscript(SettingActivity.roundAutoQuotes());
|
setDiscript(SettingActivity.roundAutoQuotes());
|
||||||
|
@ -13,12 +13,13 @@ import android.widget.RadioGroup;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
import com.openbravo.data.basic.BasicException;
|
import com.openbravo.data.basic.BasicException;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
@ -46,6 +47,7 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
|
|
||||||
ThemeUIManager themeUIManager;
|
ThemeUIManager themeUIManager;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.tv_hourSystem12)
|
@BindView(R.id.tv_hourSystem12)
|
||||||
RadioButton tvHourSystem12;
|
RadioButton tvHourSystem12;
|
||||||
@BindView(R.id.tv_hourSystem24)
|
@BindView(R.id.tv_hourSystem24)
|
||||||
@ -114,6 +116,14 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
RadioButton tvTextAnimTabDigitUp;
|
RadioButton tvTextAnimTabDigitUp;
|
||||||
@BindView(R.id.tv_theme_config_recover)
|
@BindView(R.id.tv_theme_config_recover)
|
||||||
Button tvThemeConfigRecover;
|
Button tvThemeConfigRecover;
|
||||||
|
@BindView(R.id.button_round)
|
||||||
|
Button buttonRound;
|
||||||
|
@BindView(R.id.tv_SecondSubscript)
|
||||||
|
CheckBox tvSecondSubscript;
|
||||||
|
@BindView(R.id.tv_textStyle_border)
|
||||||
|
CheckBox tvTextStyleBorder;
|
||||||
|
@BindView(R.id.tv_textStyle_border_color)
|
||||||
|
Button tvTextStyleBorderColor;
|
||||||
|
|
||||||
public DigitClockConfigFragment(ThemeUIManager themeUIManager) {
|
public DigitClockConfigFragment(ThemeUIManager themeUIManager) {
|
||||||
this.themeUIManager = themeUIManager;
|
this.themeUIManager = themeUIManager;
|
||||||
@ -233,6 +243,17 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
changeGradientColor(button8, 4);
|
changeGradientColor(button8, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttonRound.setOnClickListener(view1 -> {
|
||||||
|
for (int i = 0; i < confColors.length; i++)
|
||||||
|
confColors[i] = roundColor();
|
||||||
|
digitViewModel.setTimeLinearGradientColorsArray(confColors);
|
||||||
|
button4.setBackgroundColor(confColors[0]);
|
||||||
|
button5.setBackgroundColor(confColors[1]);
|
||||||
|
button6.setBackgroundColor(confColors[2]);
|
||||||
|
button7.setBackgroundColor(confColors[3]);
|
||||||
|
button8.setBackgroundColor(confColors[4]);
|
||||||
|
});
|
||||||
|
|
||||||
tvThemeUIStyle1.setOnClickListener(v -> changeThemeUIStyle(1));
|
tvThemeUIStyle1.setOnClickListener(v -> changeThemeUIStyle(1));
|
||||||
|
|
||||||
tvThemeUIStyle2.setOnClickListener(v -> changeThemeUIStyle(2));
|
tvThemeUIStyle2.setOnClickListener(v -> changeThemeUIStyle(2));
|
||||||
@ -258,6 +279,33 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tvSecondSubscript.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
digitViewModel.setSecondSubscript(tvSecondSubscript.isChecked());
|
||||||
|
});
|
||||||
|
|
||||||
|
tvTextStyleBorder.setOnCheckedChangeListener((group, checkedId) -> {
|
||||||
|
digitViewModel.setCharBackgroundBorder(tvTextStyleBorder.isChecked());
|
||||||
|
tvTextStyleBorderColor.setClickable(tvTextStyleBorder.isChecked());
|
||||||
|
});
|
||||||
|
|
||||||
|
tvTextStyleBorderColor.setOnClickListener(v->{
|
||||||
|
if (colorPickerDialog == null)
|
||||||
|
colorPickerDialog = new ColorPickerPop(getActivity());
|
||||||
|
|
||||||
|
colorPickerDialog.setOnColorChangeListenter(new ColorPickerPop.OnColorListener() {
|
||||||
|
@Override
|
||||||
|
public void onEnsure(int color) {
|
||||||
|
digitViewModel.setCharBackgroundBorderColor(color);
|
||||||
|
tvTextStyleBorderColor.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBack() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
colorPickerDialog.show(digitViewModel.getCharBackgroundBorderColor().getValue());
|
||||||
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +362,7 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
digitViewModel.loadFromModel();
|
digitViewModel.loadFromModel();
|
||||||
loadForViewModel();
|
loadForViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onDestroyView中进行解绑操作
|
* onDestroyView中进行解绑操作
|
||||||
*/
|
*/
|
||||||
@ -393,9 +442,16 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
button6.setClickable(able);
|
button6.setClickable(able);
|
||||||
button7.setClickable(able);
|
button7.setClickable(able);
|
||||||
button8.setClickable(able);
|
button8.setClickable(able);
|
||||||
|
buttonRound.setClickable(able);
|
||||||
});
|
});
|
||||||
|
|
||||||
setTextColor(globalViewModel.getForegroundColor().getValue());
|
setTextColor(globalViewModel.getForegroundColor().getValue());
|
||||||
|
|
||||||
|
tvSecondSubscript.setChecked(digitViewModel.getSecondSubscript().getValue());
|
||||||
|
|
||||||
|
tvTextStyleBorder.setChecked(digitViewModel.getCharBackgroundBorder().getValue());
|
||||||
|
tvTextStyleBorderColor.setBackgroundColor(digitViewModel.getCharBackgroundBorderColor().getValue());
|
||||||
|
tvTextStyleBorderColor.setClickable(digitViewModel.getCharBackgroundBorder().getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTextColor(int color) {
|
private void setTextColor(int color) {
|
||||||
@ -404,6 +460,7 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
tvHourSystem24.setTextColor(color);
|
tvHourSystem24.setTextColor(color);
|
||||||
|
|
||||||
tvSecoundShow.setTextColor(color);
|
tvSecoundShow.setTextColor(color);
|
||||||
|
tvSecondSubscript.setTextColor(color);
|
||||||
|
|
||||||
textView3.setTextColor(color);
|
textView3.setTextColor(color);
|
||||||
|
|
||||||
@ -428,10 +485,24 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
button6.setTextColor(color);
|
button6.setTextColor(color);
|
||||||
button7.setTextColor(color);
|
button7.setTextColor(color);
|
||||||
button8.setTextColor(color);
|
button8.setTextColor(color);
|
||||||
|
buttonRound.setTextColor(color);
|
||||||
|
|
||||||
tvThemeUIStyle1.setTextColor(color);
|
tvThemeUIStyle1.setTextColor(color);
|
||||||
tvThemeUIStyle2.setTextColor(color);
|
tvThemeUIStyle2.setTextColor(color);
|
||||||
tvThemeUIStyle3.setTextColor(color);
|
tvThemeUIStyle3.setTextColor(color);
|
||||||
tvThemeUIStyle4.setTextColor(color);
|
tvThemeUIStyle4.setTextColor(color);
|
||||||
|
|
||||||
|
tvTextStyleBorder.setTextColor(color);
|
||||||
|
tvTextStyleBorderColor.setTextColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Random rand = new Random();
|
||||||
|
|
||||||
|
public static int roundColor() {
|
||||||
|
int alpha = 200;
|
||||||
|
int r = rand.nextInt(255);
|
||||||
|
int g = rand.nextInt(255);
|
||||||
|
int b = rand.nextInt(255);
|
||||||
|
return alpha << 24 | r << 16 | g << 8 | b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,12 @@ public class DigitClockFragment extends Fragment {
|
|||||||
tv_time.setTextColor(integer);
|
tv_time.setTextColor(integer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
digitViewModel.getSecondSubscript().observe(this,isSubscript->tv_time.setSecondSubscript(isSubscript));
|
||||||
|
|
||||||
|
digitViewModel.getCharBackgroundBorder().observe(this,able->tv_time.setCharBackgroundBorder(able));
|
||||||
|
|
||||||
|
digitViewModel.getCharBackgroundBorderColor().observe(this,color->tv_time.setCharBackgroundBorderColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBaseLine(boolean isFullScreen){
|
private void updateBaseLine(boolean isFullScreen){
|
||||||
|
@ -136,10 +136,21 @@ public class DateModel implements Serializable {
|
|||||||
return String.format("%02d:%02d", hour, minute);
|
return String.format("%02d:%02d", hour, minute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTimeString(boolean heartbeat,boolean isHourSystem12) {
|
||||||
|
if(isHourSystem12&&hour>12)
|
||||||
|
if(heartbeat)
|
||||||
|
return String.format("%02d:%02d %02d", hour-12, minute, second);
|
||||||
|
else
|
||||||
|
return String.format("%02d:%02d:%02d", hour-12, minute, second);
|
||||||
|
if(heartbeat)
|
||||||
|
return String.format("%02d:%02d %02d", hour, minute, second);
|
||||||
|
return String.format("%02d:%02d:%02d", hour, minute, second);
|
||||||
|
}
|
||||||
|
|
||||||
public String getTimeString(boolean isHourSystem12) {
|
public String getTimeString(boolean isHourSystem12) {
|
||||||
if(isHourSystem12&&hour>12)
|
if(isHourSystem12&&hour>12)
|
||||||
return String.format("%02d:%02d %02d", hour-12, minute, second);
|
return String.format("%02d:%02d:%02d", hour-12, minute, second);
|
||||||
return String.format("%02d:%02d %02d", hour, minute, second);
|
return String.format("%02d:%02d:%02d", hour, minute, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNowWithTime() {
|
public static String getNowWithTime() {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package clock.socoolby.com.clock.model;
|
package clock.socoolby.com.clock.model;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -25,6 +27,15 @@ public class DigitPerferenceModel {
|
|||||||
protected final static String KEY_IS_DISPLAY_SECOND = "key_is_display_second";
|
protected final static String KEY_IS_DISPLAY_SECOND = "key_is_display_second";
|
||||||
protected boolean displaySecond = true;
|
protected boolean displaySecond = true;
|
||||||
|
|
||||||
|
protected final static String KEY_IS_DISPLAY_SECOND_SUBSCRIPT = "key_is_display_second_subscript";
|
||||||
|
protected boolean timeTextSecondSubscript = true;
|
||||||
|
|
||||||
|
protected final static String KEY_IS_CHAR_BACKGROUND_BORDER = "key_is_char_background_border";
|
||||||
|
protected boolean charBackgroundBorder = false;
|
||||||
|
|
||||||
|
protected final static String KEY_IS_CHAR_BACKGROUND_BORDER_COLOR = "key_is_char_background_border_color";
|
||||||
|
protected Integer charBackgroundBorderColor=0;
|
||||||
|
|
||||||
public void fromJsonString(JSONObject jsonObject) throws JSONException {
|
public void fromJsonString(JSONObject jsonObject) throws JSONException {
|
||||||
linearGradientAble=jsonObject.optBoolean(KEY_IS_LINEARGRADIENT_ABLE,false);
|
linearGradientAble=jsonObject.optBoolean(KEY_IS_LINEARGRADIENT_ABLE,false);
|
||||||
timeColorsArray=stringToIntegerArray(jsonObject.optString(KEY_FOREGROUND_TIME_COLORS_ARRAY,null));
|
timeColorsArray=stringToIntegerArray(jsonObject.optString(KEY_FOREGROUND_TIME_COLORS_ARRAY,null));
|
||||||
@ -32,7 +43,10 @@ public class DigitPerferenceModel {
|
|||||||
shadowType=jsonObject.optInt(KEY_TIME_TEXT_SHADOW_TYPE,0);
|
shadowType=jsonObject.optInt(KEY_TIME_TEXT_SHADOW_TYPE,0);
|
||||||
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
|
timeTextCharAnimatorType=jsonObject.optInt(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,0);
|
||||||
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
|
fontName=jsonObject.optString(KEY_FONT_NAME,"default");
|
||||||
displaySecond = jsonObject.getBoolean(KEY_IS_DISPLAY_SECOND);
|
displaySecond = jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND,false);
|
||||||
|
timeTextSecondSubscript=jsonObject.optBoolean(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,true);
|
||||||
|
charBackgroundBorder=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER,false);
|
||||||
|
charBackgroundBorderColor=jsonObject.optInt(KEY_IS_CHAR_BACKGROUND_BORDER_COLOR, Color.BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +58,9 @@ public class DigitPerferenceModel {
|
|||||||
jsonObject.put(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,timeTextCharAnimatorType);
|
jsonObject.put(KEY_TIME_TEXT_CHAR_ANIMATOR_TYPE,timeTextCharAnimatorType);
|
||||||
jsonObject.put(KEY_FONT_NAME,fontName);
|
jsonObject.put(KEY_FONT_NAME,fontName);
|
||||||
jsonObject.put(KEY_IS_DISPLAY_SECOND, displaySecond);
|
jsonObject.put(KEY_IS_DISPLAY_SECOND, displaySecond);
|
||||||
|
jsonObject.put(KEY_IS_DISPLAY_SECOND_SUBSCRIPT,timeTextSecondSubscript);
|
||||||
|
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER,charBackgroundBorder);
|
||||||
|
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER_COLOR,charBackgroundBorderColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String integerArrayToString(Integer[] fromArrays){
|
public static String integerArrayToString(Integer[] fromArrays){
|
||||||
@ -124,4 +141,28 @@ public class DigitPerferenceModel {
|
|||||||
public void setFontName(String fontName) {
|
public void setFontName(String fontName) {
|
||||||
this.fontName = fontName;
|
this.fontName = fontName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTimeTextSecondSubscript() {
|
||||||
|
return timeTextSecondSubscript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeTextSecondSubscript(boolean timeTextSecondSubscript) {
|
||||||
|
this.timeTextSecondSubscript = timeTextSecondSubscript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCharBackgroundBorder() {
|
||||||
|
return charBackgroundBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorder(boolean charBackgroundBorder) {
|
||||||
|
this.charBackgroundBorder = charBackgroundBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCharBackgroundBorderColor() {
|
||||||
|
return charBackgroundBorderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorderColor(Integer charBackgroundBorderColor) {
|
||||||
|
this.charBackgroundBorderColor = charBackgroundBorderColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,4 +689,32 @@ public class SharePerferenceModel implements Serializable {
|
|||||||
this.simulatePerferenceModel = simulatePerferenceModel;
|
this.simulatePerferenceModel = simulatePerferenceModel;
|
||||||
dirtySave();
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTimeTextSecondSubscript(Boolean secondSubscript) {
|
||||||
|
digitPerferenceModel.setTimeTextSecondSubscript(secondSubscript);
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTimeTextSecondSubscript(){
|
||||||
|
return digitPerferenceModel.isTimeTextSecondSubscript();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCharBackgroundBorder() {
|
||||||
|
return digitPerferenceModel.isCharBackgroundBorder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorder(boolean charBackgroundBorder) {
|
||||||
|
digitPerferenceModel.setCharBackgroundBorder(charBackgroundBorder);
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCharBackgroundBorderColor() {
|
||||||
|
return digitPerferenceModel.getCharBackgroundBorderColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorderColor(Integer charBackgroundBorderColor) {
|
||||||
|
digitPerferenceModel.setCharBackgroundBorderColor(charBackgroundBorderColor);
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,12 +58,12 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
this.alterManager = alterManager;
|
this.alterManager = alterManager;
|
||||||
this.alterViewModel=alterViewModel;
|
this.alterViewModel=alterViewModel;
|
||||||
this.themeUIViewModel=themeUIViewModel;
|
this.themeUIViewModel=themeUIViewModel;
|
||||||
|
LunarCalendarManager.init(ClockApplication.getContext());
|
||||||
|
model=ClockApplication.getInstance().getModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start(){
|
public void start(){
|
||||||
LunarCalendarManager.init(ClockApplication.getContext());
|
|
||||||
model=ClockApplication.getInstance().getModel();
|
|
||||||
//Log.d(TAG,"create timer and timerTask.................................");
|
//Log.d(TAG,"create timer and timerTask.................................");
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
handler = new Handler(this);
|
handler = new Handler(this);
|
||||||
@ -79,6 +79,15 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
timer.schedule(timerTask, 1000, 1000);
|
timer.schedule(timerTask, 1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop(){
|
||||||
|
if(timer!=null) {
|
||||||
|
timerTask.cancel();
|
||||||
|
timer.cancel();
|
||||||
|
timer=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
@ -226,6 +235,7 @@ public class ClockStateMachine implements Handler.Callback{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDestory() {
|
public void onDestory() {
|
||||||
|
if(timer!=null)
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,12 @@ public class DigitViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<String> timeFontName =new MutableLiveData<>();
|
private MutableLiveData<String> timeFontName =new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<Boolean> secondSubscript=new MutableLiveData<>();//缩小
|
||||||
|
|
||||||
|
private MutableLiveData<Boolean> charBackgroundBorder=new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<Integer> charBackgroundBorderColor=new MutableLiveData<>();
|
||||||
|
|
||||||
SharePerferenceModel model;
|
SharePerferenceModel model;
|
||||||
|
|
||||||
public DigitViewModel(SharePerferenceModel model) {
|
public DigitViewModel(SharePerferenceModel model) {
|
||||||
@ -49,6 +55,9 @@ public class DigitViewModel extends ViewModel {
|
|||||||
baseLineDown.setValue(0);
|
baseLineDown.setValue(0);
|
||||||
timeFontStyleSize.setValue(100);
|
timeFontStyleSize.setValue(100);
|
||||||
timeFontName.setValue(model.getFontName());
|
timeFontName.setValue(model.getFontName());
|
||||||
|
secondSubscript.setValue(model.isTimeTextSecondSubscript());
|
||||||
|
charBackgroundBorder.setValue(model.isCharBackgroundBorder());
|
||||||
|
charBackgroundBorderColor.setValue(model.getCharBackgroundBorderColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<Boolean> getDisplaySecond() {
|
public MutableLiveData<Boolean> getDisplaySecond() {
|
||||||
@ -143,4 +152,30 @@ public class DigitViewModel extends ViewModel {
|
|||||||
return timeFontName;
|
return timeFontName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Boolean> getSecondSubscript() {
|
||||||
|
return secondSubscript;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecondSubscript(Boolean secondSubscript) {
|
||||||
|
this.secondSubscript.setValue(secondSubscript);
|
||||||
|
model.setTimeTextSecondSubscript(secondSubscript);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Boolean> getCharBackgroundBorder() {
|
||||||
|
return charBackgroundBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorder(Boolean charBackgroundBorder) {
|
||||||
|
this.charBackgroundBorder.setValue(charBackgroundBorder);
|
||||||
|
model.setCharBackgroundBorder(charBackgroundBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getCharBackgroundBorderColor() {
|
||||||
|
return charBackgroundBorderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorderColor(Integer charBackgroundBorderColor) {
|
||||||
|
this.charBackgroundBorderColor.setValue(charBackgroundBorderColor);
|
||||||
|
model.setCharBackgroundBorderColor(charBackgroundBorderColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package clock.socoolby.com.clock.widget.animatorview.animator;
|
||||||
|
|
||||||
|
public class SnakeAnimator {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -8,12 +8,14 @@ import android.graphics.Matrix;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@ -35,10 +37,54 @@ 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=new int[]{roundColor(), roundColor(), roundColor(), roundColor(), roundColor()};
|
private int[] linearGradientColors;
|
||||||
|
|
||||||
|
private CharSequence preString = "";
|
||||||
|
|
||||||
private CharSequence preString=null;
|
private boolean secondSubscript = false;
|
||||||
|
|
||||||
|
private boolean charBackgroundBorder = false;
|
||||||
|
|
||||||
|
private int charBackgroundBorderColor = Color.BLACK;
|
||||||
|
|
||||||
|
private int textWidth = 0;
|
||||||
|
private int textHight;
|
||||||
|
private int textfontHight;
|
||||||
|
private int baseCharWidth;
|
||||||
|
private int flagCharwidth;
|
||||||
|
private int smallTextHight;
|
||||||
|
private int smallCharWidth;
|
||||||
|
private int textLength;
|
||||||
|
private int textSmallSpan;
|
||||||
|
private HashMap<Integer, AbstractCharAnimator> charAnimatorHashMap = new HashMap<>();
|
||||||
|
|
||||||
|
private CharAnimatorEnum currentCharAnimatorType = CharAnimatorEnum.Marquee3D_Up;
|
||||||
|
|
||||||
|
AbstractCharAnimator charAnimator;
|
||||||
|
|
||||||
|
float startX, startY;
|
||||||
|
|
||||||
|
Paint smallCharPaint = null;
|
||||||
|
|
||||||
|
Paint mTextPaint;
|
||||||
|
|
||||||
|
float fontScale;
|
||||||
|
|
||||||
|
String charStr;
|
||||||
|
|
||||||
|
float centerY;
|
||||||
|
|
||||||
|
CharSequence textToDraw;
|
||||||
|
|
||||||
|
Paint.FontMetricsInt fm;
|
||||||
|
|
||||||
|
int padding = 2;
|
||||||
|
|
||||||
|
int charWidth;
|
||||||
|
|
||||||
|
Paint mDividerPaint, mBackgroundPaint;
|
||||||
|
|
||||||
|
boolean layoutReflushAble=true;
|
||||||
|
|
||||||
public DigitTextView(Context context) {
|
public DigitTextView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -55,9 +101,8 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
/*mDividerPaint = new Paint();
|
mDividerPaint = new Paint();
|
||||||
mDividerPaint.setAntiAlias(true);
|
mDividerPaint.setAntiAlias(true);
|
||||||
mDividerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mDividerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
mDividerPaint.setColor(Color.WHITE);
|
mDividerPaint.setColor(Color.WHITE);
|
||||||
@ -65,13 +110,11 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
|
|
||||||
mBackgroundPaint = new Paint();
|
mBackgroundPaint = new Paint();
|
||||||
mBackgroundPaint.setAntiAlias(true);
|
mBackgroundPaint.setAntiAlias(true);
|
||||||
mBackgroundPaint.setColor(Color.BLACK);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setBaseLineDown(float baseLineDown) {
|
public void setBaseLineDown(float baseLineDown) {
|
||||||
this.baseLineDown = baseLineDown;
|
this.baseLineDown = baseLineDown;
|
||||||
|
layoutReflushAble=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] pos = {0.1f, 0.3f, 0.5f, 0.7f, 0.9f};
|
float[] pos = {0.1f, 0.3f, 0.5f, 0.7f, 0.9f};
|
||||||
@ -82,15 +125,6 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
|
|
||||||
boolean linearGradientReCreate = false;
|
boolean linearGradientReCreate = false;
|
||||||
|
|
||||||
public void setLinearGradientRandom(boolean able){
|
|
||||||
if(able){
|
|
||||||
linearGradientColors= new int[]{roundColor(), roundColor(), roundColor(), roundColor(), roundColor()};
|
|
||||||
isLinearGradientPosAble=rand.nextBoolean();
|
|
||||||
isReflectedAble=rand.nextBoolean();
|
|
||||||
}
|
|
||||||
setLinearGradientAble(able);
|
|
||||||
setShadowType(ShadowTypeEnum.valueOf(rand.nextInt(3)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLinearGradientAble(boolean able) {
|
public void setLinearGradientAble(boolean able) {
|
||||||
isLinearGradientAble = able;
|
isLinearGradientAble = able;
|
||||||
@ -102,7 +136,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
linearGradientReCreate = true;
|
linearGradientReCreate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkReCreate(){
|
private void linearGradientReflush() {
|
||||||
mLinearGradient = null;
|
mLinearGradient = null;
|
||||||
if (isLinearGradientAble && linearGradientColors != null) {
|
if (isLinearGradientAble && linearGradientColors != null) {
|
||||||
mLinearGradient = new LinearGradient(0, 0, getWidth(), getHeight(), linearGradientColors, pos, Shader.TileMode.CLAMP);
|
mLinearGradient = new LinearGradient(0, 0, getWidth(), getHeight(), linearGradientColors, pos, Shader.TileMode.CLAMP);
|
||||||
@ -167,47 +201,28 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
isReflectedAble = reflectedAble;
|
isReflectedAble = reflectedAble;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int textWidth=0;
|
public boolean isSecondSubscript() {
|
||||||
private int textHight;
|
return secondSubscript;
|
||||||
private int textfontHight;
|
}
|
||||||
private int baseCharWidth;
|
|
||||||
private int flagCharwidth;
|
|
||||||
private int smallTextHight;
|
|
||||||
private int smallCharWidth;
|
|
||||||
private int textLength;
|
|
||||||
private int textSmallSpan;
|
|
||||||
private HashMap<Integer, AbstractCharAnimator> charAnimatorHashMap=new HashMap<>();
|
|
||||||
|
|
||||||
private CharAnimatorEnum currentCharAnimatorType= CharAnimatorEnum.Marquee3D_Up;
|
public void setSecondSubscript(boolean secondSubscript) {
|
||||||
|
this.secondSubscript = secondSubscript;
|
||||||
|
layoutReflushAble=true;
|
||||||
|
}
|
||||||
|
|
||||||
AbstractCharAnimator charAnimator;
|
@Override
|
||||||
|
public void setTextSize(float size) {
|
||||||
|
super.setTextSize(size);
|
||||||
|
layoutReflushAble=true;
|
||||||
|
}
|
||||||
|
|
||||||
float startX,startY;
|
@Override
|
||||||
|
public void setTypeface(@Nullable Typeface tf, int style) {
|
||||||
Paint smallCharPaint=null;
|
super.setTypeface(tf, style);
|
||||||
|
layoutReflushAble=true;
|
||||||
Paint mTextPaint;
|
}
|
||||||
|
|
||||||
float fontScale;
|
|
||||||
|
|
||||||
String charStr;
|
|
||||||
|
|
||||||
float centerY;
|
|
||||||
|
|
||||||
CharSequence textToDraw;
|
|
||||||
|
|
||||||
Paint.FontMetricsInt fm;
|
|
||||||
|
|
||||||
int padding=2;
|
|
||||||
|
|
||||||
protected void onDraw(Canvas canvas) {
|
|
||||||
|
|
||||||
mTextPaint=getPaint();
|
|
||||||
|
|
||||||
mTextPaint.setColor(getCurrentTextColor());
|
|
||||||
|
|
||||||
textToDraw=getText();
|
|
||||||
|
|
||||||
|
private void layoutReflush(CharSequence textToDraw){
|
||||||
fm = mTextPaint.getFontMetricsInt();
|
fm = mTextPaint.getFontMetricsInt();
|
||||||
|
|
||||||
baseCharWidth = getCharWidth("8", mTextPaint);
|
baseCharWidth = getCharWidth("8", mTextPaint);
|
||||||
@ -218,8 +233,8 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
textfontHight = (int) getFontHeight(mTextPaint);
|
textfontHight = (int) getFontHeight(mTextPaint);
|
||||||
textHight = -fm.descent - fm.ascent;
|
textHight = -fm.descent - fm.ascent;
|
||||||
|
|
||||||
smallTextHight=0;
|
smallTextHight = textHight;
|
||||||
smallCharWidth=0;
|
smallCharWidth = baseCharWidth;
|
||||||
|
|
||||||
textLength = textToDraw.length();
|
textLength = textToDraw.length();
|
||||||
textSmallSpan = 0;
|
textSmallSpan = 0;
|
||||||
@ -229,19 +244,43 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (textLength > 7) {
|
if (textLength > 7) {
|
||||||
|
if (secondSubscript) {
|
||||||
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();
|
||||||
smallTextHight = -fm.descent - fm.ascent;
|
smallTextHight = -fm.descent - fm.ascent;
|
||||||
textSmallSpan=smallCharWidth*2;
|
} else
|
||||||
|
textSmallSpan = textSmallSpan + flagCharwidth;
|
||||||
|
textSmallSpan = textSmallSpan + smallCharWidth * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layoutReflushAble=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean layoutReflushCheck(CharSequence textToDraw){
|
||||||
|
if(layoutReflushAble||textToDraw.length()!=preString.length())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
//long before=System.currentTimeMillis();
|
||||||
|
mTextPaint = getPaint();
|
||||||
|
|
||||||
|
mTextPaint.setColor(getCurrentTextColor());
|
||||||
|
|
||||||
|
textToDraw = getText();
|
||||||
|
|
||||||
|
if(layoutReflushCheck(textToDraw))
|
||||||
|
layoutReflush(textToDraw);
|
||||||
|
|
||||||
startX = (getWidth() - textWidth - textSmallSpan) / 2;
|
startX = (getWidth() - textWidth - textSmallSpan) / 2;
|
||||||
startY = (getHeight() + textHight) / 2;
|
startY = (getHeight() + textHight) / 2;
|
||||||
|
|
||||||
if (linearGradientReCreate)
|
if (linearGradientReCreate)
|
||||||
checkReCreate();
|
linearGradientReflush();
|
||||||
|
|
||||||
for (int i = 0; i < textLength; i++) {
|
for (int i = 0; i < textLength; i++) {
|
||||||
charStr = String.valueOf(textToDraw.charAt(i));
|
charStr = String.valueOf(textToDraw.charAt(i));
|
||||||
@ -250,9 +289,56 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
canvas.drawText(charStr, startX, startY + baseLineDown, mTextPaint);
|
canvas.drawText(charStr, startX, startY + baseLineDown, mTextPaint);
|
||||||
startX += flagCharwidth;
|
startX += flagCharwidth;
|
||||||
} else {
|
} else {
|
||||||
int charWidth= getCharWidth(charStr,mTextPaint);
|
drawCharWithAnaimatorCheck(canvas, i, charStr, startX, startY, mTextPaint);
|
||||||
|
startX = startX + baseCharWidth + padding;
|
||||||
|
}
|
||||||
|
} else if (i == 5) {
|
||||||
|
if (secondSubscript)
|
||||||
|
startX += smallCharWidth / 2;
|
||||||
|
else {
|
||||||
|
canvas.drawText(charStr, startX, startY + baseLineDown, mTextPaint);
|
||||||
|
startX += flagCharwidth;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (secondSubscript) {
|
||||||
|
centerY = (getHeight() + smallTextHight) / 2;
|
||||||
|
centerY = centerY + (startY - centerY) / 2 + smallCharPaint.getFontMetrics().descent;
|
||||||
|
if (charBackgroundBorder)
|
||||||
|
drawBackground(canvas, startX, startY + baseLineDown - smallTextHight, smallCharWidth, smallTextHight, mBackgroundPaint);
|
||||||
|
drawChar(canvas, charStr, startX, centerY + baseLineDown, smallCharPaint);
|
||||||
|
} else {
|
||||||
|
drawCharWithAnaimatorCheck(canvas, i, charStr, startX, startY, mTextPaint);
|
||||||
|
startX += padding;
|
||||||
|
}
|
||||||
|
startX += smallCharWidth;
|
||||||
|
//Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textHight+"small text hight:"+smallTextHight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
preString = textToDraw;
|
||||||
|
//Log.d(Tag,"total draw time:"+(System.currentTimeMillis()-before));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void drawBackground(Canvas canvas, float startX, float startY, int width, int height, Paint mBackgroundPaint) {
|
||||||
|
mBackgroundPaint.setColor(charBackgroundBorderColor);
|
||||||
|
canvas.drawRoundRect(new RectF(startX, startY, startX + width, startY + height), 10, 10, mBackgroundPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawDivider(Canvas canvas, float startX, float startY, int width, int height, Paint mDividerPaint) {
|
||||||
|
//canvas.drawLine(startX, startY+height/2, startX+width, startY+height/2, mDividerPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawChar(Canvas canvas, String c, float startX, float startY, Paint mTextPaint) {
|
||||||
|
if (isReflectedAble)
|
||||||
|
drawCharReflected(canvas, c, startX, startY, mTextPaint);
|
||||||
|
canvas.drawText(c, startX, startY, mTextPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawCharWithAnaimatorCheck(Canvas canvas, int i, String charStr, float startX, float startY, Paint mTextPaint) {
|
||||||
|
charWidth = getCharWidth(charStr, mTextPaint);
|
||||||
//Log.d(Tag,"view width:"+getWidth()+"\t heitht:"+getHeight()+"\t startx:"+startX+"\t startY:"+startY+"\t baseCharWidth:"+baseCharWidth+"\t text hight:"+textHight+"\t text font hight:"+textfontHight);
|
//Log.d(Tag,"view width:"+getWidth()+"\t heitht:"+getHeight()+"\t startx:"+startX+"\t startY:"+startY+"\t baseCharWidth:"+baseCharWidth+"\t text hight:"+textHight+"\t text font hight:"+textfontHight);
|
||||||
//drawBackground(canvas,startX , startY + baseLineDown-textfontHight+(textfontHight-textHight)/4,baseCharWidth,textfontHight,mBackgroundPaint);
|
if (charBackgroundBorder)
|
||||||
|
drawBackground(canvas, startX, startY + baseLineDown - textfontHight + (textfontHight - textHight) / 4, baseCharWidth, textfontHight, mBackgroundPaint);
|
||||||
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()) {
|
||||||
@ -269,46 +355,20 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
invalidate();
|
invalidate();
|
||||||
} else {
|
} else {
|
||||||
drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
||||||
//drawDivider(canvas, startX, startY + baseLineDown - textfontHight + (textfontHight - textHight) / 4, baseCharWidth, textfontHight, mDividerPaint);
|
if (charBackgroundBorder)
|
||||||
|
drawDivider(canvas, startX, startY + baseLineDown - textfontHight + (textfontHight - textHight) / 4, baseCharWidth, textfontHight, mDividerPaint);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
drawChar(canvas, charStr, startX + (baseCharWidth - charWidth) / 2, startY + baseLineDown, mTextPaint);
|
||||||
//drawDivider(canvas, startX, startY + baseLineDown - textfontHight +(textfontHight - textHight) / 4, baseCharWidth, textfontHight, mDividerPaint);
|
if (charBackgroundBorder)
|
||||||
|
drawDivider(canvas, startX, startY + baseLineDown - textfontHight + (textfontHight - textHight) / 4, baseCharWidth, textfontHight, mDividerPaint);
|
||||||
}
|
}
|
||||||
startX=startX+baseCharWidth+padding;
|
|
||||||
}
|
|
||||||
}else if(i==5) {
|
|
||||||
startX+=smallCharWidth/2;
|
|
||||||
} else {
|
|
||||||
centerY=(getHeight()+smallTextHight)/2;
|
|
||||||
centerY=centerY+(startY-centerY)/2+smallCharPaint.getFontMetrics().descent;
|
|
||||||
drawChar(canvas, charStr, startX, centerY+baseLineDown, smallCharPaint);
|
|
||||||
startX+=smallCharWidth;
|
|
||||||
//Log.d(Tag,"view hight:"+getHeight()+"\t startY:"+startY+"\t text hight:"+textHight+"small text hight:"+smallTextHight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
preString=textToDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
Paint mDividerPaint,mBackgroundPaint;
|
|
||||||
|
|
||||||
private void drawBackground(Canvas canvas,float startX,float startY,int width,int height,Paint mBackgroundPaint) {
|
|
||||||
canvas.drawRoundRect(new RectF(startX,startY,startX+width,startY+height), 10, 10, mBackgroundPaint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawDivider(Canvas canvas,float startX,float startY,int width,int height,Paint mDividerPaint) {
|
|
||||||
canvas.drawLine(startX, startY+height/2, startX+width, startY+height/2, mDividerPaint);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawChar(Canvas canvas,String c,float startX,float startY,Paint mTextPaint){
|
|
||||||
if(isReflectedAble)
|
|
||||||
drawCharReflected(canvas,c, startX, startY, mTextPaint);
|
|
||||||
canvas.drawText(c, startX, startY, mTextPaint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Paint reflectedPaint;
|
Paint reflectedPaint;
|
||||||
Matrix matrix;
|
Matrix matrix;
|
||||||
LinearGradient reflectedShader;
|
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();
|
||||||
reflectedPaint = new Paint(mTextPaint);
|
reflectedPaint = new Paint(mTextPaint);
|
||||||
@ -354,6 +414,7 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Random rand = new Random();
|
static Random rand = new Random();
|
||||||
|
|
||||||
public static int roundColor() {
|
public static int roundColor() {
|
||||||
int alpha = 200;
|
int alpha = 200;
|
||||||
int r = rand.nextInt(255);
|
int r = rand.nextInt(255);
|
||||||
@ -371,4 +432,19 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
return ((int) Math.ceil(fm.descent - fm.top) + 2);
|
return ((int) Math.ceil(fm.descent - fm.top) + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCharBackgroundBorder() {
|
||||||
|
return charBackgroundBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorder(boolean charBackgroundBorder) {
|
||||||
|
this.charBackgroundBorder = charBackgroundBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCharBackgroundBorderColor() {
|
||||||
|
return charBackgroundBorderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCharBackgroundBorderColor(int charBackgroundBorderColor) {
|
||||||
|
this.charBackgroundBorderColor = charBackgroundBorderColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,16 @@
|
|||||||
android:id="@+id/tv_secoundShow"
|
android:id="@+id/tv_secoundShow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="2"
|
android:layout_weight="1"
|
||||||
android:text="秒显" />
|
android:text="秒显" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/tv_SecondSubscript"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="下标秒" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tv_theme_config_recover"
|
android:id="@+id/tv_theme_config_recover"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -74,7 +81,8 @@
|
|||||||
android:id="@+id/tv_textStyle_group"
|
android:id="@+id/tv_textStyle_group"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="5"
|
||||||
|
android:gravity="center"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -114,6 +122,20 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="倒影" />
|
android:text="倒影" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/tv_textStyle_border"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="底框" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/tv_textStyle_border_color"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="底框色" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -237,8 +259,16 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:text="尾" />
|
android:text="尾" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_round"
|
||||||
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Loading…
x
Reference in New Issue
Block a user