2022-05-15 17:03:57 -04:00
|
|
|
package eu.kanade.presentation.browse
|
2022-05-15 15:59:53 +02:00
|
|
|
|
2022-10-01 21:32:08 +07:00
|
|
|
import androidx.compose.animation.core.animateDpAsState
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.foundation.combinedClickable
|
2023-02-22 00:04:11 +07:00
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
2022-10-01 21:32:08 +07:00
|
|
|
import androidx.compose.foundation.layout.Box
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.foundation.layout.Column
|
2023-02-22 00:04:11 +07:00
|
|
|
import androidx.compose.foundation.layout.FlowRow
|
2022-10-10 02:52:56 +07:00
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
|
import androidx.compose.foundation.layout.RowScope
|
|
|
|
import androidx.compose.foundation.layout.padding
|
2022-10-01 21:32:08 +07:00
|
|
|
import androidx.compose.foundation.layout.size
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
|
import androidx.compose.material.icons.Icons
|
2022-10-29 23:43:51 +08:00
|
|
|
import androidx.compose.material.icons.outlined.Close
|
2023-12-11 22:24:33 -05:00
|
|
|
import androidx.compose.material.icons.outlined.GetApp
|
|
|
|
import androidx.compose.material.icons.outlined.Public
|
|
|
|
import androidx.compose.material.icons.outlined.Refresh
|
|
|
|
import androidx.compose.material.icons.outlined.Settings
|
|
|
|
import androidx.compose.material.icons.outlined.VerifiedUser
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.material3.AlertDialog
|
|
|
|
import androidx.compose.material3.Button
|
2022-10-01 21:32:08 +07:00
|
|
|
import androidx.compose.material3.CircularProgressIndicator
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.IconButton
|
|
|
|
import androidx.compose.material3.LocalTextStyle
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
2022-10-01 21:32:08 +07:00
|
|
|
import androidx.compose.material3.ProvideTextStyle
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.TextButton
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
|
import androidx.compose.runtime.remember
|
2022-05-19 17:43:27 -04:00
|
|
|
import androidx.compose.runtime.setValue
|
2022-05-15 15:59:53 +02:00
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.text.style.TextOverflow
|
|
|
|
import androidx.compose.ui.unit.dp
|
2023-11-18 13:54:56 -05:00
|
|
|
import dev.icerock.moko.resources.StringResource
|
2022-05-15 15:59:53 +02:00
|
|
|
import eu.kanade.presentation.browse.components.BaseBrowseItem
|
|
|
|
import eu.kanade.presentation.browse.components.ExtensionIcon
|
2022-10-01 21:32:08 +07:00
|
|
|
import eu.kanade.presentation.manga.components.DotSeparatorNoSpaceText
|
2022-05-15 15:59:53 +02:00
|
|
|
import eu.kanade.tachiyomi.extension.model.Extension
|
|
|
|
import eu.kanade.tachiyomi.extension.model.InstallStep
|
|
|
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionUiModel
|
2023-07-23 20:03:37 -04:00
|
|
|
import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsScreenModel
|
2022-05-15 15:59:53 +02:00
|
|
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
2023-11-18 13:54:56 -05:00
|
|
|
import tachiyomi.i18n.MR
|
2023-02-18 16:33:03 -05:00
|
|
|
import tachiyomi.presentation.core.components.FastScrollLazyColumn
|
2023-02-18 15:52:52 -05:00
|
|
|
import tachiyomi.presentation.core.components.material.PullRefresh
|
2023-02-18 16:03:01 -05:00
|
|
|
import tachiyomi.presentation.core.components.material.padding
|
|
|
|
import tachiyomi.presentation.core.components.material.topSmallPaddingValues
|
2023-11-18 19:41:33 -05:00
|
|
|
import tachiyomi.presentation.core.i18n.stringResource
|
2023-02-20 10:12:41 -05:00
|
|
|
import tachiyomi.presentation.core.screens.EmptyScreen
|
|
|
|
import tachiyomi.presentation.core.screens.LoadingScreen
|
2023-02-18 17:04:32 -05:00
|
|
|
import tachiyomi.presentation.core.theme.header
|
2023-02-18 16:33:03 -05:00
|
|
|
import tachiyomi.presentation.core.util.plus
|
|
|
|
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
2022-05-15 15:59:53 +02:00
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun ExtensionScreen(
|
2023-07-23 20:03:37 -04:00
|
|
|
state: ExtensionsScreenModel.State,
|
2022-10-10 02:52:56 +07:00
|
|
|
contentPadding: PaddingValues,
|
2023-01-23 05:19:46 +08:00
|
|
|
searchQuery: String?,
|
2022-05-15 15:59:53 +02:00
|
|
|
onLongClickItem: (Extension) -> Unit,
|
|
|
|
onClickItemCancel: (Extension) -> Unit,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView: (Extension.Available) -> Unit,
|
2022-05-15 15:59:53 +02:00
|
|
|
onInstallExtension: (Extension.Available) -> Unit,
|
|
|
|
onUninstallExtension: (Extension) -> Unit,
|
|
|
|
onUpdateExtension: (Extension.Installed) -> Unit,
|
|
|
|
onTrustExtension: (Extension.Untrusted) -> Unit,
|
|
|
|
onOpenExtension: (Extension.Installed) -> Unit,
|
|
|
|
onClickUpdateAll: () -> Unit,
|
|
|
|
onRefresh: () -> Unit,
|
|
|
|
) {
|
2022-12-08 11:40:57 +08:00
|
|
|
PullRefresh(
|
2022-11-24 10:28:25 +07:00
|
|
|
refreshing = state.isRefreshing,
|
2022-05-15 15:59:53 +02:00
|
|
|
onRefresh = onRefresh,
|
2023-11-22 10:09:41 +07:00
|
|
|
enabled = { !state.isLoading },
|
2022-05-15 15:59:53 +02:00
|
|
|
) {
|
2022-07-16 20:44:37 +02:00
|
|
|
when {
|
2023-08-25 22:25:00 -04:00
|
|
|
state.isLoading -> LoadingScreen(Modifier.padding(contentPadding))
|
2022-12-08 22:15:10 +08:00
|
|
|
state.isEmpty -> {
|
|
|
|
val msg = if (!searchQuery.isNullOrEmpty()) {
|
2023-11-18 13:54:56 -05:00
|
|
|
MR.strings.no_results_found
|
2022-12-08 22:15:10 +08:00
|
|
|
} else {
|
2023-11-18 13:54:56 -05:00
|
|
|
MR.strings.empty_screen
|
2022-12-08 22:15:10 +08:00
|
|
|
}
|
|
|
|
EmptyScreen(
|
2023-11-18 13:54:56 -05:00
|
|
|
stringRes = msg,
|
2022-12-08 22:15:10 +08:00
|
|
|
modifier = Modifier.padding(contentPadding),
|
|
|
|
)
|
|
|
|
}
|
2022-07-16 20:44:37 +02:00
|
|
|
else -> {
|
2022-05-15 15:59:53 +02:00
|
|
|
ExtensionContent(
|
2022-11-24 10:28:25 +07:00
|
|
|
state = state,
|
2022-10-10 02:52:56 +07:00
|
|
|
contentPadding = contentPadding,
|
2022-05-15 15:59:53 +02:00
|
|
|
onLongClickItem = onLongClickItem,
|
|
|
|
onClickItemCancel = onClickItemCancel,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView = onClickItemWebView,
|
2022-05-15 15:59:53 +02:00
|
|
|
onInstallExtension = onInstallExtension,
|
|
|
|
onUninstallExtension = onUninstallExtension,
|
|
|
|
onUpdateExtension = onUpdateExtension,
|
|
|
|
onTrustExtension = onTrustExtension,
|
|
|
|
onOpenExtension = onOpenExtension,
|
|
|
|
onClickUpdateAll = onClickUpdateAll,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionContent(
|
2023-07-23 20:03:37 -04:00
|
|
|
state: ExtensionsScreenModel.State,
|
2022-10-10 02:52:56 +07:00
|
|
|
contentPadding: PaddingValues,
|
2022-05-15 15:59:53 +02:00
|
|
|
onLongClickItem: (Extension) -> Unit,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView: (Extension.Available) -> Unit,
|
2022-05-15 15:59:53 +02:00
|
|
|
onClickItemCancel: (Extension) -> Unit,
|
|
|
|
onInstallExtension: (Extension.Available) -> Unit,
|
|
|
|
onUninstallExtension: (Extension) -> Unit,
|
|
|
|
onUpdateExtension: (Extension.Installed) -> Unit,
|
|
|
|
onTrustExtension: (Extension.Untrusted) -> Unit,
|
|
|
|
onOpenExtension: (Extension.Installed) -> Unit,
|
|
|
|
onClickUpdateAll: () -> Unit,
|
|
|
|
) {
|
2022-05-19 17:43:27 -04:00
|
|
|
var trustState by remember { mutableStateOf<Extension.Untrusted?>(null) }
|
|
|
|
|
2022-06-19 21:33:25 +07:00
|
|
|
FastScrollLazyColumn(
|
2023-01-15 23:32:27 +08:00
|
|
|
contentPadding = contentPadding + topSmallPaddingValues,
|
2022-05-15 15:59:53 +02:00
|
|
|
) {
|
2023-01-10 23:18:34 -05:00
|
|
|
state.items.forEach { (header, items) ->
|
|
|
|
item(
|
|
|
|
contentType = "header",
|
|
|
|
key = "extensionHeader-${header.hashCode()}",
|
|
|
|
) {
|
|
|
|
when (header) {
|
|
|
|
is ExtensionUiModel.Header.Resource -> {
|
|
|
|
val action: @Composable RowScope.() -> Unit =
|
2023-11-18 13:54:56 -05:00
|
|
|
if (header.textRes == MR.strings.ext_updates_pending) {
|
2023-01-10 23:18:34 -05:00
|
|
|
{
|
|
|
|
Button(onClick = { onClickUpdateAll() }) {
|
|
|
|
Text(
|
2023-11-18 19:41:33 -05:00
|
|
|
text = stringResource(MR.strings.ext_update_all),
|
2023-01-10 23:18:34 -05:00
|
|
|
style = LocalTextStyle.current.copy(
|
|
|
|
color = MaterialTheme.colorScheme.onPrimary,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
2023-01-10 23:18:34 -05:00
|
|
|
} else {
|
|
|
|
{}
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
2023-01-10 23:18:34 -05:00
|
|
|
ExtensionHeader(
|
|
|
|
textRes = header.textRes,
|
2023-12-01 22:27:15 -05:00
|
|
|
modifier = Modifier.animateItemPlacement(),
|
2023-01-10 23:18:34 -05:00
|
|
|
action = action,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
is ExtensionUiModel.Header.Text -> {
|
|
|
|
ExtensionHeader(
|
|
|
|
text = header.text,
|
2023-12-01 22:27:15 -05:00
|
|
|
modifier = Modifier.animateItemPlacement(),
|
2023-01-10 23:18:34 -05:00
|
|
|
)
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
2023-01-10 23:18:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
items(
|
|
|
|
items = items,
|
|
|
|
contentType = { "item" },
|
|
|
|
key = { "extension-${it.hashCode()}" },
|
|
|
|
) { item ->
|
|
|
|
ExtensionItem(
|
2023-12-01 22:27:15 -05:00
|
|
|
modifier = Modifier.animateItemPlacement(),
|
2023-01-10 23:18:34 -05:00
|
|
|
item = item,
|
|
|
|
onClickItem = {
|
|
|
|
when (it) {
|
|
|
|
is Extension.Available -> onInstallExtension(it)
|
|
|
|
is Extension.Installed -> onOpenExtension(it)
|
|
|
|
is Extension.Untrusted -> { trustState = it }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLongClickItem = onLongClickItem,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView = onClickItemWebView,
|
2023-01-10 23:18:34 -05:00
|
|
|
onClickItemCancel = onClickItemCancel,
|
|
|
|
onClickItemAction = {
|
|
|
|
when (it) {
|
|
|
|
is Extension.Available -> onInstallExtension(it)
|
|
|
|
is Extension.Installed -> {
|
|
|
|
if (it.hasUpdate) {
|
|
|
|
onUpdateExtension(it)
|
|
|
|
} else {
|
|
|
|
onOpenExtension(it)
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
}
|
2023-01-10 23:18:34 -05:00
|
|
|
is Extension.Untrusted -> { trustState = it }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (trustState != null) {
|
|
|
|
ExtensionTrustDialog(
|
|
|
|
onClickConfirm = {
|
2022-05-19 17:43:27 -04:00
|
|
|
onTrustExtension(trustState!!)
|
|
|
|
trustState = null
|
2022-05-15 15:59:53 +02:00
|
|
|
},
|
|
|
|
onClickDismiss = {
|
2022-05-19 17:43:27 -04:00
|
|
|
onUninstallExtension(trustState!!)
|
|
|
|
trustState = null
|
2022-05-15 15:59:53 +02:00
|
|
|
},
|
|
|
|
onDismissRequest = {
|
2022-05-19 17:43:27 -04:00
|
|
|
trustState = null
|
2022-05-15 15:59:53 +02:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionItem(
|
2022-05-15 15:59:53 +02:00
|
|
|
item: ExtensionUiModel.Item,
|
|
|
|
onClickItem: (Extension) -> Unit,
|
|
|
|
onLongClickItem: (Extension) -> Unit,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView: (Extension.Available) -> Unit,
|
2022-05-15 15:59:53 +02:00
|
|
|
onClickItemCancel: (Extension) -> Unit,
|
|
|
|
onClickItemAction: (Extension) -> Unit,
|
2023-11-17 09:46:13 -05:00
|
|
|
modifier: Modifier = Modifier,
|
2022-05-15 15:59:53 +02:00
|
|
|
) {
|
|
|
|
val (extension, installStep) = item
|
|
|
|
BaseBrowseItem(
|
|
|
|
modifier = modifier
|
|
|
|
.combinedClickable(
|
|
|
|
onClick = { onClickItem(extension) },
|
|
|
|
onLongClick = { onLongClickItem(extension) },
|
|
|
|
),
|
|
|
|
onClickItem = { onClickItem(extension) },
|
|
|
|
onLongClickItem = { onLongClickItem(extension) },
|
|
|
|
icon = {
|
2022-10-01 21:32:08 +07:00
|
|
|
Box(
|
|
|
|
modifier = Modifier
|
|
|
|
.size(40.dp),
|
|
|
|
contentAlignment = Alignment.Center,
|
|
|
|
) {
|
|
|
|
val idle = installStep.isCompleted()
|
|
|
|
if (!idle) {
|
|
|
|
CircularProgressIndicator(
|
|
|
|
modifier = Modifier.size(40.dp),
|
|
|
|
strokeWidth = 2.dp,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-10-21 18:09:30 -04:00
|
|
|
val padding by animateDpAsState(
|
|
|
|
targetValue = if (idle) 0.dp else 8.dp,
|
|
|
|
label = "iconPadding",
|
|
|
|
)
|
2022-10-01 21:32:08 +07:00
|
|
|
ExtensionIcon(
|
|
|
|
extension = extension,
|
|
|
|
modifier = Modifier
|
|
|
|
.matchParentSize()
|
|
|
|
.padding(padding),
|
|
|
|
)
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
},
|
|
|
|
action = {
|
|
|
|
ExtensionItemActions(
|
|
|
|
extension = extension,
|
|
|
|
installStep = installStep,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView = onClickItemWebView,
|
2022-05-15 15:59:53 +02:00
|
|
|
onClickItemCancel = onClickItemCancel,
|
|
|
|
onClickItemAction = onClickItemAction,
|
|
|
|
)
|
|
|
|
},
|
|
|
|
) {
|
|
|
|
ExtensionItemContent(
|
|
|
|
extension = extension,
|
2022-10-01 21:32:08 +07:00
|
|
|
installStep = installStep,
|
2022-05-15 15:59:53 +02:00
|
|
|
modifier = Modifier.weight(1f),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionItemContent(
|
2022-05-15 15:59:53 +02:00
|
|
|
extension: Extension,
|
2022-10-01 21:32:08 +07:00
|
|
|
installStep: InstallStep,
|
2022-05-15 15:59:53 +02:00
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
) {
|
|
|
|
Column(
|
2022-11-13 18:11:51 +01:00
|
|
|
modifier = modifier.padding(start = MaterialTheme.padding.medium),
|
2022-05-15 15:59:53 +02:00
|
|
|
) {
|
|
|
|
Text(
|
|
|
|
text = extension.name,
|
|
|
|
maxLines = 1,
|
|
|
|
overflow = TextOverflow.Ellipsis,
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
)
|
2022-10-01 21:32:08 +07:00
|
|
|
// Won't look good but it's not like we can ellipsize overflowing content
|
|
|
|
FlowRow(
|
|
|
|
modifier = Modifier.secondaryItemAlpha(),
|
2023-02-22 00:04:11 +07:00
|
|
|
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
2022-05-15 15:59:53 +02:00
|
|
|
) {
|
2022-10-01 21:32:08 +07:00
|
|
|
ProvideTextStyle(value = MaterialTheme.typography.bodySmall) {
|
|
|
|
if (extension is Extension.Installed && extension.lang.isNotEmpty()) {
|
|
|
|
Text(
|
|
|
|
text = LocaleHelper.getSourceDisplayName(extension.lang, LocalContext.current),
|
|
|
|
)
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
|
2022-10-01 21:32:08 +07:00
|
|
|
if (extension.versionName.isNotEmpty()) {
|
|
|
|
Text(
|
|
|
|
text = extension.versionName,
|
|
|
|
)
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
|
2022-10-01 21:32:08 +07:00
|
|
|
val warning = when {
|
2023-11-18 13:54:56 -05:00
|
|
|
extension is Extension.Untrusted -> MR.strings.ext_untrusted
|
|
|
|
extension is Extension.Installed && extension.isUnofficial -> MR.strings.ext_unofficial
|
|
|
|
extension is Extension.Installed && extension.isObsolete -> MR.strings.ext_obsolete
|
|
|
|
extension.isNsfw -> MR.strings.ext_nsfw_short
|
2022-10-01 21:32:08 +07:00
|
|
|
else -> null
|
|
|
|
}
|
|
|
|
if (warning != null) {
|
|
|
|
Text(
|
2023-11-18 19:41:33 -05:00
|
|
|
text = stringResource(warning).uppercase(),
|
2022-05-15 15:59:53 +02:00
|
|
|
color = MaterialTheme.colorScheme.error,
|
2022-10-01 21:32:08 +07:00
|
|
|
maxLines = 1,
|
|
|
|
overflow = TextOverflow.Ellipsis,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!installStep.isCompleted()) {
|
|
|
|
DotSeparatorNoSpaceText()
|
|
|
|
Text(
|
|
|
|
text = when (installStep) {
|
2023-11-18 19:41:33 -05:00
|
|
|
InstallStep.Pending -> stringResource(MR.strings.ext_pending)
|
|
|
|
InstallStep.Downloading -> stringResource(MR.strings.ext_downloading)
|
|
|
|
InstallStep.Installing -> stringResource(MR.strings.ext_installing)
|
2022-10-01 21:32:08 +07:00
|
|
|
else -> error("Must not show non-install process text")
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionItemActions(
|
2022-05-15 15:59:53 +02:00
|
|
|
extension: Extension,
|
|
|
|
installStep: InstallStep,
|
|
|
|
modifier: Modifier = Modifier,
|
2023-12-11 22:24:33 -05:00
|
|
|
onClickItemWebView: (Extension.Available) -> Unit = {},
|
2022-05-15 15:59:53 +02:00
|
|
|
onClickItemCancel: (Extension) -> Unit = {},
|
|
|
|
onClickItemAction: (Extension) -> Unit = {},
|
|
|
|
) {
|
2022-10-01 21:32:08 +07:00
|
|
|
val isIdle = installStep.isCompleted()
|
2023-12-11 22:24:33 -05:00
|
|
|
|
|
|
|
Row(
|
|
|
|
modifier = modifier,
|
|
|
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
|
|
|
) {
|
|
|
|
when {
|
|
|
|
!isIdle -> {
|
|
|
|
IconButton(onClick = { onClickItemCancel(extension) }) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.Close,
|
|
|
|
contentDescription = stringResource(MR.strings.action_cancel),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
installStep == InstallStep.Error -> {
|
|
|
|
IconButton(onClick = { onClickItemAction(extension) }) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.Refresh,
|
|
|
|
contentDescription = stringResource(MR.strings.action_retry),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
installStep == InstallStep.Idle -> {
|
|
|
|
when (extension) {
|
|
|
|
is Extension.Installed -> {
|
|
|
|
if (extension.hasUpdate) {
|
|
|
|
IconButton(onClick = { onClickItemAction(extension) }) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.GetApp,
|
|
|
|
contentDescription = stringResource(MR.strings.ext_update),
|
|
|
|
)
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
}
|
2023-12-11 22:24:33 -05:00
|
|
|
|
|
|
|
IconButton(onClick = { onClickItemAction(extension) }) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.Settings,
|
|
|
|
contentDescription = stringResource(MR.strings.action_settings),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is Extension.Untrusted -> {
|
|
|
|
IconButton(onClick = { onClickItemAction(extension) }) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.VerifiedUser,
|
|
|
|
contentDescription = stringResource(MR.strings.ext_trust),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
is Extension.Available -> {
|
|
|
|
if (extension.sources.isNotEmpty()) {
|
|
|
|
IconButton(
|
|
|
|
onClick = { onClickItemWebView(extension) },
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.Public,
|
|
|
|
contentDescription = stringResource(MR.strings.action_open_in_web_view),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton(onClick = { onClickItemAction(extension) }) {
|
|
|
|
Icon(
|
|
|
|
imageVector = Icons.Outlined.GetApp,
|
|
|
|
contentDescription = stringResource(MR.strings.ext_install),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionHeader(
|
2023-11-18 13:54:56 -05:00
|
|
|
textRes: StringResource,
|
2022-05-15 15:59:53 +02:00
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
action: @Composable RowScope.() -> Unit = {},
|
|
|
|
) {
|
|
|
|
ExtensionHeader(
|
2023-11-18 19:41:33 -05:00
|
|
|
text = stringResource(textRes),
|
2022-05-15 15:59:53 +02:00
|
|
|
modifier = modifier,
|
|
|
|
action = action,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionHeader(
|
2022-05-15 15:59:53 +02:00
|
|
|
text: String,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
action: @Composable RowScope.() -> Unit = {},
|
|
|
|
) {
|
|
|
|
Row(
|
2022-11-13 18:11:51 +01:00
|
|
|
modifier = modifier.padding(horizontal = MaterialTheme.padding.medium),
|
2022-05-15 15:59:53 +02:00
|
|
|
verticalAlignment = Alignment.CenterVertically,
|
|
|
|
) {
|
|
|
|
Text(
|
|
|
|
text = text,
|
|
|
|
modifier = Modifier
|
|
|
|
.padding(vertical = 8.dp)
|
|
|
|
.weight(1f),
|
|
|
|
style = MaterialTheme.typography.header,
|
|
|
|
)
|
|
|
|
action()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-09-18 22:38:44 -04:00
|
|
|
private fun ExtensionTrustDialog(
|
2022-05-15 15:59:53 +02:00
|
|
|
onClickConfirm: () -> Unit,
|
|
|
|
onClickDismiss: () -> Unit,
|
|
|
|
onDismissRequest: () -> Unit,
|
|
|
|
) {
|
|
|
|
AlertDialog(
|
|
|
|
title = {
|
2023-11-18 19:41:33 -05:00
|
|
|
Text(text = stringResource(MR.strings.untrusted_extension))
|
2022-05-15 15:59:53 +02:00
|
|
|
},
|
|
|
|
text = {
|
2023-11-18 19:41:33 -05:00
|
|
|
Text(text = stringResource(MR.strings.untrusted_extension_message))
|
2022-05-15 15:59:53 +02:00
|
|
|
},
|
|
|
|
confirmButton = {
|
|
|
|
TextButton(onClick = onClickConfirm) {
|
2023-11-18 19:41:33 -05:00
|
|
|
Text(text = stringResource(MR.strings.ext_trust))
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
dismissButton = {
|
|
|
|
TextButton(onClick = onClickDismiss) {
|
2023-11-18 19:41:33 -05:00
|
|
|
Text(text = stringResource(MR.strings.ext_uninstall))
|
2022-05-15 15:59:53 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
onDismissRequest = onDismissRequest,
|
|
|
|
)
|
|
|
|
}
|