Skip to content

Commit

Permalink
Update plugin library
Browse files Browse the repository at this point in the history
Revert "Fix getOrDefault()" since this workaround has been merged into
the plugin library.

This reverts commit 6f400bf.
  • Loading branch information
Mygod committed Feb 8, 2017
1 parent 4c2e2d0 commit b801fa6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ shrinkResources := true
typedResources := false
resConfigs := Seq("zh-rCN")

libraryDependencies += "com.github.shadowsocks" %% "plugin" % "0.0.1"
libraryDependencies += "com.github.shadowsocks" %% "plugin" % "0.0.2"
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ class ConfigFragment extends PreferenceFragment {

override def onCreatePreferences(bundle: Bundle, key: String): Unit = addPreferencesFromResource(R.xml.config)

def getOrDefault(options: PluginOptions, key: String, defaultValue: String): String = {
options.get(key) match {
case v: String => v
case _ => defaultValue
}
}

def onInitializePluginOptions(options: PluginOptions): Unit = {
this.options = options
for ((key, defaultValue) <- Array(("obfs", "http"), ("obfs-host", "cloudfront.net"))) {
val pref = findPreference(key)
pref match {
case ddp: DropDownPreference => ddp.setValue(getOrDefault(options, key, defaultValue))
case etp: EditTextPreference => etp.setText(getOrDefault(options, key, defaultValue))
case ddp: DropDownPreference => ddp.setValue(options.getOrDefault(key, defaultValue))
case etp: EditTextPreference => etp.setText(options.getOrDefault(key, defaultValue))
}
pref.setOnPreferenceChangeListener((_, value) => {
options.put(key, value.toString)
Expand Down

0 comments on commit b801fa6

Please sign in to comment.