Skip to content

Commit

Permalink
Fix NullPointer crash opening settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SeventhM committed Apr 4, 2024
1 parent 849bf1c commit 7660e22
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ class BinaryDictionary : Dictionary, AutoCloseable {
min(alternatives.size, MAX_ALTERNATIVES)
)
}
Arrays.fill(mOutputChars, 0.toChar())
Arrays.fill(mFrequencies, 0)
mOutputChars.fill(0.toChar())
mFrequencies.fill(0)

if (mNativeDict == 0L) return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class LatinIMESettings : FragmentActivity(), OnSharedPreferenceChangeListener,

override fun onResume() {
super.onResume()
init()
val autoTextSize = AutoText.getSize(fragment.listView)
if (autoTextSize < 1) {
(fragment.findPreference<Preference>(PREDICTION_SETTINGS_KEY) as PreferenceGroup?)!!.removePreference(
Expand Down Expand Up @@ -150,6 +151,7 @@ class LatinIMESettings : FragmentActivity(), OnSharedPreferenceChangeListener,
}

override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String?) {
init()
BackupManager(this).dataChanged()
// If turning on voice input, show dialog
if (key == VOICE_SETTINGS_KEY && !mVoiceOn) {
Expand All @@ -163,6 +165,7 @@ class LatinIMESettings : FragmentActivity(), OnSharedPreferenceChangeListener,
}

private fun updateSummaries() {
init()
val res = resources
mSettingsKeyPreference!!.setSummary(
res.getStringArray(R.array.settings_key_modes)[mSettingsKeyPreference!!.findIndexOfValue(
Expand All @@ -178,11 +181,13 @@ class LatinIMESettings : FragmentActivity(), OnSharedPreferenceChangeListener,
}

private fun showVoiceConfirmation() {
init()
mOkClicked = false
showDialog(VOICE_INPUT_CONFIRM_DIALOG)
}

private fun updateVoiceModeSummary() {
init()
mVoicePreference!!.setSummary(
resources.getStringArray(R.array.voice_input_modes_summary)[mVoicePreference!!.findIndexOfValue(
mVoicePreference!!.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ open class SeekBarPreference(context: Context, attrs: AttributeSet?) :
}

@Deprecated("Deprecated in Java")
override fun onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any) {
override fun onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any?) {
if (restorePersistedValue) {
setVal(getPersistedFloat(0.0f))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class SeekBarPreferenceString(context: Context, attrs: AttributeSet?) :
}

@Deprecated("Deprecated in Java")
override fun onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any) {
override fun onSetInitialValue(restorePersistedValue: Boolean, defaultValue: Any?) {
if (restorePersistedValue) {
setVal(floatFromString(getPersistedString("0.0")))
} else {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@
<!-- Press the "enter" key after the user speaks. Summary of option in settings.-->
<string name="auto_submit_summary" tools:ignore="MissingTranslation">Automatically press enter when searching or going to the next field.</string>

<string name="open_the_keyboard" tools:ignore="MissingTranslation"><font size="17"><b>Open the keyboard\n</b></font><font size="3">\n</font></string>

<!-- appears above the image showing the back button used to close the keyboard -->
<string name="close_the_keyboard" tools:ignore="MissingTranslation"><font size="17"><b>Close the keyboard\n</b></font><font size="3">\n</font>Press the Back key.</string>

Expand Down

0 comments on commit 7660e22

Please sign in to comment.