Misc improvements for plugin design
This commit is contained in:
@@ -18,11 +18,8 @@
|
||||
android:targetSdkVersion="25"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:name=".ShadowsocksApplication"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:backupAgent=".ShadowsocksBackupAgent"
|
||||
android:label="@string/app_name"
|
||||
android:banner="@drawable/ic_start_connected">
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
<string name="connection_test_error_status_code">Error code: #%d</string>
|
||||
|
||||
<!-- proxy category -->
|
||||
<string name="proxy_cat">Server Settings</string>
|
||||
<string name="profile_name">Profile Name</string>
|
||||
<string name="proxy">Server</string>
|
||||
<string name="remote_port">Remote Port</string>
|
||||
@@ -35,7 +34,6 @@
|
||||
<string name="enc_method">Encrypt Method</string>
|
||||
|
||||
<!-- feature category -->
|
||||
<string name="feature_cat">Feature Settings</string>
|
||||
<string name="ipv6">IPv6 Route</string>
|
||||
<string name="ipv6_summary">Redirect IPv6 traffic to remote</string>
|
||||
<string name="onetime_auth">One-time Authentication</string>
|
||||
@@ -75,8 +73,6 @@
|
||||
<string name="profile_invalid_input">No valid profile data found.</string>
|
||||
|
||||
<!-- alert category -->
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
<string name="close">Close</string>
|
||||
<string name="profile_empty">Please select a profile</string>
|
||||
<string name="proxy_empty">Proxy/Password should not be empty</string>
|
||||
@@ -105,8 +101,6 @@
|
||||
|
||||
<!-- profile -->
|
||||
<string name="profile_config">Profile config</string>
|
||||
<string name="unsaved_changes_prompt">Changes not saved. Do you want to save?</string>
|
||||
<string name="apply">Apply</string>
|
||||
<string name="delete">Remove</string>
|
||||
<string name="delete_confirm_prompt">Are you sure you want to remove this profile?</string>
|
||||
<string name="share_qr_nfc">QR code/NFC</string>
|
||||
|
||||
@@ -38,7 +38,9 @@ object PluginManager {
|
||||
case null =>
|
||||
case path => return path
|
||||
} catch {
|
||||
case t: Throwable => if (throwable == null) throwable = t
|
||||
case t: Throwable =>
|
||||
t.printStackTrace()
|
||||
if (throwable == null) throwable = t
|
||||
}
|
||||
|
||||
// add other plugin types here
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.github.shadowsocks.plugin;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ public final class PluginOptions extends HashMap<String, String> {
|
||||
super(initialCapacity, loadFactor);
|
||||
}
|
||||
|
||||
private PluginOptions(String options, boolean parseId) throws IllegalArgumentException {
|
||||
private PluginOptions(String options, boolean parseId) {
|
||||
if (TextUtils.isEmpty(options)) return;
|
||||
final StringTokenizer tokenizer = new StringTokenizer(options, "\\=;", true);
|
||||
final StringBuilder current = new StringBuilder();
|
||||
@@ -31,8 +32,7 @@ public final class PluginOptions extends HashMap<String, String> {
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
String nextToken = tokenizer.nextToken();
|
||||
if ("\\".equals(nextToken)) current.append(tokenizer.nextToken());
|
||||
else if ("=".equals(nextToken)) {
|
||||
if (key != null) throw new IllegalArgumentException("Duplicate keys in " + options);
|
||||
else if ("=".equals(nextToken) && key == null) {
|
||||
key = current.toString();
|
||||
current.setLength(0);
|
||||
} else if (";".equals(nextToken))
|
||||
@@ -46,12 +46,13 @@ public final class PluginOptions extends HashMap<String, String> {
|
||||
put(current.toString(), null);
|
||||
current.setLength(0);
|
||||
}
|
||||
else current.append(nextToken);
|
||||
}
|
||||
}
|
||||
public PluginOptions(String options) throws IllegalArgumentException {
|
||||
public PluginOptions(String options) {
|
||||
this(options, true);
|
||||
}
|
||||
public PluginOptions(String id, String options) throws IllegalArgumentException {
|
||||
public PluginOptions(String id, String options) {
|
||||
this(options, false);
|
||||
this.id = id;
|
||||
}
|
||||
@@ -85,4 +86,18 @@ public final class PluginOptions extends HashMap<String, String> {
|
||||
public String toString() {
|
||||
return toString(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
PluginOptions that = (PluginOptions) o;
|
||||
return Objects.equals(id, that.id) && super.equals(that);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="proxy_cat">Server Settings</string>
|
||||
<string name="feature_cat">Feature Settings</string>
|
||||
<string name="unsaved_changes_prompt">Changes not saved. Do you want to save?</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
<string name="apply">Apply</string>
|
||||
</resources>
|
||||
@@ -14,8 +14,8 @@ import android.os.ParcelFileDescriptor
|
||||
* ...
|
||||
* <application>
|
||||
* ...
|
||||
* <provider android:name="com.github.shadowsocks.$PLUGIN_ID.PluginProvider"
|
||||
* android:authorities="com.github.shadowsocks.$PLUGIN_ID">
|
||||
* <provider android:name="com.github.shadowsocks.$PLUGIN_ID.BinaryProvider"
|
||||
* android:authorities="com.github.shadowsocks.plugin.$PLUGIN_ID">
|
||||
* <intent-filter>
|
||||
* <category android:name="com.github.shadowsocks.plugin.CATEGORY_NATIVE_PLUGIN" />
|
||||
* </intent-filter>
|
||||
|
||||
Reference in New Issue
Block a user