Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Add workaround disabling RTL bracket flipping on Samsung devices
Browse files Browse the repository at this point in the history
See #206
  • Loading branch information
nightkr committed Jul 30, 2024
1 parent b16c46b commit d4c357c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
9 changes: 8 additions & 1 deletion app/src/main/java/se/nullable/flickboard/ui/Key.kt
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,14 @@ fun KeyActionIndicator(
),
textDirection = when (layoutTextDirection) {
TextDirection.LeftToRight -> androidx.compose.ui.text.style.TextDirection.Ltr
TextDirection.RightToLeft -> androidx.compose.ui.text.style.TextDirection.Rtl
TextDirection.RightToLeft ->
when {
LocalAppSettings.current.noReverseRtlBrackets.state.value ->
androidx.compose.ui.text.style.TextDirection.Content

else ->
androidx.compose.ui.text.style.TextDirection.Rtl
}
}
),
)
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/se/nullable/flickboard/ui/Keyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fun Keyboard(
val toneConfig = rememberUpdatedState(toneMode.value.config)
val backgroundImage = appSettings.backgroundImage.state
val keyboardMargin = appSettings.keyboardMargin.state
val noReverseRtlBrackets = appSettings.noReverseRtlBrackets.state
var modifierState: ModifierState by remember { mutableStateOf(ModifierState()) }
LaunchedEffect(modifierState) {
onModifierStateUpdated(modifierState)
Expand Down Expand Up @@ -198,7 +199,10 @@ fun Keyboard(
.let {
when (layoutState.value.textDirection) {
TextDirection.LeftToRight -> it
TextDirection.RightToLeft -> it.flipBrackets()
TextDirection.RightToLeft -> when {
noReverseRtlBrackets.value -> it
else -> it.flipBrackets()
}
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/se/nullable/flickboard/ui/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import se.nullable.flickboard.model.layouts.messageaseNumericPhoneLayer
import se.nullable.flickboard.model.layouts.miniNumbersCalculatorLayer
import se.nullable.flickboard.model.layouts.miniNumbersPhoneLayer
import se.nullable.flickboard.ui.theme.Typography
import se.nullable.flickboard.ui.util.isSamsungDevice
import se.nullable.flickboard.util.Boxed
import se.nullable.flickboard.util.MaterialToneMode
import java.io.FileOutputStream
Expand Down Expand Up @@ -1136,6 +1137,14 @@ class AppSettings(val ctx: SettingsContext) {
render = { String.format(locale = Locale.getDefault(), "%.2fs", it) }
)

val noReverseRtlBrackets = Setting.Bool(
key = "noReverseRtlBrackets",
label = "Do not reverse brackets in right-to-left languages",
defaultValue = isSamsungDevice,
ctx = ctx,
description = "This is required for the correct brackets to be typed on some devices (especially Samsung)",
)

// Pseudo-option used to store history
val emojiHistory =
Setting.Text(key = "emojiHistory", label = "Emoji history", defaultValue = "", ctx = ctx)
Expand Down Expand Up @@ -1225,7 +1234,8 @@ class AppSettings(val ctx: SettingsContext) {
settings = listOf(
dropLastGesturePoint,
ignoreJumpsLongerThanPx,
flicksMustBeLongerThanSeconds
flicksMustBeLongerThanSeconds,
noReverseRtlBrackets,
),
),
SettingsSection(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package se.nullable.flickboard.ui.util

import android.os.Build

val isSamsungDevice = Build.MANUFACTURER == "samsung"

0 comments on commit d4c357c

Please sign in to comment.