2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00
This commit is contained in:
Jonathan Almeida 2019-06-12 16:35:06 -04:00 committed by Colin Lee
parent 22549c75d3
commit 177098ba41

View File

@ -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
}
}