-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed no-internet crash bug Ridiculous the lengths I have to go to to explain Google the app does NOT get stuck but is simply loading... before: Proxy can now properly be turned off Removed on boot setting as that happens automatically Easier setup and better layout Live external IP view Remember: turning off wifi works better! Added clearer loading screen and easier setup ADB over Bluetooth only needs to be enabled the first time Faster proxy switching with WRITE_SECURE_SETTINGS
- Loading branch information
1 parent
c4a32fd
commit 839ee6d
Showing
10 changed files
with
148 additions
and
102 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
67 changes: 67 additions & 0 deletions
67
wear/src/main/java/nl/jolanrensen/permanentproxy/RequestPermissionActivity.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,67 @@ | ||
package nl.jolanrensen.permanentproxy | ||
|
||
import android.app.Activity | ||
import android.content.pm.PackageManager | ||
import android.os.Bundle | ||
import android.support.wearable.activity.WearableActivity | ||
import kotlinx.android.synthetic.main.activity_request_permission.* | ||
import nl.jolanrensen.permanentproxy.Constants.logE | ||
import nl.jolanrensen.permanentproxy.Constants.toastLong | ||
import kotlin.concurrent.thread | ||
|
||
class RequestPermissionActivity : WearableActivity() { | ||
|
||
@Volatile | ||
var currentADBProcess: SendSingleCommand? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_request_permission) | ||
|
||
cancel.setOnClickListener { | ||
finish() | ||
} | ||
|
||
thread(start = true) { | ||
val logs = arrayListOf<String>() | ||
try { | ||
currentADBProcess = SendSingleCommand( | ||
logs = logs, | ||
context = this, | ||
ip = "localhost", | ||
port = Constants.PORT, | ||
command = "pm grant \\\nnl.jolanrensen.permanentproxy \\\nandroid.permission.WRITE_SECURE_SETTINGS", | ||
timeout = 4000, | ||
ctrlC = false | ||
) { | ||
currentADBProcess = null | ||
Constants.logD(it.toString()) | ||
runOnUiThread { | ||
if (checkCallingOrSelfPermission("android.permission.WRITE_SECURE_SETTINGS") | ||
== PackageManager.PERMISSION_GRANTED | ||
) { | ||
toastLong(getString(R.string.permission_granted)) | ||
setResult(Activity.RESULT_OK) | ||
} else { | ||
toastLong(getString(R.string.something_wrong)) | ||
} | ||
finish() | ||
} | ||
} | ||
} catch (e: Exception) { | ||
currentADBProcess = null | ||
logE("$logs", e) | ||
runOnUiThread { | ||
toastLong(getString(R.string.something_wrong)) | ||
finish() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onStop() { | ||
currentADBProcess?.cancel() | ||
logE("requesting permission canceled") | ||
super.onStop() | ||
} | ||
} |
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,56 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/black" | ||
android:padding="@dimen/box_inset_layout_padding" | ||
tools:context=".RequestPermissionActivity" | ||
tools:deviceIds="wear"> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:nestedScrollingEnabled="true" | ||
android:paddingStart="16dp" | ||
android:paddingEnd="16dp"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_marginTop="45dp" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/requesting_permission" | ||
android:textAlignment="center" | ||
android:textAppearance="@android:style/TextAppearance.Material.Body1" /> | ||
|
||
<ProgressBar | ||
style="?android:attr/progressBarStyle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginBottom="8dp" | ||
android:foregroundGravity="center" | ||
android:indeterminate="true" /> | ||
|
||
<TextView | ||
android:id="@+id/cancel" | ||
android:layout_width="match_parent" | ||
android:layout_height="45dp" | ||
android:layout_marginBottom="45dp" | ||
android:background="?android:attr/selectableItemBackground" | ||
android:foregroundGravity="center" | ||
android:gravity="center" | ||
android:minHeight="45dp" | ||
android:text="@string/cancel" | ||
android:textAlignment="center" | ||
android:textAppearance="@android:style/TextAppearance.Material.Body1" /> | ||
|
||
</LinearLayout> | ||
|
||
</ScrollView> | ||
</androidx.wear.widget.BoxInsetLayout> |