Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Android 平台下的智能代理
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 0 additions & 5 deletions Smart Proxy X/src/main/res/menu/main_activity_actions.xml

This file was deleted.

11 changes: 0 additions & 11 deletions Smart Proxy X/src/main/res/values-v11/styles.xml

This file was deleted.

File renamed without changes.
29 changes: 12 additions & 17 deletions Smart Proxy X/build.gradle → SmartProxyX/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
apply plugin: 'com.android.application'

repositories {
mavenCentral()

jcenter()
maven {
url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
}
}

android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 7
versionName "1.6"
targetSdkVersion 21
versionCode 8
versionName "1.7"
}

signingConfigs {
Expand All @@ -38,14 +29,18 @@ android {

buildTypes {
release {
runProguard false
minifyEnabled false // runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
}
android.applicationVariants.all { variant ->
variant.outputs[0].outputFile = file("$project.buildDir/${variant.name}.apk")
}

dependencies {
compile "com.android.support:appcompat-v7:21.0.2"
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
compile 'com.google.zxing:core:3.0.1'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.smartproxy.ui;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
Expand All @@ -11,6 +11,7 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.SwitchCompat;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
Expand All @@ -21,13 +22,15 @@
import android.widget.CompoundButton.OnCheckedChangeListener;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

import me.smartproxy.BuildConfig;
import me.smartproxy.R;
import me.smartproxy.core.LocalVpnService;

import java.io.File;
import java.util.Calendar;

public class MainActivity extends Activity implements
public class MainActivity extends ActionBarActivity implements
View.OnClickListener,
OnCheckedChangeListener,
LocalVpnService.onStatusChangedListener {
Expand All @@ -40,7 +43,7 @@ public class MainActivity extends Activity implements

private static final int START_VPN_SERVICE_REQUEST_CODE = 1985;

private Switch switchProxy;
private SwitchCompat switchProxy;
private TextView textViewLog;
private ScrollView scrollViewLog;
private TextView textViewConfigUrl;
Expand Down Expand Up @@ -79,22 +82,7 @@ void setConfigUrl(String configUrl) {
SharedPreferences preferences = getSharedPreferences("SmartProxy", MODE_PRIVATE);
Editor editor = preferences.edit();
editor.putString(CONFIG_URL_KEY, configUrl);
editor.commit();
}

String getVersionName() {
PackageManager packageManager = getPackageManager();
if (packageManager == null) {
Log.e(TAG, "null package manager is impossible");
return null;
}

try {
return packageManager.getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "package not found is impossible", e);
return null;
}
editor.apply();
}

boolean isValidUrl(String url) {
Expand Down Expand Up @@ -264,22 +252,23 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
switchProxy.setEnabled(true);
onLogReceived("canceled.");
}
return;
}

IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
String configUrl = scanResult.getContents();
if (isValidUrl(configUrl)) {
setConfigUrl(configUrl);
textViewConfigUrl.setText(configUrl);
} else {
Toast.makeText(MainActivity.this, R.string.err_invalid_url, Toast.LENGTH_SHORT).show();
}else if (requestCode == IntentIntegrator.REQUEST_CODE) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
String configUrl = scanResult.getContents();
if (isValidUrl(configUrl)) {
setConfigUrl(configUrl);
textViewConfigUrl.setText(configUrl);
} else {
Toast.makeText(MainActivity.this, R.string.err_invalid_url, Toast.LENGTH_SHORT).show();
}
}
return;
}else{
super.onActivityResult(requestCode, resultCode, intent);
}

super.onActivityResult(requestCode, resultCode, intent);


}

@Override
Expand All @@ -291,7 +280,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
return false;
}

switchProxy = (Switch) menuItem.getActionView();
switchProxy = (SwitchCompat) menuItem.getActionView();
if (switchProxy == null) {
return false;
}
Expand All @@ -307,7 +296,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_item_about:
new AlertDialog.Builder(this)
.setTitle(getString(R.string.app_name) + getVersionName())
.setTitle(getString(R.string.app_name) + BuildConfig.VERSION_NAME)
.setMessage(R.string.about_info)
.setPositiveButton(R.string.btn_ok, null)
.setNegativeButton(R.string.btn_more, new OnClickListener() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions SmartProxyX/src/main/res/menu/main_activity_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_item_switch"
app:actionViewClass="android.support.v7.widget.SwitchCompat"
app:showAsAction="always"
android:title="@string/menu_item_switch"/>
<item
android:id="@+id/menu_item_about"
android:title="@string/menu_item_about"/>
<item
android:id="@+id/menu_item_exit"
android:title="@string/menu_item_exit"/>
</menu>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<!-- API 14 theme customizations can go here. -->
</style>

Expand Down
6 changes: 6 additions & 0 deletions SmartProxyX/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<!-- API 21 theme customizations can go here. -->
</style>
</resources>
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<resources>
<color name="colorPrimary">#3f51e5</color>
<color name="colorPrimaryDark">#334ac5</color>
<color name="colorAccent">#009688</color>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Black">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
Expand All @@ -15,6 +18,9 @@
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.android.tools.build:gradle:0.14.4'
}
}

allprojects {
repositories {
mavenCentral()
jcenter()
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Sun Nov 23 11:09:55 GMT+08:00 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':Smart Proxy X'
include ':SmartProxyX'