diff options
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java | 51 | ||||
-rw-r--r-- | app/src/main/res/layout/v_location_status_indicator.xml | 196 |
2 files changed, 203 insertions, 44 deletions
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; } } diff --git a/app/src/main/res/layout/v_location_status_indicator.xml b/app/src/main/res/layout/v_location_status_indicator.xml index 97b55917..22453167 100644 --- a/app/src/main/res/layout/v_location_status_indicator.xml +++ b/app/src/main/res/layout/v_location_status_indicator.xml @@ -1,49 +1,193 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" - android:weightSum="100" - android:layout_margin="8dp" - > + android:layout_margin="8dp"> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_vertical_first" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.166" + /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_vertical_second" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.334" + /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_vertical_third" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.5" + /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_vertical_fourth" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.666" + /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_vertical_fifth" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.833" + /> + + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_horizontal_top" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.166" + /> + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_horizontal_upper" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.333" + /> + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_hoizontal_mid" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.5" + /> + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_hoizontal_lower" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.666" + /> + <androidx.constraintlayout.widget.Guideline + android:id="@+id/guideline_hoizontal_bottom" + android:layout_width="0dp" + android:layout_height="0dp" + android:orientation="horizontal" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintGuide_percent="0.833" + /> + <View - android:id="@+id/level3" - android:layout_width="match_parent" + android:id="@+id/level1" + android:layout_width="0dp" android:layout_height="0dp" - android:layout_weight="30" - android:background="@color/green200" - android:visibility="invisible" + android:background="@color/red200" + android:visibility="visible" + app:layout_constraintRight_toLeftOf="@+id/guideline_vertical_first" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/guideline_hoizontal_bottom" + android:layout_marginLeft="1dp" + android:layout_marginRight="1dp" + android:layout_marginStart="1dp" + android:layout_marginEnd="1dp" /> - <Space - android:layout_width="match_parent" + <View + android:id="@+id/level1_2" + android:layout_width="0dp" android:layout_height="0dp" - android:layout_weight="5" + android:background="@color/red200" + android:visibility="visible" + app:layout_constraintRight_toLeftOf="@+id/guideline_vertical_second" + app:layout_constraintLeft_toRightOf="@id/guideline_vertical_first" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/guideline_hoizontal_lower" + android:layout_marginLeft="1dp" + android:layout_marginRight="1dp" + android:layout_marginStart="1dp" + android:layout_marginEnd="1dp" /> <View android:id="@+id/level2" - android:layout_width="match_parent" + android:layout_width="0dp" android:layout_height="0dp" - android:layout_weight="30" - android:background="@color/green200" - android:visibility="invisible" + android:background="@color/yellow200" + android:visibility="visible" + app:layout_constraintRight_toLeftOf="@+id/guideline_vertical_third" + app:layout_constraintLeft_toRightOf="@id/guideline_vertical_second" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/guideline_hoizontal_mid" + android:layout_marginLeft="1dp" + android:layout_marginRight="1dp" + android:layout_marginStart="1dp" + android:layout_marginEnd="1dp" /> - <Space - android:layout_width="match_parent" + <View + android:id="@+id/level2_2" + android:layout_width="0dp" android:layout_height="0dp" - android:layout_weight="5" + android:background="@color/yellow200" + android:visibility="visible" + app:layout_constraintRight_toLeftOf="@+id/guideline_vertical_fourth" + app:layout_constraintLeft_toRightOf="@id/guideline_vertical_third" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/guideline_horizontal_upper" + android:layout_marginLeft="1dp" + android:layout_marginRight="1dp" + android:layout_marginStart="1dp" + android:layout_marginEnd="1dp" /> <View - android:id="@+id/level1" - android:layout_width="match_parent" + android:id="@+id/level3" + android:layout_width="0dp" + android:layout_height="0dp" + android:background="@color/green200" + android:visibility="visible" + app:layout_constraintRight_toLeftOf="@+id/guideline_vertical_fifth" + app:layout_constraintLeft_toRightOf="@id/guideline_vertical_fourth" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/guideline_horizontal_top" + android:layout_marginLeft="1dp" + android:layout_marginRight="1dp" + android:layout_marginStart="1dp" + android:layout_marginEnd="1dp" + /> + + <View + android:id="@+id/level3_2" + android:layout_width="0dp" android:layout_height="0dp" - android:layout_weight="30" android:background="@color/green200" - android:visibility="invisible" - /> + android:visibility="visible" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintLeft_toLeftOf="@id/guideline_vertical_fifth" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toTopOf="parent" + android:layout_marginLeft="1dp" + android:layout_marginRight="1dp" + android:layout_marginStart="1dp" + android:layout_marginEnd="1dp" + /> -</LinearLayout>
\ No newline at end of file +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file |