Commit da8e41d7 authored by Max Lv's avatar Max Lv

Handle exceptions when parsing per-app config string

parent 062dfb35
...@@ -160,16 +160,20 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC ...@@ -160,16 +160,20 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
if (!proxiedAppString.isEmpty) { if (!proxiedAppString.isEmpty) {
val editor = prefs.edit val editor = prefs.edit
val i = proxiedAppString.indexOf('\n') val i = proxiedAppString.indexOf('\n')
if (i < 0) try {
editor.putBoolean(Key.isBypassApps, proxiedAppString.toBoolean).putString(Key.proxied, "").apply() if (i < 0)
else editor.putBoolean(Key.isBypassApps, proxiedAppString.substring(0, i).toBoolean) editor.putBoolean(Key.isBypassApps, proxiedAppString.toBoolean).putString(Key.proxied, "").apply()
.putString(Key.proxied, proxiedAppString.substring(i + 1)).apply() else editor.putBoolean(Key.isBypassApps, proxiedAppString.substring(0, i).toBoolean)
Toast.makeText(this, R.string.action_import_msg, Toast.LENGTH_SHORT).show() .putString(Key.proxied, proxiedAppString.substring(i + 1)).apply()
// Restart activity Toast.makeText(this, R.string.action_import_msg, Toast.LENGTH_SHORT).show()
appListView.setVisibility(View.GONE) // Restart activity
loadingView.setVisibility(View.VISIBLE) appListView.setVisibility(View.GONE)
reloadApps() loadingView.setVisibility(View.VISIBLE)
return true reloadApps()
return true
} catch {
case _: java.lang.IllegalArgumentException => // ignore
}
} }
} }
} }
......
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