android: Show countdown and retry button in notification
authorTobias Brunner <tobias@strongswan.org>
Mon, 18 Jun 2018 14:57:03 +0000 (16:57 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:39 +0000 (11:31 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java
src/frontends/android/app/src/main/res/values-de/strings.xml
src/frontends/android/app/src/main/res/values-pl/strings.xml
src/frontends/android/app/src/main/res/values-ru/strings.xml
src/frontends/android/app/src/main/res/values-ua/strings.xml
src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index b0c1298..7910f7d 100644 (file)
@@ -417,10 +417,30 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                        s = mService.getErrorText();
                        builder.setSmallIcon(R.drawable.ic_notification_warning);
                        builder.setColor(ContextCompat.getColor(this, R.color.error_text));
-                       builder.setContentText(getString(R.string.tap_for_details));
+
+                       if (!publicVersion && profile != null)
+                       {
+                               int retry = mService.getRetryIn();
+                               if (retry > 0)
+                               {
+                                       builder.setContentText(getResources().getQuantityString(R.plurals.retry_in, retry, retry));
+                                       builder.setProgress(mService.getRetryTimeout(), retry, false);
+                               }
+
+                               Intent intent = new Intent(getApplicationContext(), VpnProfileControlActivity.class);
+                               intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                               intent.setAction(VpnProfileControlActivity.START_PROFILE);
+                               intent.putExtra(VpnProfileControlActivity.EXTRA_VPN_PROFILE_ID, profile.getUUID().toString());
+                               PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, intent,
+                                                                                                                                 PendingIntent.FLAG_UPDATE_CURRENT);
+                               builder.addAction(R.drawable.ic_notification_connecting, getString(R.string.retry), pending);
+                               add_action = true;
+                       }
                }
                else
                {
+                       builder.setProgress(0, 0, false);
+
                        switch (state)
                        {
                                case CONNECTING:
index 4dc812c..cc107e6 100644 (file)
@@ -31,7 +31,6 @@
     <string name="strongswan_shortcut">strongSwan-Verknüpfung</string>
     <string name="permanent_notification_name">VPN Verbindungsstatus</string>
     <string name="permanent_notification_description">Zeigt Informationen zum Verbindungsstatus der VPN Verbindung und dient als permanente Notification dazu, den VPN Dienst im Hintergrund am Laufen zu halten.</string>
-    <string name="tap_for_details">Antippen für Details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Einstellungen</string>
index d4cf10e..b2ee092 100644 (file)
@@ -31,7 +31,6 @@
     <string name="strongswan_shortcut">Skrót strongSwan</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
-    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index be34c2d..5373fdd 100644 (file)
@@ -28,7 +28,6 @@
     <string name="strongswan_shortcut">Ссылка на strongSwan</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
-    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index faad4a7..a9dfbad 100644 (file)
@@ -29,7 +29,6 @@
     <string name="strongswan_shortcut">strongSwan посилання</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
-    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index 5b350fa..501d4bb 100644 (file)
@@ -28,7 +28,6 @@
     <string name="strongswan_shortcut">strongSwan快捷方式</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
-    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index 4d5afc7..f94efda 100644 (file)
@@ -28,7 +28,6 @@
     <string name="strongswan_shortcut">strongSwan快速選單</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
-    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index c4b697b..79d6e76 100644 (file)
@@ -31,7 +31,6 @@
     <string name="strongswan_shortcut">strongSwan shortcut</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
-    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>