mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-29 13:27:57 +01:00
Clean up strings and resources (#8253)
* Clean up strings and resources * fix pringle's typo * restore catching file pick errors * add back file chooser title * revert #7740 and remove try-catch of chooser-wrapped intent * swap xmlns lines * swap xml tools lines
This commit is contained in:
@@ -102,7 +102,7 @@ private fun MigrateSourceList(
|
||||
IconButton(onClick = onToggleSortingMode) {
|
||||
when (sortingMode) {
|
||||
SetMigrateSorting.Mode.ALPHABETICAL -> Icon(Icons.Outlined.SortByAlpha, contentDescription = stringResource(R.string.action_sort_alpha))
|
||||
SetMigrateSorting.Mode.TOTAL -> Icon(Icons.Outlined.Numbers, contentDescription = stringResource(R.string.action_sort_total))
|
||||
SetMigrateSorting.Mode.TOTAL -> Icon(Icons.Outlined.Numbers, contentDescription = stringResource(R.string.action_sort_count))
|
||||
}
|
||||
}
|
||||
IconButton(onClick = onToggleSortingDirection) {
|
||||
|
||||
@@ -292,11 +292,12 @@ private fun MangaAndSourceTitlesLarge(
|
||||
MangaCover.Book(
|
||||
modifier = Modifier.fillMaxWidth(0.65f),
|
||||
data = coverDataProvider(),
|
||||
contentDescription = stringResource(R.string.manga_cover),
|
||||
onClick = onCoverClick,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Text(
|
||||
text = title.takeIf { it.isNotBlank() } ?: stringResource(R.string.unknown),
|
||||
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
modifier = Modifier.clickableNoIndication(
|
||||
onLongClick = { if (title.isNotBlank()) context.copyToClipboard(title, title) },
|
||||
@@ -419,11 +420,12 @@ private fun MangaAndSourceTitlesSmall(
|
||||
.sizeIn(maxWidth = 100.dp)
|
||||
.align(Alignment.Top),
|
||||
data = coverDataProvider(),
|
||||
contentDescription = stringResource(R.string.manga_cover),
|
||||
onClick = onCoverClick,
|
||||
)
|
||||
Column(modifier = Modifier.padding(start = 16.dp)) {
|
||||
Text(
|
||||
text = title.ifBlank { stringResource(R.string.unknown) },
|
||||
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
modifier = Modifier.clickableNoIndication(
|
||||
onLongClick = {
|
||||
@@ -583,7 +585,7 @@ private fun MangaSummary(
|
||||
val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down)
|
||||
Icon(
|
||||
painter = rememberAnimatedVectorPainter(image, !expanded),
|
||||
contentDescription = null,
|
||||
contentDescription = stringResource(if (expanded) R.string.manga_info_collapse else R.string.manga_info_expand),
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
modifier = Modifier.background(Brush.radialGradient(colors = colors.asReversed())),
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package eu.kanade.presentation.more.settings.screen
|
||||
|
||||
import android.Manifest
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
@@ -111,7 +113,12 @@ class SettingsBackupScreen : SearchableSettings {
|
||||
onConfirm = {
|
||||
showCreateDialog = false
|
||||
flag = it
|
||||
chooseBackupDir.launch(Backup.getBackupFilename())
|
||||
try {
|
||||
chooseBackupDir.launch(Backup.getBackupFilename())
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
flag = 0
|
||||
context.toast(R.string.file_picker_error)
|
||||
}
|
||||
},
|
||||
onDismissRequest = { showCreateDialog = false },
|
||||
)
|
||||
@@ -260,12 +267,16 @@ class SettingsBackupScreen : SearchableSettings {
|
||||
onDismissRequest = onDismissRequest,
|
||||
title = { Text(text = stringResource(R.string.pref_restore_backup)) },
|
||||
text = {
|
||||
var msg = stringResource(R.string.backup_restore_content_full)
|
||||
if (err.sources.isNotEmpty()) {
|
||||
msg += "\n\n${stringResource(R.string.backup_restore_missing_sources)}\n${err.sources.joinToString("\n") { "- $it" }}"
|
||||
}
|
||||
if (err.sources.isNotEmpty()) {
|
||||
msg += "\n\n${stringResource(R.string.backup_restore_missing_trackers)}\n${err.trackers.joinToString("\n") { "- $it" }}"
|
||||
val msg = buildString {
|
||||
append(stringResource(R.string.backup_restore_content_full))
|
||||
if (err.sources.isNotEmpty()) {
|
||||
append("\n\n").append(stringResource(R.string.backup_restore_missing_sources))
|
||||
err.sources.joinTo(this, separator = "\n- ", prefix = "\n- ")
|
||||
}
|
||||
if (err.trackers.isNotEmpty()) {
|
||||
append("\n\n").append(stringResource(R.string.backup_restore_missing_trackers))
|
||||
err.trackers.joinTo(this, separator = "\n- ", prefix = "\n- ")
|
||||
}
|
||||
}
|
||||
Text(text = msg)
|
||||
},
|
||||
@@ -285,7 +296,14 @@ class SettingsBackupScreen : SearchableSettings {
|
||||
}
|
||||
}
|
||||
|
||||
val chooseBackup = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) {
|
||||
val chooseBackup = rememberLauncherForActivityResult(
|
||||
object : ActivityResultContracts.GetContent() {
|
||||
override fun createIntent(context: Context, input: String): Intent {
|
||||
val intent = super.createIntent(context, input)
|
||||
return Intent.createChooser(intent, context.getString(R.string.file_select_backup))
|
||||
}
|
||||
},
|
||||
) {
|
||||
if (it != null) {
|
||||
val results = try {
|
||||
BackupFileValidator().validate(context, it)
|
||||
@@ -311,6 +329,7 @@ class SettingsBackupScreen : SearchableSettings {
|
||||
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(R.string.restore_miui_warning, Toast.LENGTH_LONG)
|
||||
}
|
||||
// no need to catch because it's wrapped with a chooser
|
||||
chooseBackup.launch("*/*")
|
||||
} else {
|
||||
context.toast(R.string.restore_in_progress)
|
||||
@@ -363,7 +382,13 @@ class SettingsBackupScreen : SearchableSettings {
|
||||
subtitle = remember(backupDir) {
|
||||
UniFile.fromUri(context, backupDir.toUri()).filePath!! + "/automatic"
|
||||
},
|
||||
onClick = { pickBackupLocation.launch(null) },
|
||||
onClick = {
|
||||
try {
|
||||
pickBackupLocation.launch(null)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
context.toast(R.string.file_picker_error)
|
||||
}
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
pref = backupPreferences.numberOfBackups(),
|
||||
|
||||
@@ -65,7 +65,7 @@ class SettingsDownloadScreen : SearchableSettings {
|
||||
downloadPreferences = downloadPreferences,
|
||||
categories = allCategories,
|
||||
),
|
||||
getDownloadNewChaptersGroup(
|
||||
getAutoDownloadGroup(
|
||||
downloadPreferences = downloadPreferences,
|
||||
allCategories = allCategories,
|
||||
),
|
||||
@@ -196,7 +196,7 @@ class SettingsDownloadScreen : SearchableSettings {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getDownloadNewChaptersGroup(
|
||||
private fun getAutoDownloadGroup(
|
||||
downloadPreferences: DownloadPreferences,
|
||||
allCategories: List<Category>,
|
||||
): Preference.PreferenceGroup {
|
||||
@@ -227,7 +227,7 @@ class SettingsDownloadScreen : SearchableSettings {
|
||||
}
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(R.string.pref_download_new),
|
||||
title = stringResource(R.string.pref_category_auto_download),
|
||||
preferenceItems = listOf(
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = downloadNewChaptersPref,
|
||||
|
||||
@@ -67,6 +67,7 @@ class SettingsReaderScreen : SearchableSettings {
|
||||
title = stringResource(R.string.pref_page_transitions),
|
||||
),
|
||||
getDisplayGroup(readerPreferences = readerPref),
|
||||
getReadingGroup(readerPreferences = readerPref),
|
||||
getPagedGroup(readerPreferences = readerPref),
|
||||
getWebtoonGroup(readerPreferences = readerPref),
|
||||
getNavigationGroup(readerPreferences = readerPref),
|
||||
@@ -120,6 +121,27 @@ class SettingsReaderScreen : SearchableSettings {
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getReadingGroup(readerPreferences: ReaderPreferences): Preference.PreferenceGroup {
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(R.string.pref_category_reading),
|
||||
preferenceItems = listOf(
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.skipRead(),
|
||||
title = stringResource(R.string.pref_skip_read_chapters),
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.skipFiltered(),
|
||||
title = stringResource(R.string.pref_skip_filtered_chapters),
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.alwaysShowChapterTransition(),
|
||||
title = stringResource(R.string.pref_always_show_chapter_transition),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun getPagedGroup(readerPreferences: ReaderPreferences): Preference.PreferenceGroup {
|
||||
val navModePref = readerPreferences.navigationModePager()
|
||||
@@ -308,6 +330,7 @@ class SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.folderPerManga(),
|
||||
title = stringResource(R.string.pref_create_folder_per_manga),
|
||||
subtitle = stringResource(R.string.pref_create_folder_per_manga_summary),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -70,7 +70,6 @@ import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* Controller that shows the currently active downloads.
|
||||
* Uses R.layout.fragment_download_queue.
|
||||
*/
|
||||
class DownloadController :
|
||||
FullComposeController<DownloadPresenter>(),
|
||||
|
||||
@@ -56,7 +56,7 @@ class LibraryController(
|
||||
onClickFilter = ::showSettingsSheet,
|
||||
onClickRefresh = {
|
||||
val started = LibraryUpdateService.start(context, it)
|
||||
context.toast(if (started) R.string.updating_library else R.string.update_already_running)
|
||||
context.toast(if (started) R.string.updating_category else R.string.update_already_running)
|
||||
started
|
||||
},
|
||||
onClickInvertSelection = { presenter.invertSelection(presenter.activeCategory) },
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.content.Intent
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.activity.result.PickVisualMediaRequest
|
||||
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -88,7 +86,7 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.MangaFul
|
||||
} catch (e: Throwable) {
|
||||
withUIContext {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
activity.toast(R.string.error_saving_cover)
|
||||
activity.toast(R.string.error_sharing_cover)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,8 +112,11 @@ class MangaFullCoverDialog : FullComposeController<MangaFullCoverDialog.MangaFul
|
||||
private fun changeCover(action: EditCoverAction) {
|
||||
when (action) {
|
||||
EditCoverAction.EDIT -> {
|
||||
// This will open new Photo Picker eventually.
|
||||
// See https://github.com/tachiyomiorg/tachiyomi/pull/8253#issuecomment-1285747310
|
||||
val intent = Intent(Intent.ACTION_GET_CONTENT).apply { type = "image/*" }
|
||||
startActivityForResult(
|
||||
PickVisualMedia().createIntent(activity!!, PickVisualMediaRequest(PickVisualMedia.ImageOnly)),
|
||||
Intent.createChooser(intent, resources?.getString(R.string.file_select_cover)),
|
||||
REQUEST_IMAGE_OPEN,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user