diff options
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | main/src/main/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java | 18 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 11 |
4 files changed, 15 insertions, 19 deletions
diff --git a/build.gradle b/build.gradle index ca6943d4..4c697cda 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0-rc1' + classpath 'com.android.tools.build:gradle:2.1.0' } } diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index dbc44a68..53509ae4 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -84,12 +84,15 @@ <service android:name=".OpenVPNTileService" + android:value="true" android:label="@string/qs_title" android:icon="@drawable/icon" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> + <meta-data android:name="android.service.quicksettings.ACTIVE_TILE" + android:value="false" /> </service> <activity android:name=".api.GrantPermissionsActivity"> diff --git a/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java b/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java index 244eb62c..7d954894 100644 --- a/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java +++ b/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java @@ -59,7 +59,7 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi bindService(intent, new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder binder) { - OpenVPNService service = ((OpenVPNService.LocalBinder) binder).getService(); + OpenVPNService service = ((OpenVPNService.LocalBinder) binder).getService(); if (service != null && service.getManagement() != null) service.getManagement().stopVPN(false); @@ -72,8 +72,7 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi } }, Context.BIND_AUTO_CREATE); - } - else + } else launchVPN(bootProfile, this); } @@ -90,11 +89,9 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi context.startActivity(startVpnIntent); } - @SuppressLint("Override") @TargetApi(Build.VERSION_CODES.N) @Override - public int onTileAdded() { - return TILE_MODE_ACTIVE; + public void onTileAdded() { } @Override @@ -125,9 +122,16 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi } } else { vpn = ProfileManager.getLastConnectedVpn(); - t.setLabel(getString(R.string.qs_disconnect, vpn.getName())); + String name; + if (vpn == null) + name = "null?!"; + else + name = vpn.getName(); + t.setLabel(getString(R.string.qs_disconnect, name)); t.setState(Tile.STATE_ACTIVE); } + + t.updateTile(); } diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 752fbb2a..321140fd 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -929,12 +929,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac if (mProcessThread == null && !mNotificationAlwaysVisible) return; - - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) - tileUpdateN(); - - - boolean lowpriority = false; // Display byte count only after being connected @@ -963,11 +957,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } } - @TargetApi(Build.VERSION_CODES.N) - private void tileUpdateN() { - TileService.requestListeningState(this, new ComponentName(this, OpenVPNTileService.class)); - } - private void doSendBroadcast(String state, ConnectionStatus level) { Intent vpnstatus = new Intent(); vpnstatus.setAction("de.blinkt.openvpn.VPN_STATUS"); |