6.6.3 - Alpha2 - 设置页面对话框相关设置支持 "使用默认值" 菜单选项
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
"improvement": [
|
"improvement": [
|
||||||
"主页抽屉在横向屏幕或超宽屏幕的宽度适应性",
|
"主页抽屉在横向屏幕或超宽屏幕的宽度适应性",
|
||||||
"关于应用与开发者页面增加水平布局及小屏布局适配",
|
"关于应用与开发者页面增加水平布局及小屏布局适配",
|
||||||
|
"设置页面对话框相关设置支持 \"使用默认值\" 菜单选项",
|
||||||
"文件管理器浮动按钮展开后点击其他区域可自动隐藏",
|
"文件管理器浮动按钮展开后点击其他区域可自动隐藏",
|
||||||
"打包单文件时自动读取并勾选已安装应用的声明权限 _[`issue #362`](http://issues.autojs6.com/362)_",
|
"打包单文件时自动读取并勾选已安装应用的声明权限 _[`issue #362`](http://issues.autojs6.com/362)_",
|
||||||
"已忽略更新记录及客户端模式连接地址记录支持清空操作",
|
"已忽略更新记录及客户端模式连接地址记录支持清空操作",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.content.Context
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import androidx.preference.Preference.SummaryProvider
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import org.autojs.autojs.core.pref.Pref
|
import org.autojs.autojs.core.pref.Pref
|
||||||
import org.autojs.autojs.ui.common.NotAskAgainDialog
|
import org.autojs.autojs.ui.common.NotAskAgainDialog
|
||||||
@@ -32,6 +31,12 @@ open class MaterialListPreference : MaterialDialogPreference {
|
|||||||
protected val entry: CharSequence?
|
protected val entry: CharSequence?
|
||||||
get() = mItemValues.takeIf { it.isNotEmpty() }?.toList()?.get(itemPrefIndex ?: mItemDefaultIndex)
|
get() = mItemValues.takeIf { it.isNotEmpty() }?.toList()?.get(itemPrefIndex ?: mItemDefaultIndex)
|
||||||
|
|
||||||
|
protected val defaultEntry: CharSequence?
|
||||||
|
get() {
|
||||||
|
val keyIndex = getKeyIndex(mItemDefaultKey) ?: return null
|
||||||
|
return mItemValues.takeIf { it.isNotEmpty() }?.toList()?.get(keyIndex)
|
||||||
|
}
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int, bundle: Bundle) : super(context, attrs, defStyleAttr, defStyleRes) {
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int, bundle: Bundle) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||||
init(context, attrs, defStyleAttr, defStyleRes, bundle)
|
init(context, attrs, defStyleAttr, defStyleRes, bundle)
|
||||||
}
|
}
|
||||||
@@ -53,7 +58,13 @@ open class MaterialListPreference : MaterialDialogPreference {
|
|||||||
.let { a ->
|
.let { a ->
|
||||||
getAttrString(a, R.styleable.MaterialListPreference_dialogTitle)?.also { dialogTitle = it }
|
getAttrString(a, R.styleable.MaterialListPreference_dialogTitle)?.also { dialogTitle = it }
|
||||||
getAttrString(a, R.styleable.MaterialListPreference_dialogContent)?.also { dialogContent = it }
|
getAttrString(a, R.styleable.MaterialListPreference_dialogContent)?.also { dialogContent = it }
|
||||||
|
getAttrColor(a, R.styleable.MaterialListPreference_negativeColor)?.takeIf { it != -1 }?.let {
|
||||||
|
negativeColor = it
|
||||||
|
}
|
||||||
positiveText = getAttrString(a, R.styleable.MaterialListPreference_positiveText) ?: context.getString(R.string.dialog_button_confirm)
|
positiveText = getAttrString(a, R.styleable.MaterialListPreference_positiveText) ?: context.getString(R.string.dialog_button_confirm)
|
||||||
|
getAttrColor(a, R.styleable.MaterialListPreference_positiveColor)?.takeIf { it != -1 }?.let {
|
||||||
|
positiveColor = it
|
||||||
|
}
|
||||||
negativeText = getAttrString(a, R.styleable.MaterialListPreference_negativeText) ?: context.getString(R.string.dialog_button_cancel)
|
negativeText = getAttrString(a, R.styleable.MaterialListPreference_negativeText) ?: context.getString(R.string.dialog_button_cancel)
|
||||||
getAttrTextArray(a, R.styleable.MaterialListPreference_itemKeys)?.also { mItemKeys = it.toList() }
|
getAttrTextArray(a, R.styleable.MaterialListPreference_itemKeys)?.also { mItemKeys = it.toList() }
|
||||||
getAttrTextArray(a, R.styleable.MaterialListPreference_itemValues)?.also { mItemValues = it.toList() }
|
getAttrTextArray(a, R.styleable.MaterialListPreference_itemValues)?.also { mItemValues = it.toList() }
|
||||||
@@ -88,6 +99,15 @@ open class MaterialListPreference : MaterialDialogPreference {
|
|||||||
}
|
}
|
||||||
return@itemsCallbackSingleChoice true
|
return@itemsCallbackSingleChoice true
|
||||||
}
|
}
|
||||||
|
if (defaultEntry != null) {
|
||||||
|
builder.options(
|
||||||
|
listOf(
|
||||||
|
MaterialDialog.OptionMenuItemSpec(context.getString(R.string.dialog_button_use_default)) { dialog ->
|
||||||
|
dialog.selectedIndex = mItemDefaultIndex
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user