Skip to content

Commit 5917944

Browse files
committed
fix: replace forced assertions with null-safe fallbacks in SuggestionStripView and SubtypeSettings
1 parent 2234599 commit 5917944

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

app/src/main/java/helium314/keyboard/latin/suggestions/SuggestionStripView.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,12 @@ class SuggestionStripView(context: Context, attrs: AttributeSet?, defStyle: Int)
10121012
wrapper.addView(dictDownloadButton, expandIndex + 1)
10131013
}
10141014
val colors = Settings.getValues().mColors
1015-
colors.setColor(dictDownloadButton!!, ColorType.TOOL_BAR_KEY)
1016-
dictDownloadButton?.setBackgroundResource(R.drawable.toolbar_key_background)
1017-
colors.setColor(dictDownloadButton!!.background, ColorType.TOOL_BAR_EXPAND_KEY_BACKGROUND)
1018-
dictDownloadButton?.isVisible = true
1015+
dictDownloadButton?.let { btn ->
1016+
colors.setColor(btn, ColorType.TOOL_BAR_KEY)
1017+
btn.setBackgroundResource(R.drawable.toolbar_key_background)
1018+
btn.background?.let { bg -> colors.setColor(bg, ColorType.TOOL_BAR_EXPAND_KEY_BACKGROUND) }
1019+
btn.isVisible = true
1020+
}
10191021
} else {
10201022
dictDownloadButton?.isVisible = false
10211023
}

app/src/main/java/helium314/keyboard/latin/utils/SubtypeSettings.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ object SubtypeSettings {
226226
}
227227
if (subtypes.isEmpty()) {
228228
// hardcoded fallback to en-US for weird cases
229-
systemSubtypes.add(resourceSubtypesByLocale[Locale.US]!!.first())
229+
resourceSubtypesByLocale[Locale.US]?.firstOrNull()?.let { systemSubtypes.add(it) }
230+
?: resourceSubtypesByLocale.values.firstOrNull()?.firstOrNull()?.let { systemSubtypes.add(it) }
230231
} else {
231232
systemSubtypes.addAll(subtypes)
232233
}

0 commit comments

Comments
 (0)