summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java36
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java19
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java1
-rw-r--r--app/src/main/res/layout/eip_service_fragment.xml6
-rw-r--r--app/src/main/res/values-es/strings.xml3
-rw-r--r--app/src/main/res/values/strings.xml2
6 files changed, 49 insertions, 18 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
index 06fe0a42..18d7b45d 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
@@ -4,7 +4,7 @@ import android.content.*;
import android.graphics.*;
import android.test.*;
import android.view.*;
-import android.widget.Toast;
+import android.widget.Button;
import com.robotium.solo.*;
@@ -46,19 +46,19 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
* I cannot automate that dialog.
*/
public void testOnOffOpenVpn() {
- clickVpnImage();
+ clickVpnButton();
turningEipOn();
- clickVpnImage();
+ clickVpnButton();
turningEipOff();
- clickVpnImage();
+ clickVpnButton();
turningEipOn();
- clickVpnImage();
+ clickVpnButton();
turningEipOff();
- /*clickVpnImage();;
+ /*clickVpnButton();;
turningEipOn();
turnNetworkOff();
@@ -67,12 +67,15 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
}
- private void clickVpnImage() {
- View vpn_status_image = getVpnButton();
- solo.clickOnView(vpn_status_image);
+ private void clickVpnButton() {
+ solo.clickOnView(getVpnButton());
}
- private FabButton getVpnButton() {
+ private Button getVpnButton() {
+ return (Button) solo.getView(R.id.vpn_main_button);
+ }
+
+ private FabButton getVpnImage() {
return (FabButton) solo.getView(R.id.vpn_Status_Image);
}
@@ -91,12 +94,12 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
}
private void assertInProgress() {
- ProgressRingView a = (ProgressRingView) getVpnButton().findViewById(R.id.fabbutton_ring);
+ ProgressRingView a = (ProgressRingView) getVpnImage().findViewById(R.id.fabbutton_ring);
assertTrue(isShownWithinConfinesOfVisibleScreen(a));
}
private boolean iconConnected() {
- CircleImageView a = (CircleImageView) getVpnButton().findViewById(R.id.fabbutton_circle);
+ CircleImageView a = (CircleImageView) getVpnImage().findViewById(R.id.fabbutton_circle);
a.setDrawingCacheEnabled(true);
return a.getDrawingCache().equals(getActivity().getResources().getDrawable(R.drawable.ic_stat_vpn));
}
@@ -133,7 +136,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
}
private boolean iconDisconnected() {
- CircleImageView a = (CircleImageView) getVpnButton().findViewById(R.id.fabbutton_circle);
+ CircleImageView a = (CircleImageView) getVpnImage().findViewById(R.id.fabbutton_circle);
a.setDrawingCacheEnabled(true);
return a.getDrawingCache().equals(getActivity().getResources().getDrawable(R.drawable.ic_stat_vpn_offline));
}
@@ -209,9 +212,9 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
private void changeAndTestProvider(String provider) {
changeProvider(provider);
sleep(1);
- clickVpnImage();
+ clickVpnButton();
turningEipOn();
- clickVpnImage();
+ clickVpnButton();
turningEipOff();
}
@@ -246,6 +249,9 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
assertSuccessfulLogin();
}
public void testVpnIconIsDisplayed() {
+ assertTrue(isShownWithinConfinesOfVisibleScreen(getVpnImage()));
+ }
+ public void testVpnButtonIsDisplayed() {
assertTrue(isShownWithinConfinesOfVisibleScreen(getVpnButton()));
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index 6decacb7..30147f65 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -20,6 +20,7 @@ import android.app.*;
import android.content.*;
import android.os.*;
import android.view.*;
+import android.widget.*;
import org.jetbrains.annotations.*;
@@ -37,10 +38,11 @@ public class EipFragment extends Fragment implements Observer {
protected static final String IS_PENDING = TAG + ".is_pending";
protected static final String IS_CONNECTED = TAG + ".is_connected";
public static final String START_ON_BOOT = "start on boot";
- private static final String SHOWED_LOG = TAG + ".showed_log";
@InjectView(R.id.vpn_Status_Image)
FabButton vpn_status_image;
+ @InjectView(R.id.vpn_main_button)
+ Button main_button;
private static Dashboard dashboard;
private static EIPReceiver mEIPReceiver;
@@ -101,7 +103,7 @@ public class EipFragment extends Fragment implements Observer {
Dashboard.preferences.edit().putBoolean(Dashboard.START_ON_BOOT, is_on).commit();
}
- @OnClick(R.id.vpn_Status_Image)
+ @OnClick(R.id.vpn_main_button)
void handleIcon() {
if (eip_status.isConnected() || eip_status.isConnecting())
handleSwitchOff();
@@ -244,6 +246,7 @@ public class EipFragment extends Fragment implements Observer {
VoidVpnService.stop();
}
updateIcon();
+ updateButton();
}
private void updateIcon() {
@@ -261,6 +264,18 @@ public class EipFragment extends Fragment implements Observer {
}
}
+ private void updateButton() {
+ if (eip_status.isConnected() || eip_status.isConnecting()) {
+ if(eip_status.isConnecting()) {
+ main_button.setText(dashboard.getString(android.R.string.cancel));
+ } else {
+ main_button.setText(dashboard.getString(R.string.vpn_button_turn_off));
+ }
+ } else {
+ main_button.setText(dashboard.getString(R.string.vpn_button_turn_on));
+ }
+ }
+
protected class EIPReceiver extends ResultReceiver {
protected EIPReceiver(Handler handler) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
index 1c64328e..171035d1 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -20,6 +20,7 @@ import android.content.*;
import com.google.gson.*;
import com.google.gson.reflect.*;
+import com.google.gson.stream.JsonWriter;
import org.json.*;
diff --git a/app/src/main/res/layout/eip_service_fragment.xml b/app/src/main/res/layout/eip_service_fragment.xml
index e013c7b4..b3651b51 100644
--- a/app/src/main/res/layout/eip_service_fragment.xml
+++ b/app/src/main/res/layout/eip_service_fragment.xml
@@ -15,6 +15,12 @@
android:text="@string/eip_service_label"
android:textAppearance="?android:attr/textAppearanceMedium" />
+ <Button
+ android:id="@+id/vpn.main.button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ />
+
<view
android:id="@+id/vpn.Status.Image"
android:layout_width="@dimen/progress_button"
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 42b8cce4..063c3f8b 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -77,5 +77,6 @@
<string name="logging_in_user_status">está iniciando sesión.</string>
<string name="logging_out_user_status">está cerrando sesión.</string>
<string name="signingup_message">está siendo registrado.</string>
-
+ <string name="vpn.button.turn.on">Iniciar VPN</string>
+ <string name="vpn.button.turn.off">Apagar VPN</string>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 07bc4770..674bb7c8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -75,4 +75,6 @@
<string name="logging_in_user_status">is logging in.</string>
<string name="logging_out_user_status">is logging out.</string>
<string name="signingup_message">is being registered.</string>
+ <string name="vpn.button.turn.on">Turn on VPN</string>
+ <string name="vpn.button.turn.off">Turn off VPN</string>
</resources>