Commit 6c924f2d authored by Max Lv's avatar Max Lv

remove unified preference

parent 1463cb6c
package com.github.shadowsocks.aidl;
parcelable Config;
\ No newline at end of file
package com.github.shadowsocks.aidl;
import android.os.Parcel;
import android.os.Parcelable;
public class Config implements Parcelable {
public boolean isGlobalProxy = true;
public boolean isGFWList = true;
public boolean isBypassApps = false;
public boolean isTrafficStat = false;
public boolean isUdpDns = false;
public String profileName = "Untitled";
public String proxy = "127.0.0.1";
public String sitekey = "null";
public String encMethod = "rc4";
public String proxiedAppString = "";
public int remotePort = 1984;
public int localPort = 1080;
public static final Parcelable.Creator<Config> CREATOR = new Parcelable.Creator<Config>() {
public Config createFromParcel(Parcel in) {
return new Config(in);
}
public Config[] newArray(int size) {
return new Config[size];
}
};
public Config(boolean isGlobalProxy, boolean isGFWList, boolean isBypassApps,
boolean isTrafficStat, boolean isUdpDns, String profileName, String proxy, String sitekey,
String encMethod, String proxiedAppString, int remotePort, int localPort) {
this.isGlobalProxy = isGlobalProxy;
this.isGFWList = isGFWList;
this.isBypassApps = isBypassApps;
this.isTrafficStat = isTrafficStat;
this.isUdpDns = isUdpDns;
this.profileName = profileName;
this.proxy = proxy;
this.sitekey = sitekey;
this.encMethod = encMethod;
this.proxiedAppString = proxiedAppString;
this.remotePort = remotePort;
this.localPort = localPort;
}
private Config(Parcel in) {
readFromParcel(in);
}
public void readFromParcel(Parcel in) {
isGlobalProxy = in.readInt() == 1;
isGFWList = in.readInt() == 1;
isBypassApps = in.readInt() == 1;
isTrafficStat = in.readInt() == 1;
isUdpDns = in.readInt() == 1;
profileName = in.readString();
proxy = in.readString();
sitekey = in.readString();
encMethod = in.readString();
proxiedAppString = in.readString();
remotePort = in.readInt();
localPort = in.readInt();
}
@Override public int describeContents() {
return 0;
}
@Override public void writeToParcel(Parcel out, int flags) {
out.writeInt(isGlobalProxy ? 1 : 0);
out.writeInt(isGFWList ? 1 : 0);
out.writeInt(isBypassApps ? 1 : 0);
out.writeInt(isTrafficStat ? 1 : 0);
out.writeInt(isUdpDns ? 1 : 0);
out.writeString(profileName);
out.writeString(proxy);
out.writeString(sitekey);
out.writeString(encMethod);
out.writeString(proxiedAppString);
out.writeInt(remotePort);
out.writeInt(localPort);
}
}
package com.github.shadowsocks.aidl;
import com.github.shadowsocks.aidl.Config;
import com.github.shadowsocks.aidl.IShadowsocksServiceCallback;
interface IShadowsocksService {
int getMode();
int getState();
oneway void registerCallback(IShadowsocksServiceCallback cb);
oneway void unregisterCallback(IShadowsocksServiceCallback cb);
oneway void start(in Config config);
oneway void stop();
}
package com.github.shadowsocks.aidl;
interface IShadowsocksServiceCallback {
oneway void stateChanged(int state, String msg);
}
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
android:defaultValue="true" android:defaultValue="true"
android:summary="@string/traffic_stat_summary" android:summary="@string/traffic_stat_summary"
android:title="@string/traffic_stat"> android:title="@string/traffic_stat">
</CheckBoxPreference> </CheckBoxPreference>
<CheckBoxPreference <CheckBoxPreference
android:key="isUdpDns" android:key="isUdpDns"
android:defaultValue="false" android:defaultValue="false"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<preference-headers <preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:unified="http://schemas.android.com/apk/res-auto">
<header <header
unified:fragment="com.github.shadowsocks.Shadowsocks$ProxyFragment" android:fragment="com.github.shadowsocks.Shadowsocks$ProxyFragment"
unified:title="@string/proxy_cat" android:title="@string/proxy_cat" />
unified:preferenceRes="@xml/pref_proxy"/>
<header <header
unified:fragment="com.github.shadowsocks.Shadowsocks$FeatureFragment" android:fragment="com.github.shadowsocks.Shadowsocks$FeatureFragment"
unified:title="@string/feature_cat" android:title="@string/feature_cat" />
unified:preferenceRes="@xml/pref_feature"/>
</preference-headers>
</preference-headers>
\ No newline at end of file
...@@ -50,8 +50,8 @@ import android.widget._ ...@@ -50,8 +50,8 @@ import android.widget._
import com.google.analytics.tracking.android.{MapBuilder, EasyTracker} import com.google.analytics.tracking.android.{MapBuilder, EasyTracker}
import de.keyboardsurfer.android.widget.crouton.{Crouton, Style, Configuration} import de.keyboardsurfer.android.widget.crouton.{Crouton, Style, Configuration}
import java.util.Hashtable import java.util.Hashtable
import net.saik0.android.unifiedpreference.UnifiedPreferenceFragment import android.preference.PreferenceFragment
import net.saik0.android.unifiedpreference.UnifiedSherlockPreferenceActivity import com.actionbarsherlock.app.SherlockPreferenceActivity
import org.jraf.android.backport.switchwidget.Switch import org.jraf.android.backport.switchwidget.Switch
import android.content.pm.{PackageInfo, PackageManager} import android.content.pm.{PackageInfo, PackageManager}
import android.net.{Uri, VpnService} import android.net.{Uri, VpnService}
...@@ -175,7 +175,7 @@ object Shadowsocks { ...@@ -175,7 +175,7 @@ object Shadowsocks {
} }
} }
class ProxyFragment extends UnifiedPreferenceFragment { class ProxyFragment extends PreferenceFragment {
var receiver: BroadcastReceiver = null var receiver: BroadcastReceiver = null
...@@ -200,6 +200,7 @@ object Shadowsocks { ...@@ -200,6 +200,7 @@ object Shadowsocks {
override def onCreate(bundle: Bundle) { override def onCreate(bundle: Bundle) {
super.onCreate(bundle) super.onCreate(bundle)
addPreferencesFromResource(R.xml.pref_proxy)
val filter = new IntentFilter() val filter = new IntentFilter()
filter.addAction(Action.UPDATE_FRAGMENT) filter.addAction(Action.UPDATE_FRAGMENT)
receiver = new BroadcastReceiver { receiver = new BroadcastReceiver {
...@@ -226,7 +227,7 @@ object Shadowsocks { ...@@ -226,7 +227,7 @@ object Shadowsocks {
} }
} }
class FeatureFragment extends UnifiedPreferenceFragment { class FeatureFragment extends PreferenceFragment {
var receiver: BroadcastReceiver = null var receiver: BroadcastReceiver = null
...@@ -258,6 +259,7 @@ object Shadowsocks { ...@@ -258,6 +259,7 @@ object Shadowsocks {
override def onCreate(bundle: Bundle) { override def onCreate(bundle: Bundle) {
super.onCreate(bundle) super.onCreate(bundle)
addPreferencesFromResource(R.xml.pref_feature)
val filter = new IntentFilter() val filter = new IntentFilter()
filter.addAction(Action.UPDATE_FRAGMENT) filter.addAction(Action.UPDATE_FRAGMENT)
receiver = new BroadcastReceiver { receiver = new BroadcastReceiver {
...@@ -287,7 +289,7 @@ object Shadowsocks { ...@@ -287,7 +289,7 @@ object Shadowsocks {
} }
class Shadowsocks class Shadowsocks
extends UnifiedSherlockPreferenceActivity extends SherlockPreferenceActivity
with CompoundButton.OnCheckedChangeListener with CompoundButton.OnCheckedChangeListener
with MenuAdapter.MenuListener { with MenuAdapter.MenuListener {
...@@ -547,12 +549,23 @@ class Shadowsocks ...@@ -547,12 +549,23 @@ class Shadowsocks
onContentChanged() onContentChanged()
} }
override def onBuildHeaders(target: java.util.List[PreferenceActivity.Header]) {
loadHeadersFromResource(R.xml.shadowsocks_headers, target);
}
def isSinglePane: Boolean = {
Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
}
override def onCreate(savedInstanceState: Bundle) { override def onCreate(savedInstanceState: Bundle) {
// Initialize the preference
setHeaderRes(R.xml.shadowsocks_headers)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
if (isSinglePane) {
// Load the legacy preferences headers
addPreferencesFromResource(R.xml.pref_all);
}
// Initialize the profile // Initialize the profile
currentProfile = { currentProfile = {
profileManager.getProfile(settings.getInt(Key.profileId, -1)) getOrElse currentProfile profileManager.getProfile(settings.getInt(Key.profileId, -1)) getOrElse currentProfile
......
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