simplified the virtual key title size configuration
This commit is contained in:
parent
671a2c2d15
commit
8d4dd1f067
6 changed files with 59 additions and 41 deletions
|
|
@ -29,9 +29,6 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
protected TraditionalT9 tt9;
|
||||
protected Vibration vibration;
|
||||
|
||||
protected float complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
protected float complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE;
|
||||
|
||||
private boolean hold = false;
|
||||
private boolean repeat = false;
|
||||
private long lastLongClickTime = 0;
|
||||
|
|
@ -230,6 +227,23 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Multiplier for the title font size.
|
||||
*/
|
||||
protected float getTitleRelativeSize() {
|
||||
return SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Multiplier for the subtitle font size.
|
||||
*/
|
||||
protected float getSubTitleRelativeSize() {
|
||||
return SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* render
|
||||
* Sets the key label using "getTitle()" and "getSubtitle()" or if they both
|
||||
|
|
@ -257,16 +271,16 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
sb.append(subtitle);
|
||||
|
||||
float padding = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
if (complexLabelTitleSize == SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE) {
|
||||
if (getTitleRelativeSize() == SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE) {
|
||||
padding /= 10;
|
||||
}
|
||||
|
||||
sb.setSpan(new RelativeSizeSpan(complexLabelTitleSize), 0, titleLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
sb.setSpan(new RelativeSizeSpan(getTitleRelativeSize()), 0, titleLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
if (!new Text(title).startsWithGraphic()) {
|
||||
sb.setSpan(new StyleSpan(Typeface.ITALIC), 0, titleLength, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
}
|
||||
sb.setSpan(new RelativeSizeSpan(padding), titleLength, titleLength + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
sb.setSpan(new RelativeSizeSpan(complexLabelSubTitleSize), titleLength + 1, sb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
sb.setSpan(new RelativeSizeSpan(getSubTitleRelativeSize()), titleLength + 1, sb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
|
||||
setText(sb);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
|||
import io.github.sspanak.tt9.ui.Vibration;
|
||||
|
||||
public class SoftKeyFilter extends SoftKey {
|
||||
public SoftKeyFilter(Context context) { super(context); setFontSize(); }
|
||||
public SoftKeyFilter(Context context, AttributeSet attrs) { super(context, attrs); setFontSize(); }
|
||||
public SoftKeyFilter(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setFontSize(); }
|
||||
public SoftKeyFilter(Context context) { super(context); }
|
||||
public SoftKeyFilter(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyFilter(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
private void setFontSize() {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
}
|
||||
@Override protected float getTitleRelativeSize() { return super.getTitleRelativeSize() / 0.85f; }
|
||||
@Override protected float getSubTitleRelativeSize() { return super.getSubTitleRelativeSize() / 0.85f; }
|
||||
|
||||
@Override
|
||||
protected void handleHold() {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ public class SoftKeyFn extends SoftKeyNumber {
|
|||
public SoftKeyFn(Context context, AttributeSet attrs) { super(context, attrs);}
|
||||
public SoftKeyFn(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr);}
|
||||
|
||||
@Override protected float getSubTitleRelativeSize() { return super.getSubTitleRelativeSize() * 0.8f; }
|
||||
|
||||
|
||||
@Override protected void handleHold() {
|
||||
preventRepeat();
|
||||
|
|
@ -50,7 +52,6 @@ public class SoftKeyFn extends SoftKeyNumber {
|
|||
|
||||
|
||||
protected String getTextSubTitle(int resId) {
|
||||
complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE * 0.8f;
|
||||
return getContext().getString(resId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,23 +8,12 @@ import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
|||
import io.github.sspanak.tt9.ui.Vibration;
|
||||
|
||||
public class SoftKeyLF4 extends SwipeableKey {
|
||||
public SoftKeyLF4(Context context) {
|
||||
super(context);
|
||||
setFontSize();
|
||||
}
|
||||
public SoftKeyLF4(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setFontSize();
|
||||
}
|
||||
public SoftKeyLF4(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
setFontSize();
|
||||
}
|
||||
public SoftKeyLF4(Context context) { super(context); }
|
||||
public SoftKeyLF4(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyLF4(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
private void setFontSize() {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
}
|
||||
@Override protected float getTitleRelativeSize() { return super.getTitleRelativeSize() / 0.85f; }
|
||||
@Override protected float getSubTitleRelativeSize() { return super.getSubTitleRelativeSize() / 0.85f; }
|
||||
|
||||
@Override
|
||||
protected void handleHold() {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,27 @@ public class SoftKeyNumber extends SoftKey {
|
|||
}
|
||||
|
||||
|
||||
private boolean isArabicNumber() {
|
||||
return tt9 != null && !tt9.isInputModeNumeric() && LanguageKind.isArabic(tt9.getLanguage());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected float getTitleRelativeSize() {
|
||||
return isArabicNumber() ? SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE : SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected float getSubTitleRelativeSize() {
|
||||
if (tt9 != null && !tt9.isInputModeNumeric() && getNumber(getId()) == 0) {
|
||||
return 1.1f;
|
||||
}
|
||||
|
||||
return super.getSubTitleRelativeSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleHold() {
|
||||
preventRepeat();
|
||||
|
|
@ -109,11 +130,9 @@ public class SoftKeyNumber extends SoftKey {
|
|||
protected String getTitle() {
|
||||
int number = getNumber(getId());
|
||||
|
||||
if (tt9 != null && !tt9.isInputModeNumeric() && LanguageKind.isArabic(tt9.getLanguage())) {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE;
|
||||
if (isArabicNumber() && tt9.getLanguage() != null) {
|
||||
return tt9.getLanguage().getKeyNumber(number);
|
||||
} else {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
return String.valueOf(number);
|
||||
}
|
||||
}
|
||||
|
|
@ -146,7 +165,6 @@ public class SoftKeyNumber extends SoftKey {
|
|||
} else if (tt9.isInputModeNumeric()) {
|
||||
return "+";
|
||||
} else {
|
||||
complexLabelSubTitleSize = 1;
|
||||
return "␣";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ import io.github.sspanak.tt9.R;
|
|||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
|
||||
public class SoftKeyRF3 extends SoftKey {
|
||||
public SoftKeyRF3(Context context) { super(context); setFontSize(); }
|
||||
public SoftKeyRF3(Context context, AttributeSet attrs) { super(context, attrs); setFontSize(); }
|
||||
public SoftKeyRF3(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setFontSize(); }
|
||||
public SoftKeyRF3(Context context) { super(context); }
|
||||
public SoftKeyRF3(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyRF3(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
private void setFontSize() {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
}
|
||||
@Override protected float getTitleRelativeSize() { return super.getTitleRelativeSize() / 0.85f; }
|
||||
@Override protected float getSubTitleRelativeSize() { return super.getSubTitleRelativeSize() / 0.85f; }
|
||||
|
||||
private boolean isVoiceInputMissing() {
|
||||
return tt9 != null && tt9.isVoiceInputMissing();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue