Commit 6e4dd864 authored by Mygod's avatar Mygod

Properly respect dynamic resources

parent 4499d088
...@@ -44,8 +44,8 @@ abstract class ResolvedPlugin(protected val resolveInfo: ResolveInfo) : Plugin() ...@@ -44,8 +44,8 @@ abstract class ResolvedPlugin(protected val resolveInfo: ResolveInfo) : Plugin()
else -> error("unknown type for plugin meta-data idAliases") else -> error("unknown type for plugin meta-data idAliases")
} }
} }
override val label: CharSequence by lazy { resolveInfo.loadLabel(app.packageManager) } override val label: CharSequence get() = resolveInfo.loadLabel(app.packageManager)
override val icon: Drawable by lazy { resolveInfo.loadIcon(app.packageManager) } override val icon: Drawable get() = resolveInfo.loadIcon(app.packageManager)
override val defaultConfig by lazy { override val defaultConfig by lazy {
componentInfo.metaData.loadString(PluginContract.METADATA_KEY_DEFAULT_CONFIG) { resources } componentInfo.metaData.loadString(PluginContract.METADATA_KEY_DEFAULT_CONFIG) { resources }
} }
......
...@@ -62,12 +62,13 @@ class PluginPreferenceDialogFragment : PreferenceDialogFragmentCompat() { ...@@ -62,12 +62,13 @@ class PluginPreferenceDialogFragment : PreferenceDialogFragmentCompat() {
fun bind(plugin: Plugin, selected: Boolean = false) { fun bind(plugin: Plugin, selected: Boolean = false) {
this.plugin = plugin this.plugin = plugin
text1.text = plugin.label val label = plugin.label
text1.text = label
text2.text = plugin.id text2.text = plugin.id
val typeface = if (selected) Typeface.BOLD else Typeface.NORMAL val typeface = if (selected) Typeface.BOLD else Typeface.NORMAL
text1.setTypeface(null, typeface) text1.setTypeface(null, typeface)
text2.setTypeface(null, typeface) text2.setTypeface(null, typeface)
text2.isVisible = plugin.id.isNotEmpty() && plugin.label != plugin.id text2.isVisible = plugin.id.isNotEmpty() && label != plugin.id
icon.setImageDrawable(plugin.icon) icon.setImageDrawable(plugin.icon)
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Optional new metadata `com.github.shadowsocks.plugin.id.aliases` for plugin ID aliases; * Optional new metadata `com.github.shadowsocks.plugin.id.aliases` for plugin ID aliases;
(see doc for `PluginContract.METADATA_KEY_ID_ALIASES` and main documentation "Plugin ID Aliasing" for more information) (see doc for `PluginContract.METADATA_KEY_ID_ALIASES` and main documentation "Plugin ID Aliasing" for more information)
* Please use `android:path` instead of `android:pathPrefix`, sample code in documentations have been updated to reflect this recommendation. * Please use `android:path` instead of `android:pathPrefix`, sample code in documentations have been updated to reflect this recommendation.
* You can now use `android:resources` on `meta-data` tags. (main/host app update required) * You can now use `android:resources` on `meta-data` tags. (main/host app update required, however, you should never use dynamic resources)
* Fix occasional crash in `AlertDialogFragment`. * Fix occasional crash in `AlertDialogFragment`.
* Translation updates. * Translation updates.
* Dependency updates: * Dependency updates:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment