Skip to content

Commit 004fe12

Browse files
committed
Xndroid 1.0.5
0 parents  commit 004fe12

File tree

297 files changed

+129536
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+129536
-0
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Xndroid
2+
XX-Net的Android深度适配版本.
3+
4+
## 特性
5+
* 集成XX-Net 3.6.7(版本号会自动更新)
6+
* 集成LightningBrowser 4.5.1, 默认使用 localhost:8087 代理, 关闭证书警告, 无需任何配置即可直接使用
7+
* 将XX-Net目录放到应用数据目录(/data/data/net.xx.xndroid), 避免误删, 卸载自动删除
8+
* 使用前台服务, 避免意外退出(部分机型可能仍然强制结束进程,需要根据各机型的特点设置.如MIUI在最近应用列表中锁定)
9+
* 监听电量, 网络, 休眠状态, 自动调整最大扫描线程数
10+
* 将语言地区信息添加到环境变量, 避免XX-Net启动时显示为英文
11+
* 调用证书管理器安装证书, 确认即可一键安装(如果已经设置过图案解锁,却要求输入凭证,先清除屏幕锁即可)
12+
13+
## 感谢以下项目
14+
* [XX-Net](https://github.com/XX-net/XX-Net)
15+
* [LightningBrowser](https://github.com/anthonycr/Lightning-Browser)

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
buildToolsVersion '26.0.2'
6+
defaultConfig {
7+
applicationId "net.xx.xndroid"
8+
minSdkVersion 14
9+
targetSdkVersion 26
10+
versionCode 9
11+
versionName "1.0.5"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(include: ['*.jar'], dir: 'libs')
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:26.+'
28+
compile 'com.android.support:design:26.+'
29+
compile 'com.android.support:support-v4:26.+'
30+
androidTestCompile 'junit:junit:4.12'
31+
compile project(':lightning')
32+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in D:\ProgramData\Android\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package net.xx.xndroid;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("net.xx.xndroid", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="net.xx.xndroid">
5+
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
9+
10+
<application
11+
android:allowBackup="true"
12+
android:icon="@mipmap/ic_launcher"
13+
android:label="Xndroid"
14+
android:supportsRtl="true"
15+
tools:replace="android:label"
16+
android:theme="@style/AppTheme">
17+
<activity
18+
android:name=".MainActivity"
19+
android:label="@string/app_name"
20+
android:launchMode="singleTop"
21+
android:theme="@style/AppTheme.NoActionBar">
22+
<intent-filter>
23+
<action android:name="android.intent.action.MAIN" />
24+
25+
<category android:name="android.intent.category.LAUNCHER" />
26+
</intent-filter>
27+
</activity>
28+
29+
<service
30+
android:name=".XXnetService"
31+
android:enabled="true"
32+
android:exported="true"></service>
33+
</application>
34+
35+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package net.xx.xndroid;
2+
3+
import android.app.Fragment;
4+
import android.os.Bundle;
5+
import android.support.annotation.Nullable;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
import net.xx.xndroid.xxnet.XXnetAttribute;
12+
13+
public class AboutFragment extends Fragment {
14+
15+
private View mRootView;
16+
private TextView mVersionView;
17+
private TextView mXXnetVersion;
18+
private View mUpdateView;
19+
20+
@Override
21+
public void onResume() {
22+
super.onResume();
23+
mXXnetVersion.setText("XX-net " + XXnetAttribute.sXXversion);
24+
}
25+
26+
@Override
27+
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
28+
if(mRootView !=null )
29+
return mRootView;
30+
mRootView = inflater.inflate(R.layout.fragment_about, container, false);
31+
mVersionView = mRootView.findViewById(R.id.xndroid_version);
32+
mVersionView.setText("Xndroid " + AppModel.sVersionName);
33+
mXXnetVersion = mRootView.findViewById(R.id.xndroid_xxnet_version);
34+
mUpdateView = mRootView.findViewById(R.id.xndroid_check_update);
35+
mUpdateView.setOnClickListener(new View.OnClickListener() {
36+
@Override
37+
public void onClick(View v) {
38+
new Thread(new Runnable() {
39+
@Override
40+
public void run() {
41+
AppModel.showToast(getString(R.string.getting_version));
42+
UpdateManager.checkUpdate(true);
43+
}
44+
}).start();
45+
}
46+
});
47+
return mRootView;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package net.xx.xndroid;
2+
3+
4+
import android.content.Context;
5+
import android.content.Intent;
6+
import android.content.SharedPreferences;
7+
import android.content.pm.PackageManager;
8+
import android.net.ConnectivityManager;
9+
import android.net.NetworkInfo;
10+
import android.os.Build;
11+
import android.preference.PreferenceManager;
12+
import android.widget.Toast;
13+
14+
import net.xx.xndroid.util.LogUtil;
15+
16+
public class AppModel {
17+
public static String sAppPath;
18+
public static MainActivity sActivity;
19+
public static String sFilePath;
20+
public static String sXndroidFile;
21+
public static Runnable sUpdateInfoUI;
22+
public static String sLang;
23+
public static String sPackageName;
24+
public static int sVersionCode;
25+
public static String sVersionName;
26+
27+
public static SharedPreferences sPreferences;
28+
public static boolean sAutoThread = true;
29+
public static final String PER_AUTO_THREAD = "XNDROID_AUTO_THREAD";
30+
public static final String PER_VERSION = "XNDROID_VERSION";
31+
32+
33+
public static void showToast(final String mesg) {
34+
sActivity.runOnUiThread(new Runnable() {
35+
@Override
36+
public void run() {
37+
Toast.makeText(sActivity, mesg, Toast.LENGTH_LONG).show();
38+
}
39+
});
40+
}
41+
42+
43+
public static boolean sAppStoped = false;
44+
public static void appStop(){
45+
if(sAppStoped)
46+
return;
47+
sAppStoped = true;
48+
sActivity.runOnUiThread(new Runnable() {
49+
@Override
50+
public void run() {
51+
sActivity.postStop();
52+
}
53+
});
54+
new Thread(new Runnable() {
55+
@Override
56+
public void run() {
57+
XXnetService service = XXnetService.getDefaultService();
58+
if(service != null)
59+
service.postStop();
60+
android.os.Process.killProcess(android.os.Process.myPid());
61+
62+
}
63+
}).start();
64+
65+
}
66+
67+
68+
public static boolean sDevBatteryLow = false;
69+
public static boolean sDevMobileWork = false;
70+
public static boolean sDevScreenOff = false;
71+
public static boolean sIsForeground = true;
72+
73+
public static void checkNetwork(){
74+
sDevMobileWork = false;
75+
ConnectivityManager connectivityManager = (ConnectivityManager)AppModel
76+
.sActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
77+
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
78+
if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
79+
if (activeNetworkInfo.getType() == (ConnectivityManager.TYPE_MOBILE)) {
80+
sDevMobileWork = true;
81+
}
82+
}
83+
LogUtil.defaultLogWrite("info", "network change, use_mobile_network=" + AppModel.sDevMobileWork);
84+
}
85+
86+
87+
public static void appInit(final MainActivity activity){
88+
if(sAppStoped)
89+
return;
90+
sAppStoped = false;
91+
sActivity = activity;
92+
sFilePath = activity.getFilesDir().getAbsolutePath();
93+
sAppPath = activity.getFilesDir().getParent();
94+
sXndroidFile = sFilePath + "/xndroid_files";
95+
sPackageName = activity.getPackageName();
96+
try {
97+
sVersionCode = activity.getPackageManager().
98+
getPackageInfo(sPackageName, PackageManager.GET_CONFIGURATIONS).versionCode;
99+
sVersionName = activity.getPackageManager().
100+
getPackageInfo(sPackageName, PackageManager.GET_CONFIGURATIONS).versionName;
101+
} catch (PackageManager.NameNotFoundException e) {
102+
e.printStackTrace();
103+
}
104+
sPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
105+
sAutoThread = sPreferences.getBoolean(PER_AUTO_THREAD, true);
106+
sPreferences.edit().putInt(PER_VERSION, sVersionCode).apply();
107+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
108+
sLang = sActivity.getResources().getConfiguration().getLocales().toString();
109+
}else {
110+
sLang = sActivity.getResources().getConfiguration().locale.toString();
111+
}
112+
Intent intent = new Intent(activity,XXnetService.class);
113+
activity.startService(intent);
114+
}
115+
}

0 commit comments

Comments
 (0)