mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 14:40:06 +08:00
fix(gui): avoid strange spinner
This commit is contained in:
parent
21e700e162
commit
f6b985c55e
@ -18,10 +18,7 @@ import io.nekohasekai.sagernet.ktx.*
|
||||
import io.nekohasekai.sagernet.utils.Theme
|
||||
import io.nekohasekai.sagernet.widget.AppListPreference
|
||||
import moe.matsuri.nb4a.Protocols
|
||||
import moe.matsuri.nb4a.ui.ColorPickerPreference
|
||||
import moe.matsuri.nb4a.ui.LongClickMenuPreference
|
||||
import moe.matsuri.nb4a.ui.MTUPreference
|
||||
import moe.matsuri.nb4a.ui.SimpleMenuPreference
|
||||
import moe.matsuri.nb4a.ui.*
|
||||
|
||||
class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
|
||||
@ -113,9 +110,10 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
val requireTransproxy = findPreference<SwitchPreference>(Key.REQUIRE_TRANSPROXY)!!
|
||||
val transproxyPort = findPreference<EditTextPreference>(Key.TRANSPROXY_PORT)!!
|
||||
val transproxyMode = findPreference<SimpleMenuPreference>(Key.TRANSPROXY_MODE)!!
|
||||
val logLevel = findPreference<LongClickMenuPreference>(Key.LOG_LEVEL)!!
|
||||
val logLevel = findPreference<LongClickListPreference>(Key.LOG_LEVEL)!!
|
||||
val mtu = findPreference<MTUPreference>(Key.MTU)!!
|
||||
|
||||
logLevel.dialogLayoutResource = R.layout.layout_loglevel_help
|
||||
logLevel.setOnPreferenceChangeListener { _, _ ->
|
||||
needRestart()
|
||||
true
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package moe.matsuri.nb4a.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import io.nekohasekai.sagernet.R
|
||||
|
||||
class LongClickListPreference
|
||||
@JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyle: Int = R.attr.dropdownPreferenceStyle
|
||||
) : ListPreference(context, attrs, defStyle, 0) {
|
||||
private var mLongClickListener: View.OnLongClickListener? = null
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
val itemView: View = holder.itemView
|
||||
itemView.setOnLongClickListener {
|
||||
mLongClickListener?.onLongClick(it) ?: true
|
||||
}
|
||||
}
|
||||
|
||||
fun setOnLongClickListener(longClickListener: View.OnLongClickListener) {
|
||||
this.mLongClickListener = longClickListener
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import androidx.core.content.res.TypedArrayUtils
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import io.nekohasekai.sagernet.R
|
||||
@ -13,11 +13,13 @@ import io.nekohasekai.sagernet.R
|
||||
class MTUPreference
|
||||
@JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyle: Int = R.attr.dropdownPreferenceStyle
|
||||
) : SimpleMenuPreference(context, attrs, defStyle, 0) {
|
||||
) : ListPreference(context, attrs, defStyle, 0) {
|
||||
|
||||
init {
|
||||
setSummaryProvider {
|
||||
value.toString()
|
||||
}
|
||||
dialogLayoutResource = R.layout.layout_mtu_help
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
|
||||
9
app/src/main/res/layout/layout_loglevel_help.xml
Normal file
9
app/src/main/res/layout/layout_loglevel_help.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/help"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/log_level_help"
|
||||
android:textAlignment="center">
|
||||
|
||||
</TextView>
|
||||
9
app/src/main/res/layout/layout_mtu_help.xml
Normal file
9
app/src/main/res/layout/layout_mtu_help.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/help"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/mtu_help"
|
||||
android:textAlignment="center">
|
||||
|
||||
</TextView>
|
||||
@ -511,5 +511,7 @@ Anyone can write advanced plugins, which can control NekoBox. please download an
|
||||
<string name="show_group_in_notification">Show group name in in notification</string>
|
||||
<string name="reset_connections">Reset Connections</string>
|
||||
<string name="remove_duplicate">Remove duplicate servers</string>
|
||||
<string name="mtu_help">Long press the preference to set custom MTU.</string>
|
||||
<string name="log_level_help">Long press the preference to set the buffer size.</string>
|
||||
|
||||
</resources>
|
||||
@ -74,7 +74,7 @@
|
||||
app:summary="@string/show_direct_speed_sum"
|
||||
app:title="@string/show_direct_speed"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<moe.matsuri.nb4a.ui.LongClickMenuPreference
|
||||
<moe.matsuri.nb4a.ui.LongClickListPreference
|
||||
app:defaultValue="0"
|
||||
app:entries="@array/log_level"
|
||||
app:entryValues="@array/int_array_5"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user