diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 388b0a33..4c1302b1 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="21" + android:versionName="1.3.9"> diff --git a/assets/fonts/Iceland.ttf b/assets/fonts/Iceland.ttf new file mode 100644 index 00000000..df1938c2 Binary files /dev/null and b/assets/fonts/Iceland.ttf differ diff --git a/pom.xml b/pom.xml index 0818c3ab..19a74594 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.shadowsocks shadowsocks - 1.3.8 + 1.3.9 apk Shadowsocks @@ -38,7 +38,7 @@ com.actionbarsherlock actionbarsherlock - 4.3.0 + 4.2.0 apklib diff --git a/res/layout/layout_switch.xml b/res/layout/layout_switch.xml index 973d96cb..01b97abe 100644 --- a/res/layout/layout_switch.xml +++ b/res/layout/layout_switch.xml @@ -4,6 +4,17 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + - Shadowsocks + shadowsocks Service Controller diff --git a/src/com/github/shadowsocks/Shadowsocks.java b/src/com/github/shadowsocks/Shadowsocks.java index 39f2ea0c..5189711c 100755 --- a/src/com/github/shadowsocks/Shadowsocks.java +++ b/src/com/github/shadowsocks/Shadowsocks.java @@ -40,6 +40,7 @@ package com.github.shadowsocks; import android.app.AlertDialog; import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -47,6 +48,7 @@ import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetManager; +import android.graphics.Typeface; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -55,6 +57,7 @@ import android.util.Log; import android.view.KeyEvent; import android.widget.CompoundButton; import android.widget.RelativeLayout; +import android.widget.TextView; import android.widget.Toast; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; @@ -67,6 +70,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Hashtable; public class Shadowsocks extends UnifiedSherlockPreferenceActivity implements CompoundButton.OnCheckedChangeListener, OnSharedPreferenceChangeListener { @@ -186,9 +190,16 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity getSupportActionBar().setCustomView(switchLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); + getSupportActionBar().setDisplayShowHomeEnabled(false); + switchButton = (Switch) switchLayout.findViewById(R.id.switchButton); + TextView title = (TextView) switchLayout.findViewById(R.id.title); + Typeface tf = Typefaces.get(this, "fonts/Iceland.ttf"); + if (tf != null) title.setTypeface(tf); + title.setText(R.string.app_name); + } @Override @@ -616,4 +627,27 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity } } + public static class Typefaces { + private static final String TAG = "Typefaces"; + + private static final Hashtable cache = new Hashtable(); + + public static Typeface get(Context c, String assetPath) { + synchronized (cache) { + if (!cache.containsKey(assetPath)) { + try { + Typeface t = Typeface.createFromAsset(c.getAssets(), + assetPath); + cache.put(assetPath, t); + } catch (Exception e) { + Log.e(TAG, "Could not get typeface '" + assetPath + + "' because " + e.getMessage()); + return null; + } + } + return cache.get(assetPath); + } + } + } + } diff --git a/src/com/github/shadowsocks/Utils.java b/src/com/github/shadowsocks/Utils.java index 2ab89644..6d22d96f 100755 --- a/src/com/github/shadowsocks/Utils.java +++ b/src/com/github/shadowsocks/Utils.java @@ -45,9 +45,14 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.drawable.Drawable; import android.os.Environment; import android.util.Log; +import org.apache.http.conn.util.InetAddressUtils; import java.io.*; +import java.net.InetAddress; +import java.net.NetworkInterface; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class Utils { @@ -71,6 +76,30 @@ public class Utils { private static String iptables = null; private static String data_path = null; + /** + * Get IP address from first non-localhost interface + */ + public static boolean isIPv6Support() { + try { + List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); + for (NetworkInterface intf : interfaces) { + List addrs = Collections.list(intf.getInetAddresses()); + for (InetAddress addr : addrs) { + if (!addr.isLoopbackAddress()) { + String sAddr = addr.getHostAddress().toUpperCase(); + boolean isIPv6 = InetAddressUtils.isIPv6Address(sAddr); + if (isIPv6) { + return true; + } + } + } + } + } catch (Exception ex) { + // Ignore + } // for now eat exceptions + return false; + } + public static String getABI() { String abi = getSystemProperty(ABI_PROP); if (abi != null) {