Commit a2841483 authored by Max Lv's avatar Max Lv

refine UI

parent d5a3e6da
......@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.github.shadowsocks"
android:installLocation="auto"
android:versionCode="20"
android:versionName="1.3.8">
android:versionCode="21"
android:versionName="1.3.9">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.shadowsocks</groupId>
<artifactId>shadowsocks</artifactId>
<version>1.3.8</version>
<version>1.3.9</version>
<packaging>apk</packaging>
<name>Shadowsocks</name>
......@@ -38,7 +38,7 @@
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.3.0</version>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
......
......@@ -4,6 +4,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="24dp"
android:textSize="24sp"
android:text="@string/app_name"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"/>
<org.jraf.android.backport.switchwidget.Switch
android:id="@+id/switchButton"
android:layout_width="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Shadowsocks</string>
<string name="app_name">shadowsocks</string>
<!-- function category -->
<string name="function_cat">Service Controller</string>
......
......@@ -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<String, Typeface> cache = new Hashtable<String, Typeface>();
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);
}
}
}
}
......@@ -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<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface intf : interfaces) {
List<InetAddress> 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) {
......
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