Remove "Flashing" overlay

Fix #3579, fix #3250
This commit is contained in:
Rikka 2021-01-16 13:28:59 +08:00 committed by GitHub
parent 13fbf397d1
commit 95a5b57265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 33 deletions

View File

@ -41,6 +41,11 @@ abstract class BaseUIFragment<VM : BaseViewModel, Binding : ViewDataBinding> :
return binding.root return binding.root
} }
override fun onStart() {
super.onStart()
activity.supportActionBar?.subtitle = null
}
override fun onEventDispatched(event: ViewEvent) = when(event) { override fun onEventDispatched(event: ViewEvent) = when(event) {
is ContextExecutor -> event(requireContext()) is ContextExecutor -> event(requireContext())
is ActivityExecutor -> event(activity) is ActivityExecutor -> event(activity)

View File

@ -29,6 +29,6 @@ val viewModelModules = module {
viewModel { MainViewModel() } viewModel { MainViewModel() }
// Legacy // Legacy
viewModel { (args: FlashFragmentArgs) -> FlashViewModel(args, get()) } viewModel { (args: FlashFragmentArgs) -> FlashViewModel(args) }
viewModel { SuRequestViewModel(get(), get(), get(SUTimeout), get()) } viewModel { SuRequestViewModel(get(), get(), get(SUTimeout), get()) }
} }

View File

@ -32,6 +32,10 @@ class FlashFragment : BaseUIFragment<FlashViewModel, FragmentFlashMd2Binding>()
super.onStart() super.onStart()
setHasOptionsMenu(true) setHasOptionsMenu(true)
activity.setTitle(R.string.flash_screen_title) activity.setTitle(R.string.flash_screen_title)
viewModel.subtitle.observe(this) {
activity.supportActionBar?.setSubtitle(it)
}
} }
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {

View File

@ -1,9 +1,10 @@
package com.topjohnwu.magisk.ui.flash package com.topjohnwu.magisk.ui.flash
import android.content.res.Resources
import android.net.Uri import android.net.Uri
import android.view.MenuItem import android.view.MenuItem
import androidx.databinding.Bindable import androidx.databinding.Bindable
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
@ -26,17 +27,15 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class FlashViewModel( class FlashViewModel(
args: FlashFragmentArgs, args: FlashFragmentArgs
private val resources: Resources
) : BaseViewModel() { ) : BaseViewModel() {
@get:Bindable @get:Bindable
var showReboot = Shell.rootAccess() var showReboot = Shell.rootAccess()
set(value) = set(value, field, { field = it }, BR.showReboot) set(value) = set(value, field, { field = it }, BR.showReboot)
@get:Bindable private val _subtitle = MutableLiveData(R.string.flashing)
var behaviorText = resources.getString(R.string.flashing) val subtitle get() = _subtitle as LiveData<Int>
set(value) = set(value, field, { field = it }, BR.behaviorText)
val adapter = RvBindingAdapter<ConsoleItem>() val adapter = RvBindingAdapter<ConsoleItem>()
val items = diffListOf<ConsoleItem>() val items = diffListOf<ConsoleItem>()
@ -91,9 +90,9 @@ class FlashViewModel(
private fun onResult(success: Boolean) { private fun onResult(success: Boolean) {
state = if (success) State.LOADED else State.LOADING_FAILED state = if (success) State.LOADED else State.LOADING_FAILED
behaviorText = when { when {
success -> resources.getString(R.string.done) success -> _subtitle.postValue(R.string.done)
else -> resources.getString(R.string.failure) else -> _subtitle.postValue(R.string.failure)
} }
} }

View File

@ -56,29 +56,6 @@
app:icon="@drawable/ic_restart" app:icon="@drawable/ic_restart"
app:iconTint="?colorOnPrimary" /> app:iconTint="?colorOnPrimary" />
<com.google.android.material.card.MaterialCardView
style="@style/WidgetFoundation.Card.Elevated"
goneUnless="@{viewModel.loading}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:contentPadding="@dimen/l1">
<TextView
movieBehavior="@{viewModel.loading}"
movieBehaviorText="@{viewModel.behaviorText}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="monospace"
android:gravity="center"
android:textAppearance="@style/AppearanceFoundation.Body"
android:textColor="?colorOnSurface"
android:textStyle="bold"
tools:text="Flashing..." />
</com.google.android.material.card.MaterialCardView>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout> </layout>