Some bugfixes for new UI
This commit is contained in:
@@ -105,6 +105,7 @@ class ProfileConfigFragment extends PreferenceFragment with OnMenuItemClickListe
|
||||
pluginConfiguration = new PluginConfiguration(app.settings.getString(Key.plugin, null))
|
||||
plugin.setValue(pluginConfiguration.selected)
|
||||
plugin.checkSummary()
|
||||
pluginConfigure.setEnabled(!TextUtils.isEmpty(pluginConfiguration.selected))
|
||||
pluginConfigure.setText(pluginConfiguration.selectedOptions.toString)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import scala.collection.mutable
|
||||
*/
|
||||
class PluginConfiguration(val pluginsOptions: Map[String, PluginOptions], val selected: String) {
|
||||
private def this(plugins: Array[PluginOptions]) =
|
||||
this(plugins.map(opt => opt.id -> opt).toMap, if (plugins.isEmpty) "" else plugins(0).id)
|
||||
this(plugins.filter(_.id.nonEmpty).map(opt => opt.id -> opt).toMap, if (plugins.isEmpty) "" else plugins(0).id)
|
||||
def this(plugin: String) = this(if (plugin == null) Array[PluginOptions]() else plugin.split("\n").map {
|
||||
case line if line.startsWith("kcptun ") =>
|
||||
val opt = new PluginOptions()
|
||||
@@ -30,7 +30,8 @@ class PluginConfiguration(val pluginsOptions: Map[String, PluginOptions], val se
|
||||
case line => new PluginOptions(line)
|
||||
})
|
||||
|
||||
def selectedOptions: PluginOptions = pluginsOptions(selected)
|
||||
def getOptions(id: String): PluginOptions = if (id.isEmpty) new PluginOptions() else pluginsOptions(id)
|
||||
def selectedOptions: PluginOptions = getOptions(selected)
|
||||
|
||||
override def toString: String = {
|
||||
val result = new mutable.ListBuffer[PluginOptions]()
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ final class BottomSheetPreferenceDialogFragment extends PreferenceDialogFragment
|
||||
dialog
|
||||
}
|
||||
|
||||
def onDialogClosed(positiveResult: Boolean): Unit = if (clickedIndex >= 0) {
|
||||
def onDialogClosed(positiveResult: Boolean): Unit = if (clickedIndex >= 0 && clickedIndex != index) {
|
||||
val value = preference.getEntryValues()(clickedIndex).toString
|
||||
if (preference.callChangeListener(value)) preference.setValue(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user