From 6d3c122bebf0ad4f7dc22d4963dc73dea4248251 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 31 Jul 2021 16:34:09 +0200 Subject: adapt EIP main screen and strings to simply secure proposals --- .../de/blinkt/openvpn/core/OpenVPNService.java | 1 + .../java/de/blinkt/openvpn/core/VpnStatus.java | 10 ++ .../bitmaskclient/base/fragments/EipFragment.java | 39 +++++-- app/src/main/res/layout-port/f_eip.xml | 108 +++++++++++++++++++ app/src/main/res/layout-xlarge-port/f_eip.xml | 119 +++++++++++++++++++++ app/src/main/res/layout-xlarge/f_eip.xml | 61 +++++++---- app/src/main/res/layout/f_eip.xml | 103 ++++++++++++------ app/src/main/res/layout/v_location_button.xml | 3 +- app/src/main/res/values/untranslatable.xml | 8 +- 9 files changed, 391 insertions(+), 61 deletions(-) create mode 100644 app/src/main/res/layout-port/f_eip.xml create mode 100644 app/src/main/res/layout-xlarge-port/f_eip.xml (limited to 'app') diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 9ed2054e..ae38a59b 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -377,6 +377,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac // connections[n], n>0 gets choosen? Connection connection = mProfile.mConnections[0]; + VpnStatus.setCurrentlyConnectingProfile(mProfile); VpnStatus.logInfo(R.string.building_configration); VpnStatus.updateStateString("VPN_GENERATE_CONFIG", "", R.string.building_configration, ConnectionStatus.LEVEL_START); diff --git a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java index 8007f7c5..a8fed675 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java @@ -48,6 +48,7 @@ public class VpnStatus { final static java.lang.Object readFileLock = new Object(); private static VpnProfile lastConnectedProfile; + private static VpnProfile currentlyConnectingProfile; public static TrafficHistory trafficHistory; @@ -170,6 +171,15 @@ public class VpnStatus { } + public static void setCurrentlyConnectingProfile(VpnProfile connectingProfile) { + currentlyConnectingProfile = connectingProfile; + } + + public static String getCurrentlyConnectingVpnName() { + return currentlyConnectingProfile != null ? currentlyConnectingProfile.mName : null; + } + + public static String getLastConnectedVpnName() { return lastConnectedProfile != null ? lastConnectedProfile.mName : null; } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java index af34b7a5..e9402468 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java @@ -39,6 +39,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatTextView; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -50,6 +51,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import butterknife.Unbinder; +import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.ConnectionStatus; import de.blinkt.openvpn.core.IOpenVPNServiceInternal; import de.blinkt.openvpn.core.OpenVPNService; @@ -84,6 +86,7 @@ import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_LOG_IN; import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_SWITCH_PROVIDER; import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; +import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getPreferredCity; import static se.leap.bitmaskclient.base.utils.ViewHelper.convertDimensionToPx; import static se.leap.bitmaskclient.eip.EipSetupObserver.gatewayOrder; import static se.leap.bitmaskclient.eip.EipSetupObserver.reconnectingWithDifferentGateway; @@ -109,6 +112,12 @@ public class EipFragment extends Fragment implements Observer { @BindView(R.id.gateway_location_button) LocationButton locationButton; + @BindView(R.id.main_description) + AppCompatTextView mainDescription; + + @BindView(R.id.sub_description) + AppCompatTextView subDescription; + private Unbinder unbinder; private EipStatus eipStatus; @@ -408,21 +417,20 @@ public class EipFragment extends Fragment implements Observer { return; } - //Log.d(TAG, "eip fragment eipStatus state: " + eipStatus.getState() + " - level: " + eipStatus.getLevel() + " - is reconnecting: " + eipStatus.isReconnecting()); - - + Log.d(TAG, "eip fragment eipStatus state: " + eipStatus.getState() + " - level: " + eipStatus.getLevel() + " - is reconnecting: " + eipStatus.isReconnecting()); if (eipStatus.isConnecting() ) { setMainButtonEnabled(true); showConnectingLayout(activity); if (eipStatus.isReconnecting()) { - locationButton.setText(getString(R.string.reconnecting)); + subDescription.setText(getString(R.string.reconnecting)); } else { - locationButton.setText(getString(R.string.finding_best_connection)); + subDescription.setText(R.string.connection_not_connected); } + locationButton.setText(getString(R.string.finding_best_connection)); + mainDescription.setText(R.string.eip_state_insecure); locationButton.setVisibility(VISIBLE); locationButton.setLocationLoad(UNKNOWN); - } else if (eipStatus.isConnected() ) { - locationButton.setText(activity.getString(R.string.vpn_button_turn_off)); + } else if (eipStatus.isConnected()) { setMainButtonEnabled(true); vpnStateImage.setStateIcon(R.drawable.vpn_connected); vpnStateImage.stopProgress(false); @@ -430,23 +438,34 @@ public class EipFragment extends Fragment implements Observer { locationButton.setText(VpnStatus.getLastConnectedVpnName()); locationButton.setVisibility(VISIBLE); colorBackground(); + mainDescription.setText(R.string.eip_state_connected); + subDescription.setText(getPreferredCity(getContext()) == null ? + R.string.eip_state_connected_recommended : + R.string.eip_state_connected_manual); } else if(isOpenVpnRunningWithoutNetwork()){ - locationButton.setText(activity.getString(R.string.vpn_button_turn_off)); + Log.d(TAG, "eip fragment eipStatus - isOpenVpnRunningWithoutNetwork"); setMainButtonEnabled(true); vpnStateImage.setStateIcon(R.drawable.vpn_disconnected); vpnStateImage.stopProgress(false); locationButton.setVisibility(VISIBLE); + locationButton.setText(VpnStatus.getCurrentlyConnectingVpnName()); setVpnRouteText(); colorBackgroundALittle(); + mainDescription.setText(R.string.eip_state_insecure); + subDescription.setText(R.string.eip_state_no_network); } else if (eipStatus.isDisconnected() && reconnectingWithDifferentGateway()) { showConnectingLayout(activity); // showRetryToast(activity); locationButton.setText(getString(R.string.finding_best_connection)); locationButton.setVisibility(VISIBLE); locationButton.setLocationLoad(UNKNOWN); + mainDescription.setText(R.string.eip_state_insecure); + subDescription.setText(R.string.reconnecting); } else if (eipStatus.isDisconnecting()) { setMainButtonEnabled(false); showDisconnectingLayout(activity); + mainDescription.setText(R.string.eip_state_insecure); + subDescription.setText(R.string.connection_not_connected); } else if (eipStatus.isBlocking()) { setMainButtonEnabled(true); vpnStateImage.setStateIcon(R.drawable.vpn_blocking); @@ -455,6 +474,8 @@ public class EipFragment extends Fragment implements Observer { locationButton.setText(getString(R.string.finding_best_connection)); locationButton.setVisibility(VISIBLE); locationButton.setLocationLoad(UNKNOWN); + mainDescription.setText(R.string.eip_state_connected); + subDescription.setText(R.string.eip_state_blocking); } else { locationButton.setText(activity.getString(R.string.vpn_button_turn_on)); setMainButtonEnabled(true); @@ -463,6 +484,8 @@ public class EipFragment extends Fragment implements Observer { greyscaleBackground(); locationButton.setLocationLoad(UNKNOWN); locationButton.setVisibility(GONE); + mainDescription.setText(R.string.eip_state_insecure); + subDescription.setText(R.string.connection_not_connected); } } diff --git a/app/src/main/res/layout-port/f_eip.xml b/app/src/main/res/layout-port/f_eip.xml new file mode 100644 index 00000000..4dae126c --- /dev/null +++ b/app/src/main/res/layout-port/f_eip.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-xlarge-port/f_eip.xml b/app/src/main/res/layout-xlarge-port/f_eip.xml new file mode 100644 index 00000000..5325d6a6 --- /dev/null +++ b/app/src/main/res/layout-xlarge-port/f_eip.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout-xlarge/f_eip.xml b/app/src/main/res/layout-xlarge/f_eip.xml index bef2d635..8ed9a57c 100644 --- a/app/src/main/res/layout-xlarge/f_eip.xml +++ b/app/src/main/res/layout-xlarge/f_eip.xml @@ -1,4 +1,8 @@ + @@ -34,7 +38,7 @@ android:orientation="horizontal" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" - app:layout_constraintGuide_percent="0.7" + app:layout_constraintGuide_percent="0.66" /> - - + + + + + app:layout_constraintGuide_percent="0.1" + app:layout_constraintRight_toRightOf="parent" /> + app:layout_constraintGuide_percent="0.3" /> + + + + + app:layout_constraintGuide_percent="0.7" /> - - - + + + + diff --git a/app/src/main/res/layout/v_location_button.xml b/app/src/main/res/layout/v_location_button.xml index 9e5445a4..d8eed9a3 100644 --- a/app/src/main/res/layout/v_location_button.xml +++ b/app/src/main/res/layout/v_location_button.xml @@ -6,11 +6,10 @@ android:layout_gravity="center_vertical" android:padding="@dimen/stdpadding" android:background="@drawable/cust_button_primary_rect" - android:layout_height="wrap_content"> + android:layout_height="match_parent"> %1$s doesn\'t support bridges to circumvent VPN filtering. Do you want to choose a different location or disable bridges? Disable bridges Choose different location - + Connection Insecure + You are connected to the recommended location + You are connected to + Connecting... + You may be leaking information to your internet provider or local network. + You have no working Internet connection. Once you get it back, you will be automatically connected to + %1$s is blocking all internet traffic. \ No newline at end of file -- cgit v1.2.3