enabled background blending on Android 15 for improved edge-to-edge experience
This commit is contained in:
parent
aa3a3de661
commit
3b4ded4362
11 changed files with 90 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ import io.github.sspanak.tt9.ime.modes.InputModeKind;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
||||||
import io.github.sspanak.tt9.ui.tray.StatusBar;
|
import io.github.sspanak.tt9.ui.tray.StatusBar;
|
||||||
|
import io.github.sspanak.tt9.util.SystemSettings;
|
||||||
|
|
||||||
abstract class UiHandler extends AbstractHandler {
|
abstract class UiHandler extends AbstractHandler {
|
||||||
protected SettingsStore settings;
|
protected SettingsStore settings;
|
||||||
|
|
@ -44,6 +45,7 @@ abstract class UiHandler extends AbstractHandler {
|
||||||
statusBar.setText(inputMode);
|
statusBar.setText(inputMode);
|
||||||
mainView.hideCommandPalette();
|
mainView.hideCommandPalette();
|
||||||
mainView.render();
|
mainView.render();
|
||||||
|
SystemSettings.setNavigationBarDarkTheme(getWindow().getWindow(), settings.getDarkTheme());
|
||||||
|
|
||||||
if (!isInputViewShown()) {
|
if (!isInputViewShown()) {
|
||||||
updateInputViewShown();
|
updateInputViewShown();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package io.github.sspanak.tt9.ui.main;
|
package io.github.sspanak.tt9.ui.main;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
|
|
@ -238,6 +239,45 @@ abstract class BaseMainLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean shouldEnableBackgroundBlending() {
|
||||||
|
if (view == null || tt9 == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isLandscape = DeviceInfo.isLandscapeOrientation(view.getContext());
|
||||||
|
int width = tt9.getSettings().getWidthPercent();
|
||||||
|
|
||||||
|
return
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM
|
||||||
|
&& ((isLandscape && width >= 75) || (!isLandscape && width >= 65));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void setBackgroundBlending() {
|
||||||
|
if (view == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean yes = shouldEnableBackgroundBlending();
|
||||||
|
|
||||||
|
view.setBackgroundColor(
|
||||||
|
yes ? view.getContext().getResources().getColor(R.color.keyboard_background) : Color.TRANSPARENT
|
||||||
|
);
|
||||||
|
|
||||||
|
final int separatorVisibility = yes ? View.VISIBLE : View.GONE;
|
||||||
|
|
||||||
|
View leftBumperTopSeparator = view.findViewById(R.id.bumper_left_top_separator);
|
||||||
|
if (leftBumperTopSeparator != null) {
|
||||||
|
leftBumperTopSeparator.setVisibility(separatorVisibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
View rightBumperTopSeparator = view.findViewById(R.id.bumper_right_top_separator);
|
||||||
|
if (rightBumperTopSeparator != null) {
|
||||||
|
rightBumperTopSeparator.setVisibility(separatorVisibility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
abstract void showCommandPalette();
|
abstract void showCommandPalette();
|
||||||
abstract void hideCommandPalette();
|
abstract void hideCommandPalette();
|
||||||
abstract boolean isCommandPaletteShown();
|
abstract boolean isCommandPaletteShown();
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,7 @@ class MainLayoutNumpad extends BaseMainLayout {
|
||||||
preventEdgeToEdge();
|
preventEdgeToEdge();
|
||||||
setWidth(tt9.getSettings().getWidthPercent(), tt9.getSettings().getAlignment());
|
setWidth(tt9.getSettings().getWidthPercent(), tt9.getSettings().getAlignment());
|
||||||
setKeyColumnWidth(tt9.getSettings().getNumpadFnKeyScale());
|
setKeyColumnWidth(tt9.getSettings().getNumpadFnKeyScale());
|
||||||
|
setBackgroundBlending();
|
||||||
showLongSpace(
|
showLongSpace(
|
||||||
tt9.getSettings().isNumpadShapeLongSpace() && !tt9.isInputModeNumeric() && !LanguageKind.isKorean(tt9.getLanguage()),
|
tt9.getSettings().isNumpadShapeLongSpace() && !tt9.isInputModeNumeric() && !LanguageKind.isKorean(tt9.getLanguage()),
|
||||||
defaultKeyHeight
|
defaultKeyHeight
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ class MainLayoutTray extends BaseMainLayout {
|
||||||
setSoftKeysVisibility();
|
setSoftKeysVisibility();
|
||||||
preventEdgeToEdge();
|
preventEdgeToEdge();
|
||||||
setWidth(tt9.getSettings().getWidthPercent(), tt9.getSettings().getAlignment());
|
setWidth(tt9.getSettings().getWidthPercent(), tt9.getSettings().getAlignment());
|
||||||
|
setBackgroundBlending();
|
||||||
enableClickHandlers();
|
enableClickHandlers();
|
||||||
for (SoftKey key : getKeys()) {
|
for (SoftKey key : getKeys()) {
|
||||||
key.render();
|
key.render();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowInsetsController;
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
|
|
@ -68,4 +70,25 @@ public class SystemSettings {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Even though the background changes automatically on Android 15, thanks to edge-to-edge,
|
||||||
|
* the text/icon color remains the device default. This function allows us to change it.
|
||||||
|
* @see : <a href="https://stackoverflow.com/a/77240330">the only working solution</a>.
|
||||||
|
*/
|
||||||
|
public static void setNavigationBarDarkTheme(@Nullable Window window, boolean dark) {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowInsetsController insetsController = window != null ? window.getInsetsController() : null;
|
||||||
|
if (insetsController == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
insetsController.setSystemBarsAppearance(
|
||||||
|
dark ? 0 : WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
|
||||||
|
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/TTheme.FullScreenContainer">
|
style="@style/TTheme.FullScreenContainer">
|
||||||
|
|
||||||
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_left" />
|
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_left">
|
||||||
|
<View android:id="@+id/bumper_left_top_separator" style="@style/TTheme.Bumper.TopSeparator" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout style="@style/TTheme.Numpad" android:id="@+id/keyboard_container">
|
<LinearLayout style="@style/TTheme.Numpad" android:id="@+id/keyboard_container">
|
||||||
<View style="@style/TTheme.Keyboard.TopSeparator" />
|
<View style="@style/TTheme.Keyboard.TopSeparator" />
|
||||||
|
|
@ -27,6 +29,8 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_right" />
|
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_right">
|
||||||
|
<View android:id="@+id/bumper_right_top_separator" style="@style/TTheme.Bumper.TopSeparator" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/TTheme.FullScreenContainer">
|
style="@style/TTheme.FullScreenContainer">
|
||||||
|
|
||||||
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_left" />
|
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_left">
|
||||||
|
<View android:id="@+id/bumper_left_top_separator" style="@style/TTheme.Bumper.TopSeparator" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout style="@style/TTheme.MainSmall" android:id="@+id/keyboard_container">
|
<LinearLayout style="@style/TTheme.MainSmall" android:id="@+id/keyboard_container">
|
||||||
<View style="@style/TTheme.Keyboard.TopSeparator" />
|
<View style="@style/TTheme.Keyboard.TopSeparator" />
|
||||||
|
|
@ -21,6 +23,8 @@
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_right" />
|
<LinearLayout style="@style/TTheme.FullScreenContainer.SideBumper" android:id="@+id/bumper_right">
|
||||||
|
<View android:id="@+id/bumper_right_top_separator" style="@style/TTheme.Bumper.TopSeparator" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- only used for calculating the initial default width -->
|
||||||
<dimen name="numpad_max_width">720dp</dimen>
|
<dimen name="numpad_max_width">720dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<color name="keyboard_wrapper_background">@color/keyboard_background</color>
|
||||||
|
<color name="keyboard_wrapper_top_separator">@color/keyboard_top_separator</color>
|
||||||
|
|
||||||
<color name="key_lf4_background">@color/key_fn_background</color>
|
<color name="key_lf4_background">@color/key_fn_background</color>
|
||||||
<color name="key_lf4_ripple">@color/key_fn_ripple</color>
|
<color name="key_lf4_ripple">@color/key_fn_ripple</color>
|
||||||
<color name="key_lf4_text">@color/key_fn_text</color>
|
<color name="key_lf4_text">@color/key_fn_text</color>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
<color name="keyboard_background">#e8eaed</color>
|
<color name="keyboard_background">#e8eaed</color>
|
||||||
<color name="keyboard_text">#3d3d3f</color>
|
<color name="keyboard_text">#3d3d3f</color>
|
||||||
<color name="keyboard_top_separator">@color/key_fn_background</color>
|
<color name="keyboard_top_separator">@color/key_fn_background</color>
|
||||||
|
<color name="keyboard_wrapper_background">#00000000</color>
|
||||||
|
<color name="keyboard_wrapper_top_separator">#00000000</color>
|
||||||
|
|
||||||
<color name="key_num_background">#fff</color>
|
<color name="key_num_background">#fff</color>
|
||||||
<color name="key_num_ripple">#eff0f1</color>
|
<color name="key_num_ripple">#eff0f1</color>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:layoutDirection">ltr</item>
|
<item name="android:layoutDirection">ltr</item>
|
||||||
<item name="android:orientation">horizontal</item>
|
<item name="android:orientation">horizontal</item>
|
||||||
|
<item name="android:background">@color/keyboard_wrapper_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TTheme.FullScreenContainer.SideBumper" parent="">
|
<style name="TTheme.FullScreenContainer.SideBumper" parent="">
|
||||||
|
|
@ -40,6 +41,10 @@
|
||||||
<item name="android:background">@color/keyboard_top_separator</item>
|
<item name="android:background">@color/keyboard_top_separator</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TTheme.Bumper.TopSeparator" parent="TTheme.Keyboard.TopSeparator">
|
||||||
|
<item name="android:background">@color/keyboard_wrapper_top_separator</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!--*******************************************
|
<!--*******************************************
|
||||||
Small
|
Small
|
||||||
*******************************************-->
|
*******************************************-->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue