Skip to content

Commit 2fb13cd

Browse files
authored
fix: Improve dialogs (#3165)
- Remove redundant description in import source dialog - Improve install status dialog - Don't show dialog when user canceled the installation - Remove icon (to not align center title) - Updated a few strings - Remove redundant text in Change API URL dialog
1 parent 0f0e5a3 commit 2fb13cd

5 files changed

Lines changed: 18 additions & 56 deletions

File tree

app/src/main/java/app/revanced/manager/ui/component/InstallerStatusDialog.kt

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,17 @@ package app.revanced.manager.ui.component
22

33
import android.annotation.SuppressLint
44
import android.content.pm.PackageInstaller
5-
import androidx.annotation.RequiresApi
65
import androidx.annotation.StringRes
7-
import androidx.compose.foundation.layout.Arrangement
8-
import androidx.compose.foundation.layout.Column
9-
import androidx.compose.material.icons.Icons
10-
import androidx.compose.material.icons.outlined.ErrorOutline
116
import androidx.compose.material3.AlertDialog
127
import androidx.compose.material3.ButtonDefaults
138
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
14-
import androidx.compose.material3.Icon
159
import androidx.compose.material3.MaterialTheme
1610
import androidx.compose.material3.Text
1711
import androidx.compose.material3.TextButton
1812
import androidx.compose.runtime.Composable
1913
import androidx.compose.runtime.remember
20-
import androidx.compose.ui.Alignment
21-
import androidx.compose.ui.graphics.vector.ImageVector
2214
import androidx.compose.ui.res.stringResource
2315
import androidx.compose.ui.text.style.TextAlign
24-
import androidx.compose.ui.unit.dp
2516
import app.revanced.manager.R
2617
import app.revanced.manager.ui.model.InstallerModel
2718
import com.github.materiiapps.enumutil.FromValue
@@ -43,9 +34,6 @@ fun InstallerStatusDialog(installerStatus: Int, model: InstallerModel, onDismiss
4334
dismissButton = {
4435
dialogKind.dismissButton?.invoke(model, onDismiss)
4536
},
46-
icon = {
47-
Icon(dialogKind.icon, null)
48-
},
4937
title = {
5038
Text(
5139
text = stringResource(dialogKind.title),
@@ -54,12 +42,7 @@ fun InstallerStatusDialog(installerStatus: Int, model: InstallerModel, onDismiss
5442
)
5543
},
5644
text = {
57-
Column(
58-
horizontalAlignment = Alignment.CenterHorizontally,
59-
verticalArrangement = Arrangement.spacedBy(16.dp),
60-
) {
61-
Text(stringResource(dialogKind.contentStringResId))
62-
}
45+
Text(stringResource(dialogKind.contentStringResId))
6346
}
6447
)
6548
}
@@ -85,66 +68,54 @@ enum class DialogKind(
8568
val flag: Int,
8669
val title: Int,
8770
@param:StringRes val contentStringResId: Int,
88-
val icon: ImageVector = Icons.Outlined.ErrorOutline,
8971
val confirmButton: InstallerStatusDialogButton = installerStatusDialogButton(R.string.ok),
9072
val dismissButton: InstallerStatusDialogButton? = null,
9173
) {
9274
FAILURE(
9375
flag = PackageInstaller.STATUS_FAILURE,
9476
title = R.string.installation_failed_dialog_title,
9577
contentStringResId = R.string.installation_failed_description,
96-
confirmButton = installerStatusDialogButton(R.string.install_app) { model ->
97-
model.install()
98-
}
99-
),
100-
FAILURE_ABORTED(
101-
flag = PackageInstaller.STATUS_FAILURE_ABORTED,
102-
title = R.string.installation_cancelled_dialog_title,
103-
contentStringResId = R.string.installation_aborted_description,
104-
confirmButton = installerStatusDialogButton(R.string.install_app) { model ->
105-
model.install()
106-
}
78+
confirmButton = installerStatusDialogButton(R.string.try_again) { it.install() },
79+
dismissButton = installerStatusDialogButton(R.string.cancel),
10780
),
10881
FAILURE_BLOCKED(
10982
flag = PackageInstaller.STATUS_FAILURE_BLOCKED,
11083
title = R.string.installation_blocked_dialog_title,
11184
contentStringResId = R.string.installation_blocked_description,
85+
dismissButton = installerStatusDialogButton(R.string.cancel),
11286
),
11387
FAILURE_CONFLICT(
11488
flag = PackageInstaller.STATUS_FAILURE_CONFLICT,
11589
title = R.string.installation_conflict_dialog_title,
11690
contentStringResId = R.string.installation_conflict_description,
117-
confirmButton = installerStatusDialogButton(R.string.reinstall) { model ->
118-
model.reinstall()
119-
},
91+
confirmButton = installerStatusDialogButton(R.string.reinstall) { it.reinstall() },
12092
dismissButton = installerStatusDialogButton(R.string.cancel),
12193
),
12294
FAILURE_INCOMPATIBLE(
12395
flag = PackageInstaller.STATUS_FAILURE_INCOMPATIBLE,
12496
title = R.string.installation_incompatible_dialog_title,
12597
contentStringResId = R.string.installation_incompatible_description,
98+
dismissButton = installerStatusDialogButton(R.string.ok),
12699
),
127100
FAILURE_INVALID(
128101
flag = PackageInstaller.STATUS_FAILURE_INVALID,
129102
title = R.string.installation_invalid_dialog_title,
130103
contentStringResId = R.string.installation_invalid_description,
131-
confirmButton = installerStatusDialogButton(R.string.reinstall) { model ->
132-
model.reinstall()
133-
},
104+
confirmButton = installerStatusDialogButton(R.string.reinstall) { it.reinstall() },
134105
dismissButton = installerStatusDialogButton(R.string.cancel),
135106
),
136107
FAILURE_STORAGE(
137108
flag = PackageInstaller.STATUS_FAILURE_STORAGE,
138109
title = R.string.installation_storage_issue_dialog_title,
139110
contentStringResId = R.string.installation_storage_issue_description,
111+
dismissButton = installerStatusDialogButton(R.string.ok),
140112
),
141113
FAILURE_TIMEOUT(
142114
flag = @SuppressLint("InlinedApi") PackageInstaller.STATUS_FAILURE_TIMEOUT,
143115
title = R.string.installation_timeout_dialog_title,
144116
contentStringResId = R.string.installation_timeout_description,
145-
confirmButton = installerStatusDialogButton(R.string.install_app) { model ->
146-
model.install()
147-
},
117+
confirmButton = installerStatusDialogButton(R.string.try_again) { it.install() },
118+
dismissButton = installerStatusDialogButton(R.string.cancel),
148119
);
149120

150121
// Needed due to the @FromValue annotation.

app/src/main/java/app/revanced/manager/ui/component/sources/ImportSourceDialog.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,20 @@ private enum class SourceType {
3737

3838
enum class ImportSourceDialogStrings(
3939
val title: Int,
40-
val type_description: Int,
4140
val type_remote_description: Int,
4241
val type_local_description: Int,
4342
val import_local: Int,
4443
val import_remote: Int
4544
) {
4645
PATCHES(
4746
R.string.add_patches,
48-
R.string.select_patches_type_dialog_description,
4947
R.string.remote_patches_description,
5048
R.string.local_patches_description,
5149
R.string.patches,
5250
R.string.patches_url
5351
),
5452
DOWNLOADERS(
5553
R.string.downloader_add,
56-
R.string.select_downloader_type_dialog_description,
5754
R.string.remote_downloaders_description,
5855
R.string.local_downloaders_description,
5956
R.string.downloaders,
@@ -117,7 +114,7 @@ fun ImportSourceDialog(
117114
AlertDialogExtended(
118115
onDismissRequest = onDismiss,
119116
title = {
120-
Text(stringResource(if (currentStep == 0) R.string.select else strings.title))
117+
Text(stringResource(strings.title))
121118
},
122119
text = {
123120
steps[currentStep]()
@@ -167,10 +164,6 @@ private fun SelectSourceTypeStep(
167164
modifier = Modifier.verticalScroll(rememberScrollState()),
168165
verticalArrangement = Arrangement.spacedBy(24.dp)
169166
) {
170-
Text(
171-
modifier = Modifier.padding(horizontal = 24.dp),
172-
text = stringResource(strings.type_description)
173-
)
174167
Column {
175168
ListItem(
176169
modifier = Modifier.clickable(

app/src/main/java/app/revanced/manager/ui/screen/PatcherScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package app.revanced.manager.ui.screen
22

33
import android.app.Activity
4-
import android.os.Build
4+
import android.content.pm.PackageInstaller
55
import android.view.WindowManager
66
import androidx.activity.compose.BackHandler
77
import androidx.activity.compose.rememberLauncherForActivityResult
@@ -150,6 +150,8 @@ fun PatcherScreen(
150150
}
151151

152152
viewModel.packageInstallerStatus?.let {
153+
// Don't show when the user cancels the installation (they can click Install again anyway)
154+
if (it == PackageInstaller.STATUS_FAILURE_ABORTED) return@let
153155
InstallerStatusDialog(it, viewModel, viewModel::dismissPackageInstallerDialog)
154156
}
155157

app/src/main/java/app/revanced/manager/ui/screen/settings/DeveloperSettingsScreen.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ private fun APIUrlDialog(currentUrl: String, defaultUrl: String, onSubmit: (Stri
193193
modifier = Modifier.verticalScroll(rememberScrollState()),
194194
verticalArrangement = Arrangement.spacedBy(16.dp)
195195
) {
196-
Text(
197-
text = stringResource(R.string.api_url_dialog_description),
198-
style = MaterialTheme.typography.bodyMedium,
199-
color = MaterialTheme.colorScheme.onSurfaceVariant
200-
)
201196
Text(
202197
text = stringResource(R.string.api_url_dialog_warning),
203198
style = MaterialTheme.typography.bodyMedium,

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Second \"item\" text"</string>
3030
<string name="onboarding_updates_note">ReVanced Manager will connect to %s in order to download initial versions if your device is connected to the internet</string>
3131

3232
<string name="retry">Retry</string>
33+
<string name="try_again">Try again</string>
3334
<string name="onboarding_skip">Skip for now</string>
3435
<string name="onboarding_recommended_version">Recommended version: %s</string>
3536

@@ -534,14 +535,14 @@ It’s only compatible with these versions: %2$s</string>
534535
<string name="installation_cancelled_dialog_title">Install canceled</string>
535536
<string name="installation_blocked_dialog_title">Install blocked</string>
536537
<string name="installation_conflict_dialog_title">Install conflict</string>
537-
<string name="installation_incompatible_dialog_title">Install incompatible</string>
538+
<string name="installation_incompatible_dialog_title">Incompatible app</string>
538539
<string name="installation_invalid_dialog_title">Install invalid</string>
539540
<string name="installation_storage_issue_dialog_title">Not enough storage</string>
540-
<string name="installation_timeout_dialog_title">Install timed out</string>
541+
<string name="installation_timeout_dialog_title">Timed out</string>
541542
<string name="installation_failed_description">There was a problem installing the app</string>
542543
<string name="installation_aborted_description">Installation was canceled</string>
543544
<string name="installation_blocked_description">Installation was blocked. Try adjusting the security settings of your device, and try again.</string>
544-
<string name="installation_conflict_description">An existing app is preventing the install. Uninstall the app, and try again.</string>
545+
<string name="installation_conflict_description">An existing app is preventing your installation. Uninstall the app, and try again.</string>
545546
<string name="installation_incompatible_description">This app isn’t compatible with your device. Use an APK that is compatible, and try again.</string>
546547
<string name="installation_invalid_description">There was a problem installing the app. Uninstall the app, and try again.</string>
547548
<string name="installation_storage_issue_description">There’s not enough storage space to install this app. Free up some space, and try again.</string>

0 commit comments

Comments
 (0)