From 551ee22aafae99c1f0802ec48f43d448cc77db37 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 22 Jul 2021 15:31:08 +0200 Subject: first implementation of the gateway button, started to remove labels from EipFragment, implement method to get the avearage load of a location as an enum value --- .../base/views/LocationIndicator.java | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java (limited to 'app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java new file mode 100644 index 00000000..f5e3dbe2 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java @@ -0,0 +1,76 @@ +package se.leap.bitmaskclient.base.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; + +import androidx.annotation.Nullable; + +import se.leap.bitmaskclient.R; +import se.leap.bitmaskclient.eip.GatewaysManager; + +public class LocationIndicator extends LinearLayout { + + private View level1; + private View level2; + private View level3; + + public LocationIndicator(Context context) { + super(context); + initLayout(context); + } + + public LocationIndicator(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + initLayout(context); + + } + + public LocationIndicator(Context context, @Nullable 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_location_status_indicator, this, true); + level1 = rootview.findViewById(R.id.level1); + level2 = rootview.findViewById(R.id.level2); + level3 = rootview.findViewById(R.id.level3); + } + + public void setLoad(GatewaysManager.Load load) { + switch (load) { + case GOOD: + level1.setBackgroundColor(getResources().getColor(R.color.green200)); + level2.setBackgroundColor(getResources().getColor(R.color.green200)); + level3.setBackgroundColor(getResources().getColor(R.color.green200)); + level1.setVisibility(VISIBLE); + level2.setVisibility(VISIBLE); + level3.setVisibility(VISIBLE); + break; + case AVERAGE: + level1.setBackgroundColor(getResources().getColor(R.color.yellow200)); + level2.setBackgroundColor(getResources().getColor(R.color.yellow200)); + level1.setVisibility(VISIBLE); + level2.setVisibility(VISIBLE); + level3.setVisibility(INVISIBLE); + break; + case CRITICAL: + level1.setBackgroundColor(getResources().getColor(R.color.red200)); + level1.setVisibility(VISIBLE); + level2.setVisibility(INVISIBLE); + level3.setVisibility(INVISIBLE); + break; + default: + level1.setVisibility(INVISIBLE); + level2.setVisibility(INVISIBLE); + level3.setVisibility(INVISIBLE); + break; + } + } +} -- cgit v1.2.3 From 96a397b01da596204e3e9d1ff2dd2c176f76e5b3 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 15 Nov 2021 20:42:58 +0100 Subject: improve location status indicator, adapt according to desktop --- .../base/views/LocationIndicator.java | 51 ++++++++++++++-------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java index f5e3dbe2..8245893d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java @@ -7,15 +7,21 @@ import android.view.View; import android.widget.LinearLayout; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.eip.GatewaysManager; +import static androidx.core.content.ContextCompat.getColor; + public class LocationIndicator extends LinearLayout { private View level1; + private View level1_2; private View level2; + private View level2_2; private View level3; + private View level3_2; public LocationIndicator(Context context) { super(context); @@ -39,37 +45,46 @@ public class LocationIndicator extends LinearLayout { .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rootview = inflater.inflate(R.layout.v_location_status_indicator, this, true); level1 = rootview.findViewById(R.id.level1); + level1_2 = rootview.findViewById(R.id.level1_2); level2 = rootview.findViewById(R.id.level2); + level2_2 = rootview.findViewById(R.id.level2_2); level3 = rootview.findViewById(R.id.level3); + level3_2 = rootview.findViewById(R.id.level3_2); } public void setLoad(GatewaysManager.Load load) { switch (load) { case GOOD: - level1.setBackgroundColor(getResources().getColor(R.color.green200)); - level2.setBackgroundColor(getResources().getColor(R.color.green200)); - level3.setBackgroundColor(getResources().getColor(R.color.green200)); - level1.setVisibility(VISIBLE); - level2.setVisibility(VISIBLE); - level3.setVisibility(VISIBLE); + level1.setBackgroundColor(getColor(getContext(), R.color.green200)); + level1_2.setBackgroundColor(getColor(getContext(), R.color.green200)); + level2.setBackgroundColor(getColor(getContext(), R.color.green200)); + level2_2.setBackgroundColor(getColor(getContext(), R.color.green200)); + level3.setBackgroundColor(getColor(getContext(), R.color.green200)); + level3_2.setBackgroundColor(getColor(getContext(), R.color.green200)); break; case AVERAGE: - level1.setBackgroundColor(getResources().getColor(R.color.yellow200)); - level2.setBackgroundColor(getResources().getColor(R.color.yellow200)); - level1.setVisibility(VISIBLE); - level2.setVisibility(VISIBLE); - level3.setVisibility(INVISIBLE); + level1.setBackgroundColor(getColor(getContext(), R.color.yellow200)); + level1_2.setBackgroundColor(getColor(getContext(), R.color.yellow200)); + level2.setBackgroundColor(getColor(getContext(), R.color.yellow200)); + level2_2.setBackgroundColor(getColor(getContext(), R.color.yellow200)); + level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); break; case CRITICAL: - level1.setBackgroundColor(getResources().getColor(R.color.red200)); - level1.setVisibility(VISIBLE); - level2.setVisibility(INVISIBLE); - level3.setVisibility(INVISIBLE); + level1.setBackgroundColor(getColor(getContext(), R.color.red200)); + level1_2.setBackgroundColor(getColor(getContext(), R.color.red200)); + level2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level2_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); break; default: - level1.setVisibility(INVISIBLE); - level2.setVisibility(INVISIBLE); - level3.setVisibility(INVISIBLE); + level1.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level1_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level2_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent)); + level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent));; break; } } -- cgit v1.2.3