mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-16 12:11:26 +00:00
fix restart button focus on flash result
This commit is contained in:
parent
482a5b991b
commit
e0d5d90267
@ -6,6 +6,7 @@ import android.content.pm.ActivityInfo
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.navigation.NavDeepLinkBuilder
|
import androidx.navigation.NavDeepLinkBuilder
|
||||||
import com.topjohnwu.magisk.MainDirections
|
import com.topjohnwu.magisk.MainDirections
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
@ -37,6 +38,15 @@ class FlashFragment : BaseFragment<FragmentFlashMd2Binding>() {
|
|||||||
viewModel.subtitle.observe(this) {
|
viewModel.subtitle.observe(this) {
|
||||||
activity?.supportActionBar?.setSubtitle(it)
|
activity?.supportActionBar?.setSubtitle(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.flashResult.observe(this) { success ->
|
||||||
|
binding.restartBtn.apply {
|
||||||
|
if (success && viewModel.showReboot) {
|
||||||
|
if (!this.isVisible) this.show()
|
||||||
|
if (!this.isFocused) this.requestFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
@ -66,7 +76,7 @@ class FlashFragment : BaseFragment<FragmentFlashMd2Binding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onKeyEvent(event: KeyEvent): Boolean {
|
override fun onKeyEvent(event: KeyEvent): Boolean {
|
||||||
return when(event.keyCode) {
|
return when (event.keyCode) {
|
||||||
KeyEvent.KEYCODE_VOLUME_UP,
|
KeyEvent.KEYCODE_VOLUME_UP,
|
||||||
KeyEvent.KEYCODE_VOLUME_DOWN -> true
|
KeyEvent.KEYCODE_VOLUME_DOWN -> true
|
||||||
else -> false
|
else -> false
|
||||||
|
@ -34,6 +34,10 @@ class FlashViewModel : BaseViewModel() {
|
|||||||
private val _subtitle = MutableLiveData(R.string.flashing)
|
private val _subtitle = MutableLiveData(R.string.flashing)
|
||||||
val subtitle get() = _subtitle as LiveData<Int>
|
val subtitle get() = _subtitle as LiveData<Int>
|
||||||
|
|
||||||
|
private val _flashResult = MutableLiveData<Boolean>()
|
||||||
|
val flashResult: LiveData<Boolean>
|
||||||
|
get() = _flashResult
|
||||||
|
|
||||||
val items = diffListOf<ConsoleItem>()
|
val items = diffListOf<ConsoleItem>()
|
||||||
lateinit var args: FlashFragmentArgs
|
lateinit var args: FlashFragmentArgs
|
||||||
|
|
||||||
@ -88,6 +92,7 @@ class FlashViewModel : BaseViewModel() {
|
|||||||
success -> _subtitle.postValue(R.string.done)
|
success -> _subtitle.postValue(R.string.done)
|
||||||
else -> _subtitle.postValue(R.string.failure)
|
else -> _subtitle.postValue(R.string.failure)
|
||||||
}
|
}
|
||||||
|
_flashResult.value = success
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMenuItemClicked(item: MenuItem): Boolean {
|
fun onMenuItemClicked(item: MenuItem): Boolean {
|
||||||
@ -100,7 +105,8 @@ class FlashViewModel : BaseViewModel() {
|
|||||||
private fun savePressed() = withExternalRW {
|
private fun savePressed() = withExternalRW {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val name = "magisk_install_log_%s.log".format(
|
val name = "magisk_install_log_%s.log".format(
|
||||||
System.currentTimeMillis().toTime(timeFormatStandard))
|
System.currentTimeMillis().toTime(timeFormatStandard)
|
||||||
|
)
|
||||||
val file = MediaStoreUtils.getFile(name, true)
|
val file = MediaStoreUtils.getFile(name, true)
|
||||||
file.uri.outputStream().bufferedWriter().use { writer ->
|
file.uri.outputStream().bufferedWriter().use { writer ->
|
||||||
synchronized(logItems) {
|
synchronized(logItems) {
|
||||||
|
@ -24,13 +24,13 @@
|
|||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/flash_content"
|
android:id="@+id/flash_content"
|
||||||
app:items="@{viewModel.items}"
|
|
||||||
scrollToLast="@{true}"
|
scrollToLast="@{true}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:fitsSystemWindowsInsets="start|end|bottom"
|
app:fitsSystemWindowsInsets="start|end|bottom"
|
||||||
|
app:items="@{viewModel.items}"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
tools:listitem="@layout/item_console_md2" />
|
tools:listitem="@layout/item_console_md2" />
|
||||||
@ -38,27 +38,31 @@
|
|||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
|
android:id="@+id/restart_btn"
|
||||||
gone="@{!viewModel.loaded || !viewModel.showReboot}"
|
gone="@{!viewModel.loaded || !viewModel.showReboot}"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom|end"
|
android:layout_gravity="bottom|end"
|
||||||
android:layout_margin="@dimen/l1"
|
android:layout_margin="@dimen/l1"
|
||||||
android:layout_marginBottom="@dimen/l1"
|
android:layout_marginBottom="@dimen/l1"
|
||||||
|
android:clickable="@{!viewModel.loaded}"
|
||||||
|
android:enabled="@{viewModel.loaded}"
|
||||||
|
android:focusable="true"
|
||||||
android:onClick="@{() -> viewModel.restartPressed()}"
|
android:onClick="@{() -> viewModel.restartPressed()}"
|
||||||
android:text="@string/reboot"
|
android:text="@string/reboot"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:textColor="?colorOnPrimary"
|
android:textColor="?colorOnPrimary"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_fitsSystemWindowsInsets="bottom"
|
|
||||||
app:backgroundTint="?colorPrimary"
|
app:backgroundTint="?colorPrimary"
|
||||||
app:icon="@drawable/ic_restart"
|
app:icon="@drawable/ic_restart"
|
||||||
app:iconTint="?colorOnPrimary" />
|
app:iconTint="?colorOnPrimary"
|
||||||
|
app:layout_fitsSystemWindowsInsets="bottom" />
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:id="@+id/snackbar_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/snackbar_container"
|
app:fitsSystemWindowsInsets="top|bottom" />
|
||||||
app:fitsSystemWindowsInsets="top|bottom"/>
|
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user