From d7d890edeee2d6fc6cb6cc08fe29b5089ad7513b Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 31 Jul 2021 18:32:01 +0200 Subject: initial implementation of classic on-off push button --- .../bitmaskclient/base/fragments/EipFragment.java | 27 +++++++--------------- app/src/main/res/drawable/ic_btn_on_connecting.xml | 22 ++++++++++++++++++ app/src/main/res/drawable/ic_btn_on_disabled.xml | 20 ++++++++++++++++ .../main/res/drawable/ic_btn_on_primary_color.xml | 22 ++++++++++++++++++ app/src/main/res/layout/v_main_button.xml | 14 +++++++---- 5 files changed, 81 insertions(+), 24 deletions(-) create mode 100644 app/src/main/res/drawable/ic_btn_on_connecting.xml create mode 100644 app/src/main/res/drawable/ic_btn_on_disabled.xml create mode 100644 app/src/main/res/drawable/ic_btn_on_primary_color.xml 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 e9402468..3650804f 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 @@ -27,7 +27,6 @@ import android.graphics.ColorMatrixColorFilter; import android.os.Bundle; import android.os.IBinder; import android.os.Vibrator; -import android.text.TextUtils; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; @@ -51,7 +50,6 @@ 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; @@ -420,7 +418,7 @@ public class EipFragment extends Fragment implements Observer { Log.d(TAG, "eip fragment eipStatus state: " + eipStatus.getState() + " - level: " + eipStatus.getLevel() + " - is reconnecting: " + eipStatus.isReconnecting()); if (eipStatus.isConnecting() ) { setMainButtonEnabled(true); - showConnectingLayout(activity); + showConnectionTransitionLayout(true); if (eipStatus.isReconnecting()) { subDescription.setText(getString(R.string.reconnecting)); } else { @@ -432,7 +430,7 @@ public class EipFragment extends Fragment implements Observer { locationButton.setLocationLoad(UNKNOWN); } else if (eipStatus.isConnected()) { setMainButtonEnabled(true); - vpnStateImage.setStateIcon(R.drawable.vpn_connected); + vpnStateImage.setStateIcon(R.drawable.ic_btn_on_primary_color); vpnStateImage.stopProgress(false); locationButton.setLocationLoad(gatewaysManager.getLoadForLocation(VpnStatus.getLastConnectedVpnName())); locationButton.setText(VpnStatus.getLastConnectedVpnName()); @@ -445,16 +443,15 @@ public class EipFragment extends Fragment implements Observer { } else if(isOpenVpnRunningWithoutNetwork()){ Log.d(TAG, "eip fragment eipStatus - isOpenVpnRunningWithoutNetwork"); setMainButtonEnabled(true); - vpnStateImage.setStateIcon(R.drawable.vpn_disconnected); + vpnStateImage.setStateIcon(R.drawable.ic_btn_on_primary_color); 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); + showConnectionTransitionLayout(true); // showRetryToast(activity); locationButton.setText(getString(R.string.finding_best_connection)); locationButton.setVisibility(VISIBLE); @@ -463,12 +460,12 @@ public class EipFragment extends Fragment implements Observer { subDescription.setText(R.string.reconnecting); } else if (eipStatus.isDisconnecting()) { setMainButtonEnabled(false); - showDisconnectingLayout(activity); + showConnectionTransitionLayout(false); 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); + vpnStateImage.setStateIcon(R.drawable.ic_btn_on_primary_color); vpnStateImage.stopProgress(false); colorBackgroundALittle(); locationButton.setText(getString(R.string.finding_best_connection)); @@ -518,16 +515,8 @@ public class EipFragment extends Fragment implements Observer { showToast(activity, message, true ); } - private void showConnectingLayout(Context activity) { - showConnectionTransitionLayout(activity, true); - } - - private void showDisconnectingLayout(Activity activity) { - showConnectionTransitionLayout(activity, false); - } - - private void showConnectionTransitionLayout(Context activity, boolean isConnecting) { - vpnStateImage.setStateIcon(R.drawable.vpn_connecting); + private void showConnectionTransitionLayout(boolean isConnecting) { + vpnStateImage.setStateIcon(R.drawable.ic_btn_on_connecting); vpnStateImage.showProgress(); if (isConnecting) { colorBackgroundALittle(); diff --git a/app/src/main/res/drawable/ic_btn_on_connecting.xml b/app/src/main/res/drawable/ic_btn_on_connecting.xml new file mode 100644 index 00000000..4b3d1384 --- /dev/null +++ b/app/src/main/res/drawable/ic_btn_on_connecting.xml @@ -0,0 +1,22 @@ + + + + diff --git a/app/src/main/res/drawable/ic_btn_on_disabled.xml b/app/src/main/res/drawable/ic_btn_on_disabled.xml new file mode 100644 index 00000000..9c83422d --- /dev/null +++ b/app/src/main/res/drawable/ic_btn_on_disabled.xml @@ -0,0 +1,20 @@ + + + + diff --git a/app/src/main/res/drawable/ic_btn_on_primary_color.xml b/app/src/main/res/drawable/ic_btn_on_primary_color.xml new file mode 100644 index 00000000..9f449299 --- /dev/null +++ b/app/src/main/res/drawable/ic_btn_on_primary_color.xml @@ -0,0 +1,22 @@ + + + + diff --git a/app/src/main/res/layout/v_main_button.xml b/app/src/main/res/layout/v_main_button.xml index d8ae211c..741fc88f 100644 --- a/app/src/main/res/layout/v_main_button.xml +++ b/app/src/main/res/layout/v_main_button.xml @@ -102,6 +102,7 @@ app:layout_constraintEnd_toEndOf="@id/border_guideline_right" app:layout_constraintStart_toStartOf="@id/border_guideline_left" app:layout_constraintTop_toTopOf="@id/border_guideline_top" + app:layout_constraintDimensionRatio="1:1" android:indeterminate="true" android:indeterminateDuration="800" android:indeterminateDrawable="@drawable/progressbar_circle" @@ -117,16 +118,19 @@ app:layout_constraintEnd_toStartOf="@+id/vpn_btn_guideline_right" app:layout_constraintStart_toStartOf="@+id/vpn_btn_guideline_left" app:layout_constraintTop_toTopOf="@+id/vpn_btn_guideline_top" + app:layout_constraintDimensionRatio="1:1" app:srcCompat="@drawable/black_circle" /> + app:layout_constraintBottom_toTopOf="@+id/icn_guideline_bottom" + app:layout_constraintEnd_toStartOf="@+id/icn_guideline_right" + app:layout_constraintStart_toStartOf="@+id/icn_guideline_left" + app:layout_constraintTop_toTopOf="@+id/icn_guideline_top" + app:layout_constraintDimensionRatio="1:1" + app:layout_constraintVertical_bias="0.35" + app:srcCompat="@drawable/ic_btn_on_disabled" /> \ No newline at end of file -- cgit v1.2.3