Skip to content

Commit

Permalink
v4.0:
Browse files Browse the repository at this point in the history
Updated dependencies
Fixed scrolling with scroll wheel
Added country to current IP
Current IP can now show IPv6
Replaced Port/IP buttons with text fields
Made setting the proxy clearer (this also allows for spam setting the proxy now which might help idk)
Changed some delay updating stuff
  • Loading branch information
Jolanrensen committed Jul 8, 2020
1 parent a486ec1 commit da58fc9
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 209 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
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 @@
#Tue Oct 08 22:17:23 CEST 2019
#Wed Jul 08 23:42:34 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
14 changes: 6 additions & 8 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "nl.jolanrensen.permanentproxy"
minSdkVersion 23
targetSdkVersion 29
versionCode 15
versionName "3.8"
versionCode 16
versionName "4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -25,11 +23,11 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
wearApp project(':wear')
Expand Down
23 changes: 10 additions & 13 deletions wear/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "nl.jolanrensen.permanentproxy"
minSdkVersion 23
targetSdkVersion 29
versionCode 15
versionName "3.8"
versionCode 16
versionName "4.0"
}
buildTypes {
release {
Expand All @@ -31,19 +29,18 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
implementation 'com.google.android.support:wearable:2.5.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
implementation 'com.google.android.support:wearable:2.7.0'
implementation files('../libraries/commons-codec-1.10-rep.jar')
implementation 'com.tananaev:adblib:1.2'
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// implementation 'com.android.billingclient:billing:1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation "androidx.core:core-ktx:1.2.0-rc01"
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'com.android.support:wear:28.0.0'
compileOnly 'com.google.android.wearable:wearable:2.5.0'
compileOnly 'com.google.android.wearable:wearable:2.7.0'
}
1 change: 1 addition & 0 deletions wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<!-- <uses-permission android:name="com.android.vending.BILLING" />-->

<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
42 changes: 24 additions & 18 deletions wear/src/main/java/nl/jolanrensen/permanentproxy/Constants.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package nl.jolanrensen.permanentproxy

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_VIEW
Expand Down Expand Up @@ -41,28 +42,27 @@ object Constants {
val turnOffProxyCommand =
"settings delete global http_proxy; \\\nsettings delete global global_http_proxy_host; \\\nsettings delete global global_http_proxy_port; \\\nsettings delete global global_http_proxy_exclusion_list; \\\nsettings delete global global_proxy_pac_url"

fun Context.startProxy(
p: SharedPreferences? = null,
fun Activity.startProxy(
address: String,
port: Int,
updateGooglePay: Boolean = true
) {
p?.edit(commit = true) {
putBoolean("onBoot", true)
}
Settings.Global.putString(contentResolver, Settings.Global.HTTP_PROXY, "$address:$port")
if (updateGooglePay) sendBroadcast(
Intent("android.server.checkin.CHECKIN")
)
if (updateGooglePay) {
GlobalScope.launch {
delay(1000)
runOnUiThread {
sendBroadcast(Intent("android.server.checkin.CHECKIN"))
logD("Broadcast message to check country for GPay")
}
}

}
}

fun Context.stopProxy(
p: SharedPreferences,
onFailure: (() -> Unit)? = null
) {
p.edit(commit = true) {
putBoolean("onBoot", false)
}
thread(start = true) {
val logs = arrayListOf<String>()
try {
Expand Down Expand Up @@ -101,31 +101,37 @@ object Constants {
val Context.currentProxy
get() = try {
(Settings.Global.getString(contentResolver, "global_http_proxy_host") + ":" +
Settings.Global.getString(contentResolver, "global_http_proxy_port")).let {
Settings.Global.getString(contentResolver, "global_http_proxy_port")).let {
if (it == "null:null") null else it
}
} catch (e: Exception) {
logE("proxy", e)
null
}

fun getCurrentIP(callback: (String?) -> Unit) {
fun getCurrentIP(callback: (ip: String?, countryCode: String?) -> Unit) {
val process = GlobalScope.launch(Dispatchers.IO) {
try {
val ip: String
callback(
JSONObject(URL("https://api.ipify.org?format=json").readText()).getString("ip")
URL("https://api64.ipify.org")
.readText()
.also { ip = it },
JSONObject(
URL("http://ip-api.com/json/$ip").readText()
).getString("countryCode")
)
} catch (e: Exception) {
logE("", e)
callback(null)
callback(null, null)
}
}

GlobalScope.launch {
delay(5)
delay(100)
if (process.isActive) {
process.cancel()
callback(null)
callback(null, null)
}
}
}
Expand Down
Loading

0 comments on commit da58fc9

Please sign in to comment.