-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b78028
commit ff833e4
Showing
357 changed files
with
102,305 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/build | ||
/release | ||
# no tests written yet | ||
/src/androidTest | ||
/src/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
// ./gradlew app:build | ||
//app/build/outputs/aar/app-release.aar | ||
|
||
def javaVersion = JavaVersion.VERSION_1_8 | ||
|
||
android { | ||
compileSdkVersion 29 | ||
compileOptions { | ||
sourceCompatibility javaVersion | ||
targetCompatibility javaVersion | ||
} | ||
kotlinOptions.jvmTarget = javaVersion | ||
defaultConfig { | ||
minSdkVersion rootProject.minSdkVersion | ||
targetSdkVersion 29 | ||
//versionCode 1030100 | ||
//versionName "1.3.1" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled true | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
//consumerProguardFiles 'proguard-rules.pro' //added this line | ||
} | ||
} | ||
|
||
externalNativeBuild { | ||
ndkBuild { | ||
path 'src/main/jni/Android.mk' | ||
} | ||
} | ||
packagingOptions.exclude '**/*.kotlin_*' | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.preference:preference:1.1.1' | ||
implementation 'com.github.shadowsocks:plugin:1.3.4' | ||
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" | ||
androidTestImplementation 'androidx.test:runner:1.2.0' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
-keepattributes SourceFile,LineNumberTable | ||
-dontobfuscate | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.github.shadowsocks.plugin.obfs_local"> | ||
<uses-feature android:name="android.hardware.touchscreen" | ||
android:required="false"/> | ||
<application android:icon="@mipmap/ic_launcher"> | ||
<provider android:name=".SSVpnBinaryProvider" | ||
android:exported="true" | ||
android:authorities="com.github.shadowsocks.plugin.obfs_local.SSVpnBinaryProvider"> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/> | ||
<data android:scheme="plugin" | ||
android:host="com.github.shadowsocks" | ||
android:pathPrefix="/obfs-local"/> | ||
</intent-filter> | ||
<meta-data android:name="com.github.shadowsocks.plugin.id" | ||
android:value="obfs-local"/> | ||
<meta-data android:name="com.github.shadowsocks.plugin.default_config" | ||
android:value="obfs=http"/> | ||
<meta-data android:name="com.github.shadowsocks.plugin.executable_path" | ||
android:value="libobfs-local.so"/> | ||
</provider> | ||
<activity android:name=".ConfigActivity"> | ||
<intent-filter> | ||
<action android:name="com.github.shadowsocks.plugin.ACTION_CONFIGURE"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<data android:scheme="plugin" | ||
android:host="com.github.shadowsocks" | ||
android:path="/obfs-local"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
20 changes: 20 additions & 0 deletions
20
obfs/src/main/java/com/github/shadowsocks/plugin/obfs_local/BinaryProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.shadowsocks.plugin.obfs_local | ||
|
||
import android.net.Uri | ||
import android.os.ParcelFileDescriptor | ||
import com.github.shadowsocks.plugin.NativePluginProvider | ||
import com.github.shadowsocks.plugin.PathProvider | ||
import java.io.File | ||
import java.io.FileNotFoundException | ||
|
||
class SSVpnBinaryProvider : NativePluginProvider() { | ||
override fun populateFiles(provider: PathProvider) { | ||
provider.addPath("obfs-local", 755) | ||
} | ||
|
||
override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libobfs-local.so" | ||
override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) { | ||
"/obfs-local" -> ParcelFileDescriptor.open(File(getExecutable()), ParcelFileDescriptor.MODE_READ_ONLY) | ||
else -> throw FileNotFoundException() | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
obfs/src/main/java/com/github/shadowsocks/plugin/obfs_local/ConfigActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.github.shadowsocks.plugin.obfs_local | ||
|
||
import android.os.Bundle | ||
import android.view.MenuItem | ||
import android.view.View | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.widget.Toolbar | ||
import androidx.core.view.updatePadding | ||
import com.github.shadowsocks.plugin.ConfigurationActivity | ||
import com.github.shadowsocks.plugin.PluginOptions | ||
|
||
class ConfigActivity : ConfigurationActivity(), Toolbar.OnMenuItemClickListener { | ||
//fix activity_main: Error inflating class fragment | ||
//https://stackoverflow.com/questions/19874882/android-view-inflateexception-binary-xml-file-error-inflating-class-fragment | ||
private lateinit var child: ConfigFragment | ||
private lateinit var oldOptions: PluginOptions | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_config) | ||
findViewById<View>(android.R.id.content).apply { | ||
setOnApplyWindowInsetsListener { view, insets -> | ||
view.updatePadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop, | ||
insets.systemWindowInsetRight) | ||
@Suppress("DEPRECATION") | ||
insets.replaceSystemWindowInsets(0, 0, 0, insets.systemWindowInsetBottom) | ||
} | ||
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
} | ||
findViewById<Toolbar>(R.id.toolbar).apply { | ||
title = this@ConfigActivity.title | ||
setNavigationIcon(R.drawable.ic_navigation_close) | ||
setNavigationOnClickListener { onBackPressed() } | ||
inflateMenu(R.menu.menu_config) | ||
setOnMenuItemClickListener(this@ConfigActivity) | ||
} | ||
|
||
child = ConfigFragment() | ||
supportFragmentManager.beginTransaction() | ||
.replace(R.id.fragment_container, child) | ||
.commit() | ||
} | ||
|
||
override fun onInitializePluginOptions(options: PluginOptions) { | ||
oldOptions = options | ||
child.onInitializePluginOptions(options) | ||
} | ||
|
||
override fun onMenuItemClick(item: MenuItem?) = when (item?.itemId) { | ||
R.id.action_apply -> { | ||
saveChanges(child.options) | ||
finish() | ||
true | ||
} | ||
else -> false | ||
} | ||
|
||
override fun onBackPressed() { | ||
if (child.options != oldOptions) AlertDialog.Builder(this).run { | ||
setTitle(R.string.unsaved_changes_prompt) | ||
setPositiveButton(R.string.yes) { _, _ -> | ||
saveChanges(child.options) | ||
finish() | ||
} | ||
setNegativeButton(R.string.no) { _, _ -> finish() } | ||
setNeutralButton(android.R.string.cancel, null) | ||
create() | ||
}.show() else super.onBackPressed() | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
obfs/src/main/java/com/github/shadowsocks/plugin/obfs_local/ConfigFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.github.shadowsocks.plugin.obfs_local | ||
|
||
import android.os.Bundle | ||
import android.text.InputType | ||
import android.view.View | ||
import androidx.core.view.updatePadding | ||
import androidx.preference.EditTextPreference | ||
import androidx.preference.ListPreference | ||
import androidx.preference.Preference | ||
import androidx.preference.PreferenceFragmentCompat | ||
import com.github.shadowsocks.plugin.PluginOptions | ||
|
||
class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener { | ||
private val obfs by lazy { findPreference<ListPreference>("obfs")!! } | ||
private val obfshost by lazy { findPreference<EditTextPreference>("obfs-host")!! } | ||
private val obfsuri by lazy { findPreference<EditTextPreference>("obfs-uri")!! } | ||
val options get() = PluginOptions().apply { | ||
put("obfs", obfs.value ?: "http") | ||
put("obfs-host", obfshost.text ?: "cloudfront.net") | ||
//put("obfs-uri", obfsuri.text ?: "/") | ||
} | ||
|
||
fun onInitializePluginOptions(options: PluginOptions) { | ||
//Log.e("obfs.value","onInitializePluginOptions "+ obfs.value) | ||
//Log.e("obfs.value","options[\"obfs\"] "+ options["obfs"]) | ||
obfs.value = options["obfs"] ?: "http" | ||
//Log.e("obfs.value","onInitializePluginOptions "+ obfs.value) | ||
obfshost.text = options["obfs-host"] ?: "cloudfront.net" | ||
//obfsuri.text = options["obfs-uri"] ?: "/" | ||
} | ||
|
||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
addPreferencesFromResource(R.xml.config) | ||
obfs.onPreferenceChangeListener = this | ||
obfshost.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI } | ||
obfsuri.isVisible=false | ||
obfsuri.isEnabled=false | ||
//obfsuri.setOnBindEditTextListener { it.inputType = InputType.TYPE_TEXT_VARIATION_URI } | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
listView.setOnApplyWindowInsetsListener { v, insets -> | ||
insets.apply { v.updatePadding(bottom = systemWindowInsetBottom) } | ||
} | ||
|
||
//if (savedInstanceState != null) { | ||
// onInitializePluginOptions(PluginOptions(savedInstanceState.getString(PluginContract.EXTRA_OPTIONS))) | ||
//} | ||
} | ||
|
||
/* | ||
override fun onSaveInstanceState(outState: Bundle) { | ||
super.onSaveInstanceState(outState) | ||
outState.putString(PluginContract.EXTRA_OPTIONS, options.toString()) | ||
} | ||
*/ | ||
|
||
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { | ||
return true | ||
} | ||
} |
Oops, something went wrong.