mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
Migrate Home screen to Jetpack Compose with miuix
Replace the Home screen's data-binding XML layouts with a Compose UI using miuix components. HomeViewModel now uses StateFlow instead of @Bindable/ObservableHost for UI state. HomeFragment hosts the new HomeScreen composable via ComposeView. Remove old XML layouts (fragment_home_md2, include_home_magisk, include_home_manager, item_developer, item_icon_link) and the DeveloperItem RvItem class that are no longer needed. Made-with: Cursor
This commit is contained in:
@@ -1,127 +0,0 @@
|
||||
package com.topjohnwu.magisk.ui.home
|
||||
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Const
|
||||
import com.topjohnwu.magisk.databinding.RvItem
|
||||
import com.topjohnwu.magisk.core.R as CoreR
|
||||
|
||||
interface Dev {
|
||||
val name: String
|
||||
}
|
||||
|
||||
private interface JohnImpl : Dev {
|
||||
override val name get() = "topjohnwu"
|
||||
}
|
||||
|
||||
private interface VvbImpl : Dev {
|
||||
override val name get() = "vvb2060"
|
||||
}
|
||||
|
||||
private interface YUImpl : Dev {
|
||||
override val name get() = "yujincheng08"
|
||||
}
|
||||
|
||||
private interface RikkaImpl : Dev {
|
||||
override val name get() = "RikkaW"
|
||||
}
|
||||
|
||||
private interface CanyieImpl : Dev {
|
||||
override val name get() = "canyie"
|
||||
}
|
||||
|
||||
sealed class DeveloperItem : Dev {
|
||||
|
||||
abstract val items: List<IconLink>
|
||||
val handle get() = "@${name}"
|
||||
|
||||
object John : DeveloperItem(), JohnImpl {
|
||||
override val items =
|
||||
listOf(
|
||||
object : IconLink.Twitter(), JohnImpl {},
|
||||
IconLink.Github.Project
|
||||
)
|
||||
}
|
||||
|
||||
object Vvb : DeveloperItem(), VvbImpl {
|
||||
override val items =
|
||||
listOf<IconLink>(
|
||||
object : IconLink.Twitter(), VvbImpl {},
|
||||
object : IconLink.Github.User(), VvbImpl {}
|
||||
)
|
||||
}
|
||||
|
||||
object YU : DeveloperItem(), YUImpl {
|
||||
override val items =
|
||||
listOf<IconLink>(
|
||||
object : IconLink.Twitter() { override val name = "shanasaimoe" },
|
||||
object : IconLink.Github.User(), YUImpl {},
|
||||
object : IconLink.Sponsor(), YUImpl {}
|
||||
)
|
||||
}
|
||||
|
||||
object Rikka : DeveloperItem(), RikkaImpl {
|
||||
override val items =
|
||||
listOf<IconLink>(
|
||||
object : IconLink.Twitter() { override val name = "rikkawww" },
|
||||
object : IconLink.Github.User(), RikkaImpl {}
|
||||
)
|
||||
}
|
||||
|
||||
object Canyie : DeveloperItem(), CanyieImpl {
|
||||
override val items =
|
||||
listOf<IconLink>(
|
||||
object : IconLink.Twitter() { override val name = "canyie2977" },
|
||||
object : IconLink.Github.User(), CanyieImpl {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sealed class IconLink : RvItem() {
|
||||
|
||||
abstract val icon: Int
|
||||
abstract val title: Int
|
||||
abstract val link: String
|
||||
|
||||
override val layoutRes get() = R.layout.item_icon_link
|
||||
|
||||
abstract class PayPal : IconLink(), Dev {
|
||||
override val icon get() = CoreR.drawable.ic_paypal
|
||||
override val title get() = CoreR.string.paypal
|
||||
override val link get() = "https://paypal.me/$name"
|
||||
|
||||
object Project : PayPal() {
|
||||
override val name: String get() = "magiskdonate"
|
||||
}
|
||||
}
|
||||
|
||||
object Patreon : IconLink() {
|
||||
override val icon get() = CoreR.drawable.ic_patreon
|
||||
override val title get() = CoreR.string.patreon
|
||||
override val link get() = Const.Url.PATREON_URL
|
||||
}
|
||||
|
||||
abstract class Twitter : IconLink(), Dev {
|
||||
override val icon get() = CoreR.drawable.ic_twitter
|
||||
override val title get() = CoreR.string.twitter
|
||||
override val link get() = "https://twitter.com/$name"
|
||||
}
|
||||
|
||||
abstract class Github : IconLink() {
|
||||
override val icon get() = CoreR.drawable.ic_github
|
||||
override val title get() = CoreR.string.github
|
||||
|
||||
abstract class User : Github(), Dev {
|
||||
override val link get() = "https://github.com/$name"
|
||||
}
|
||||
|
||||
object Project : Github() {
|
||||
override val link get() = Const.Url.SOURCE_CODE_URL
|
||||
}
|
||||
}
|
||||
|
||||
abstract class Sponsor : IconLink(), Dev {
|
||||
override val icon get() = CoreR.drawable.ic_favorite
|
||||
override val title get() = CoreR.string.github
|
||||
override val link get() = "https://github.com/sponsors/$name"
|
||||
}
|
||||
}
|
||||
@@ -7,58 +7,55 @@ import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.findNavController
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.BaseFragment
|
||||
import com.topjohnwu.magisk.arch.viewModel
|
||||
import com.topjohnwu.magisk.arch.NavigationActivity
|
||||
import com.topjohnwu.magisk.arch.VMFactory
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.download.DownloadEngine
|
||||
import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding
|
||||
import com.topjohnwu.magisk.ui.theme.MagiskTheme
|
||||
import com.topjohnwu.magisk.core.R as CoreR
|
||||
import androidx.navigation.findNavController
|
||||
import com.topjohnwu.magisk.arch.NavigationActivity
|
||||
|
||||
class HomeFragment : BaseFragment<FragmentHomeMd2Binding>(), MenuProvider {
|
||||
class HomeFragment : Fragment(), MenuProvider {
|
||||
|
||||
override val layoutRes = R.layout.fragment_home_md2
|
||||
override val viewModel by viewModel<HomeViewModel>()
|
||||
private val viewModel by lazy {
|
||||
ViewModelProvider(this, VMFactory)[HomeViewModel::class.java]
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
activity?.setTitle(CoreR.string.section_home)
|
||||
(activity as? NavigationActivity<*>)?.setTitle(CoreR.string.section_home)
|
||||
DownloadEngine.observeProgress(this, viewModel::onProgressUpdate)
|
||||
}
|
||||
|
||||
private fun checkTitle(text: TextView, icon: ImageView) {
|
||||
text.post {
|
||||
if (text.layout?.getEllipsisCount(0) != 0) {
|
||||
with (icon) {
|
||||
layoutParams.width = 0
|
||||
layoutParams.height = 0
|
||||
requestLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
|
||||
// If titles are squished, hide icons
|
||||
with(binding.homeMagiskWrapper) {
|
||||
checkTitle(homeMagiskTitle, homeMagiskIcon)
|
||||
}
|
||||
with(binding.homeManagerWrapper) {
|
||||
checkTitle(homeManagerTitle, homeManagerIcon)
|
||||
return ComposeView(requireContext()).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent {
|
||||
MagiskTheme {
|
||||
HomeScreen(viewModel = viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return binding.root
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
activity?.addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.STARTED)
|
||||
}
|
||||
|
||||
override fun onCreateMenu(menu: Menu, inflater: MenuInflater) {
|
||||
@@ -77,14 +74,16 @@ class HomeFragment : BaseFragment<FragmentHomeMd2Binding>(), MenuProvider {
|
||||
it.contentResolver,
|
||||
)
|
||||
}
|
||||
R.id.action_reboot -> activity?.let { RebootMenu.inflate(it).show() }
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
R.id.action_reboot -> (activity as? NavigationActivity<*>)?.let {
|
||||
RebootMenu.inflate(it).show()
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.stateManagerProgress = 0
|
||||
viewModel.resetProgress()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.topjohnwu.magisk.ui.home
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.core.Info
|
||||
import com.topjohnwu.magisk.core.R as CoreR
|
||||
import top.yukonga.miuix.kmp.basic.Card
|
||||
import top.yukonga.miuix.kmp.basic.Icon
|
||||
import top.yukonga.miuix.kmp.basic.LinearProgressIndicator
|
||||
import top.yukonga.miuix.kmp.basic.Text
|
||||
import top.yukonga.miuix.kmp.basic.TextButton
|
||||
import top.yukonga.miuix.kmp.theme.MiuixTheme
|
||||
|
||||
@Composable
|
||||
fun HomeScreen(viewModel: HomeViewModel) {
|
||||
val uiState by viewModel.uiState.collectAsState()
|
||||
val context = LocalContext.current
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(top = 8.dp, bottom = 16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
if (uiState.isNoticeVisible) {
|
||||
NoticeCard(onHide = viewModel::hideNotice)
|
||||
}
|
||||
|
||||
MagiskCard(viewModel = viewModel)
|
||||
|
||||
ManagerCard(viewModel = viewModel, uiState = uiState)
|
||||
|
||||
if (Info.env.isActive) {
|
||||
TextButton(
|
||||
text = stringResource(CoreR.string.uninstall_magisk_title),
|
||||
onClick = { viewModel.onDeletePressed() },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
|
||||
SupportCard(onLinkClicked = { viewModel.onLinkPressed(it) })
|
||||
|
||||
DevelopersCard(onLinkClicked = { openLink(context, it) })
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun NoticeCard(onHide: () -> Unit) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Row(
|
||||
modifier = Modifier.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(CoreR.string.home_notice_content),
|
||||
style = MiuixTheme.textStyles.body2,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
TextButton(
|
||||
text = stringResource(CoreR.string.hide),
|
||||
onClick = onHide
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MagiskCard(viewModel: HomeViewModel) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
painter = painterResource(CoreR.drawable.ic_magisk_outline),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MiuixTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(Modifier.width(12.dp))
|
||||
Text(
|
||||
text = stringResource(CoreR.string.magisk),
|
||||
style = MiuixTheme.textStyles.headline2,
|
||||
color = MiuixTheme.colorScheme.primary,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
when (viewModel.magiskState) {
|
||||
HomeViewModel.State.OUTDATED -> TextButton(
|
||||
text = stringResource(CoreR.string.update),
|
||||
onClick = { viewModel.onMagiskPressed() }
|
||||
)
|
||||
else -> TextButton(
|
||||
text = stringResource(CoreR.string.install),
|
||||
onClick = { viewModel.onMagiskPressed() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
InfoRow(
|
||||
label = stringResource(CoreR.string.home_installed_version),
|
||||
value = viewModel.magiskInstalledVersion.ifEmpty {
|
||||
stringResource(CoreR.string.not_available)
|
||||
}
|
||||
)
|
||||
InfoRow(
|
||||
label = stringResource(CoreR.string.zygisk),
|
||||
value = stringResource(if (Info.isZygiskEnabled) CoreR.string.yes else CoreR.string.no)
|
||||
)
|
||||
InfoRow(
|
||||
label = "Ramdisk",
|
||||
value = stringResource(if (Info.ramdisk) CoreR.string.yes else CoreR.string.no)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ManagerCard(viewModel: HomeViewModel, uiState: HomeViewModel.UiState) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_manager),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(32.dp),
|
||||
tint = MiuixTheme.colorScheme.primary
|
||||
)
|
||||
Spacer(Modifier.width(12.dp))
|
||||
Text(
|
||||
text = stringResource(CoreR.string.home_app_title),
|
||||
style = MiuixTheme.textStyles.headline2,
|
||||
color = MiuixTheme.colorScheme.primary,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
when (uiState.appState) {
|
||||
HomeViewModel.State.OUTDATED -> TextButton(
|
||||
text = stringResource(CoreR.string.update),
|
||||
onClick = { viewModel.onManagerPressed() }
|
||||
)
|
||||
HomeViewModel.State.UP_TO_DATE -> TextButton(
|
||||
text = stringResource(CoreR.string.install),
|
||||
onClick = { viewModel.onManagerPressed() }
|
||||
)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
InfoRow(
|
||||
label = stringResource(CoreR.string.home_latest_version),
|
||||
value = uiState.managerRemoteVersion.ifEmpty {
|
||||
stringResource(
|
||||
if (uiState.appState == HomeViewModel.State.LOADING) CoreR.string.loading
|
||||
else CoreR.string.not_available
|
||||
)
|
||||
}
|
||||
)
|
||||
InfoRow(
|
||||
label = stringResource(CoreR.string.home_installed_version),
|
||||
value = viewModel.managerInstalledVersion
|
||||
)
|
||||
val context = LocalContext.current
|
||||
InfoRow(
|
||||
label = stringResource(CoreR.string.home_package),
|
||||
value = context.packageName
|
||||
)
|
||||
|
||||
if (uiState.managerProgress in 1..99) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
LinearProgressIndicator(
|
||||
progress = uiState.managerProgress / 100f,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InfoRow(label: String, value: String) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 2.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text(
|
||||
text = label,
|
||||
style = MiuixTheme.textStyles.body2,
|
||||
color = MiuixTheme.colorScheme.onSurfaceVariantSummary
|
||||
)
|
||||
Text(
|
||||
text = value,
|
||||
style = MiuixTheme.textStyles.body2,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SupportCard(onLinkClicked: (String) -> Unit) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = stringResource(CoreR.string.home_support_title),
|
||||
style = MiuixTheme.textStyles.headline2,
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(CoreR.string.home_support_content),
|
||||
style = MiuixTheme.textStyles.body2,
|
||||
color = MiuixTheme.colorScheme.onSurfaceVariantSummary
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
LinkChip(
|
||||
icon = CoreR.drawable.ic_patreon,
|
||||
label = stringResource(CoreR.string.patreon),
|
||||
onClick = { onLinkClicked(com.topjohnwu.magisk.core.Const.Url.PATREON_URL) }
|
||||
)
|
||||
LinkChip(
|
||||
icon = CoreR.drawable.ic_paypal,
|
||||
label = stringResource(CoreR.string.paypal),
|
||||
onClick = { onLinkClicked("https://paypal.me/magiskdonate") }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun DevelopersCard(onLinkClicked: (String) -> Unit) {
|
||||
val developers = listOf(
|
||||
DeveloperInfo("topjohnwu", listOf(
|
||||
LinkInfo("Twitter", CoreR.drawable.ic_twitter, "https://twitter.com/topjohnwu"),
|
||||
LinkInfo("GitHub", CoreR.drawable.ic_github, com.topjohnwu.magisk.core.Const.Url.SOURCE_CODE_URL),
|
||||
)),
|
||||
DeveloperInfo("vvb2060", listOf(
|
||||
LinkInfo("Twitter", CoreR.drawable.ic_twitter, "https://twitter.com/vvb2060"),
|
||||
LinkInfo("GitHub", CoreR.drawable.ic_github, "https://github.com/vvb2060"),
|
||||
)),
|
||||
DeveloperInfo("yujincheng08", listOf(
|
||||
LinkInfo("Twitter", CoreR.drawable.ic_twitter, "https://twitter.com/shanasaimoe"),
|
||||
LinkInfo("GitHub", CoreR.drawable.ic_github, "https://github.com/yujincheng08"),
|
||||
LinkInfo("Sponsor", CoreR.drawable.ic_favorite, "https://github.com/sponsors/yujincheng08"),
|
||||
)),
|
||||
DeveloperInfo("rikkawww", listOf(
|
||||
LinkInfo("Twitter", CoreR.drawable.ic_twitter, "https://twitter.com/rikkawww"),
|
||||
LinkInfo("GitHub", CoreR.drawable.ic_github, "https://github.com/rikkawww"),
|
||||
)),
|
||||
DeveloperInfo("canyie", listOf(
|
||||
LinkInfo("Twitter", CoreR.drawable.ic_twitter, "https://twitter.com/canyie2977"),
|
||||
LinkInfo("GitHub", CoreR.drawable.ic_github, "https://github.com/canyie"),
|
||||
)),
|
||||
)
|
||||
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
Text(
|
||||
text = stringResource(CoreR.string.home_follow_title),
|
||||
style = MiuixTheme.textStyles.headline2,
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
developers.forEach { dev ->
|
||||
DeveloperRow(dev = dev, onLinkClicked = onLinkClicked)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
private fun DeveloperRow(dev: DeveloperInfo, onLinkClicked: (String) -> Unit) {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
Text(
|
||||
text = "@${dev.name}",
|
||||
style = MiuixTheme.textStyles.body1,
|
||||
)
|
||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
dev.links.forEach { link ->
|
||||
LinkChip(
|
||||
icon = link.icon,
|
||||
label = link.label,
|
||||
onClick = { onLinkClicked(link.url) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LinkChip(icon: Int, label: String, onClick: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clickable(onClick = onClick)
|
||||
.padding(vertical = 6.dp, horizontal = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(icon),
|
||||
contentDescription = label,
|
||||
modifier = Modifier.size(18.dp),
|
||||
tint = MiuixTheme.colorScheme.onSurfaceVariantActions
|
||||
)
|
||||
Text(
|
||||
text = label,
|
||||
style = MiuixTheme.textStyles.body2,
|
||||
color = MiuixTheme.colorScheme.onSurfaceVariantActions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private data class DeveloperInfo(val name: String, val links: List<LinkInfo>)
|
||||
private data class LinkInfo(val label: String, val icon: Int, val url: String)
|
||||
|
||||
private fun openLink(context: Context, url: String) {
|
||||
try {
|
||||
context.startActivity(Intent(Intent.ACTION_VIEW, url.toUri()).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
})
|
||||
} catch (_: ActivityNotFoundException) { }
|
||||
}
|
||||
@@ -5,13 +5,8 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.Toast
|
||||
import androidx.core.net.toUri
|
||||
import androidx.databinding.Bindable
|
||||
import com.topjohnwu.magisk.BR
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.arch.ActivityExecutor
|
||||
import com.topjohnwu.magisk.arch.AsyncLoadViewModel
|
||||
import com.topjohnwu.magisk.arch.ContextExecutor
|
||||
import com.topjohnwu.magisk.arch.UIActivity
|
||||
import com.topjohnwu.magisk.arch.ViewEvent
|
||||
import com.topjohnwu.magisk.core.BuildConfig
|
||||
import com.topjohnwu.magisk.core.Config
|
||||
@@ -21,14 +16,15 @@ import com.topjohnwu.magisk.core.download.Subject.App
|
||||
import com.topjohnwu.magisk.core.ktx.await
|
||||
import com.topjohnwu.magisk.core.ktx.toast
|
||||
import com.topjohnwu.magisk.core.repository.NetworkService
|
||||
import com.topjohnwu.magisk.databinding.bindExtra
|
||||
import com.topjohnwu.magisk.databinding.set
|
||||
import com.topjohnwu.magisk.dialog.EnvFixDialog
|
||||
import com.topjohnwu.magisk.dialog.ManagerInstallDialog
|
||||
import com.topjohnwu.magisk.dialog.UninstallDialog
|
||||
import com.topjohnwu.magisk.events.SnackbarEvent
|
||||
import com.topjohnwu.magisk.utils.asText
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlin.math.roundToInt
|
||||
import com.topjohnwu.magisk.core.R as CoreR
|
||||
|
||||
@@ -40,14 +36,15 @@ class HomeViewModel(
|
||||
LOADING, INVALID, OUTDATED, UP_TO_DATE
|
||||
}
|
||||
|
||||
val magiskTitleBarrierIds =
|
||||
intArrayOf(R.id.home_magisk_icon, R.id.home_magisk_title, R.id.home_magisk_button)
|
||||
val appTitleBarrierIds =
|
||||
intArrayOf(R.id.home_manager_icon, R.id.home_manager_title, R.id.home_manager_button)
|
||||
data class UiState(
|
||||
val isNoticeVisible: Boolean = Config.safetyNotice,
|
||||
val appState: State = State.LOADING,
|
||||
val managerRemoteVersion: String = "",
|
||||
val managerProgress: Int = 0,
|
||||
)
|
||||
|
||||
@get:Bindable
|
||||
var isNoticeVisible = Config.safetyNotice
|
||||
set(value) = set(value, field, { field = it }, BR.noticeVisible)
|
||||
private val _uiState = MutableStateFlow(UiState())
|
||||
val uiState: StateFlow<UiState> = _uiState.asStateFlow()
|
||||
|
||||
val magiskState
|
||||
get() = when {
|
||||
@@ -57,52 +54,34 @@ class HomeViewModel(
|
||||
else -> State.UP_TO_DATE
|
||||
}
|
||||
|
||||
@get:Bindable
|
||||
var appState = State.LOADING
|
||||
set(value) = set(value, field, { field = it }, BR.appState)
|
||||
|
||||
val magiskInstalledVersion
|
||||
val magiskInstalledVersion: String
|
||||
get() = Info.env.run {
|
||||
if (isActive)
|
||||
("$versionString ($versionCode)" + if (isDebug) " (D)" else "").asText()
|
||||
"$versionString ($versionCode)" + if (isDebug) " (D)" else ""
|
||||
else
|
||||
CoreR.string.not_available.asText()
|
||||
""
|
||||
}
|
||||
|
||||
@get:Bindable
|
||||
var managerRemoteVersion = CoreR.string.loading.asText()
|
||||
set(value) = set(value, field, { field = it }, BR.managerRemoteVersion)
|
||||
|
||||
val managerInstalledVersion
|
||||
val managerInstalledVersion: String
|
||||
get() = "${BuildConfig.APP_VERSION_NAME} (${BuildConfig.APP_VERSION_CODE})" +
|
||||
if (BuildConfig.DEBUG) " (D)" else ""
|
||||
|
||||
@get:Bindable
|
||||
var stateManagerProgress = 0
|
||||
set(value) = set(value, field, { field = it }, BR.stateManagerProgress)
|
||||
|
||||
val extraBindings = bindExtra {
|
||||
it.put(BR.viewModel, this)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var checkedEnv = false
|
||||
}
|
||||
|
||||
override suspend fun doLoadWork() {
|
||||
appState = State.LOADING
|
||||
_uiState.update { it.copy(appState = State.LOADING) }
|
||||
Info.fetchUpdate(svc)?.apply {
|
||||
appState = when {
|
||||
BuildConfig.APP_VERSION_CODE < versionCode -> State.OUTDATED
|
||||
else -> State.UP_TO_DATE
|
||||
}
|
||||
|
||||
val isDebug = Config.updateChannel == Config.Value.DEBUG_CHANNEL
|
||||
managerRemoteVersion =
|
||||
("$version (${versionCode})" + if (isDebug) " (D)" else "").asText()
|
||||
_uiState.update {
|
||||
it.copy(
|
||||
appState = if (BuildConfig.APP_VERSION_CODE < versionCode) State.OUTDATED else State.UP_TO_DATE,
|
||||
managerRemoteVersion = "$version ($versionCode)" + if (isDebug) " (D)" else ""
|
||||
)
|
||||
}
|
||||
} ?: run {
|
||||
appState = State.INVALID
|
||||
managerRemoteVersion = CoreR.string.not_available.asText()
|
||||
_uiState.update { it.copy(appState = State.INVALID, managerRemoteVersion = "") }
|
||||
}
|
||||
ensureEnv()
|
||||
}
|
||||
@@ -111,7 +90,11 @@ class HomeViewModel(
|
||||
|
||||
fun onProgressUpdate(progress: Float, subject: Subject) {
|
||||
if (subject is App)
|
||||
stateManagerProgress = progress.times(100f).roundToInt()
|
||||
_uiState.update { it.copy(managerProgress = progress.times(100f).roundToInt()) }
|
||||
}
|
||||
|
||||
fun resetProgress() {
|
||||
_uiState.update { it.copy(managerProgress = 0) }
|
||||
}
|
||||
|
||||
fun onLinkPressed(link: String) = object : ViewEvent(), ContextExecutor {
|
||||
@@ -128,7 +111,7 @@ class HomeViewModel(
|
||||
|
||||
fun onDeletePressed() = UninstallDialog().show()
|
||||
|
||||
fun onManagerPressed() = when (appState) {
|
||||
fun onManagerPressed() = when (_uiState.value.appState) {
|
||||
State.LOADING -> SnackbarEvent(CoreR.string.loading).publish()
|
||||
State.INVALID -> SnackbarEvent(CoreR.string.no_connection).publish()
|
||||
else -> withExternalRW {
|
||||
@@ -144,7 +127,7 @@ class HomeViewModel(
|
||||
|
||||
fun hideNotice() {
|
||||
Config.safetyNotice = false
|
||||
isNoticeVisible = false
|
||||
_uiState.update { it.copy(isNoticeVisible = false) }
|
||||
}
|
||||
|
||||
private suspend fun ensureEnv() {
|
||||
@@ -156,11 +139,4 @@ class HomeViewModel(
|
||||
}
|
||||
checkedEnv = true
|
||||
}
|
||||
|
||||
val showTest = false
|
||||
fun onTestPressed() = object : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: UIActivity<*>) {
|
||||
/* Entry point to trigger test events within the app */
|
||||
}
|
||||
}.publish()
|
||||
}
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.topjohnwu.magisk.core.Info" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.ui.home.DeveloperItem" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.ui.home.IconLink" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:fillViewport="true"
|
||||
android:paddingTop="@dimen/internal_action_bar_size"
|
||||
android:paddingBottom="@dimen/l3"
|
||||
app:fitsSystemWindowsInsets="top|bottom"
|
||||
tools:layout_marginTop="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/l1">
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button"
|
||||
gone="@{!viewModel.showTest}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:onClick="@{() -> viewModel.onTestPressed()}"
|
||||
android:text="TEST"
|
||||
android:textAllCaps="false"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card.Primary"
|
||||
goneUnless="@{viewModel.noticeVisible}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:layout_marginBottom="@dimen/l1"
|
||||
android:focusable="false">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_notice_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/l1"
|
||||
android:text="@string/home_notice_content"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption.OnPrimary"
|
||||
app:layout_constraintEnd_toStartOf="@+id/home_notice_hide"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/home_notice_hide"
|
||||
style="@style/WidgetFoundation.Button.Text.OnPrimary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> viewModel.hideNotice()}"
|
||||
android:text="@string/hide"
|
||||
android:textAllCaps="false"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<include
|
||||
android:id="@+id/home_magisk_wrapper"
|
||||
layout="@layout/include_home_magisk"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_device_wrapper" />
|
||||
|
||||
<include
|
||||
android:id="@+id/home_manager_wrapper"
|
||||
layout="@layout/include_home_manager"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_wrapper" />
|
||||
|
||||
<Space
|
||||
goneUnless="@{Info.env.isActive}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/l1" />
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button.Outlined.Error"
|
||||
goneUnless="@{Info.env.isActive}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:onClick="@{() -> viewModel.onDeletePressed()}"
|
||||
android:text="@string/uninstall_magisk_title"
|
||||
android:textAllCaps="false"
|
||||
android:textSize="12sp"
|
||||
app:cornerRadius="@dimen/r1"
|
||||
app:icon="@drawable/ic_delete_md2" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:focusable="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/l1"
|
||||
android:paddingBottom="@dimen/l1">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:text="@string/home_support_title"
|
||||
android:textAppearance="@style/AppearanceFoundation.Title" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l_50"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:text="@string/home_support_content"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption.Variant" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/l_50" >
|
||||
|
||||
<include
|
||||
item="@{IconLink.Patreon.INSTANCE}"
|
||||
layout="@layout/item_icon_link"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<include
|
||||
item="@{IconLink.PayPal.Project.INSTANCE}"
|
||||
layout="@layout/item_icon_link"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_margin="@dimen/l1"
|
||||
android:focusable="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/l1">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:text="@string/home_follow_title"
|
||||
android:textAppearance="@style/AppearanceFoundation.Title" />
|
||||
|
||||
<include
|
||||
item="@{DeveloperItem.John.INSTANCE}"
|
||||
layout="@layout/item_developer"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l_50" />
|
||||
|
||||
<include
|
||||
item="@{DeveloperItem.Vvb.INSTANCE}"
|
||||
layout="@layout/item_developer"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l_50" />
|
||||
|
||||
<include
|
||||
item="@{DeveloperItem.YU.INSTANCE}"
|
||||
layout="@layout/item_developer"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l_50" />
|
||||
|
||||
<include
|
||||
item="@{DeveloperItem.Rikka.INSTANCE}"
|
||||
layout="@layout/item_developer"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l_50" />
|
||||
|
||||
<include
|
||||
item="@{DeveloperItem.Canyie.INSTANCE}"
|
||||
layout="@layout/item_developer"
|
||||
viewModel="@{viewModel}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l_50" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</layout>
|
||||
@@ -1,174 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.topjohnwu.magisk.core.Info" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.ui.home.HomeViewModel.State" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingTop="@dimen/l_50"
|
||||
android:paddingEnd="@dimen/l1"
|
||||
android:paddingBottom="@dimen/l_50"
|
||||
tools:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/home_magisk_icon"
|
||||
style="@style/WidgetFoundation.Icon.Primary"
|
||||
android:padding="@dimen/l_25"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_magisk_outline" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_magisk_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:text="@string/magisk"
|
||||
android:textAppearance="@style/AppearanceFoundation.Title"
|
||||
android:textColor="?colorPrimary"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/home_magisk_icon"
|
||||
app:layout_constraintEnd_toStartOf="@+id/home_magisk_button"
|
||||
app:layout_constraintStart_toEndOf="@+id/home_magisk_icon"
|
||||
app:layout_constraintTop_toTopOf="@+id/home_magisk_icon" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/home_magisk_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/home_magisk_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/home_magisk_title">
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button"
|
||||
gone="@{viewModel.magiskState != State.OUTDATED}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> viewModel.onMagiskPressed()}"
|
||||
android:text="@string/update"
|
||||
android:textAllCaps="false"
|
||||
android:layout_gravity="end"
|
||||
app:icon="@drawable/ic_update_md2" />
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
gone="@{viewModel.magiskState == State.OUTDATED}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:onClick="@{() -> viewModel.onMagiskPressed()}"
|
||||
android:text="@string/install"
|
||||
android:textAllCaps="false"
|
||||
app:icon="@drawable/ic_install"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/home_magisk_title_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:referencedIds="@{viewModel.magiskTitleBarrierIds}"
|
||||
tools:constraint_referenced_ids="home_magisk_icon,home_magisk_title,home_magisk_button" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_title_barrier">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/home_magisk_installed_version"
|
||||
style="@style/W.Home.Item.Top"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent"
|
||||
android:text="@string/home_installed_version" />
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent.Right"
|
||||
android:text="@{viewModel.magiskInstalledVersion}"
|
||||
tools:text="22.0 (22000)" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/home_device_details_zygisk"
|
||||
style="@style/W.Home.Item"
|
||||
app:layout_constraintStart_toStartOf="@+id/home_magisk_installed_version"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_magisk_installed_version">
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent"
|
||||
android:text="@string/zygisk" />
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent.Right"
|
||||
android:text="@{Info.isZygiskEnabled ? @string/yes : @string/no}"
|
||||
tools:text="Yes" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/home_device_details_ramdisk"
|
||||
style="@style/W.Home.Item.Bottom"
|
||||
app:layout_constraintStart_toStartOf="@+id/home_magisk_installed_version"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_device_details_zygisk">
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent"
|
||||
android:text="Ramdisk" />
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent.Right"
|
||||
android:text="@{Info.ramdisk ? @string/yes : @string/no }"
|
||||
tools:text="Yes" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
@@ -1,182 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.topjohnwu.magisk.ui.home.HomeViewModel.State" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingTop="@dimen/l_50"
|
||||
android:paddingEnd="@dimen/l1"
|
||||
android:paddingBottom="@dimen/l_50"
|
||||
tools:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/home_manager_icon"
|
||||
style="@style/WidgetFoundation.Icon.Primary"
|
||||
android:padding="@dimen/l_50"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_manager" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_manager_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:text="@string/home_app_title"
|
||||
android:textAppearance="@style/AppearanceFoundation.Title"
|
||||
android:textColor="?colorPrimary"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/home_manager_icon"
|
||||
app:layout_constraintEnd_toStartOf="@+id/home_manager_button"
|
||||
app:layout_constraintStart_toEndOf="@+id/home_manager_icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@string/home_app_title" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/home_manager_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/home_manager_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/home_manager_title">
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button"
|
||||
gone="@{viewModel.appState != State.OUTDATED}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> viewModel.onManagerPressed()}"
|
||||
android:text="@string/update"
|
||||
android:textAllCaps="false"
|
||||
android:layout_gravity="end"
|
||||
app:icon="@drawable/ic_update_md2" />
|
||||
|
||||
<Button
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
gone="@{viewModel.appState != State.UP_TO_DATE}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:onClick="@{() -> viewModel.onManagerPressed()}"
|
||||
android:text="@string/install"
|
||||
android:textAllCaps="false"
|
||||
app:icon="@drawable/ic_install"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/home_manager_title_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:referencedIds="@{viewModel.appTitleBarrierIds}"
|
||||
tools:constraint_referenced_ids="home_manager_icon,home_manager_title,home_manager_button" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
android:scrollbars="none"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_title_barrier">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/home_manager_latest_version"
|
||||
style="@style/W.Home.Item.Top"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent"
|
||||
android:text="@string/home_latest_version" />
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent.Right"
|
||||
android:text="@{viewModel.managerRemoteVersion}"
|
||||
tools:text="22.0 (22000) (16)" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/home_manager_installed_version"
|
||||
style="@style/W.Home.Item"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_latest_version">
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent"
|
||||
android:text="@string/home_installed_version" />
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent.Right"
|
||||
android:text="@{viewModel.managerInstalledVersion}"
|
||||
tools:text="22.0 (22000) (16)" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/home_manager_internal_connection"
|
||||
style="@style/W.Home.Item.Bottom"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_manager_installed_version">
|
||||
|
||||
<TextView
|
||||
style="@style/W.Home.ItemContent"
|
||||
android:text="@string/home_package" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/home_manager_extra_connection_value"
|
||||
style="@style/W.Home.ItemContent.Right"
|
||||
android:text="@{context.packageName}"
|
||||
tools:text="com.topjohnwu.magisk" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ProgressBar
|
||||
style="@style/WidgetFoundation.ProgressBar"
|
||||
gone="@{viewModel.stateManagerProgress == 0 || viewModel.stateManagerProgress == 100}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:max="100"
|
||||
android:progress="@{viewModel.stateManagerProgress}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="item"
|
||||
type="com.topjohnwu.magisk.ui.home.DeveloperItem" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingEnd="@dimen/l1">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{item.handle}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption"
|
||||
android:textStyle="bold"
|
||||
tools:text="\@topjohnwu" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
app:items="@{item.items}"
|
||||
app:extraBindings="@{viewModel.extraBindings}"
|
||||
app:nestedScrollingEnabled="@{false}"
|
||||
android:overScrollMode="never"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:orientation="horizontal"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/item_icon_link" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="item"
|
||||
type="com.topjohnwu.magisk.ui.home.IconLink" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.topjohnwu.magisk.ui.home.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:minWidth="48dp"
|
||||
android:onClick="@{() -> viewModel.onLinkPressed(item.link)}"
|
||||
android:padding="@dimen/l_50"
|
||||
tools:layout_gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/developer_link"
|
||||
style="@style/WidgetFoundation.Image.Small"
|
||||
android:layout_gravity="center"
|
||||
app:srcCompat="@{item.icon}"
|
||||
app:tint="?colorOnSurface"
|
||||
tools:srcCompat="@drawable/ic_paypal" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</layout>
|
||||
Reference in New Issue
Block a user