Skip to content

Commit

Permalink
Updated Run v1 UI with new components
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Oct 24, 2023
1 parent a9d8054 commit bfb445f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</activity>
<activity
android:name=".activity.OoniRunActivity"
android:label="@string/APP_NAME"
android:label=""
android:exported="true"
android:launchMode="singleTop"
android:parentActivityName=".activity.MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.openobservatory.ooniprobe.activity;

import android.content.Intent;
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Bundle;
import android.util.Patterns;
import android.view.View;
import android.view.Window;
import android.webkit.URLUtil;
import android.widget.Toast;

import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;

Expand Down Expand Up @@ -127,6 +130,7 @@ private void loadScreen(String mv, String tn, String ta){
}

private void loadOutOfDate() {
setTextColor(getResources().getColor(R.color.color_black));
binding.title.setText(R.string.OONIRun_OONIProbeOutOfDate);
binding.desc.setText(R.string.OONIRun_OONIProbeNewerVersion);
binding.run.setText(R.string.OONIRun_Update);
Expand Down Expand Up @@ -154,14 +158,35 @@ private void loadSuite(AbstractSuite suite, List<String> 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);

});
}

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);
Expand Down
55 changes: 35 additions & 20 deletions app/src/main/res/layout/activity_oonirun.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
tools:context=".activity.OoniRunActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand All @@ -22,27 +25,48 @@
android:orientation="vertical"
app:layout_collapseMode="parallax">

<ImageView
android:id="@+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_horizontal"
app:tint="@color/color_gray9" />

<TextView
android:id="@+id/title"
style="@style/TextAppearance.MaterialComponents.Headline6"
style="@style/TextAppearance.MaterialComponents.Headline5"
android:textColor="@color/color_white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/OONIRun_InvalidParameter" />
android:text="@string/OONIRun_InvalidParameter"
tools:text="@string/OONIRun_TestName" />

<ImageView
android:id="@+id/icon"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
app:tint="@color/color_white"
tools:src="@drawable/test_websites"/>

<TextView
android:id="@+id/desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/OONIRun_YouAreAboutToRun" />
android:layout_marginTop="8dp"
android:text="@string/OONIRun_YouAreAboutToRun"
android:textColor="@color/color_white"/>

<com.google.android.material.button.MaterialButton
android:id="@+id/run"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:text="@string/OONIRun_Run"
android:textAllCaps="false"
android:textColor="@android:color/white"
app:cornerRadius="24dp"
app:rippleColor="@color/ripple_material_dark"
app:strokeColor="@android:color/white" />
</LinearLayout>

<androidx.appcompat.widget.Toolbar
Expand All @@ -67,18 +91,9 @@
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="32dp"
android:paddingBottom="64dp"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<Button
android:id="@+id/run"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_margin="16dp"
android:text="@string/OONIRun_Run"
android:textAllCaps="false"
android:backgroundTint="@color/color_base"
app:cornerRadius="24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout><!-- app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" -->

0 comments on commit bfb445f

Please sign in to comment.