mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/3388: Set max length for device name (https://github.com/mozilla-mobile/fenix/pull/3397)
This commit is contained in:
parent
22549c75d3
commit
177098ba41
@ -6,10 +6,12 @@ package org.mozilla.fenix.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.InputFilter
|
||||
import android.text.format.DateUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.Navigation
|
||||
import androidx.preference.CheckBoxPreference
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
@ -111,11 +113,14 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
|
||||
// Device Name
|
||||
val deviceConstellation = accountManager.authenticatedAccount()?.deviceConstellation()
|
||||
val deviceNameKey = context!!.getPreferenceKey(R.string.pref_key_sync_device_name)
|
||||
findPreference<Preference>(deviceNameKey)?.apply {
|
||||
findPreference<EditTextPreference>(deviceNameKey)?.apply {
|
||||
onPreferenceChangeListener = getChangeListenerForDeviceName()
|
||||
deviceConstellation?.state()?.currentDevice?.let { device ->
|
||||
summary = device.displayName
|
||||
}
|
||||
setOnBindEditTextListener { editText ->
|
||||
editText.filters = arrayOf(InputFilter.LengthFilter(DEVICE_NAME_MAX_LENGTH))
|
||||
}
|
||||
}
|
||||
|
||||
deviceConstellation?.registerDeviceObserver(deviceConstellationObserver, owner = this, autoPause = true)
|
||||
@ -257,4 +262,8 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DEVICE_NAME_MAX_LENGTH = 128
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user