Skip to content

Commit

Permalink
actions: bump androidx.preference:preference to 1.2.1 (fixes #1931) (
Browse files Browse the repository at this point in the history
…#1915)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gideon Okuro <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2024
1 parent 5fd5f3d commit 20684b3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dependencies {
implementation 'com.google.android:flexbox:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.preference:preference:1.1.1"
implementation "androidx.preference:preference:1.2.1"
testImplementation 'junit:junit:4.13.2'
implementation 'com.github.parse-community:ParseLiveQuery-Android:1.2.2'
implementation 'com.github.parse-community.Parse-SDK-Android:parse:4.2.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ abstract class BasePreferenceFragment: PreferenceFragmentCompat(), BackPressRece

override fun onResume() {
super.onResume()
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(preferenceChangeListener)
preferenceScreen.sharedPreferences?.registerOnSharedPreferenceChangeListener(preferenceChangeListener)
}

override fun onPause() {
super.onPause()
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(preferenceChangeListener)
preferenceScreen.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(preferenceChangeListener)
}

override fun onBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.preference.PreferenceManager
import android.text.ClipboardManager
import android.view.KeyCharacterMap
import android.view.KeyEvent
import io.treehouses.remote.MainApplication.Companion.context
import io.treehouses.remote.views.terminal.VDUBuffer
import io.treehouses.remote.views.terminal.vt320
import io.treehouses.remote.PreferenceConstants
Expand Down Expand Up @@ -60,7 +61,7 @@ open class BaseTerminalKeyListener(var manager: TerminalManager?,
private var clipboard: ClipboardManager? = null
protected var selectingForCopy = false
protected val selectionArea: SelectionArea = SelectionArea()
protected val prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(manager)
protected val prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)

protected fun handleDpadCenter(keyCode: Int, flag: Boolean): Boolean {
var newFlag = flag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class SettingsFragment : PreferenceFragmentCompat(), Preference.OnPreferenceClic

override fun onResume() {
super.onResume()
preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(preferenceChangeListener)
preferenceScreen.sharedPreferences?.registerOnSharedPreferenceChangeListener(preferenceChangeListener)
}

override fun onPause() {
super.onPause()
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(preferenceChangeListener)
preferenceScreen.sharedPreferences?.unregisterOnSharedPreferenceChangeListener(preferenceChangeListener)
}

override fun onPreferenceClick(preference: Preference): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ class UserCustomizationPreferenceFragment: BasePreferenceFragment() {
val clearSSHHosts = findPreference<Preference>("ssh_hosts")
val clearSSHKeys = findPreference<Preference>("ssh_keys")
val fontSize = findPreference<Preference>("font_size")

//fontSize?.setOnPreferenceChangeListener(object: Preference.OnPreferenceChangeListener(SharedPreferences, "font_size"))
fontSize?.setOnPreferenceChangeListener(object : Preference.OnPreferenceChangeListener{
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putInt("font_size", newValue.toString().toInt()).commit()
fontSize?.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, newValue ->
PreferenceManager.getDefaultSharedPreferences(requireContext()).edit().putInt("font_size", newValue.toString().toInt()).commit()
adjustFontScale(resources.configuration, newValue.toString().toInt())
activity?.recreate()
return false
false
}
})
SettingsUtils.setClickListener(this, clearCommandsList)
SettingsUtils.setClickListener(this, resetCommandsList)
SettingsUtils.setClickListener(this, clearNetworkProfiles)
Expand All @@ -48,7 +44,6 @@ class UserCustomizationPreferenceFragment: BasePreferenceFragment() {

@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
fun adjustFontScale(configuration: Configuration?, fontSize: Int) {

configuration?.let {
it.fontScale = 0.05F*fontSize.toFloat()
val metrics: DisplayMetrics = resources.displayMetrics
Expand All @@ -58,7 +53,6 @@ class UserCustomizationPreferenceFragment: BasePreferenceFragment() {

MainApplication.context.createConfigurationContext(it)
MainApplication.context.resources.displayMetrics.setTo(metrics)

}
}

Expand All @@ -69,7 +63,6 @@ class UserCustomizationPreferenceFragment: BasePreferenceFragment() {
"network_profiles" -> networkProfiles()
"ssh_hosts" -> clearSSHHosts()
"ssh_keys" -> clearSSHKeys()

}
return false
}
Expand Down Expand Up @@ -124,4 +117,4 @@ class UserCustomizationPreferenceFragment: BasePreferenceFragment() {
private const val CLEAR_SSH_HOSTS = 4
private const val CLEAR_SSH_KEYS = 5
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HomeFragment : BaseHomeFragment() {
private lateinit var bind: ActivityHomeFragmentBinding
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
bind = ActivityHomeFragmentBinding.inflate(inflater, container, false)
preferences = PreferenceManager.getDefaultSharedPreferences(context)
preferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
setupProfiles()
showDialogOnce(preferences!!)
connectRpiListener()
Expand Down Expand Up @@ -213,7 +213,7 @@ class HomeFragment : BaseHomeFragment() {
*/
private fun testConnectionListener() {
bind.testConnection.setOnClickListener {
val preference = PreferenceManager.getDefaultSharedPreferences(context).getString("led_pattern", "LED Heavy Metal")
val preference = PreferenceManager.getDefaultSharedPreferences(requireContext()).getString("led_pattern", "LED Heavy Metal")
val options = listOf(*resources.getStringArray(R.array.led_options))
val optionsCode = resources.getStringArray(R.array.led_options_commands)
viewModel.selectedLed = options.indexOf(preference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ import io.treehouses.remote.R

class RoundedListPreference : ListPreference {

constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(
context,
attrs,
defStyleAttr
)

constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

constructor(context: Context?) : super(context)
constructor(context: Context) : super(context)

override fun onClick() {
val currentIndex = findIndexOfValue(value)
Expand Down

0 comments on commit 20684b3

Please sign in to comment.