mirror of
https://gitee.com/51danju/workclock.git
synced 2025-06-22 02:02:49 +08:00
加入数字时钟的x方向位移设置,更好的和某些壁纸相配
This commit is contained in:
parent
03e6a4c474
commit
dd5505a5ab
@ -137,6 +137,8 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
VerticalRangeSeekBar tvTimeTextPadding;
|
VerticalRangeSeekBar tvTimeTextPadding;
|
||||||
@BindView(R.id.tv_textStyle_border_doubble)
|
@BindView(R.id.tv_textStyle_border_doubble)
|
||||||
CheckBox tvTextStyleBorderDoubble;
|
CheckBox tvTextStyleBorderDoubble;
|
||||||
|
@BindView(R.id.tv_time_text_basline_x)
|
||||||
|
VerticalRangeSeekBar tvTimeTextBaslineX;
|
||||||
|
|
||||||
public DigitClockConfigFragment(ThemeUIManager themeUIManager) {
|
public DigitClockConfigFragment(ThemeUIManager themeUIManager) {
|
||||||
this.themeUIManager = themeUIManager;
|
this.themeUIManager = themeUIManager;
|
||||||
@ -174,10 +176,13 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
|
|
||||||
tvTimeTextBaslineDown.setTickMarkTextArray(new CharSequence[]{"下", "位移", "上"});
|
tvTimeTextBaslineDown.setTickMarkTextArray(new CharSequence[]{"下", "位移", "上"});
|
||||||
|
|
||||||
|
tvTimeTextBaslineX.setTickMarkTextArray(new CharSequence[]{"右", "位移", "左"});
|
||||||
|
|
||||||
tvTimeTextSubscriptScale.setTickMarkTextArray(new CharSequence[]{"1", "秒比", "100"});
|
tvTimeTextSubscriptScale.setTickMarkTextArray(new CharSequence[]{"1", "秒比", "100"});
|
||||||
|
|
||||||
tvTimeTextPadding.setTickMarkTextArray(new CharSequence[]{"0", "间隔", "20"});
|
tvTimeTextPadding.setTickMarkTextArray(new CharSequence[]{"0", "间隔", "20"});
|
||||||
|
|
||||||
|
|
||||||
loadForViewModel();
|
loadForViewModel();
|
||||||
|
|
||||||
tvHourSystemGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
tvHourSystemGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@ -185,8 +190,6 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
switch (checkedId) {
|
switch (checkedId) {
|
||||||
case R.id.tv_hourSystem12:
|
case R.id.tv_hourSystem12:
|
||||||
globalViewModel.setHourSystem12(tvHourSystem12.isChecked());
|
|
||||||
break;
|
|
||||||
case R.id.tv_hourSystem24:
|
case R.id.tv_hourSystem24:
|
||||||
globalViewModel.setHourSystem12(tvHourSystem12.isChecked());
|
globalViewModel.setHourSystem12(tvHourSystem12.isChecked());
|
||||||
break;
|
break;
|
||||||
@ -375,6 +378,23 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tvTimeTextBaslineX.setOnRangeChangedListener(new OnRangeChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) {
|
||||||
|
digitViewModel.setBaseLineX(new Float(leftValue - 100).intValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(RangeSeekBar view, boolean isLeft) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(RangeSeekBar view, boolean isLeft) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tvTimeTextSubscriptScale.setOnRangeChangedListener(new OnRangeChangedListener() {
|
tvTimeTextSubscriptScale.setOnRangeChangedListener(new OnRangeChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) {
|
public void onRangeChanged(RangeSeekBar view, float leftValue, float rightValue, boolean isFromUser) {
|
||||||
@ -566,6 +586,13 @@ public class DigitClockConfigFragment extends Fragment {
|
|||||||
baseLineDown = 100;
|
baseLineDown = 100;
|
||||||
tvTimeTextBaslineDown.setProgress(baseLineDown);
|
tvTimeTextBaslineDown.setProgress(baseLineDown);
|
||||||
|
|
||||||
|
baseLineDown = 100f + digitViewModel.getBaseLineX().getValue();
|
||||||
|
if (baseLineDown > 200)
|
||||||
|
baseLineDown = 200;
|
||||||
|
else if (baseLineDown < 0)
|
||||||
|
baseLineDown = 100;
|
||||||
|
tvTimeTextBaslineX.setProgress(baseLineDown);
|
||||||
|
|
||||||
tvTimeTextSubscriptScale.setVisibility(digitViewModel.getDisplaySecond().getValue() ? View.VISIBLE : View.GONE);
|
tvTimeTextSubscriptScale.setVisibility(digitViewModel.getDisplaySecond().getValue() ? View.VISIBLE : View.GONE);
|
||||||
tvTimeTextSubscriptScale.setProgress(digitViewModel.getSubscriptFontScale().getValue());
|
tvTimeTextSubscriptScale.setProgress(digitViewModel.getSubscriptFontScale().getValue());
|
||||||
|
|
||||||
|
@ -6,19 +6,13 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
|
|
||||||
import android.os.Message;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
|
||||||
|
|
||||||
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.dao.base.TimeFontStyle;
|
import clock.socoolby.com.clock.dao.base.TimeFontStyle;
|
||||||
import clock.socoolby.com.clock.event.ClockEvent;
|
|
||||||
import clock.socoolby.com.clock.event.ClockEventListener;
|
|
||||||
import clock.socoolby.com.clock.event.EventListenerHandle;
|
import clock.socoolby.com.clock.event.EventListenerHandle;
|
||||||
import clock.socoolby.com.clock.event.EventManger;
|
import clock.socoolby.com.clock.event.EventManger;
|
||||||
import clock.socoolby.com.clock.state.ClockStateMachine;
|
import clock.socoolby.com.clock.state.ClockStateMachine;
|
||||||
@ -108,6 +102,13 @@ public class DigitClockFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
digitViewModel.getBaseLineX().observe(this, new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Integer integer) {
|
||||||
|
tv_time.setBaseLineY(integer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
digitViewModel.getLinearGradientAble().observe(this, new Observer<Boolean>() {
|
digitViewModel.getLinearGradientAble().observe(this, new Observer<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Boolean aBoolean) {
|
public void onChanged(Boolean aBoolean) {
|
||||||
|
@ -49,6 +49,9 @@ public class DigitPerferenceModel {
|
|||||||
protected final static String KEY_TIME_TEXT_BASELINE_DOWN= "key_time_text_baseline_down";
|
protected final static String KEY_TIME_TEXT_BASELINE_DOWN= "key_time_text_baseline_down";
|
||||||
protected Integer baseLineDown=13;
|
protected Integer baseLineDown=13;
|
||||||
|
|
||||||
|
protected final static String KEY_TIME_TEXT_BASELINE_Y= "key_time_text_baseline_y";
|
||||||
|
protected Integer baseLineX =0;
|
||||||
|
|
||||||
protected final static String KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE= "key_time_text_subscript_font_scale";
|
protected final static String KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE= "key_time_text_subscript_font_scale";
|
||||||
protected Integer subscriptFontScale=40;
|
protected Integer subscriptFontScale=40;
|
||||||
|
|
||||||
@ -78,6 +81,7 @@ public class DigitPerferenceModel {
|
|||||||
subscriptFontScale=jsonObject.optInt(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE, 40);
|
subscriptFontScale=jsonObject.optInt(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE, 40);
|
||||||
timeTextPadding=jsonObject.optInt(KEY_TIME_TEXT_PADDING, 2);
|
timeTextPadding=jsonObject.optInt(KEY_TIME_TEXT_PADDING, 2);
|
||||||
charBackgroundBorderWithDoubble=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE, false);
|
charBackgroundBorderWithDoubble=jsonObject.optBoolean(KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE, false);
|
||||||
|
baseLineX =jsonObject.optInt(KEY_TIME_TEXT_BASELINE_Y,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -99,6 +103,7 @@ public class DigitPerferenceModel {
|
|||||||
jsonObject.put(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE,subscriptFontScale);
|
jsonObject.put(KEY_TIME_TEXT_SUBSCRIPT_FONT_SCALE,subscriptFontScale);
|
||||||
jsonObject.put(KEY_TIME_TEXT_PADDING,timeTextPadding);
|
jsonObject.put(KEY_TIME_TEXT_PADDING,timeTextPadding);
|
||||||
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE,charBackgroundBorderWithDoubble);
|
jsonObject.put(KEY_IS_CHAR_BACKGROUND_BORDER_DUBBLE,charBackgroundBorderWithDoubble);
|
||||||
|
jsonObject.put(KEY_TIME_TEXT_BASELINE_Y, baseLineX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String integerArrayToString(Integer[] fromArrays){
|
public static String integerArrayToString(Integer[] fromArrays){
|
||||||
@ -259,4 +264,12 @@ public class DigitPerferenceModel {
|
|||||||
public void setFontStyleSize(Integer fontStyleSize) {
|
public void setFontStyleSize(Integer fontStyleSize) {
|
||||||
this.fontStyleSize = fontStyleSize;
|
this.fontStyleSize = fontStyleSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getBaseLineX() {
|
||||||
|
return baseLineX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseLineX(Integer baseLineX) {
|
||||||
|
this.baseLineX = baseLineX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,10 @@ import android.util.Log;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import clock.socoolby.com.clock.Constants;
|
import clock.socoolby.com.clock.Constants;
|
||||||
import clock.socoolby.com.clock.utils.FileUtils;
|
|
||||||
|
|
||||||
public class SharePerferenceModel extends AbstractPerferenceModel {
|
public class SharePerferenceModel extends AbstractPerferenceModel {
|
||||||
|
|
||||||
@ -633,6 +631,15 @@ public class SharePerferenceModel extends AbstractPerferenceModel {
|
|||||||
dirtySave();
|
dirtySave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getBaseLineX() {
|
||||||
|
return digitPerferenceModel.getBaseLineX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseLineX(Integer baseLineY) {
|
||||||
|
digitPerferenceModel.setBaseLineX(baseLineY);
|
||||||
|
dirtySave();
|
||||||
|
}
|
||||||
|
|
||||||
//simulate
|
//simulate
|
||||||
|
|
||||||
public String getSimulateClockTypeName() {
|
public String getSimulateClockTypeName() {
|
||||||
|
@ -48,6 +48,8 @@ public class DigitViewModel extends ViewModel {
|
|||||||
|
|
||||||
private MutableLiveData<Boolean> charBackgroundBorderWithDoubble=new MutableLiveData<>();
|
private MutableLiveData<Boolean> charBackgroundBorderWithDoubble=new MutableLiveData<>();
|
||||||
|
|
||||||
|
private MutableLiveData<Integer> baseLineX =new MutableLiveData<>();
|
||||||
|
|
||||||
|
|
||||||
SharePerferenceModel model;
|
SharePerferenceModel model;
|
||||||
|
|
||||||
@ -74,6 +76,7 @@ public class DigitViewModel extends ViewModel {
|
|||||||
subscriptFontScale.setValue(model.getSubscriptFontScale());
|
subscriptFontScale.setValue(model.getSubscriptFontScale());
|
||||||
timeTextPadding.setValue(model.getTimeTextPadding());
|
timeTextPadding.setValue(model.getTimeTextPadding());
|
||||||
charBackgroundBorderWithDoubble.setValue(model.isCharBackgroundBorderWithDoubble());
|
charBackgroundBorderWithDoubble.setValue(model.isCharBackgroundBorderWithDoubble());
|
||||||
|
baseLineX.setValue(model.getBaseLineX());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableLiveData<Boolean> getDisplaySecond() {
|
public MutableLiveData<Boolean> getDisplaySecond() {
|
||||||
@ -241,4 +244,13 @@ public class DigitViewModel extends ViewModel {
|
|||||||
this.charBackgroundBorderWithDoubble.setValue(charBackgroundBorderWithDoubble);
|
this.charBackgroundBorderWithDoubble.setValue(charBackgroundBorderWithDoubble);
|
||||||
model.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble);
|
model.setCharBackgroundBorderWithDoubble(charBackgroundBorderWithDoubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Integer> getBaseLineX() {
|
||||||
|
return baseLineX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseLineX(Integer baseLineX) {
|
||||||
|
this.baseLineX.setValue(baseLineX);
|
||||||
|
model.setBaseLineX(baseLineX);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ import clock.socoolby.com.clock.widget.textview.charanimator.Up2DownCharAnimator
|
|||||||
public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
||||||
public static final String Tag = DigitTextView.class.getSimpleName();
|
public static final String Tag = DigitTextView.class.getSimpleName();
|
||||||
|
|
||||||
float baseLineDownScale = 0;
|
float baseLineYScale = 0;
|
||||||
|
float baseLineXScale = 0;
|
||||||
|
|
||||||
private LinearGradient mLinearGradient;
|
private LinearGradient mLinearGradient;
|
||||||
|
|
||||||
@ -116,7 +117,12 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBaseLineDown(float baseLineDown) {
|
public void setBaseLineDown(float baseLineDown) {
|
||||||
this.baseLineDownScale =baseLineDown;
|
this.baseLineYScale =baseLineDown;
|
||||||
|
layoutReflushAble=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseLineY(float baseLineDown) {
|
||||||
|
this.baseLineXScale =baseLineDown;
|
||||||
layoutReflushAble=true;
|
layoutReflushAble=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,8 +260,6 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
textSubscriptSpan = textSubscriptSpan + subscriptCharWidth * 2;
|
textSubscriptSpan = textSubscriptSpan + subscriptCharWidth * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
layoutReflushAble=false;
|
layoutReflushAble=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,8 +287,8 @@ public class DigitTextView extends androidx.appcompat.widget.AppCompatTextView {
|
|||||||
if(layoutReflushCheck(textToDraw))
|
if(layoutReflushCheck(textToDraw))
|
||||||
layoutReflush(textToDraw);
|
layoutReflush(textToDraw);
|
||||||
|
|
||||||
startX = (getWidth() - textWidth - textSubscriptSpan) / 2;
|
startX = (getWidth() - textWidth - textSubscriptSpan) / 2+getHeight()/2*(-baseLineXScale /100);
|
||||||
startY = (getHeight() + textBodyHight) / 2+getHeight()/2*(-baseLineDownScale /100);
|
startY = (getHeight() + textBodyHight) / 2+getHeight()/2*(-baseLineYScale /100);
|
||||||
|
|
||||||
for (int i = 0; i < textLength; i++) {
|
for (int i = 0; i < textLength; i++) {
|
||||||
charStr = String.valueOf(textToDraw.charAt(i));
|
charStr = String.valueOf(textToDraw.charAt(i));
|
||||||
|
@ -344,7 +344,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_above="@id/text_style_group4"
|
android:layout_above="@id/text_style_group4"
|
||||||
android:layout_below="@id/text_style_group2"
|
android:layout_below="@id/text_style_group2"
|
||||||
android:layout_toLeftOf="@id/tv_time_text_basline_down"
|
android:layout_toLeftOf="@id/tv_time_text_basline_x"
|
||||||
android:layout_marginRight="20dp"
|
android:layout_marginRight="20dp"
|
||||||
app:rsb_mode="single"
|
app:rsb_mode="single"
|
||||||
app:rsb_gravity="center"
|
app:rsb_gravity="center"
|
||||||
@ -377,5 +377,24 @@
|
|||||||
app:rsb_max="200"
|
app:rsb_max="200"
|
||||||
app:rsb_min_interval="5"
|
app:rsb_min_interval="5"
|
||||||
/>
|
/>
|
||||||
|
<com.jaygoo.widget.VerticalRangeSeekBar
|
||||||
|
android:id="@+id/tv_time_text_basline_x"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_above="@id/text_style_group4"
|
||||||
|
android:layout_below="@id/text_style_group2"
|
||||||
|
android:layout_toLeftOf="@id/tv_time_text_basline_down"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
app:rsb_mode="single"
|
||||||
|
app:rsb_gravity="center"
|
||||||
|
app:rsb_progress_radius="4dp"
|
||||||
|
app:rsb_thumb_width="30dp"
|
||||||
|
app:rsb_thumb_height="30dp"
|
||||||
|
app:rsb_tick_mark_mode="other"
|
||||||
|
app:rsb_tick_mark_gravity="center"
|
||||||
|
app:rsb_min="0"
|
||||||
|
app:rsb_max="200"
|
||||||
|
app:rsb_min_interval="5"
|
||||||
|
/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
x
Reference in New Issue
Block a user