Updated Flash / SuRequest activities with app themes

CompatActivity/Fragment logic has been moved to respective BaseUI. Some deprecated and unused styles have been removed in favor or newer themes.
This commit is contained in:
Viktor De Pasquale 2020-01-27 18:12:32 +01:00 committed by John Wu
parent fbe776db0b
commit 7bf7bfb9c6
22 changed files with 177 additions and 311 deletions

View File

@ -9,14 +9,14 @@ import androidx.core.net.toUri
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Const
import com.topjohnwu.magisk.core.intent
import com.topjohnwu.magisk.core.view.Notifications
import com.topjohnwu.magisk.databinding.ActivityFlashBinding
import com.topjohnwu.magisk.extensions.snackbar
import com.topjohnwu.magisk.model.events.BackPressEvent
import com.topjohnwu.magisk.model.events.PermissionEvent
import com.topjohnwu.magisk.model.events.SnackbarEvent
import com.topjohnwu.magisk.model.events.ViewEvent
import com.topjohnwu.magisk.ui.base.BaseUIActivity
import com.topjohnwu.magisk.core.view.Notifications
import com.topjohnwu.magisk.ui.base.CompatNavigationDelegate
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import java.io.File
@ -24,7 +24,6 @@ import java.io.File
open class FlashActivity : BaseUIActivity<FlashViewModel, ActivityFlashBinding>() {
override val layoutRes: Int = R.layout.activity_flash
override val themeRes: Int = R.style.MagiskTheme_Flashing
override val viewModel: FlashViewModel by viewModel {
val uri = intent.data ?: let { finish(); Uri.EMPTY }
val additionalUri = intent.getParcelableExtra(Const.Key.FLASH_DATA) ?: uri
@ -32,6 +31,9 @@ open class FlashActivity : BaseUIActivity<FlashViewModel, ActivityFlashBinding>(
parametersOf(action, uri, additionalUri)
}
override val navigation: CompatNavigationDelegate<BaseUIActivity<FlashViewModel, ActivityFlashBinding>>? =
null
override fun onCreate(savedInstanceState: Bundle?) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
super.onCreate(savedInstanceState)
@ -49,7 +51,6 @@ open class FlashActivity : BaseUIActivity<FlashViewModel, ActivityFlashBinding>(
super.onEventDispatched(event)
when (event) {
is SnackbarEvent -> snackbar(snackbarView, event.message(this), event.length, event.f)
is BackPressEvent -> onBackPressed()
is PermissionEvent -> withPermissions(*event.permissions.toTypedArray()) {
onSuccess { event.callback.onNext(true) }
onFailure {

View File

@ -13,7 +13,7 @@ import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Const
import com.topjohnwu.magisk.databinding.ComparableRvItem
import com.topjohnwu.magisk.extensions.*
import com.topjohnwu.magisk.model.entity.recycler.ConsoleRvItem
import com.topjohnwu.magisk.model.entity.recycler.ConsoleItem
import com.topjohnwu.magisk.model.events.SnackbarEvent
import com.topjohnwu.magisk.model.flash.FlashResultListener
import com.topjohnwu.magisk.model.flash.Flashing
@ -48,7 +48,7 @@ class FlashViewModel(
private val logItems = Collections.synchronizedList(mutableListOf<String>())
init {
outItems.sendUpdatesTo(items) { it.map { ConsoleRvItem(it) } }
outItems.sendUpdatesTo(items) { it.map { ConsoleItem(it) } }
outItems.copyNewInputInto(logItems)
state = State.LOADING

View File

@ -2,6 +2,7 @@ package com.topjohnwu.magisk.legacy.surequest
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.view.Window
@ -13,14 +14,17 @@ import com.topjohnwu.magisk.model.events.DieEvent
import com.topjohnwu.magisk.model.events.ViewActionEvent
import com.topjohnwu.magisk.model.events.ViewEvent
import com.topjohnwu.magisk.ui.base.BaseUIActivity
import com.topjohnwu.magisk.ui.base.CompatNavigationDelegate
import org.koin.androidx.viewmodel.ext.android.viewModel
open class SuRequestActivity : BaseUIActivity<SuRequestViewModel, ActivityRequestBinding>() {
override val layoutRes: Int = R.layout.activity_request
override val themeRes: Int = R.style.MagiskTheme_SU
override val viewModel: SuRequestViewModel by viewModel()
override val navigation: CompatNavigationDelegate<BaseUIActivity<SuRequestViewModel, ActivityRequestBinding>>? =
null
override fun onBackPressed() {
viewModel.denyPressed()
}
@ -58,6 +62,12 @@ open class SuRequestActivity : BaseUIActivity<SuRequestViewModel, ActivityReques
}
}
override fun getTheme(): Resources.Theme {
val theme = super.getTheme()
theme.applyStyle(R.style.Foundation_Floating, true)
return theme
}
override fun onEventDispatched(event: ViewEvent) {
super.onEventDispatched(event)
when (event) {

View File

@ -1,11 +0,0 @@
package com.topjohnwu.magisk.model.navigation
import androidx.fragment.app.Fragment
import kotlin.reflect.KClass
interface Navigator {
//TODO Elevate Fragment to MagiskFragment<*,*> once everything is on board with it
val baseFragments: List<KClass<out Fragment>>
}

View File

@ -1,24 +1,41 @@
package com.topjohnwu.magisk.ui.base
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.graphics.Insets
import androidx.databinding.DataBindingUtil
import androidx.databinding.OnRebindCallback
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.base.BaseActivity
import com.topjohnwu.magisk.extensions.snackbar
import com.topjohnwu.magisk.extensions.startAnimations
import com.topjohnwu.magisk.model.events.EventHandler
import com.topjohnwu.magisk.model.events.SnackbarEvent
import com.topjohnwu.magisk.model.events.ViewEvent
import com.topjohnwu.magisk.ui.theme.Theme
import kotlin.reflect.KClass
abstract class BaseUIActivity<ViewModel : BaseViewModel, Binding : ViewDataBinding> :
BaseActivity(), EventHandler {
BaseActivity(), CompatView<ViewModel>, EventHandler {
protected lateinit var binding: Binding
protected abstract val layoutRes: Int
abstract val viewModel: ViewModel
protected open val themeRes: Int = R.style.MagiskTheme
protected open val themeRes: Int = Theme.selected.themeRes
override val viewRoot: View get() = binding.root
override val navigation by lazy { CompatNavigationDelegate(this) as CompatNavigationDelegate? }
private val delegate by lazy { CompatDelegate(this) }
open val navHost: Int = 0
open val snackbarView get() = binding.root
open val baseFragments = listOf<KClass<out Fragment>>()
init {
val theme = Config.darkThemeExtended
@ -35,5 +52,49 @@ abstract class BaseUIActivity<ViewModel : BaseViewModel, Binding : ViewDataBindi
setVariable(BR.viewModel, viewModel)
lifecycleOwner = this@BaseUIActivity
}
binding.addOnRebindCallback(object : OnRebindCallback<Binding>() {
override fun onPreBind(binding: Binding): Boolean {
(binding.root as? ViewGroup)?.startAnimations()
return super.onPreBind(binding)
}
})
delegate.onCreate()
navigation?.onCreate(savedInstanceState)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
navigation?.onActivityResult(requestCode, resultCode, data)
}
override fun onResume() {
super.onResume()
delegate.onResume()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
navigation?.onSaveInstanceState(outState)
}
override fun onEventDispatched(event: ViewEvent) {
delegate.onEventExecute(event, this)
when (event) {
is SnackbarEvent -> snackbar(snackbarView, event.message(this), event.length, event.f)
}
}
override fun onBackPressed() {
if (navigation == null || navigation?.onBackPressed()?.not() == true) {
super.onBackPressed()
}
}
override fun peekSystemWindowInsets(insets: Insets) {
viewModel.insets.value = insets
}
protected fun ViewEvent.dispatchOnSelf() = onEventDispatched(this)
}

View File

@ -4,20 +4,28 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.Insets
import androidx.databinding.DataBindingUtil
import androidx.databinding.OnRebindCallback
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.extensions.startAnimations
import com.topjohnwu.magisk.model.events.EventHandler
import com.topjohnwu.magisk.model.events.ViewEvent
abstract class BaseUIFragment<ViewModel : BaseViewModel, Binding : ViewDataBinding> :
Fragment(), EventHandler {
Fragment(), CompatView<ViewModel>, EventHandler {
protected val activity get() = requireActivity() as BaseUIActivity<*, *>
protected lateinit var binding: Binding
protected abstract val layoutRes: Int
abstract val viewModel: ViewModel
override val viewRoot: View get() = binding.root
override val navigation by lazy { activity.navigation }
private val delegate by lazy { CompatDelegate(this) }
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -25,9 +33,9 @@ abstract class BaseUIFragment<ViewModel : BaseViewModel, Binding : ViewDataBindi
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DataBindingUtil.inflate<Binding>(inflater, layoutRes, container, false).apply {
setVariable(BR.viewModel, viewModel)
@ -39,9 +47,35 @@ abstract class BaseUIFragment<ViewModel : BaseViewModel, Binding : ViewDataBindi
override fun onEventDispatched(event: ViewEvent) {
super.onEventDispatched(event)
activity.onEventDispatched(event)
delegate.onEventExecute(event, this)
}
open fun onBackPressed(): Boolean = false
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.addOnRebindCallback(object : OnRebindCallback<Binding>() {
override fun onPreBind(binding: Binding): Boolean {
this@BaseUIFragment.onPreBind(binding)
return true
}
})
delegate.onCreate()
}
override fun onResume() {
super.onResume()
delegate.onResume()
}
protected open fun onPreBind(binding: Binding) {
(binding.root as? ViewGroup)?.startAnimations()
}
protected fun ViewEvent.dispatchOnSelf() = delegate.onEventExecute(this, this@BaseUIFragment)
}

View File

@ -1,84 +1,14 @@
package com.topjohnwu.magisk.ui.base
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.core.content.getSystemService
import androidx.databinding.OnRebindCallback
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.topjohnwu.magisk.extensions.snackbar
import com.topjohnwu.magisk.extensions.startAnimations
import com.topjohnwu.magisk.model.events.SnackbarEvent
import com.topjohnwu.magisk.model.events.ViewEvent
import com.topjohnwu.magisk.model.navigation.Navigator
import com.topjohnwu.magisk.ui.theme.Theme
import kotlin.reflect.KClass
// TODO (diareuse): Merge into BaseUIActivity after all legacy UI is migrated
abstract class CompatActivity<ViewModel : BaseViewModel, Binding : ViewDataBinding> :
BaseUIActivity<ViewModel, Binding>(), CompatView<ViewModel>, Navigator {
override val themeRes = Theme.selected.themeRes
override val viewRoot: View get() = binding.root
override val navigation: CompatNavigationDelegate<CompatActivity<ViewModel, Binding>>? by lazy {
CompatNavigationDelegate(this)
}
override val baseFragments = listOf<KClass<out Fragment>>()
private val delegate by lazy { CompatDelegate(this) }
internal abstract val navHost: Int
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
navigation?.onActivityResult(requestCode, resultCode, data)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.addOnRebindCallback(object : OnRebindCallback<Binding>() {
override fun onPreBind(binding: Binding): Boolean {
(binding.root as? ViewGroup)?.startAnimations()
return super.onPreBind(binding)
}
})
delegate.onCreate()
navigation?.onCreate(savedInstanceState)
}
override fun onResume() {
super.onResume()
delegate.onResume()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
navigation?.onSaveInstanceState(outState)
}
override fun onEventDispatched(event: ViewEvent) {
delegate.onEventExecute(event, this)
when (event) {
is SnackbarEvent -> snackbar(snackbarView, event.message(this), event.length, event.f)
}
}
override fun onBackPressed() {
if (navigation?.onBackPressed()?.not() == true) {
super.onBackPressed()
}
}
protected fun ViewEvent.dispatchOnSelf() = onEventDispatched(this)
}
BaseUIActivity<ViewModel, Binding>()
fun Activity.hideKeyboard() {
val view = currentFocus ?: return

View File

@ -18,7 +18,6 @@ class CompatDelegate internal constructor(
fun onCreate() {
ensureInsets()
}
fun onResume() {

View File

@ -1,56 +1,10 @@
package com.topjohnwu.magisk.ui.base
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.databinding.OnRebindCallback
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.topjohnwu.magisk.extensions.startAnimations
import com.topjohnwu.magisk.model.events.ViewEvent
// TODO (diareuse): Merge into BaseUIFragment after all legacy UI is migrated
abstract class CompatFragment<ViewModel : BaseViewModel, Binding : ViewDataBinding>
: BaseUIFragment<ViewModel, Binding>(), CompatView<ViewModel> {
override val viewRoot: View get() = binding.root
override val navigation by lazy { compatActivity.navigation }
private val delegate by lazy { CompatDelegate(this) }
protected val compatActivity get() = requireActivity() as CompatActivity<*, *>
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.addOnRebindCallback(object : OnRebindCallback<Binding>() {
override fun onPreBind(binding: Binding): Boolean {
this@CompatFragment.onPreBind(binding)
return true
}
})
delegate.onCreate()
}
override fun onResume() {
super.onResume()
delegate.onResume()
}
override fun onEventDispatched(event: ViewEvent) {
delegate.onEventExecute(event, this)
}
protected open fun onPreBind(binding: Binding) {
(binding.root as? ViewGroup)?.startAnimations()
}
protected fun ViewEvent.dispatchOnSelf() = delegate.onEventExecute(this, this@CompatFragment)
}
: BaseUIFragment<ViewModel, Binding>(), CompatView<ViewModel>
fun Fragment.hideKeyboard() {
activity?.hideKeyboard()

View File

@ -7,14 +7,13 @@ import com.ncapdevi.fragnav.FragNavTransactionOptions
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.model.navigation.MagiskAnimBuilder
import com.topjohnwu.magisk.model.navigation.MagiskNavigationEvent
import com.topjohnwu.magisk.model.navigation.Navigator
import com.topjohnwu.magisk.ui.ReselectionTarget
import timber.log.Timber
class CompatNavigationDelegate<out Source>(
private val source: Source,
private val listener: FragNavController.TransactionListener? = null
) : FragNavController.RootFragmentListener where Source : CompatActivity<*, *>, Source : Navigator {
) : FragNavController.RootFragmentListener where Source : BaseUIActivity<*, *> {
private val controller by lazy {
check(source.navHost != 0) { "Did you forget to override \"navHostId\"?" }

View File

@ -6,7 +6,6 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.graphics.Insets
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -29,8 +28,6 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
MotionRevealHelper.withViews(binding.hideFilter, binding.hideFilterToggle, value)
}
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onAttach(context: Context) {
super.onAttach(context)
activity.setTitle(R.string.magiskhide)

View File

@ -3,7 +3,6 @@ package com.topjohnwu.magisk.ui.home
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import androidx.core.graphics.Insets
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding
import com.topjohnwu.magisk.model.navigation.Navigation
@ -15,8 +14,6 @@ class HomeFragment : CompatFragment<HomeViewModel, FragmentHomeMd2Binding>() {
override val layoutRes = R.layout.fragment_home_md2
override val viewModel by viewModel<HomeViewModel>()
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onStart() {
super.onStart()
activity.title = resources.getString(R.string.section_home)

View File

@ -1,7 +1,6 @@
package com.topjohnwu.magisk.ui.install
import android.content.Intent
import androidx.core.graphics.Insets
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentInstallMd2Binding
import com.topjohnwu.magisk.model.events.RequestFileEvent
@ -13,8 +12,6 @@ class InstallFragment : CompatFragment<InstallViewModel, FragmentInstallMd2Bindi
override val layoutRes = R.layout.fragment_install_md2
override val viewModel by viewModel<InstallViewModel>()
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
viewModel.data.value = RequestFileEvent.resolve(requestCode, resultCode, data)

View File

@ -5,7 +5,6 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.graphics.Insets
import androidx.core.view.isVisible
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentLogMd2Binding
@ -28,8 +27,6 @@ class LogFragment : CompatFragment<LogViewModel, FragmentLogMd2Binding>() {
(activity as MainActivity).invalidateToolbar()
}
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onStart() {
super.onStart()
setHasOptionsMenu(true)

View File

@ -6,7 +6,6 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.graphics.Insets
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
@ -39,8 +38,6 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
MotionRevealHelper.withViews(binding.moduleFilter, binding.moduleFilterToggle, value)
}
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
InstallExternalModuleEvent.onActivityResult(requireContext(), requestCode, resultCode, data)

View File

@ -2,7 +2,6 @@ package com.topjohnwu.magisk.ui.settings
import android.os.Bundle
import android.view.View
import androidx.core.graphics.Insets
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentSettingsMd2Binding
import com.topjohnwu.magisk.ui.base.CompatFragment
@ -14,8 +13,6 @@ class SettingsFragment : CompatFragment<SettingsViewModel, FragmentSettingsMd2Bi
override val layoutRes = R.layout.fragment_settings_md2
override val viewModel by viewModel<SettingsViewModel>()
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onStart() {
super.onStart()

View File

@ -5,7 +5,6 @@ import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.graphics.Insets
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentSuperuserMd2Binding
import com.topjohnwu.magisk.model.navigation.Navigation
@ -18,8 +17,6 @@ class SuperuserFragment : CompatFragment<SuperuserViewModel, FragmentSuperuserMd
override val layoutRes = R.layout.fragment_superuser_md2
override val viewModel by viewModel<SuperuserViewModel>()
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onStart() {
super.onStart()
activity.title = resources.getString(R.string.superuser)

View File

@ -1,6 +1,5 @@
package com.topjohnwu.magisk.ui.theme
import androidx.core.graphics.Insets
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.FragmentThemeMd2Binding
import com.topjohnwu.magisk.ui.base.CompatFragment
@ -11,8 +10,6 @@ class ThemeFragment : CompatFragment<ThemeViewModel, FragmentThemeMd2Binding>()
override val layoutRes = R.layout.fragment_theme_md2
override val viewModel by viewModel<ThemeViewModel>()
override fun consumeSystemWindowInsets(insets: Insets) = insets
override fun onStart() {
super.onStart()

View File

@ -16,20 +16,27 @@
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
style="@style/WidgetFoundation.Appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppBarLayoutTheme.Flashing">
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
<!--todo(diareuse) replace this with menus and navigation icon like a normal human being-->
<com.google.android.material.appbar.MaterialToolbar
style="@style/WidgetFoundation.Toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:popupTheme="@style/ToolbarPopupTheme.Flashing">
app:layout_scrollFlags="scroll|enterAlways">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginLeft="@{viewModel.insets.left}"
android:layout_marginTop="@{viewModel.insets.top}"
android:layout_marginRight="@{viewModel.insets.right}"
android:animateLayoutChanges="true">
<FrameLayout
@ -46,7 +53,7 @@
android:layout_gravity="center"
android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_back"
app:tint="@android:color/white" />
app:tint="?colorOnSurface" />
</FrameLayout>
@ -57,7 +64,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:textColor="@android:color/white"
android:textColor="?colorOnSurface"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
@ -78,74 +85,46 @@
android:layout_gravity="center"
android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_save_compat"
app:tint="@android:color/white" />
app:tint="?colorOnSurface" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/flash_content"
itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.items}"
scrollToLast="@{true}"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
android:clipToPadding="false"
android:orientation="vertical"
android:paddingLeft="@{viewModel.insets.left}"
android:paddingRight="@{viewModel.insets.right}"
android:paddingBottom="@{viewModel.insets.bottom}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listitem="@layout/item_console" />
<androidx.recyclerview.widget.RecyclerView
itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.items}"
android:id="@+id/flash_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
scrollToLast="@{true}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_console" />
<com.google.android.material.card.MaterialCardView
invisibleScale="@{!viewModel.loaded || !viewModel.canShowReboot}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_generic"
app:cardBackgroundColor="@color/colorSecondary"
app:cardCornerRadius="26dp"
app:cardPreventCornerOverlap="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:onClick="@{() -> viewModel.restartPressed()}"
android:padding="@dimen/margin_generic_half">
<androidx.appcompat.widget.AppCompatImageView
style="@style/Widget.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:srcCompat="@drawable/ic_restart"
app:tint="@color/colorTextTinted" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/Widget.Text.Emphasize.Tinted"
gone="@{!viewModel.showRestartTitle}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_generic_half"
android:paddingRight="@dimen/margin_generic_half"
android:text="@string/reboot" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
invisibleScale="@{!viewModel.loaded || !viewModel.canShowReboot}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/l1"
android:layout_marginBottom="@{(int) @dimen/l1 + viewModel.insets.bottom}"
android:onClick="@{() -> viewModel.restartPressed()}"
android:text="@string/reboot"
android:textAllCaps="false"
android:textStyle="bold"
app:backgroundTint="?colorPrimary"
app:icon="@drawable/ic_restart"
app:tint="?colorOnPrimary" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -1,17 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ThemeFoundation" parent="Theme.MaterialComponents.NoActionBar" />
<style name="MagiskTheme.SUFoundation" parent="Theme.MaterialComponents.Dialog" />
<style name="MagiskTheme" parent="ThemeFoundation.Colored.ExtraProps">
<!--All of these attributes are deprecated and will be removed-->
<item name="cardStyle">@style/CardViewStyle.Dark</item>
<item name="imageColorTint">@color/dark_secondary_text</item>
<item name="colorControl">?android:attr/textColorSecondary</item>
<item name="colorAccentFallback">@color/accentFallback</item>
<item name="android:windowBackground">@android:color/black</item>
</style>
</resources>

View File

@ -1,65 +1,5 @@
<resources>
<style name="ThemeFoundation" parent="Theme.MaterialComponents.Light.NoActionBar" />
<style name="ThemeFoundation.Colored">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorPrimaryVariant">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorSecondary</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorSecondaryVariant">@color/colorSecondaryDark</item>
<item name="android:windowBackground">@android:color/white</item>
</style>
<style name="ThemeFoundation.Colored.ExtraProps" />
<style name="MagiskTheme" parent="ThemeFoundation.Colored.ExtraProps">
<!--All of these attributes are deprecated and will be removed-->
<item name="cardStyle">@style/CardViewStyle.Light</item>
<item name="imageColorTint">@color/icon_grey</item>
<item name="colorControl">?android:attr/textColorSecondary</item>
<item name="colorAccentFallback">@color/accentFallback</item>
</style>
<style name="MagiskTheme.Flashing" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorPrimary">@android:color/black</item>
<item name="colorPrimaryDark">@android:color/black</item>
<item name="colorAccent">@color/colorSecondary</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorSecondaryVariant">@color/colorSecondaryDark</item>
<item name="android:windowBackground">@android:color/black</item>
</style>
<style name="MagiskTheme.SUFoundation" parent="Theme.MaterialComponents.Light.Dialog" />
<style name="MagiskTheme.SU" parent="MagiskTheme.SUFoundation">
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<!--Overlays-->
<style name="AppBarLayoutTheme" parent="ThemeOverlay.AppCompat.Dark" />
<style name="AppBarLayoutTheme.Flashing" parent="ThemeOverlay.AppCompat.Dark" />
<style name="ToolbarPopupTheme" parent="ThemeOverlay.AppCompat.Light" />
<style name="ToolbarPopupTheme.Flashing" parent="ThemeOverlay.AppCompat.Dark" />
<!--CardView-->
<style name="CardViewStyle.Dark" parent="CardView">
<item name="cardBackgroundColor">@color/card_background_color_dark</item>
</style>
<style name="CardViewStyle.Light" parent="CardView">
<item name="cardBackgroundColor">@color/card_background_color_light</item>
</style>
<style name="SplashTheme" parent="SplashThemeBase"/>
</resources>

View File

@ -9,6 +9,8 @@
<style name="Foundation.Compat" />
<!--region Do not remove-->
<style name="Empty" />
<style name="WidgetFoundation" parent="android:Widget" />
<style name="AppearanceFoundation">
@ -31,4 +33,9 @@
<item name="android:windowBackground">?colorSurface</item>
</style>
<style name="Foundation.Floating" parent="Empty">
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
</resources>