From e3cdc73429b42bdfab9b836bddab49c6b3fc9640 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 4 Aug 2023 13:11:45 +0200 Subject: implement custom 'start vpn' button design for initial provider setup --- .../leap/bitmaskclient/base/views/MainButton.java | 15 ++++++ .../fragments/SetupSuccessFragment.java | 4 +- .../res/drawable/button_setup_circle_progress.xml | 7 +++ .../button_setup_circle_progress_pressed.xml | 61 +++++++++++++++++++++ .../button_setup_circle_progress_released.xml | 62 ++++++++++++++++++++++ .../res/drawable/button_setup_circle_start.xml | 7 +++ .../drawable/button_setup_circle_start_pressed.xml | 48 +++++++++++++++++ .../button_setup_circle_start_released.xml | 45 ++++++++++++++++ 8 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/button_setup_circle_progress.xml create mode 100644 app/src/main/res/drawable/button_setup_circle_progress_pressed.xml create mode 100644 app/src/main/res/drawable/button_setup_circle_progress_released.xml create mode 100644 app/src/main/res/drawable/button_setup_circle_start.xml create mode 100644 app/src/main/res/drawable/button_setup_circle_start_pressed.xml create mode 100644 app/src/main/res/drawable/button_setup_circle_start_released.xml (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/MainButton.java b/app/src/main/java/se/leap/bitmaskclient/base/views/MainButton.java index c7273613..2fcc036e 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/MainButton.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/MainButton.java @@ -2,10 +2,13 @@ package se.leap.bitmaskclient.base.views; import android.annotation.TargetApi; import android.content.Context; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.widget.RelativeLayout; +import androidx.annotation.DrawableRes; import androidx.appcompat.widget.AppCompatImageView; import androidx.core.content.ContextCompat; @@ -56,4 +59,16 @@ public class MainButton extends RelativeLayout { button.setTag(isOn ? "button_circle_stop" : "button_circle_start"); } } + + public void setCustomDrawable(@DrawableRes int drawableResource) { + // Drawable drawable = ContextCompat.getDrawable(getContext(), drawableResource); + Drawable drawable = getContext().getDrawable(drawableResource); + if (drawable == null) { + return; + } + + drawable.setColorFilter(ContextCompat.getColor(getContext(), R.color.colorPrimaryLight), PorterDuff.Mode.MULTIPLY); + button.setImageDrawable(drawable); + button.setTag("button_setup_circle_custom"); + } } diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/SetupSuccessFragment.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/SetupSuccessFragment.java index eb775e2a..448e357a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/SetupSuccessFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/SetupSuccessFragment.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.databinding.FSetupSuccessBinding; public class SetupSuccessFragment extends BaseSetupFragment { @@ -28,9 +29,10 @@ public class SetupSuccessFragment extends BaseSetupFragment { binding.mainButton.setOnClickListener(v -> { setupActivityCallback.onSetupFinished(); - binding.mainButton.updateState(false, true); binding.mainButton.setEnabled(false); + binding.mainButton.setCustomDrawable(R.drawable.button_setup_circle_progress); }); + binding.mainButton.setCustomDrawable(R.drawable.button_setup_circle_start); return binding.getRoot(); } diff --git a/app/src/main/res/drawable/button_setup_circle_progress.xml b/app/src/main/res/drawable/button_setup_circle_progress.xml new file mode 100644 index 00000000..be45d207 --- /dev/null +++ b/app/src/main/res/drawable/button_setup_circle_progress.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_setup_circle_progress_pressed.xml b/app/src/main/res/drawable/button_setup_circle_progress_pressed.xml new file mode 100644 index 00000000..9f0021ef --- /dev/null +++ b/app/src/main/res/drawable/button_setup_circle_progress_pressed.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_setup_circle_progress_released.xml b/app/src/main/res/drawable/button_setup_circle_progress_released.xml new file mode 100644 index 00000000..244ecf10 --- /dev/null +++ b/app/src/main/res/drawable/button_setup_circle_progress_released.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_setup_circle_start.xml b/app/src/main/res/drawable/button_setup_circle_start.xml new file mode 100644 index 00000000..93665361 --- /dev/null +++ b/app/src/main/res/drawable/button_setup_circle_start.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_setup_circle_start_pressed.xml b/app/src/main/res/drawable/button_setup_circle_start_pressed.xml new file mode 100644 index 00000000..a9ca0312 --- /dev/null +++ b/app/src/main/res/drawable/button_setup_circle_start_pressed.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_setup_circle_start_released.xml b/app/src/main/res/drawable/button_setup_circle_start_released.xml new file mode 100644 index 00000000..70c82ec6 --- /dev/null +++ b/app/src/main/res/drawable/button_setup_circle_start_released.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3