Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 3c0a26bb authored by Michael Biebl's avatar Michael Biebl Committed by GitHub
Browse files

Preferences (#25)

* Set InputType for proxy_host and proxy_port programmatically

Since AndroidX it is no longer sufficient to simply specify
android:inputType in settings_app.xml.

* Drop custom IntEditTextPreference.kt

Doesn't appear to be necessary anymore.
parent 08dfa3f0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.PowerManager
import android.text.InputType
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.UiThread
import androidx.appcompat.app.AppCompatActivity
@@ -89,6 +90,18 @@ class AppSettingsActivity: AppCompatActivity() {
                }
            }

            findPreference<EditTextPreference>(Settings.PROXY_HOST)!!.apply {
                this.setOnBindEditTextListener {
                    it.inputType = InputType.TYPE_TEXT_VARIATION_URI
                }
            }

            findPreference<EditTextPreference>(Settings.PROXY_PORT)!!.apply {
                this.setOnBindEditTextListener {
                    it.inputType = InputType.TYPE_CLASS_NUMBER
                }
            }

            arguments?.getString(EXTRA_SCROLL_TO)?.let { key ->
                scrollToPreference(key)
            }
+0 −26
Original line number Diff line number Diff line
/***************************************************************************************************
 * Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details.
 **************************************************************************************************/

package at.bitfire.davdroid.ui.widget

import android.content.Context
import android.util.AttributeSet
import androidx.preference.EditTextPreference

class IntEditTextPreference(
        context: Context,
        attrs: AttributeSet
): EditTextPreference(context, attrs) {

    override fun getPersistedString(defaultReturnValue: String?) =
            getPersistedInt(-1).toString()

    override fun persistString(value: String) =
            try {
                super.persistInt(value.toInt())
            } catch (e: NumberFormatException) {
                false
            }

}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@
            android:inputType="textUri"
            android:persistent="false" />

        <at.bitfire.davdroid.ui.widget.IntEditTextPreference
        <EditTextPreference
            android:key="proxy_port"
            android:title="@string/app_settings_proxy_port"
            android:inputType="number"