Skip to content

Commit

Permalink
Modified Menu and toolbar views for RunTestsActivity with proper st…
Browse files Browse the repository at this point in the history
…yling
  • Loading branch information
aanorbel committed Nov 3, 2023
1 parent 5fbc024 commit 3902641
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
android:label="Run tests"
android:name=".activity.runtests.RunTestsActivity"
android:parentActivityName=".activity.MainActivity"
android:exported="false"/>
android:exported="false"
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.App.NoActionBar"/>
<activity
android:name=".activity.PreferenceActivity"
android:launchMode="singleTop"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.MenuItem
import android.view.*
import org.openobservatory.ooniprobe.R
import org.openobservatory.ooniprobe.activity.AbstractActivity
import org.openobservatory.ooniprobe.activity.RunningActivity
import org.openobservatory.ooniprobe.activity.runtests.RunTestsViewModel.Companion.SELECT_NONE
import org.openobservatory.ooniprobe.activity.runtests.RunTestsViewModel.Companion.SELECT_ALL
import org.openobservatory.ooniprobe.activity.runtests.RunTestsViewModel.Companion.SELECT_NONE
import org.openobservatory.ooniprobe.activity.runtests.RunTestsViewModel.Companion.SELECT_SOME
import org.openobservatory.ooniprobe.activity.runtests.adapter.RunTestsExpandableListViewAdapter
import org.openobservatory.ooniprobe.activity.runtests.models.ChildItem
Expand Down Expand Up @@ -46,6 +46,8 @@ class RunTestsActivity : AbstractActivity() {
super.onCreate(savedInstanceState)
binding = ActivityRunTestsBinding.inflate(layoutInflater)
setContentView(binding.getRoot())

setSupportActionBar(binding.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)

activityComponent?.inject(this)
Expand Down Expand Up @@ -77,6 +79,23 @@ class RunTestsActivity : AbstractActivity() {

}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.close, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.close_button -> {
finish()
true
}

else -> super.onOptionsItemSelected(item)
}
}

private fun onMenuItemClickListener(menuItem: MenuItem): Boolean {
return when (menuItem.itemId) {
R.id.runButton -> {
Expand Down
19 changes: 15 additions & 4 deletions app/src/main/res/layout/activity_run_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@
android:layout_height="match_parent"
tools:context=".activity.runtests.RunTestsActivity">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_white"
app:menu="@menu/close"
app:layout_constraintTop_toTopOf="parent"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp" />

<LinearLayout
android:id="@+id/control_layout"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="16dp"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintEnd_toEndOf="parent">

<Button
android:id="@+id/select_all"
Expand Down Expand Up @@ -60,13 +71,13 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:theme="@style/Theme.MaterialComponents.NoActionBar.App">
android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar.App.NoActionBar">

<androidx.appcompat.widget.Toolbar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_base"
android:background="@color/color_white"
app:menu="@menu/run"
app:title="@string/OONIRun_URLs"
app:titleTextAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title.App" />
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/menu/close.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/close_button"
android:title="@string/OONIRun_Close"
android:icon="@drawable/close"
app:iconTint="@color/color_black"
app:showAsAction="ifRoom|withText" />
</menu>

0 comments on commit 3902641

Please sign in to comment.