From 0cf31d76c9f48cc73446b3fde478a46cd29c7594 Mon Sep 17 00:00:00 2001 From: cyberta Date: Tue, 29 Nov 2022 00:58:36 +0100 Subject: split EipFragment and MainButon into normal and custom flavor, implement new on-off button design for Bitmask --- .../leap/bitmaskclient/base/views/MainButton.java | 124 ------------------- .../bitmaskclient/base/views/VpnStateImage.java | 99 --------------- app/src/main/res/drawable-hdpi/ic_btn_cancel.png | Bin 0 -> 486 bytes app/src/main/res/drawable-hdpi/ic_btn_on.png | Bin 0 -> 1091 bytes app/src/main/res/drawable-xhdpi/ic_btn_cancel.png | Bin 0 -> 617 bytes app/src/main/res/drawable-xhdpi/ic_btn_on.png | Bin 0 -> 1460 bytes app/src/main/res/drawable-xxhdpi/ic_btn_cancel.png | Bin 0 -> 1009 bytes app/src/main/res/drawable-xxhdpi/ic_btn_on.png | Bin 0 -> 2211 bytes .../main/res/drawable-xxxhdpi/ic_btn_cancel.png | Bin 0 -> 1361 bytes app/src/main/res/drawable-xxxhdpi/ic_btn_on.png | Bin 0 -> 3115 bytes app/src/main/res/drawable/button_circle_cancel.xml | 5 + .../res/drawable/button_circle_cancel_pressed.xml | 64 ++++++++++ .../res/drawable/button_circle_cancel_released.xml | 62 ++++++++++ app/src/main/res/drawable/button_circle_start.xml | 7 ++ .../res/drawable/button_circle_start_pressed.xml | 47 +++++++ .../res/drawable/button_circle_start_released.xml | 46 +++++++ app/src/main/res/drawable/button_circle_stop.xml | 5 + .../res/drawable/button_circle_stop_pressed.xml | 47 +++++++ .../res/drawable/button_circle_stop_released.xml | 46 +++++++ app/src/main/res/drawable/ic_btn_cancel.png | Bin 0 -> 338 bytes app/src/main/res/drawable/ic_btn_on.png | Bin 0 -> 777 bytes app/src/main/res/layout/v_main_button.xml | 136 --------------------- app/src/main/res/values/colors.xml | 7 ++ 23 files changed, 336 insertions(+), 359 deletions(-) delete mode 100644 app/src/main/java/se/leap/bitmaskclient/base/views/MainButton.java delete mode 100644 app/src/main/java/se/leap/bitmaskclient/base/views/VpnStateImage.java create mode 100644 app/src/main/res/drawable-hdpi/ic_btn_cancel.png create mode 100644 app/src/main/res/drawable-hdpi/ic_btn_on.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_btn_cancel.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_btn_on.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_btn_cancel.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_btn_on.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_btn_cancel.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_btn_on.png create mode 100644 app/src/main/res/drawable/button_circle_cancel.xml create mode 100644 app/src/main/res/drawable/button_circle_cancel_pressed.xml create mode 100644 app/src/main/res/drawable/button_circle_cancel_released.xml create mode 100644 app/src/main/res/drawable/button_circle_start.xml create mode 100644 app/src/main/res/drawable/button_circle_start_pressed.xml create mode 100644 app/src/main/res/drawable/button_circle_start_released.xml create mode 100644 app/src/main/res/drawable/button_circle_stop.xml create mode 100644 app/src/main/res/drawable/button_circle_stop_pressed.xml create mode 100644 app/src/main/res/drawable/button_circle_stop_released.xml create mode 100644 app/src/main/res/drawable/ic_btn_cancel.png create mode 100644 app/src/main/res/drawable/ic_btn_on.png delete mode 100644 app/src/main/res/layout/v_main_button.xml (limited to 'app/src/main') 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 deleted file mode 100644 index c5ac4544..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/MainButton.java +++ /dev/null @@ -1,124 +0,0 @@ -package se.leap.bitmaskclient.base.views; - -import android.annotation.TargetApi; -import android.content.Context; -import android.graphics.PorterDuff; -import android.graphics.drawable.AnimationDrawable; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.widget.RelativeLayout; - -import androidx.annotation.ColorRes; -import androidx.annotation.DrawableRes; -import androidx.appcompat.widget.AppCompatImageView; -import androidx.core.content.ContextCompat; - -import se.leap.bitmaskclient.R; - -public class MainButton extends RelativeLayout { - - private static final String TAG = MainButton.class.getSimpleName(); - - AppCompatImageView glow; - AppCompatImageView shadowLight; - AnimationDrawable glowAnimation; - - private boolean isOn = false; - private boolean isProcessing = false; - private boolean isError = true; - - - public MainButton(Context context) { - super(context); - initLayout(context); - } - - public MainButton(Context context, AttributeSet attrs) { - super(context, attrs); - initLayout(context); - } - - public MainButton(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - initLayout(context); - } - - - @TargetApi(21) - public MainButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - initLayout(context); - } - - private void initLayout(Context context) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View rootview = inflater.inflate(R.layout.v_main_btn, this, true); - - glow = rootview.findViewById(R.id.vpn_btn_glow); - glowAnimation = (AnimationDrawable) glow.getBackground(); - shadowLight = rootview.findViewById(R.id.vpn_btn_shadow_light); - } - - - private void stopGlowAnimation() { - AlphaAnimation fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); - fadeOutAnimation.setDuration(300); - fadeOutAnimation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) { - glow.setVisibility(GONE); - glowAnimation.stop(); - } - - @Override - public void onAnimationRepeat(Animation animation) {} - }); - glow.startAnimation(fadeOutAnimation); - } - - private void startGlowAnimation() { - glow.setAlpha(1.0f); - glow.setVisibility(VISIBLE); - glowAnimation.start(); - } - - public void updateState(boolean isOn, boolean isProcessing, boolean isError) { - if (this.isOn != isOn) { - this.isOn = isOn; - shadowLight.setVisibility(isOn ? VISIBLE : GONE); - } - - if (this.isProcessing != isProcessing) { - if (!isProcessing) { - stopGlowAnimation(); - } else { - startGlowAnimation(); - } - this.isProcessing = isProcessing; - } - - if (this.isError != isError) { - @DrawableRes int drawableResource = isOn ? R.drawable.on_off_btn_start_2_enabled : R.drawable.on_off_btn_start_2_disabled; - if (!isError) { - setImageWithTint(shadowLight, drawableResource, R.color.colorMainBtnHighlight); - } else { - setImageWithTint(shadowLight, drawableResource, R.color.colorMainBtnError); - } - this.isError = isError; - } - } - - private void setImageWithTint(AppCompatImageView view, @DrawableRes int resourceId, @ColorRes int color) { - view.setImageDrawable(ContextCompat.getDrawable(getContext(), resourceId)); - view.setColorFilter(ContextCompat.getColor(getContext(), color), PorterDuff.Mode.SRC_ATOP); - } - - - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/VpnStateImage.java b/app/src/main/java/se/leap/bitmaskclient/base/views/VpnStateImage.java deleted file mode 100644 index 2f8a4448..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/VpnStateImage.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2018 LEAP Encryption Access Project and contributers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package se.leap.bitmaskclient.base.views; - -import android.content.Context; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.appcompat.widget.AppCompatImageView; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.widget.ProgressBar; - -import se.leap.bitmaskclient.R; - -/** - * Created by cyberta on 12.02.18. - */ - - -public class VpnStateImage extends ConstraintLayout { - - ProgressBar progressBar; - AppCompatImageView stateIcon; - - public VpnStateImage(Context context) { - super(context); - initLayout(context); - } - - public VpnStateImage(Context context, AttributeSet attrs) { - super(context, attrs); - initLayout(context); - } - - public VpnStateImage(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - initLayout(context); - } - - void initLayout(Context context) { - LayoutInflater inflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View rootview = inflater.inflate(R.layout.v_main_button, this, true); - stateIcon = rootview.findViewById(R.id.vpn_state_key); - progressBar = rootview.findViewById(R.id.progressBar); - progressBar.setIndeterminate(true); - } - - public void showProgress() { - progressBar.setVisibility(VISIBLE); - } - - - public void stopProgress(boolean animated) { - if (!animated) { - progressBar.setVisibility(GONE); - return; - } - - AlphaAnimation fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); - fadeOutAnimation.setDuration(1000); - fadeOutAnimation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) { - progressBar.setVisibility(GONE); - } - - @Override - public void onAnimationRepeat(Animation animation) {} - }); - - progressBar.startAnimation(fadeOutAnimation); - } - - public void setStateIcon(int resource) { - stateIcon.setImageResource(resource); - } - - -} diff --git a/app/src/main/res/drawable-hdpi/ic_btn_cancel.png b/app/src/main/res/drawable-hdpi/ic_btn_cancel.png new file mode 100644 index 00000000..00feedcd Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_btn_cancel.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_btn_on.png b/app/src/main/res/drawable-hdpi/ic_btn_on.png new file mode 100644 index 00000000..2b37d25e Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_btn_on.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_btn_cancel.png b/app/src/main/res/drawable-xhdpi/ic_btn_cancel.png new file mode 100644 index 00000000..d623f8f5 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_btn_cancel.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_btn_on.png b/app/src/main/res/drawable-xhdpi/ic_btn_on.png new file mode 100644 index 00000000..4fdc9464 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_btn_on.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_btn_cancel.png b/app/src/main/res/drawable-xxhdpi/ic_btn_cancel.png new file mode 100644 index 00000000..af604d9b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_btn_cancel.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_btn_on.png b/app/src/main/res/drawable-xxhdpi/ic_btn_on.png new file mode 100644 index 00000000..d6cfc10b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_btn_on.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_btn_cancel.png b/app/src/main/res/drawable-xxxhdpi/ic_btn_cancel.png new file mode 100644 index 00000000..6c17bd78 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_btn_cancel.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_btn_on.png b/app/src/main/res/drawable-xxxhdpi/ic_btn_on.png new file mode 100644 index 00000000..b0e54b8c Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_btn_on.png differ diff --git a/app/src/main/res/drawable/button_circle_cancel.xml b/app/src/main/res/drawable/button_circle_cancel.xml new file mode 100644 index 00000000..1d94abca --- /dev/null +++ b/app/src/main/res/drawable/button_circle_cancel.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_cancel_pressed.xml b/app/src/main/res/drawable/button_circle_cancel_pressed.xml new file mode 100644 index 00000000..13970e9f --- /dev/null +++ b/app/src/main/res/drawable/button_circle_cancel_pressed.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_cancel_released.xml b/app/src/main/res/drawable/button_circle_cancel_released.xml new file mode 100644 index 00000000..2e7bc4b7 --- /dev/null +++ b/app/src/main/res/drawable/button_circle_cancel_released.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_start.xml b/app/src/main/res/drawable/button_circle_start.xml new file mode 100644 index 00000000..6d8482f4 --- /dev/null +++ b/app/src/main/res/drawable/button_circle_start.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_start_pressed.xml b/app/src/main/res/drawable/button_circle_start_pressed.xml new file mode 100644 index 00000000..ce8eb8e1 --- /dev/null +++ b/app/src/main/res/drawable/button_circle_start_pressed.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_start_released.xml b/app/src/main/res/drawable/button_circle_start_released.xml new file mode 100644 index 00000000..ce1ba997 --- /dev/null +++ b/app/src/main/res/drawable/button_circle_start_released.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_stop.xml b/app/src/main/res/drawable/button_circle_stop.xml new file mode 100644 index 00000000..674cbf15 --- /dev/null +++ b/app/src/main/res/drawable/button_circle_stop.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_stop_pressed.xml b/app/src/main/res/drawable/button_circle_stop_pressed.xml new file mode 100644 index 00000000..0561455a --- /dev/null +++ b/app/src/main/res/drawable/button_circle_stop_pressed.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_circle_stop_released.xml b/app/src/main/res/drawable/button_circle_stop_released.xml new file mode 100644 index 00000000..2e168c2d --- /dev/null +++ b/app/src/main/res/drawable/button_circle_stop_released.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_btn_cancel.png b/app/src/main/res/drawable/ic_btn_cancel.png new file mode 100644 index 00000000..0b55460a Binary files /dev/null and b/app/src/main/res/drawable/ic_btn_cancel.png differ diff --git a/app/src/main/res/drawable/ic_btn_on.png b/app/src/main/res/drawable/ic_btn_on.png new file mode 100644 index 00000000..be160a33 Binary files /dev/null and b/app/src/main/res/drawable/ic_btn_on.png differ diff --git a/app/src/main/res/layout/v_main_button.xml b/app/src/main/res/layout/v_main_button.xml deleted file mode 100644 index 741fc88f..00000000 --- a/app/src/main/res/layout/v_main_button.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 40b51436..dbc7326f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -14,6 +14,7 @@ #3b3b3b #AA424242 #22424242 + #00000000 #ef9a9a #f48fb1 @@ -45,5 +46,11 @@ @color/black800 @color/black800_high_transparent #B33A3A + #FF7D7D + #c84c51 + #FFBF00 + #C78F00 + #9FC17F + #709152 -- cgit v1.2.3