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

Farsi/Persian Layout #206

Merged
merged 22 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion app/src/main/java/se/nullable/flickboard/model/KeyM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ enum class ActionClass {

sealed class ActionVisual {
data class Icon(val resource: Int) : ActionVisual()
data class Label(val label: String) : ActionVisual()
data class Label(
val label: String,
val directionOverride: TextDirection? = null
) : ActionVisual()

data object None : ActionVisual()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ val FA_MESSAGEASE_MAIN_LAYER = Layer(
actions = mapOf(
Direction.CENTER to Action.Text("ه"),
Direction.RIGHT to Action.Text("ـ"),
Direction.BOTTOM to Action.Text("ۀ"),
Direction.BOTTOM to Action.Text("ۀ"),
Direction.BOTTOM_RIGHT to Action.Text("ق"),
)

)
),
KeyM(
actions = mapOf(
Expand All @@ -36,7 +36,10 @@ val FA_MESSAGEASE_MAIN_LAYER = Layer(
Direction.CENTER to Action.Text("م"),
Direction.TOP_RIGHT to Action.Text(
"\u200F", //RLM
visualOverride = ActionVisual.Label("¶‹"),
visualOverride = ActionVisual.Label(
"¶‹",
directionOverride = TextDirection.RightToLeft
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be TextDirection.LeftToRight to be displayed as ¶‹

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

),
),
Direction.BOTTOM_LEFT to Action.Text("چ"),
)
Expand Down Expand Up @@ -88,7 +91,7 @@ val FA_MESSAGEASE_MAIN_LAYER = Layer(
actions = mapOf(
Direction.CENTER to Action.Text("ن"),
Direction.TOP_LEFT to Action.Text("ظ"),
Direction.TOP to Action.Text("ث"),
Direction.TOP to Action.Text("ث"),
Direction.TOP_RIGHT to Action.Text("غ"),
Direction.LEFT to Action.Text("ء"),
Direction.RIGHT to Action.Text("أ"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ val FA_THUMBKEY_MAIN_LAYER = Layer(
KeyM(
actions = mapOf(
Direction.CENTER to Action.Text("د"),
Direction.BOTTOM to Action.Text("ض"),
Direction.BOTTOM to Action.Text("ض"),
Direction.BOTTOM_RIGHT to Action.Text("ص"),
)

)
),
KeyM(
actions = mapOf(
Expand All @@ -36,8 +36,11 @@ val FA_THUMBKEY_MAIN_LAYER = Layer(
Direction.CENTER to Action.Text("و"),
Direction.TOP_RIGHT to Action.Text(
"\u200F", //RLM
visualOverride = ActionVisual.Label("¶‹"),
),
visualOverride = ActionVisual.Label(
"¶‹",
directionOverride = TextDirection.RightToLeft
),
),
Direction.BOTTOM_LEFT to Action.Text("ع"),
Direction.BOTTOM to Action.Text("ء"),
)
Expand Down Expand Up @@ -87,7 +90,7 @@ val FA_THUMBKEY_MAIN_LAYER = Layer(
Direction.TOP to Action.Text(
"\u200C", //ZWNJ
visualOverride = ActionVisual.Label("‹›"),
),
),
Direction.LEFT to Action.Text("؟"),
Direction.RIGHT to Action.Text("ئ"),
Direction.BOTTOM_LEFT to Action.Text("*"),
Expand Down
20 changes: 12 additions & 8 deletions app/src/main/java/se/nullable/flickboard/ui/Key.kt
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,20 @@ fun KeyActionIndicator(
alignment = LineHeightStyle.Alignment.Center,
trim = LineHeightStyle.Trim.Both
),
textDirection = when (layoutTextDirection) {
textDirection = when (actionVisual.directionOverride) {
TextDirection.LeftToRight -> androidx.compose.ui.text.style.TextDirection.Ltr
TextDirection.RightToLeft ->
when {
LocalAppSettings.current.noReverseRtlBrackets.state.value ->
androidx.compose.ui.text.style.TextDirection.Content
TextDirection.RightToLeft -> androidx.compose.ui.text.style.TextDirection.Rtl
else -> when (layoutTextDirection) {
TextDirection.LeftToRight -> androidx.compose.ui.text.style.TextDirection.Ltr
TextDirection.RightToLeft ->
when {
LocalAppSettings.current.noReverseRtlBrackets.state.value ->
androidx.compose.ui.text.style.TextDirection.Content

else ->
androidx.compose.ui.text.style.TextDirection.Rtl
}
else ->
androidx.compose.ui.text.style.TextDirection.Rtl
}
}
}
),
)
Expand Down