From b512528148c1662dbbe767c8568ebbe05dd72bb4 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Thu, 6 Feb 2020 15:55:28 +0100 Subject: [PATCH] Updated toolbar layout to match the new aesthetic --- .../magisk/legacy/flash/FlashViewModel.kt | 10 ++- app/src/main/res/layout/activity_flash.xml | 88 +++++-------------- app/src/main/res/menu/menu_flash.xml | 9 ++ 3 files changed, 42 insertions(+), 65 deletions(-) create mode 100644 app/src/main/res/menu/menu_flash.xml diff --git a/app/src/main/java/com/topjohnwu/magisk/legacy/flash/FlashViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/legacy/flash/FlashViewModel.kt index eea72ac7e..eececd0fd 100644 --- a/app/src/main/java/com/topjohnwu/magisk/legacy/flash/FlashViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/legacy/flash/FlashViewModel.kt @@ -5,6 +5,7 @@ import android.Manifest.permission.WRITE_EXTERNAL_STORAGE import android.content.res.Resources import android.net.Uri import android.os.Handler +import android.view.MenuItem import androidx.core.os.postDelayed import androidx.databinding.ObservableArrayList import com.topjohnwu.magisk.BR @@ -86,7 +87,14 @@ class FlashViewModel( } } - fun savePressed() = withPermissions(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) + fun onMenuItemClicked(item: MenuItem): Boolean { + when (item.itemId) { + R.id.action_save -> savePressed() + } + return true + } + + private fun savePressed() = withPermissions(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) .map { now } .map { it.toTime(timeFormatStandard) } .map { Const.MAGISK_INSTALL_LOG_FILENAME.format(it) } diff --git a/app/src/main/res/layout/activity_flash.xml b/app/src/main/res/layout/activity_flash.xml index e9070fbbf..af164be1b 100644 --- a/app/src/main/res/layout/activity_flash.xml +++ b/app/src/main/res/layout/activity_flash.xml @@ -18,78 +18,38 @@ - - + android:layout_height="wrap_content" + android:paddingLeft="@{viewModel.insets.left}" + android:paddingRight="@{viewModel.insets.right}"> + app:menu="@menu/menu_flash" + app:navigationIcon="@drawable/ic_back_md2"> - - - - - - - - - - - - - - - - - + android:layout_height="wrap_content" + android:layout_gravity="center" + android:fontFamily="monospace" + android:gravity="center" + android:textColor="?colorOnSurface" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:text="Flashing..." /> @@ -109,10 +69,10 @@ android:paddingBottom="@{viewModel.insets.bottom}" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:listitem="@layout/item_console" /> + tools:listitem="@layout/item_console_md2" /> + + + \ No newline at end of file