summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2021-11-28 21:09:02 +0100
committercyBerta <cyberta@riseup.net>2021-11-28 21:09:02 +0100
commit3228b17f43b232116c192728438954c4c1412ec3 (patch)
tree24fc23c58a7b511522d7071bfe8f119b7b19355a /app
parent0ae22b0017c4796d0f27482b83ed282c1dbe7fea (diff)
make location button icon tint color configurable, use white tint for riseupvpn
Diffstat (limited to 'app')
-rw-r--r--app/src/custom/res/values/custom-theme.xml4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/views/LocationIndicator.java42
-rw-r--r--app/src/main/res/layout/v_location_button.xml5
-rw-r--r--app/src/main/res/values/attrs.xml4
-rw-r--r--app/src/main/res/values/colors.xml3
5 files changed, 39 insertions, 19 deletions
diff --git a/app/src/custom/res/values/custom-theme.xml b/app/src/custom/res/values/custom-theme.xml
index 91b48f8c..a17b401c 100644
--- a/app/src/custom/res/values/custom-theme.xml
+++ b/app/src/custom/res/values/custom-theme.xml
@@ -15,5 +15,7 @@
<color name="colorMainBtnHighlight">#58FFA9</color>
<!-- glow effect color of the on / off button if no network / traffic blocked -->
<color name="colorMainBtnError">#eF2222</color>
-
+ <!-- location button icon tint color -->
+ <color name="colorLocationButtonTint">#ffffff</color>
+ <color name="colorLocationButtonTintTransparent">#22ffffff</color>
</resources>
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 72ad03f9..08a852ec 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
@@ -1,13 +1,13 @@
package se.leap.bitmaskclient.base.views;
import android.content.Context;
+import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
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;
@@ -22,25 +22,26 @@ public class LocationIndicator extends LinearLayout {
private View level2_2;
private View level3;
private View level3_2;
+ private int tintColor;
public LocationIndicator(Context context) {
super(context);
- initLayout(context);
+ initLayout(context, null);
}
public LocationIndicator(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
- initLayout(context);
+ initLayout(context, attrs);
}
public LocationIndicator(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- initLayout(context);
+ initLayout(context, attrs);
}
- void initLayout(Context context) {
+ void initLayout(Context context, AttributeSet attrs) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootview = inflater.inflate(R.layout.v_location_status_indicator, this, true);
@@ -50,6 +51,13 @@ public class LocationIndicator extends LinearLayout {
level2_2 = rootview.findViewById(R.id.level2_2);
level3 = rootview.findViewById(R.id.level3);
level3_2 = rootview.findViewById(R.id.level3_2);
+ if (attrs != null) {
+ TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LocationIndicator);
+ this.tintColor = typedArray.getColor(R.styleable.LocationIndicator_tint, getColor(context, R.color.black800_high_transparent));
+ typedArray.recycle();
+ } else {
+ this.tintColor = getColor(context, R.color.black800_high_transparent);
+ }
}
public void setLoad(GatewaysManager.Load load) {
@@ -67,24 +75,24 @@ public class LocationIndicator extends LinearLayout {
level1_2.setBackgroundColor(getColor(getContext(), R.color.amber200));
level2.setBackgroundColor(getColor(getContext(), R.color.amber200));
level2_2.setBackgroundColor(getColor(getContext(), R.color.amber200));
- level3.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent));
- level3_2.setBackgroundColor(getColor(getContext(), R.color.black800_high_transparent));
+ level3.setBackgroundColor(tintColor);
+ level3_2.setBackgroundColor(tintColor);
break;
case CRITICAL:
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));
+ level2.setBackgroundColor(tintColor);
+ level2_2.setBackgroundColor(tintColor);
+ level3.setBackgroundColor(tintColor);
+ level3_2.setBackgroundColor(tintColor);
break;
default:
- 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));;
+ level1.setBackgroundColor(tintColor);
+ level1_2.setBackgroundColor(tintColor);
+ level2.setBackgroundColor(tintColor);
+ level2_2.setBackgroundColor(tintColor);
+ level3.setBackgroundColor(tintColor);
+ level3_2.setBackgroundColor(tintColor);
break;
}
}
diff --git a/app/src/main/res/layout/v_location_button.xml b/app/src/main/res/layout/v_location_button.xml
index 3779a964..7f16a6b1 100644
--- a/app/src/main/res/layout/v_location_button.xml
+++ b/app/src/main/res/layout/v_location_button.xml
@@ -18,6 +18,7 @@
android:scaleType="fitCenter"
android:src="@drawable/ic_web"
android:layout_gravity="center"
+ app:tint="@color/colorLocationButtonTint"
/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/recommended_icn"
@@ -31,6 +32,8 @@
android:layout_toEndOf="@id/world_icn"
android:layout_toRightOf="@id/world_icn"
android:src="@drawable/ic_lightning_bolt"
+ app:tint="@color/colorLocationButtonTint"
+
android:visibility="gone"
tools:visibility="visible"
/>
@@ -77,6 +80,7 @@
android:src="@drawable/ic_bridge_36"
android:visibility="gone"
tools:visibility="visible"
+ app:tint="@color/colorLocationButtonTint"
/>
<se.leap.bitmaskclient.base.views.LocationIndicator
@@ -91,6 +95,7 @@
android:paddingBottom="@dimen/stdpadding"
android:visibility="visible"
android:layout_gravity="center_vertical"
+ app:tint="@color/colorLocationButtonTintTransparent"
/>
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
index 5631e3f3..2bf4d8ce 100644
--- a/app/src/main/res/values/attrs.xml
+++ b/app/src/main/res/values/attrs.xml
@@ -9,6 +9,7 @@
<attr name="icon" format="reference"/>
<attr name="subtitle" format="string|reference"/>
<attr name="singleLine" format="boolean"/>
+ <attr name="tint" format="reference|color" />
<declare-styleable name="IconSwitchEntry">
<attr name="text"/>
<attr name="subtitle" />
@@ -22,4 +23,7 @@
<attr name="icon"/>
<attr name="singleLine"/>
</declare-styleable>
+ <declare-styleable name="LocationIndicator">
+ <attr name="tint"/>
+ </declare-styleable>
</resources> \ 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 c1039f70..792db1ee 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -41,7 +41,8 @@
<color name="colorEipFragmentFont">@color/black800</color>
<color name="colorFontBtn">@color/black800</color>
<color name="colorFontBtnEnabled">@color/white</color>
-
+ <color name="colorLocationButtonTint">@color/black800</color>
+ <color name="colorLocationButtonTintTransparent">@color/black800_high_transparent</color>
<color name="colorWarning">#B33A3A</color>
</resources>