From bfb445f4ccb320dd955468bb2090771ab23408f6 Mon Sep 17 00:00:00 2001 From: Norbel Ambanumben Date: Tue, 24 Oct 2023 21:19:13 +0100 Subject: [PATCH] Updated Run v1 UI with new components --- app/src/main/AndroidManifest.xml | 2 +- .../ooniprobe/activity/OoniRunActivity.java | 25 +++++++++ app/src/main/res/layout/activity_oonirun.xml | 55 ++++++++++++------- 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1b717a3e5..a3e217c42 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -108,7 +108,7 @@ urls) { binding.iconBig.setImageResource(suite.getIcon()); binding.iconBig.setVisibility(View.VISIBLE); } + setThemeColor(getResources().getColor(suite.getColor())); binding.run.setOnClickListener(v -> { RunningActivity.runAsForegroundService(OoniRunActivity.this, suite.asArray(),this::finish, preferenceManager); @@ -161,7 +166,27 @@ private void loadSuite(AbstractSuite suite, List urls) { }); } + public void setThemeColor(int color) { + Window window = getWindow(); + window.setStatusBarColor(color); + binding.appbarLayout.setBackgroundColor(color); + if (ColorUtils.calculateLuminance(color) > 0.5) { + setTextColor(getResources().getColor(R.color.color_black)); + } else { + binding.title.setTextColor(getResources().getColor(R.color.color_white)); + } + } + + public void setTextColor(int color){ + binding.title.setTextColor(color); + binding.icon.setColorFilter(color); + binding.desc.setTextColor(color); + binding.run.setTextColor(color); + binding.run.setStrokeColor(ColorStateList.valueOf(color)); + } + private void loadInvalidAttributes() { + setTextColor(getResources().getColor(R.color.color_black)); binding.title.setText(R.string.OONIRun_InvalidParameter); binding.desc.setText(R.string.OONIRun_InvalidParameter_Msg); binding.run.setText(R.string.OONIRun_Close); diff --git a/app/src/main/res/layout/activity_oonirun.xml b/app/src/main/res/layout/activity_oonirun.xml index fee9299a2..723579c47 100644 --- a/app/src/main/res/layout/activity_oonirun.xml +++ b/app/src/main/res/layout/activity_oonirun.xml @@ -1,10 +1,13 @@ @@ -22,27 +25,48 @@ android:orientation="vertical" app:layout_collapseMode="parallax"> - - + android:text="@string/OONIRun_InvalidParameter" + tools:text="@string/OONIRun_TestName" /> + + + android:layout_marginTop="8dp" + android:text="@string/OONIRun_YouAreAboutToRun" + android:textColor="@color/color_white"/> + + -