Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

### 🐛 Bug Fixes

- Fixed keyboard window decor transparency and navigation bar insets under Android 16 edge-to-edge display enforcement so the screen background is no longer obscured ([#759](https://github.com/scribe-org/Scribe-Android/issues/759)).
- The keyboard service no longer crashes when an editor starts input with no `EditorInfo` ([#699](https://github.com/scribe-org/Scribe-Android/issues/699)).
- Downloading or checking for language data updates no longer crashes the app when the server returns a malformed timestamp ([#700](https://github.com/scribe-org/Scribe-Android/issues/700)).
- Native dictionaries are re-extracted after an app update so autosuggestions no longer use dictionaries from a previous install ([#701](https://github.com/scribe-org/Scribe-Android/issues/701)).
Expand Down
48 changes: 35 additions & 13 deletions app/src/keyboards/java/be/scri/helpers/ui/KeyboardThemeManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package be.scri.helpers.ui
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.LayerDrawable
import android.graphics.drawable.RippleDrawable
Expand Down Expand Up @@ -50,6 +51,7 @@ class KeyboardThemeManager {
uiManager: KeyboardUIManager?,
) {
val targetWindow = window ?: return
targetWindow.decorView.setBackgroundColor(Color.TRANSPARENT)
targetWindow.decorView.post {
val context = service.applicationContext
val isDarkMode = getIsDarkModeOrNot(context)
Expand All @@ -66,11 +68,7 @@ class KeyboardThemeManager {
targetWindow.isNavigationBarContrastEnforced = false
}

if (isFloatingMode) {
targetWindow.decorView.setBackgroundColor(Color.TRANSPARENT)
} else {
targetWindow.decorView.setBackgroundColor(color)
}
targetWindow.decorView.setBackgroundColor(Color.TRANSPARENT)
val insetsController = WindowCompat.getInsetsController(targetWindow, targetWindow.decorView)
insetsController.isAppearanceLightNavigationBars = isLightColor(color)

Expand All @@ -89,25 +87,49 @@ class KeyboardThemeManager {
}

if (uiManager != null) {
uiManager.binding.root.setBackgroundColor(Color.TRANSPARENT)
if (isFloatingMode) {
uiManager.binding.root.setBackgroundColor(Color.TRANSPARENT)
val kbBgColor = ContextCompat.getColor(service, if (isDarkMode) R.color.dark_keyboard_bg_color else R.color.light_keyboard_bg_color)
val kbBgColor =
ContextCompat.getColor(
service,
if (isDarkMode) R.color.dark_keyboard_bg_color else R.color.light_keyboard_bg_color,
)
uiManager.binding.floatingDragBar.setBackgroundColor(kbBgColor)
val pillColor = if (isDarkMode) 0x4DFFFFFF.toInt() else 0x40000000.toInt()
uiManager.binding.floatingDragHandle.setColorFilter(pillColor)
} else {
uiManager.binding.root.setBackgroundColor(color)
uiManager.binding.keyboardCard.background = ColorDrawable(color)
}

val applyBottomPadding: (WindowInsetsCompat?) -> Unit = { windowInsets ->
val insets = windowInsets ?: ViewCompat.getRootWindowInsets(targetWindow.decorView)
val insetTypes = WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.displayCutout()
val navBarHeight = insets?.getInsets(insetTypes)?.bottom ?: 0
val extraBottomPadding = (10 * service.resources.displayMetrics.density).toInt()
val paddingBottom = if (isFloatingMode) 0 else (navBarHeight + extraBottomPadding)
val card = uiManager.binding.keyboardCard
if (card.paddingBottom != paddingBottom) {
card.setPadding(0, 0, 0, paddingBottom)
}
if (uiManager.binding.root.paddingBottom != 0) {
uiManager.binding.root.setPadding(0, 0, 0, 0)
}
}

ViewCompat.setOnApplyWindowInsetsListener(uiManager.binding.root) { view, insets ->
val insetTypes = WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
val navBarHeight = insets.getInsets(insetTypes).bottom
val paddingBottom = if (isFloatingMode) 0 else navBarHeight
view.setPadding(0, 0, 0, paddingBottom)
ViewCompat.setOnApplyWindowInsetsListener(targetWindow.decorView) { _, insets ->
applyBottomPadding(insets)
insets
}

ViewCompat.setOnApplyWindowInsetsListener(uiManager.binding.root) { _, insets ->
applyBottomPadding(insets)
insets
}

applyBottomPadding(null)

uiManager.binding.root.post {
ViewCompat.requestApplyInsets(targetWindow.decorView)
ViewCompat.requestApplyInsets(uiManager.binding.root)
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ abstract class GeneralKeyboardIME(
outInsets.touchableRegion.setEmpty()
}
} else {
val card = uiManager.binding.keyboardCard
val targetView = if (card.visibility == View.VISIBLE && card.height > 0) card else inputView
targetView.getLocationInWindow(location)
outInsets.visibleTopInsets = location[1]
outInsets.contentTopInsets = location[1]
outInsets.touchableInsets = Insets.TOUCHABLE_INSETS_VISIBLE
Expand Down
8 changes: 2 additions & 6 deletions app/src/main/res/layout/input_method_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -715,17 +715,13 @@ GeneralKeyboardIME.kt

<FrameLayout
android:id="@+id/empty_state_banner_container"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/keyboard_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
android:visibility="gone">

<TextView
android:id="@+id/empty_state_banner"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dimen name="toolbar_height">46dp</dimen>
<dimen name="toolbar_icon_height">32dp</dimen>
<dimen name="clip_drag_icon_height">40dp</dimen>
<dimen name="key_height">58dp</dimen>
<dimen name="key_height">50dp</dimen>
<dimen name="key_height_landscape">40dp</dimen>
<dimen name="conjugate_view_key_height_3x3">73dp</dimen>
<dimen name="conjugate_view_key_height_2x2">113dp</dimen>
Expand Down
Loading