diff options
author | cyBerta <cyberta@riseup.net> | 2019-05-22 20:28:08 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-05-22 20:28:08 +0200 |
commit | 7dc9f9e9caf41976d08c967d2d966648c99f929b (patch) | |
tree | a00be0a81bf0c8cf179c85b6f8058bd77e74db52 /app/src/main/java/se | |
parent | e92081d9aff29b0f2592ab960593c59b5db41dbc (diff) |
* adds a DISCONNECTING state
* fixes vpn startup issues
Diffstat (limited to 'app/src/main/java/se')
3 files changed, 35 insertions, 8 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index d54d01af..69d81ccf 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -289,6 +289,11 @@ public class EipFragment extends Fragment implements Observer { } } + private void setMainButtonEnabled(boolean enabled) { + mainButton.setEnabled(enabled); + vpnStateImage.setEnabled(enabled); + } + public void startEipFromScratch() { saveStatus(true); Context context = getContext(); @@ -370,6 +375,7 @@ public class EipFragment extends Fragment implements Observer { if (eipStatus.isConnecting() ) { + setMainButtonEnabled(true); showConnectingLayout(activity); if (eipStatus.isReconnecting()) { //Log.d(TAG, "eip show reconnecting toast!"); @@ -377,6 +383,7 @@ public class EipFragment extends Fragment implements Observer { } } else if (eipStatus.isConnected() ) { mainButton.setText(activity.getString(R.string.vpn_button_turn_off)); + setMainButtonEnabled(true); vpnStateImage.setStateIcon(R.drawable.vpn_connected); vpnStateImage.stopProgress(true); routedText.setText(R.string.vpn_securely_routed); @@ -386,6 +393,7 @@ public class EipFragment extends Fragment implements Observer { colorBackground(); } else if(isOpenVpnRunningWithoutNetwork()){ mainButton.setText(activity.getString(R.string.vpn_button_turn_off)); + setMainButtonEnabled(true); vpnStateImage.setStateIcon(R.drawable.vpn_disconnected); vpnStateImage.stopProgress(true); routedText.setText(R.string.vpn_securely_routed_no_internet); @@ -396,9 +404,12 @@ public class EipFragment extends Fragment implements Observer { } else if (eipStatus.isDisconnected() && reconnectingWithDifferentGateway()) { showConnectingLayout(activity); // showRetryToast(activity); - } - else { + } else if (eipStatus.isDisconnecting()) { + setMainButtonEnabled(false); + showDisconnectingLayout(activity); + } else { mainButton.setText(activity.getString(R.string.vpn_button_turn_on)); + setMainButtonEnabled(true); vpnStateImage.setStateIcon(R.drawable.vpn_disconnected); vpnStateImage.stopProgress(false); routedText.setVisibility(GONE); @@ -410,9 +421,9 @@ public class EipFragment extends Fragment implements Observer { private void showToast(Activity activity, String message, boolean vibrateLong) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, - (ViewGroup) activity.findViewById(R.id.custom_toast_container)); + activity.findViewById(R.id.custom_toast_container)); - TextView text = (TextView) layout.findViewById(R.id.text); + TextView text = layout.findViewById(R.id.text); text.setText(message); Vibrator v = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); @@ -441,12 +452,24 @@ public class EipFragment extends Fragment implements Observer { } private void showConnectingLayout(Context activity) { + showConnectionTransitionLayout(activity, true); + } + + private void showDisconnectingLayout(Activity activity) { + showConnectionTransitionLayout(activity, false); + } + + private void showConnectionTransitionLayout(Context activity, boolean isConnecting) { mainButton.setText(activity.getString(android.R.string.cancel)); vpnStateImage.setStateIcon(R.drawable.vpn_connecting); vpnStateImage.showProgress(); routedText.setVisibility(GONE); vpnRoute.setVisibility(GONE); - colorBackgroundALittle(); + if (isConnecting) { + colorBackgroundALittle(); + } else { + greyscaleBackground(); + } } private boolean isOpenVpnRunningWithoutNetwork() { diff --git a/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java b/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java index d9a6121b..ff94fe82 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipSetupObserver.java @@ -33,7 +33,6 @@ import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_CODE; import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_KEY; import static se.leap.bitmaskclient.Constants.EIP_ACTION_START; import static se.leap.bitmaskclient.Constants.EIP_ACTION_START_ALWAYS_ON_VPN; -import static se.leap.bitmaskclient.Constants.EIP_ACTION_STOP; import static se.leap.bitmaskclient.Constants.EIP_REQUEST; import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; @@ -252,7 +251,6 @@ class EipSetupObserver extends BroadcastReceiver implements VpnStatus.StateListe } } - private void selectNextGateway() { changingGateway.set(true); reconnectTry.set(0); diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java index 20154ac1..fc07c521 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java @@ -115,9 +115,11 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { break; case LEVEL_AUTH_FAILED: case LEVEL_NOTCONNECTED: - case LEVEL_STOPPING: currentEipLevel = EipLevel.DISCONNECTED; break; + case LEVEL_STOPPING: + currentEipLevel = EipLevel.DISCONNECTING; + break; case LEVEL_NONETWORK: case LEVEL_BLOCKING: setEipLevelWithDelay(level); @@ -207,6 +209,10 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { return currentEipLevel == EipLevel.DISCONNECTED; } + public boolean isDisconnecting() { + return currentEipLevel == EipLevel.DISCONNECTING; + } + /** * ics-openvpn's paused state is not implemented yet * @return true if vpn is paused false if not |