Skip to content

Commit

Permalink
feat: Remove mirror selection from DownloadFailedDialog screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Ushie committed Jan 16, 2025
1 parent 08ffe35 commit 7e3f8cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,65 +1,22 @@
package app.revenge.manager.ui.widgets.dialog

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.FilledTonalButton
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
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import app.revenge.manager.R
import app.revenge.manager.domain.manager.PreferenceManager
import app.revenge.manager.ui.components.settings.SettingsChoiceDialog
import org.koin.androidx.compose.get

@Composable
fun DownloadFailedDialog(
onTryAgainClick: () -> Unit,
onDismiss: () -> Unit
) {
val prefs: PreferenceManager = get()
var mirrorPickerOpened by remember {
mutableStateOf(false)
}

SettingsChoiceDialog(
visible = mirrorPickerOpened,
default = prefs.mirror,
title = { Text(stringResource(R.string.settings_mirror)) },
labelFactory = { it.baseUrl.toUri().authority ?: it.baseUrl },
onRequestClose = { mirrorPickerOpened = false },
onChoice = {
prefs.mirror = it
mirrorPickerOpened = false
}
)

AlertDialog(
onDismissRequest = onDismiss,
text = {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Text(stringResource(R.string.msg_change_mirror))
FilledTonalButton(
onClick = { mirrorPickerOpened = true },
modifier = Modifier.fillMaxWidth()
) {
Text(
text = prefs.mirror.baseUrl.toUri().authority ?: prefs.mirror.baseUrl
)
}
}
Text(stringResource(R.string.msg_try_again))
},
dismissButton = {
TextButton(onClick = onDismiss) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<string name="msg_unlocked">You are now a developer</string>
<string name="msg_permission_grant">File permissions are required to use shared storage.</string>
<string name="msg_shizuku_denied">Failed to obtain Shizuku permissions</string>
<string name="msg_change_mirror">Would you like to try again using a download mirror?</string>
<string name="msg_try_again">Would you like to try again?</string>
<string name="msg_invalid_apk">APK was corrupted, try clearing cache then reinstalling</string>
<string name="msg_download_cancelled">Download was aborted</string>
<string name="msg_download_failed">Download failed</string>
Expand Down

0 comments on commit 7e3f8cf

Please sign in to comment.