diff --git a/app/src/main/java/io/github/sspanak/tt9/hacks/DeviceInfo.java b/app/src/main/java/io/github/sspanak/tt9/hacks/DeviceInfo.java
index a78a9ed0..5a3132a6 100644
--- a/app/src/main/java/io/github/sspanak/tt9/hacks/DeviceInfo.java
+++ b/app/src/main/java/io/github/sspanak/tt9/hacks/DeviceInfo.java
@@ -3,6 +3,7 @@ package io.github.sspanak.tt9.hacks;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.os.Build;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -10,16 +11,33 @@ import android.view.KeyEvent;
import androidx.annotation.NonNull;
public class DeviceInfo {
+ private static Resources resources;
+
+ private static Resources getResources(Context context) {
+ if (resources == null) {
+ resources = context.getResources();
+ }
+ return resources;
+ }
+
public static boolean isLandscapeOrientation(Context context) {
- return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
+ return getResources(context).getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
public static int getScreenWidth(Context context) {
- return context.getResources().getDisplayMetrics().widthPixels;
+ return getResources(context).getDisplayMetrics().widthPixels;
}
public static int getScreenHeight(Context context) {
- return context.getResources().getDisplayMetrics().heightPixels;
+ return getResources(context).getDisplayMetrics().heightPixels;
+ }
+
+ public static float getScreenHeightDp(Context context) {
+ return getScreenHeight(context) / getResources(context).getDisplayMetrics().density;
+ }
+
+ public static float getScreenWidthDp(Context context) {
+ return getScreenWidth(context) / getResources(context).getDisplayMetrics().density;
}
public static boolean noBackspaceKey() {
diff --git a/app/src/main/java/io/github/sspanak/tt9/preferences/settings/SettingsStore.java b/app/src/main/java/io/github/sspanak/tt9/preferences/settings/SettingsStore.java
index 4b8f823f..aa9b7ac4 100644
--- a/app/src/main/java/io/github/sspanak/tt9/preferences/settings/SettingsStore.java
+++ b/app/src/main/java/io/github/sspanak/tt9/preferences/settings/SettingsStore.java
@@ -24,7 +24,9 @@ public class SettingsStore extends SettingsUI {
public final static byte SLOW_QUERY_TIME = 50; // ms
public final static int SLOW_QUERY_TIMEOUT = 3000; // ms
public final static float SOFT_KEY_AMOUNT_OF_KEY_SIZE_FOR_SWIPE = 0.5f; // 1 = full key size
- public final static float SOFT_KEY_CONTENT_DEFAULT_SCALE = 1.15f; // % / 100
+ public final static float SOFT_KEY_SCALE_SCREEN_COMPENSATION_NORMAL_HEIGHT = 360; // dp
+ public final static float SOFT_KEY_SCALE_SCREEN_COMPENSATION_NORMAL_WIDTH = 640; // dp
+ public final static float SOFT_KEY_SCALE_SCREEN_COMPENSATION_MAX = 1.4f;
public final static int SOFT_KEY_DOUBLE_CLICK_DELAY = 500; // ms
public final static int SOFT_KEY_REPEAT_DELAY = 40; // ms
public final static int SOFT_KEY_TITLE_MAX_CHARS = 5;
diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java
index 53e8fcea..62742c18 100644
--- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java
+++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKey.java
@@ -19,6 +19,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
+import io.github.sspanak.tt9.hacks.DeviceInfo;
import io.github.sspanak.tt9.ime.TraditionalT9;
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
import io.github.sspanak.tt9.ui.Vibration;
@@ -44,6 +45,9 @@ public class SoftKey extends com.google.android.material.button.MaterialButton i
private Drawable holdIcon = null;
private RelativeLayout overlay = null;
+ private static float screenScaleX = 0;
+ private static float screenScaleY = 0;
+
public SoftKey(Context context) {
super(context);
@@ -82,6 +86,34 @@ public class SoftKey extends com.google.android.material.button.MaterialButton i
}
+ protected float getScreenScaleX() {
+ if (screenScaleX == 0) {
+ boolean isLandscape = DeviceInfo.isLandscapeOrientation(getContext());
+ float width = isLandscape ? DeviceInfo.getScreenWidthDp(getContext()) : DeviceInfo.getScreenHeightDp(getContext());
+
+ screenScaleX = Math.min(
+ width / SettingsStore.SOFT_KEY_SCALE_SCREEN_COMPENSATION_NORMAL_WIDTH,
+ SettingsStore.SOFT_KEY_SCALE_SCREEN_COMPENSATION_MAX
+ );
+ }
+ return screenScaleX;
+ }
+
+
+ protected float getScreenScaleY() {
+ if (screenScaleY == 0) {
+ boolean isLandscape = DeviceInfo.isLandscapeOrientation(getContext());
+ float height = isLandscape ? DeviceInfo.getScreenHeightDp(getContext()) : DeviceInfo.getScreenWidthDp(getContext());
+
+ screenScaleY = Math.min(
+ height / SettingsStore.SOFT_KEY_SCALE_SCREEN_COMPENSATION_NORMAL_HEIGHT,
+ SettingsStore.SOFT_KEY_SCALE_SCREEN_COMPENSATION_MAX
+ );
+ }
+ return screenScaleY;
+ }
+
+
protected float getTT9Width() {
return tt9 != null ? tt9.getSettings().getNumpadWidthPercent() / 100f : 1;
}
@@ -305,10 +337,12 @@ public class SoftKey extends com.google.android.material.button.MaterialButton i
/**
* Multiplier for the main text font size. Used for automatically adjusting the font size to fit
- * the key when changing the keyboard dimensions.
+ * the key when changing the keyboard dimensions, and to look good on different screen sizes.
*/
protected float getTitleScale() {
- return SettingsStore.SOFT_KEY_CONTENT_DEFAULT_SCALE * Math.min(getTT9Width(), getTT9Height());
+ float keyboardSizeScale = Math.max(0.7f, Math.min(getTT9Width(), getTT9Height()));
+ float screenSizeScale = Math.min(getScreenScaleX(), getScreenScaleY());
+ return keyboardSizeScale * screenSizeScale;
}
@@ -316,8 +350,9 @@ public class SoftKey extends com.google.android.material.button.MaterialButton i
* Same as getTitleScale(), but for keys that have icons instead of text.
*/
protected float getCentralIconScale() {
- float width = getTT9Width();
- return width > 0.95f ? Math.min(1.15f, getTT9Height()) : Math.min(width, getTT9Height());
+ float keyboardSizeScale = Math.max(0.7f, Math.min(getTT9Width(), getTT9Height()));
+ keyboardSizeScale = Math.min(1.15f, keyboardSizeScale);
+ return keyboardSizeScale * Math.min(getScreenScaleX(), getScreenScaleY());
}
@@ -325,7 +360,8 @@ public class SoftKey extends com.google.android.material.button.MaterialButton i
* Similar to getTitleScale(), adjusts the font size of the hold text or icon
*/
protected float getHoldElementScale() {
- return SettingsStore.SOFT_KEY_CONTENT_DEFAULT_SCALE * Math.min(1, getTT9Height());
+ float keyboardSizeScale = Math.min(1, Math.max(getTT9Width(), getTT9Height()));
+ return keyboardSizeScale * Math.min(getScreenScaleX(), getScreenScaleY());
}
diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyBackspace.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyBackspace.java
index f4883bed..04563658 100644
--- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyBackspace.java
+++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyBackspace.java
@@ -143,7 +143,7 @@ public class SoftKeyBackspace extends SwipeableKey {
@Override
protected float getTitleScale() {
- float scale = tt9 != null && tt9.getSettings().isMainLayoutNumpad() ? super.getTitleScale() : SettingsStore.SOFT_KEY_CONTENT_DEFAULT_SCALE;
+ float scale = tt9 != null && tt9.getSettings().isMainLayoutNumpad() ? super.getTitleScale() : 1;
return scale * 1.1f;
}
diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyFilter.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyFilter.java
index a83a3579..66e23673 100644
--- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyFilter.java
+++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyFilter.java
@@ -49,7 +49,7 @@ public class SoftKeyFilter extends SoftKey {
@Override protected int getCentralIcon() { return isKorean() ? 0 : R.drawable.ic_fn_filter; }
@Override protected int getHoldIcon() { return isKorean() ? 0 : R.drawable.ic_fn_filter_off; }
- @Override protected float getTitleScale() { return isKorean() ? 1.5f * getTT9Height() : 1; }
+ @Override protected float getTitleScale() { return isKorean() ? 1.3f * Math.min(1, getTT9Height()) * getScreenScaleY() : super.getTitleScale(); }
@Override
public void render() {
diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java
index 6fd28d7c..f8663073 100644
--- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java
+++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyLF4.java
@@ -80,9 +80,12 @@ public class SoftKeyLF4 extends SwipeableKey {
if (areThereManyLanguages() && isKeySmall()) {
setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
- } else {
+ setPaddingRelative(0, 0, 0, 10);
+ } else if (areThereManyLanguages()) {
setPaddingRelative(0, 20, 0, 0);
setGravity(Gravity.CENTER);
+ } else {
+ setGravity(Gravity.CENTER);
}
diff --git a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyNumber0.java b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyNumber0.java
index 7d834d1f..28ae34f5 100644
--- a/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyNumber0.java
+++ b/app/src/main/java/io/github/sspanak/tt9/ui/main/keys/SoftKeyNumber0.java
@@ -63,7 +63,7 @@ public class SoftKeyNumber0 extends SoftKeyNumber {
@Override
protected float getTitleScale() {
if (tt9 != null && !tt9.isInputModeNumeric() && !LanguageKind.isKorean(tt9.getLanguage())) {
- return 1.5f * getTT9Height();
+ return 1.3f * Math.min(1, getTT9Height()) * getScreenScaleY();
}
return super.getTitleScale();
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 34ab5891..8320cf59 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -5,8 +5,8 @@
to ignore the Android text size scale. We can't allow scaling because it breaks the layout.
-->
-
- 18dp
+
+ 21dp
26sp
@@ -18,15 +18,16 @@
46dp
66dp
+ 18dp
-
+
48dp
16dp
12dp
32sp
72dp
-
+
30dp
12dp
@@ -49,16 +50,16 @@
666dp
9dp
- 13dp
- 11dp
+ 15dp
+ 13dp
2dp
- 4dp
- 3dp
- 3dp
+ 1dp
+ 1dp
+ 2dp
5dp
- 17sp
+ 17sp
40sp
36sp
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 61a4ba26..70839abc 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -132,6 +132,7 @@
- 0dp
- 2dp
- 0dp
+ - @dimen/main_small_command_palette_key_text_size
@@ -193,7 +194,7 @@
- @dimen/main_small_suggestion_spacing_horizontal
- @dimen/main_small_suggestion_spacing_horizontal
- - @dimen/numpad_suggestion_font_size
+ - @dimen/numpad_suggestion_text_size
@@ -308,8 +309,6 @@
- @dimen/numpad_key_spacing
- 0dp
- - @dimen/key_text_size
-
- @color/key_fn_text
- @color/key_fn_background
- @color/key_fn_ripple