summaryrefslogtreecommitdiff
path: root/app/src/normal/java
diff options
context:
space:
mode:
authorcyberta <cyberta@riseup.net>2022-11-29 00:58:36 +0100
committercyberta <cyberta@riseup.net>2022-11-30 14:19:39 +0100
commit0cf31d76c9f48cc73446b3fde478a46cd29c7594 (patch)
tree960fc28ddc55841e137431c3583a85a868eedca5 /app/src/normal/java
parent86619a6ebb4508cd75584f12db69b2c1ed22ef2d (diff)
split EipFragment and MainButon into normal and custom flavor, implement new on-off button design for Bitmask
Diffstat (limited to 'app/src/normal/java')
-rw-r--r--app/src/normal/java/se/leap/bitmaskclient/base/views/MainButton.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/src/normal/java/se/leap/bitmaskclient/base/views/MainButton.java b/app/src/normal/java/se/leap/bitmaskclient/base/views/MainButton.java
new file mode 100644
index 00000000..d8766e6b
--- /dev/null
+++ b/app/src/normal/java/se/leap/bitmaskclient/base/views/MainButton.java
@@ -0,0 +1,64 @@
+package se.leap.bitmaskclient.base.views;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.widget.RelativeLayout;
+
+import androidx.appcompat.widget.AppCompatImageView;
+import androidx.core.content.ContextCompat;
+
+import se.leap.bitmaskclient.R;
+import se.leap.bitmaskclient.databinding.VMainButtonBinding;
+
+public class MainButton extends RelativeLayout {
+
+ private static final String TAG = MainButton.class.getSimpleName();
+
+ AppCompatImageView button;
+ VMainButtonBinding binding;
+
+ 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) {
+ binding = VMainButtonBinding.inflate(LayoutInflater.from(context), this, true);
+ button = binding.button;
+ }
+
+ public void updateState(boolean isOn, boolean isProcessing, boolean isError) {
+ if (isProcessing) {
+ button.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.button_circle_cancel));
+ } else {
+ button.setImageDrawable(
+ ContextCompat.getDrawable(getContext(),
+ isOn ? R.drawable.button_circle_stop : R.drawable.button_circle_start));
+ }
+ }
+
+}