Unverified Commit 95a5b572 authored by Rikka's avatar Rikka Committed by GitHub

Remove "Flashing" overlay

Fix #3579, fix #3250
parent 13fbf397
...@@ -41,6 +41,11 @@ abstract class BaseUIFragment<VM : BaseViewModel, Binding : ViewDataBinding> : ...@@ -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)
......
...@@ -29,6 +29,6 @@ val viewModelModules = module { ...@@ -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()) }
} }
...@@ -32,6 +32,10 @@ class FlashFragment : BaseUIFragment<FlashViewModel, FragmentFlashMd2Binding>() ...@@ -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) {
......
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 ...@@ -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( ...@@ -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)
} }
} }
......
...@@ -56,29 +56,6 @@ ...@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment