[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] fixes for VPN service UI to work on Android6
commit d839b154a103b6d7a74fb6f36e47d7df09fe70f8
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Wed Jan 6 16:13:56 2016 -0500
fixes for VPN service UI to work on Android6
---
AndroidManifest.xml | 4 +-
.../torproject/android/vpn/OrbotVpnService.java | 8 ++-
.../torproject/android/vpn/VPNEnableActivity.java | 69 +++++++++++++-------
3 files changed, 54 insertions(+), 27 deletions(-)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ad2af72..caa8e74 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -62,7 +62,7 @@
-->
<activity
android:name=".service.DummyActivity"
- android:theme="@android:style/Theme.NoDisplay"
+ android:theme="@android:style/Theme.Translucent"
android:enabled="true"
android:allowTaskReparenting="true"
android:noHistory="true"
@@ -76,7 +76,7 @@
<activity
android:name=".vpn.VPNEnableActivity" android:label="@string/app_name" android:exported="false"
- android:theme="@android:style/Theme.NoDisplay"
+ android:theme="@android:style/Theme.Translucent"
/>
diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java
index a8d3b70..f4dff74 100644
--- a/src/org/torproject/android/vpn/OrbotVpnService.java
+++ b/src/org/torproject/android/vpn/OrbotVpnService.java
@@ -76,6 +76,11 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private boolean isRestart = false;
+
+ static{
+ System.loadLibrary("tun2socks");
+ }
+
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -174,9 +179,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
public void onCreate() {
super.onCreate();
- System.loadLibrary("tun2socks");
-
-
// Set the locale to English (or probably any other language that^M
// uses Hindu-Arabic (aka Latin) numerals).^M
// We have found that VpnService.Builder does something locale-dependent^M
diff --git a/src/org/torproject/android/vpn/VPNEnableActivity.java b/src/org/torproject/android/vpn/VPNEnableActivity.java
index 9083b45..8d254f1 100644
--- a/src/org/torproject/android/vpn/VPNEnableActivity.java
+++ b/src/org/torproject/android/vpn/VPNEnableActivity.java
@@ -18,6 +18,8 @@ import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
import android.widget.TextView;
/*
@@ -27,33 +29,45 @@ public class VPNEnableActivity extends Activity {
private final static int REQUEST_VPN = 7777;
private Intent intent = null;
-
+ private boolean checkVpn = true;
+ private Handler h = new Handler();
+
@Override
public void onCreate( Bundle icicle ) {
+
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+
super.onCreate( icicle );
Log.d("VPNEnableActivity","prompting user to start Orbot VPN");
- intent = VpnService.prepare(this);
- if (intent != null)
- promptStartVpnService();
- else
- startVpnService ();
+ }
+
+ public void onResume ()
+ {
+ super.onResume();
+ if (checkVpn)
+ {
+ intent = VpnService.prepare(this);
+
+ if (intent != null)
+ promptStartVpnService();
+ else
+ startVpnService ();
+
+ checkVpn = false;
+ }
}
public void promptStartVpnService ()
{
- LayoutInflater li = LayoutInflater.from(this);
- View view = li.inflate(R.layout.layout_diag, null);
-
- TextView versionName = (TextView)view.findViewById(R.id.diaglog);
- versionName.setText(R.string.you_can_enable_all_apps_on_your_device_to_run_through_the_tor_network_using_the_vpn_feature_of_android_);
-
- new AlertDialog.Builder(this)
+
+ AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(getString(R.string.app_name) + ' ' + getString(R.string.apps_mode))
- .setView(view)
+ .setMessage(getString(R.string.you_can_enable_all_apps_on_your_device_to_run_through_the_tor_network_using_the_vpn_feature_of_android_))
.setPositiveButton(R.string.activate, new Dialog.OnClickListener ()
{
@@ -73,11 +87,21 @@ public class VPNEnableActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
- finish();
+ h.postDelayed(new Runnable () {
+
+ public void run ()
+ {
+ VPNEnableActivity.this.finish();
+
+ }
+ }, 100);
}
- })
- .show();
+ }).create();
+
+ dialog.show();
+
+
}
private void startVpnService ()
@@ -86,7 +110,7 @@ public class VPNEnableActivity extends Activity {
{
Log.d("VPNEnableActivity","VPN enabled, starting Tor...");
sendIntentToService(TorServiceConstants.CMD_VPN);
- /**
+
Handler h = new Handler();
h.postDelayed(new Runnable () {
@@ -95,8 +119,7 @@ public class VPNEnableActivity extends Activity {
sendIntentToService(TorServiceConstants.ACTION_START);
finish();
}
- }, 1000);
- */
+ }, 100);
}
@@ -116,16 +139,18 @@ public class VPNEnableActivity extends Activity {
if (request == REQUEST_VPN && response == RESULT_OK)
{
sendIntentToService(TorServiceConstants.CMD_VPN);
- Handler h = new Handler();
+
h.postDelayed(new Runnable () {
public void run ()
{
sendIntentToService(TorServiceConstants.ACTION_START);
- finish();
+ finish();
}
}, 1000);
+
+
}
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits