add crouton
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
<receiver android:name=".ShadowsocksReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="android.intent.action.ACTION_SHUTDOWN"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.shadowsocks</groupId>
|
||||
<artifactId>shadowsocks</artifactId>
|
||||
@@ -21,54 +21,70 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>support-v4</artifactId>
|
||||
<version>r7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>crouton</artifactId>
|
||||
<version>1.7</version>
|
||||
<groupId>de.keyboardsurfer.android.widget</groupId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>support-v4</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.actionbarsherlock</groupId>
|
||||
<artifactId>actionbarsherlock</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<version>4.3.0</version>
|
||||
<type>apklib</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.android.analytics</groupId>
|
||||
<artifactId>analytics</artifactId>
|
||||
<version>2.0beta4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.saik0.android.unifiedpreference</groupId>
|
||||
<artifactId>unifiedpreference</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<type>apklib</type>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.actionbarsherlock</groupId>
|
||||
<artifactId>actionbarsherlock</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jraf</groupId>
|
||||
<artifactId>android-switch-backport</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>apklib</type>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.actionbarsherlock</groupId>
|
||||
<artifactId>actionbarsherlock</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
@@ -122,8 +138,10 @@
|
||||
<keypass>${sign.keypass}</keypass>
|
||||
<verbose>true</verbose>
|
||||
<arguments>
|
||||
<argument>-sigalg</argument><argument>MD5withRSA</argument>
|
||||
<argument>-digestalg</argument><argument>SHA1</argument>
|
||||
<argument>-sigalg</argument>
|
||||
<argument>MD5withRSA</argument>
|
||||
<argument>-digestalg</argument>
|
||||
<argument>SHA1</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:textSize="24sp"
|
||||
android:textSize="28sp"
|
||||
android:text="@string/app_name"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
@@ -22,4 +22,4 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -58,13 +58,14 @@ 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;
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
import net.saik0.android.unifiedpreference.UnifiedPreferenceFragment;
|
||||
import net.saik0.android.unifiedpreference.UnifiedSherlockPreferenceActivity;
|
||||
import org.jraf.android.backport.switchwidget.Switch;
|
||||
import de.keyboardsurfer.android.widget.crouton.Crouton;
|
||||
import de.keyboardsurfer.android.widget.crouton.Style;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -92,8 +93,7 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity
|
||||
Editor ed = settings.edit();
|
||||
switch (msg.what) {
|
||||
case MSG_CRASH_RECOVER:
|
||||
Toast.makeText(Shadowsocks.this, R.string.crash_alert,
|
||||
Toast.LENGTH_LONG).show();
|
||||
Crouton.makeText(Shadowsocks.this, R.string.crash_alert, Style.ALERT).show();
|
||||
ed.putBoolean("isRunning", false);
|
||||
break;
|
||||
case MSG_INITIAL_FINISH:
|
||||
@@ -153,9 +153,17 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity
|
||||
|
||||
private void crash_recovery() {
|
||||
|
||||
Utils.runRootCommand(Utils.getIptables() + " -t nat -F OUTPUT");
|
||||
|
||||
Utils.runCommand(ShadowsocksService.BASE + "proxy.sh stop");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(Utils.getIptables()).append(" -t nat -F OUTPUT").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/pdnsd.pid`").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/shadowsocks.pid`").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/polipo.pid`").append("\n");
|
||||
sb.append("killall -9 pdnsd").append("\n");
|
||||
sb.append("killall -9 redsocks").append("\n");
|
||||
sb.append("killall -9 shadowsocks").append("\n");
|
||||
sb.append("killall -9 polipo").append("\n");
|
||||
Utils.runRootCommand(sb.toString());
|
||||
|
||||
}
|
||||
|
||||
@@ -229,7 +237,7 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { // 按下的如果是BACK,同时没有重复
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
||||
try {
|
||||
finish();
|
||||
} catch (Exception ignore) {
|
||||
@@ -423,17 +431,8 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(Utils.getIptables()).append(" -t nat -F OUTPUT").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/pdnsd.pid`").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/shadowsocks.pid`").append("\n");
|
||||
sb.append("kill -9 `cat /data/data/com.github.shadowsocks/polipo.pid`").append("\n");
|
||||
sb.append("killall -9 pdnsd").append("\n");
|
||||
sb.append("killall -9 redsocks").append("\n");
|
||||
sb.append("killall -9 shadowsocks").append("\n");
|
||||
sb.append("killall -9 polipo").append("\n");
|
||||
Utils.runRootCommand(sb.toString());
|
||||
|
||||
crash_recovery();
|
||||
|
||||
copyAssets("");
|
||||
copyAssets(Utils.getABI());
|
||||
@@ -462,11 +461,7 @@ public class Shadowsocks extends UnifiedSherlockPreferenceActivity
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
stopService(new Intent(this, ShadowsocksService.class));
|
||||
} catch (Exception e) {
|
||||
// Nothing
|
||||
}
|
||||
stopService(new Intent(this, ShadowsocksService.class));
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
|
||||
@@ -52,6 +52,14 @@ public class ShadowsocksReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (intent != null) {
|
||||
final String action = intent.getAction();
|
||||
if (action.equals(Intent.ACTION_SHUTDOWN)) {
|
||||
context.stopService(new Intent(context, ShadowsocksService.class));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String versionName;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user