From c4d9a4797ef949316730aacbb1b155f19747250b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C9=91rry=20Shiv=C9=91m?= Date: Sat, 16 Dec 2023 15:39:11 +0530 Subject: [PATCH] Add toolip about swipe actions in library (#98) * Also reorganise Italian strings --------- Signed-off-by: starry-shivam --- .idea/appInsightsSettings.xml | 17 +++ app/build.gradle | 2 +- .../screens/home/viewmodels/HomeViewModel.kt | 2 +- .../library/composables/LibraryScreen.kt | 33 +++- .../library/viewmodels/LibraryViewModel.kt | 8 + .../reader/activities/ReaderActivity.kt | 31 ++-- .../settings/composables/SettingsScreen.kt | 2 +- .../welcome/composables/WelcomeScreen.kt | 2 +- .../com/starry/myne/utils/Preferencesutils.kt | 3 + app/src/main/res/values-ar/strings.xml | 7 +- app/src/main/res/values-cs/strings.xml | 7 +- app/src/main/res/values-es/strings.xml | 7 +- app/src/main/res/values-it/strings.xml | 142 +++++++++++------- app/src/main/res/values-ro/strings.xml | 7 +- app/src/main/res/values-ru/strings.xml | 7 +- app/src/main/res/values/strings.xml | 7 +- 16 files changed, 203 insertions(+), 81 deletions(-) diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml index d02d9336..f9cd1c27 100644 --- a/.idea/appInsightsSettings.xml +++ b/.idea/appInsightsSettings.xml @@ -22,6 +22,23 @@ + + + + + + + diff --git a/app/build.gradle b/app/build.gradle index f5ef00cc..7a3b1dcc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -126,7 +126,7 @@ dependencies { implementation "com.mikepenz:aboutlibraries-core:10.5.2" implementation "com.mikepenz:aboutlibraries-compose:10.5.2" // Swipe actions. - implementation "me.saket.swipe:swipe:1.0.0" + implementation "me.saket.swipe:swipe:1.2.0" // Crash Handler. implementation 'cat.ereza:customactivityoncrash:2.4.0' // Kotlin reflect API. diff --git a/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt index 57978cee..a4ccfaf1 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/home/viewmodels/HomeViewModel.kt @@ -96,7 +96,7 @@ class HomeViewModel @Inject constructor( * this: {"detail": "Invalid page."}. Hence the [BookSet] attributes become * null in this case and can cause crashes. */ - val books = if (bookSet.books != null) { + @Suppress("SENSELESS_COMPARISON") val books = if (bookSet.books != null) { bookSet.books.filter { it.formats.applicationepubzip != null } as ArrayList } else { ArrayList() diff --git a/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt index 78a359ac..704affd4 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/library/composables/LibraryScreen.kt @@ -44,10 +44,15 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarDuration +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.SnackbarResult import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState import androidx.compose.runtime.mutableStateOf @@ -104,13 +109,18 @@ import java.io.File fun LibraryScreen(navController: NavController) { val viewModel: LibraryViewModel = hiltViewModel() val state = viewModel.allItems.observeAsState(listOf()).value + val context = LocalContext.current val settingsViewModel = (context.getActivity() as MainActivity).settingsViewModel + val snackBarHostState = remember { SnackbarHostState() } + Scaffold( + snackbarHost = { SnackbarHost(snackBarHostState) }, modifier = Modifier .fillMaxSize() - .background(MaterialTheme.colorScheme.background), + .background(MaterialTheme.colorScheme.background) + .padding(bottom = 70.dp), topBar = { CustomTopAppBar( headerText = stringResource(id = R.string.library_header), @@ -123,7 +133,6 @@ fun LibraryScreen(navController: NavController) { modifier = Modifier .fillMaxSize() .background(MaterialTheme.colorScheme.background) - .padding(bottom = 70.dp) ) { if (state.isEmpty()) { NoLibraryItemAnimation() @@ -211,7 +220,7 @@ fun LibraryScreen(navController: NavController) { context.getString(R.string.error).toToast(context) } }) { - Text(stringResource(id = R.string.dialog_confirm_button)) + Text(stringResource(id = R.string.confirm)) } }, dismissButton = { TextButton(onClick = { @@ -227,6 +236,24 @@ fun LibraryScreen(navController: NavController) { } } } + + // Show tooltip for library screen. + LaunchedEffect(key1 = true) { + if (viewModel.shouldShowLibraryTooltip()) { + val result = snackBarHostState.showSnackbar( + message = context.getString(R.string.library_tooltip), + actionLabel = context.getString(R.string.got_it), + duration = SnackbarDuration.Indefinite + ) + + when (result) { + SnackbarResult.ActionPerformed -> { + viewModel.libraryTooltipDismissed() + } + SnackbarResult.Dismissed -> {} + } + } + } } } } diff --git a/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt b/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt index 0eb27973..b0209dca 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/library/viewmodels/LibraryViewModel.kt @@ -41,4 +41,12 @@ class LibraryViewModel @Inject constructor( fun getInternalReaderSetting() = preferenceUtil.getBoolean( PreferenceUtil.INTERNAL_READER_BOOL, true ) + + fun shouldShowLibraryTooltip() = preferenceUtil.getBoolean( + PreferenceUtil.SHOW_LIBRARY_TOOLTIP_BOOL, true + ) + + fun libraryTooltipDismissed() = preferenceUtil.putBoolean( + PreferenceUtil.SHOW_LIBRARY_TOOLTIP_BOOL, false + ) } \ No newline at end of file diff --git a/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt b/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt index fb8181c6..40872b12 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/reader/activities/ReaderActivity.kt @@ -28,6 +28,7 @@ import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.Crossfade import androidx.compose.animation.animateContentSize import androidx.compose.animation.expandVertically import androidx.compose.animation.fadeIn @@ -82,6 +83,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.SideEffect import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -252,7 +254,7 @@ class ReaderActivity : AppCompatActivity(), ReaderClickListener { setContent { MyneTheme(settingsViewModel = settingsViewModel) { TransparentSystemBars() - val textSizeValue = remember { mutableStateOf(viewModel.getFontSize()) } + val textSizeValue = remember { mutableIntStateOf(viewModel.getFontSize()) } val readerFontFamily = remember { mutableStateOf(viewModel.getFontFamily()) } ReaderScreen( viewModel = viewModel, @@ -491,18 +493,23 @@ class ReaderActivity : AppCompatActivity(), ReaderClickListener { ) } }, - content = { - if (viewModel.state.isLoading) { - Box( - modifier = Modifier - .fillMaxSize() - .padding(bottom = 65.dp), - contentAlignment = Alignment.Center - ) { - CircularProgressIndicator(color = MaterialTheme.colorScheme.primary) + content = { paddingValues -> + Crossfade( + targetState = viewModel.state.isLoading, + label = "reader content loading cross fade" + ) { loading -> + if (loading) { + Box( + modifier = Modifier + .fillMaxSize() + .padding(bottom = 65.dp), + contentAlignment = Alignment.Center + ) { + CircularProgressIndicator(color = MaterialTheme.colorScheme.primary) + } + } else { + readerContent(paddingValues) } - } else { - readerContent(it) } } ) diff --git a/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt index c9fba15e..0dbe97e0 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/settings/composables/SettingsScreen.kt @@ -252,7 +252,7 @@ fun GeneralOptionsUI(viewModel: SettingsViewModel) { } } }) { - Text(stringResource(id = R.string.dialog_confirm_button)) + Text(stringResource(id = R.string.confirm)) } }, dismissButton = { TextButton(onClick = { diff --git a/app/src/main/java/com/starry/myne/ui/screens/welcome/composables/WelcomeScreen.kt b/app/src/main/java/com/starry/myne/ui/screens/welcome/composables/WelcomeScreen.kt index 6f0b278d..6826f6c9 100644 --- a/app/src/main/java/com/starry/myne/ui/screens/welcome/composables/WelcomeScreen.kt +++ b/app/src/main/java/com/starry/myne/ui/screens/welcome/composables/WelcomeScreen.kt @@ -213,7 +213,7 @@ fun WelcomeScreen(navController: NavController) { } } }) { - Text(stringResource(id = R.string.dialog_confirm_button)) + Text(stringResource(id = R.string.confirm)) } }, dismissButton = { TextButton(onClick = { diff --git a/app/src/main/java/com/starry/myne/utils/Preferencesutils.kt b/app/src/main/java/com/starry/myne/utils/Preferencesutils.kt index 8136c17f..0f71bc84 100644 --- a/app/src/main/java/com/starry/myne/utils/Preferencesutils.kt +++ b/app/src/main/java/com/starry/myne/utils/Preferencesutils.kt @@ -31,6 +31,9 @@ class PreferenceUtil(context: Context) { const val READER_FONT_SIZE_INT = "reader_font_size" const val READER_FONT_STYLE_STR = "reader_font_style" const val PREFERRED_BOOK_LANG_STR = "preferred_book_language" + + // Temporary preference keys + const val SHOW_LIBRARY_TOOLTIP_BOOL = "show_library_tooltip" } private var prefs: SharedPreferences diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 7ebbe68c..e6bdc1b1 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -3,8 +3,10 @@ غير معروف اووبس!! - تأكيد + تأكيد الغاء + OK + Got it امنح اذن التخزين من فضلك لا يوجد اى تطبيق لفتح ملف epub أُووبس! فشل الاتصال بالخادم. @@ -17,6 +19,9 @@ المكتبة الاعدادات + + TIP! Swipe library items left or right to share or view book details. + شكرًا لك على تثبيت Myne!\nالرجاء تحديد قارئ الكتب الإلكترونية المفضل لديك للحصول على السرعة. البدء diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 8cc5dca1..715d630f 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -2,8 +2,10 @@ N/A "Jejda!" - Potvrdit + Potvrdit Zrušit + OK + Got it Udělte prosím přístup k úložišti! Nepodařilo se najít aplikaci, která by dokázala otevřít soubor epub. Oops! Failed to connect with the server. @@ -16,6 +18,9 @@ Knihovna Nastavení + + TIP! Swipe library items left or right to share or view book details. + ThankYou for installing Myne!\nPlease Select your preferred e-book reader to get on speed. Get Started diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index e579ebbd..4b4ca1d1 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -3,8 +3,10 @@ N/A "¡Ups!" - Confirmar + Confirmar Cancelar + OK + Got it Por favor, acepte el permiso de almacenamiento No se ha podido encontrar ninguna aplicación para abrir el fichero epub. Oops! Failed to connect with the server. @@ -17,6 +19,9 @@ Biblioteca Ajustes + + TIP! Swipe library items left or right to share or view book details. + ThankYou for installing Myne!\nPlease Select your preferred e-book reader to get on speed. Get Started diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 96f14291..058406ae 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -1,77 +1,107 @@ + N/A Ops! - Conferma + Conferma Annulla + OK + Got it Per favore consenti l\'accesso allo spazio di archiviazione! Non è stata trovata nessuna app per aprire i file epub. Ops! Connessione al server fallita. Riprova Ops! Qualcosa è andato storto. + + Home Categorie Libreria Impostazioni + + + TIP! Swipe library items left or right to share or view book details. + + Grazie per avere installato Myne! Seleziona il tuo e-book reader per cominciare. Inizia + + Tutti i libri Ordina per lingua Cerca libri Sfoglia per lingua - Categorie - Nessun libro disponibile in %s per questa categoria. - Libreria - Non c\'è nulla qui! - Apri con… - Condividi con… - Leggi - Elimina - Sei sicuro? - Ebook Reader - Inizia - Riprendi - Capitoli - Ops! Non è stato possibile aprire il file e-book :( - Ci potrebbero essere vari motivi per cui è successo. - 1. L\'e-book è stato eliminato. - Controlla nella cartella MyneEbooks all\'interno della tua directory di download, altrimenti, prova a scaricare nuovamente il libro. - 2. Il file esiste, ma hai disinstallato l\'app in precedenza. - Myne utilizza l\'API scoped-storage di Android e pertanto può accedere solo ai file creati dall\'app, non ai file personali dell\'utente. Per via di questa limitazione, una volta che l\'utente disinstalla l\'app, vengono revocati i permessi di lettura e modifica. In questo caso elimina il file ebook epub dalla cartella MyneEbooks all\'interno della directory di download e scarica nuovamente il libro. - Chiudi e torna indietro - Spiacenti, non si può andare più in alto! - Spiacenti, non si può andare più in basso! - Cambia Font - Impostazioni - Ebook Downloader - Fatto con ❤ da Shivam - Generale - Reader di default - Apri ebooks con… - Mostra - Tema predefinito - Cambia Tema - Applica - Abilita Material You - Disabilita Material You - Questa funzionalità è disponibile solo per dispositivi Android 12 o superiore. - Varie - Licenza & Riconoscimenti - Licenze open source. - Info sull\'App - Mostra info sull\'App & link utili - Immagine di copertina - Dettagli del libro - Indietro. - Condividi questo libro. - Condividi con… - Inizia la lettura - Download - Download iniziato! - Riassunto del libro - Non disponibile - Info - Un\'applicazione Android gratis & Open Source per scaricare ebooks dal Project GutenBerg. - Sviluppato da - Librerie Open Source + + + Categorie + Nessun libro disponibile in %s per questa categoria. + + + Libreria + Non c\'è nulla qui! + Apri con… + Condividi con… + Leggi + Elimina + Sei sicuro? + + + Ebook Reader + Inizia + Riprendi + Capitoli + Ops! Non è stato possibile aprire il file e-book :( + Ci potrebbero essere vari motivi per cui è successo. + 1. L\'e-book è stato eliminato. + Controlla nella cartella MyneEbooks all\'interno della tua directory di download, altrimenti, prova a scaricare nuovamente il libro. + 2. Il file esiste, ma hai disinstallato l\'app in precedenza. + Myne utilizza l\'API scoped-storage di Android e pertanto può accedere solo ai file creati dall\'app, non ai file personali dell\'utente. Per via di questa limitazione, una volta che l\'utente disinstalla l\'app, vengono revocati i permessi di lettura e modifica. In questo caso elimina il file ebook epub dalla cartella MyneEbooks all\'interno della directory di download e scarica nuovamente il libro. + Chiudi e torna indietro + + + Spiacenti, non si può andare più in alto! + Spiacenti, non si può andare più in basso! + Cambia Font + + + Impostazioni + Ebook Downloader + Fatto con ❤ da Shivam + Generale + Reader di default + Apri ebooks con… + Mostra + Tema predefinito + Cambia Tema + Applica + Abilita Material You + Disabilita Material You + Questa funzionalità è disponibile solo per dispositivi Android 12 o superiore. + Varie + Licenza & Riconoscimenti + Licenze open source. + Info sull\'App + Mostra info sull\'App & link utili + + + Immagine di copertina + + + Dettagli del libro + Indietro. + Condividi questo libro. + Condividi con… + Inizia la lettura + Download + Download iniziato! + Riassunto del libro + Non disponibile + + + Info + Un\'applicazione Android gratis & Open Source per scaricare ebooks dal Project GutenBerg. + Sviluppato da + + + Librerie Open Source \ No newline at end of file diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 2694c176..752a2ac1 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -3,8 +3,10 @@ N/A "Ups!" - Confirmă + Confirmă Anulează + OK + Got it Te rugăm să acorzi permisiunea de stocare! Nu pot găsi nicio aplicație pentru a deschide un fișier epub. Ups! Nu a reușit să se conecteze cu serverul. @@ -17,6 +19,9 @@ Librărie Setări + + TIP! Swipe library items left or right to share or view book details. + Mulțumim că ai instalat Myne!\nTe rugăm să selectezi e-book reader-ul tău preferat pentru a trece la viteză. Începeți diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 29a712c4..818e3b56 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -3,8 +3,10 @@ Неизвестно Упс!! - Подтвердить + Подтвердить Отменить + OK + Got it Пожалуйста, предоставьте разрешение на хранение! Не удается найти ни одного приложения для открытия файла epub. Упс! Не удалось подключиться к серверу. @@ -17,6 +19,9 @@ Библиотека Настройки + + TIP! Swipe library items left or right to share or view book details. + Спасибо за установку Myne!\nПожалуйста выберите способ чтения книг. Приступим diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8d075157..5d289c51 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,8 +3,10 @@ N/A "Whoops!!" - Confirm + Confirm Cancel + OK + Got it Please grant storage permission! Cannot find any app to open epub file. Oops! Failed to connect with the server. @@ -17,6 +19,9 @@ Library Settings + + TIP! Swipe library items left or right to share or view book details. + ThankYou for installing Myne!\nPlease Select your preferred e-book reader to get on speed. Get Started