🚀 Improve Toast messages
* Cancel previous toast if new appeared * Simplified call
This commit is contained in:
parent
532050f944
commit
995f371d5a
21 changed files with 126 additions and 235 deletions
|
|
@ -1,9 +1,13 @@
|
|||
package ua.acclorite.book_story.presentation.data
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
|
||||
fun String.removeTrailingZero(): String {
|
||||
var toast: Toast? = null
|
||||
|
||||
if (!this.contains('.'))
|
||||
return this
|
||||
return this
|
||||
|
|
@ -34,3 +38,11 @@ fun Intent.launchActivity(
|
|||
|
||||
success?.invoke()
|
||||
}
|
||||
|
||||
fun String.showToast(context: Context, longToast: Boolean = true) {
|
||||
toast?.cancel()
|
||||
toast = null
|
||||
|
||||
toast = Toast.makeText(context, this, if (longToast) Toast.LENGTH_LONG else Toast.LENGTH_SHORT)
|
||||
toast?.show()
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.about
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
|
|
@ -38,6 +37,7 @@ import ua.acclorite.book_story.presentation.components.GoBackButton
|
|||
import ua.acclorite.book_story.presentation.components.collapsibleUntilExitScrollBehaviorWithLazyListState
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.Screen
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.about.components.AboutItem
|
||||
import ua.acclorite.book_story.presentation.screens.about.components.AboutUpdateDialog
|
||||
import ua.acclorite.book_story.presentation.screens.about.components.badges.AboutBadges
|
||||
|
|
@ -152,27 +152,18 @@ private fun AboutScreen(
|
|||
AboutEvent.OnCheckForUpdates(
|
||||
context = context,
|
||||
noUpdatesFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.no_updates),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.no_updates)
|
||||
.showToast(context = context)
|
||||
},
|
||||
error = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_check_internet),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.error_check_internet)
|
||||
.showToast(context = context)
|
||||
}
|
||||
)
|
||||
)
|
||||
} else {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.no_updates),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.no_updates)
|
||||
.showToast(context = context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -187,11 +178,8 @@ private fun AboutScreen(
|
|||
context.getString(R.string.issues_page),
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -208,11 +196,8 @@ private fun AboutScreen(
|
|||
context.getString(R.string.releases_page),
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -251,11 +236,8 @@ private fun AboutScreen(
|
|||
context.getString(R.string.translation_page),
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.about.components
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Update
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -10,6 +9,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithContent
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.about.data.AboutEvent
|
||||
import ua.acclorite.book_story.presentation.screens.about.data.AboutState
|
||||
|
||||
|
|
@ -43,11 +43,10 @@ fun AboutUpdateDialog(
|
|||
page = context.getString(R.string.download_latest_release_page),
|
||||
context = context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser).showToast(
|
||||
context = context,
|
||||
longToast = false
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.about.components.badges
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
|
@ -15,6 +14,7 @@ import androidx.compose.ui.unit.dp
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.util.Constants
|
||||
import ua.acclorite.book_story.presentation.components.customItems
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.about.data.AboutEvent
|
||||
|
||||
/**
|
||||
|
|
@ -45,11 +45,8 @@ fun AboutBadges(
|
|||
AboutBadgeItem(badge = badge) {
|
||||
when (badge.id) {
|
||||
"tryzub" -> {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.slava_ukraini),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.slava_ukraini)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
|
@ -59,11 +56,8 @@ fun AboutBadges(
|
|||
it,
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.about.nested.credits
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
|
|
@ -26,6 +25,7 @@ import ua.acclorite.book_story.presentation.components.GoBackButton
|
|||
import ua.acclorite.book_story.presentation.components.collapsibleUntilExitScrollBehaviorWithLazyListState
|
||||
import ua.acclorite.book_story.presentation.components.customItems
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.about.data.AboutEvent
|
||||
import ua.acclorite.book_story.presentation.screens.about.data.AboutViewModel
|
||||
import ua.acclorite.book_story.presentation.screens.about.nested.credits.components.CreditItem
|
||||
|
|
@ -86,11 +86,8 @@ private fun CreditsScreen(
|
|||
page = website,
|
||||
context = context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.about.nested.license_info
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
|
|
@ -44,6 +43,7 @@ import ua.acclorite.book_story.presentation.components.collapsibleUntilExitScrol
|
|||
import ua.acclorite.book_story.presentation.components.customItems
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.Screen
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoEvent
|
||||
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoState
|
||||
import ua.acclorite.book_story.presentation.screens.about.nested.license_info.data.LicenseInfoViewModel
|
||||
|
|
@ -126,11 +126,10 @@ private fun LicenseInfoScreen(
|
|||
page = url,
|
||||
context = context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser).showToast(
|
||||
context = context,
|
||||
longToast = false
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components.change_cover_bottom_sheet
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.PickVisualMediaRequest
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
|
|
@ -21,6 +20,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.CustomBottomSheet
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoState
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
|
|
@ -56,11 +56,8 @@ fun BookInfoChangeCoverBottomSheet(
|
|||
}
|
||||
)
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.cover_image_changed),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.cover_image_changed)
|
||||
.showToast(context = context)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -90,11 +87,7 @@ fun BookInfoChangeCoverBottomSheet(
|
|||
onHistoryUpdateEvent(HistoryEvent.OnUpdateBook(it))
|
||||
},
|
||||
showResult = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
it.asString(context),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
it.asString(context).showToast(context = context)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -129,11 +122,8 @@ fun BookInfoChangeCoverBottomSheet(
|
|||
}
|
||||
)
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.cover_image_deleted),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.cover_image_deleted)
|
||||
.showToast(context = context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components.details_bottom_sheet
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
|
|
@ -13,6 +12,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.CustomBottomSheet
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoState
|
||||
import java.io.File
|
||||
|
|
@ -75,11 +75,8 @@ fun BookInfoDetailsBottomSheet(
|
|||
context,
|
||||
state.value.book.filePath.substringAfterLast("/").trim(),
|
||||
success = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.copied),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.copied)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
|
@ -92,11 +89,8 @@ fun BookInfoDetailsBottomSheet(
|
|||
context,
|
||||
state.value.book.filePath.trim(),
|
||||
success = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.copied),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.copied)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
|
@ -111,11 +105,8 @@ fun BookInfoDetailsBottomSheet(
|
|||
context,
|
||||
lastOpened,
|
||||
success = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.copied),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.copied)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
|
@ -130,13 +121,11 @@ fun BookInfoDetailsBottomSheet(
|
|||
context,
|
||||
fileSize,
|
||||
success = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.copied),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.copied)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components.dialog
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.DeleteOutline
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -9,6 +8,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithContent
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseEvent
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
|
|
@ -53,11 +53,8 @@ fun BookInfoDeleteDialog(
|
|||
}
|
||||
)
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.book_deleted),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.book_deleted)
|
||||
.showToast(context = context)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components.dialog
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.DriveFileMove
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -15,6 +14,7 @@ import ua.acclorite.book_story.presentation.components.customItems
|
|||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithLazyColumn
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.SelectableDialogItem
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoState
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
|
|
@ -69,11 +69,8 @@ fun BookInfoMoveDialog(
|
|||
onNavigate = { navigator.it() }
|
||||
)
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.book_moved),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.book_moved)
|
||||
.showToast(context = context)
|
||||
},
|
||||
withDivider = false,
|
||||
items = {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package ua.acclorite.book_story.presentation.screens.browse
|
||||
|
||||
import android.Manifest
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
|
|
@ -34,6 +33,7 @@ import ua.acclorite.book_story.presentation.data.MainEvent
|
|||
import ua.acclorite.book_story.presentation.data.MainState
|
||||
import ua.acclorite.book_story.presentation.data.MainViewModel
|
||||
import ua.acclorite.book_story.presentation.data.Screen
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.browse.components.BrowseEmptyPlaceholder
|
||||
import ua.acclorite.book_story.presentation.screens.browse.components.BrowseStoragePermissionDialog
|
||||
import ua.acclorite.book_story.presentation.screens.browse.components.adding_dialog.BrowseAddingDialog
|
||||
|
|
@ -166,14 +166,10 @@ private fun BrowseScreen(
|
|||
onLongItemClick = { selectableFile ->
|
||||
when (selectableFile.isDirectory) {
|
||||
false -> {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(
|
||||
R.string.file_path_query,
|
||||
selectableFile.fileOrDirectory.path
|
||||
),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
).showToast(context = context)
|
||||
}
|
||||
|
||||
true -> {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.browse.components.adding_dialog
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
|
@ -22,6 +21,7 @@ import ua.acclorite.book_story.domain.model.NullableBook
|
|||
import ua.acclorite.book_story.presentation.components.customItems
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithLazyColumn
|
||||
import ua.acclorite.book_story.presentation.data.LocalNavigator
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseEvent
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseState
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
|
|
@ -60,18 +60,12 @@ fun BrowseAddingDialog(
|
|||
onLibraryEvent(LibraryEvent.OnLoadList)
|
||||
},
|
||||
onFailed = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_something_went_wrong),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.error_something_went_wrong)
|
||||
.showToast(context = context)
|
||||
},
|
||||
onSuccess = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.books_added),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.books_added)
|
||||
.showToast(context = context)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -102,11 +96,8 @@ fun BrowseAddingDialog(
|
|||
if (it) {
|
||||
onEvent(BrowseEvent.OnSelectBook(book))
|
||||
} else {
|
||||
Toast.makeText(
|
||||
context,
|
||||
book.first.message?.asString(context),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
book.first.message?.asString(context)
|
||||
?.showToast(context = context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.help.components.content
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
|
|
@ -26,6 +25,7 @@ import androidx.compose.ui.text.input.KeyboardCapitalization
|
|||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.CustomIconButton
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.help.components.HelpAnnotation
|
||||
import ua.acclorite.book_story.presentation.screens.help.data.HelpEvent
|
||||
import ua.acclorite.book_story.presentation.ui.SlidingTransition
|
||||
|
|
@ -52,11 +52,8 @@ fun HelpFindBooksContent(onEvent: (HelpEvent) -> Unit) {
|
|||
page = string.substringAfterLast("|"),
|
||||
context = context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -93,11 +90,8 @@ fun HelpFindBooksContent(onEvent: (HelpEvent) -> Unit) {
|
|||
showError.value = true
|
||||
},
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -124,11 +118,8 @@ fun HelpFindBooksContent(onEvent: (HelpEvent) -> Unit) {
|
|||
context = context,
|
||||
error = { showError.value = true },
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package ua.acclorite.book_story.presentation.screens.help.components.items
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.lazy.LazyItemScope
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.help.components.HelpAnnotation
|
||||
import ua.acclorite.book_story.presentation.screens.help.components.HelpClickableNote
|
||||
|
||||
|
|
@ -24,11 +24,8 @@ fun LazyItemScope.HelpClickMeNoteItem() {
|
|||
|
||||
HelpAnnotation(
|
||||
onClick = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.help_clickable_note_action),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.help_clickable_note_action)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
) {
|
||||
append(stringResource(id = R.string.help_clickable_note_2))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.history.components
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.DeleteOutline
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -8,6 +7,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithContent
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
|
||||
|
|
@ -37,11 +37,8 @@ fun HistoryDeleteWholeHistoryDialog(
|
|||
onLibraryLoadEvent(LibraryEvent.OnLoadList)
|
||||
}
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.history_deleted),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.history_deleted)
|
||||
.showToast(context = context)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package ua.acclorite.book_story.presentation.screens.library
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.core.tween
|
||||
|
|
@ -58,6 +57,7 @@ import ua.acclorite.book_story.presentation.data.LocalNavigator
|
|||
import ua.acclorite.book_story.presentation.data.MainState
|
||||
import ua.acclorite.book_story.presentation.data.MainViewModel
|
||||
import ua.acclorite.book_story.presentation.data.Screen
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseEvent
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseViewModel
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
|
|
@ -293,11 +293,8 @@ private fun LibraryScreen(
|
|||
return@BackHandler
|
||||
}
|
||||
|
||||
Toast.makeText(
|
||||
activity,
|
||||
activity.getString(R.string.press_again_toast),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
activity.getString(R.string.press_again_toast)
|
||||
.showToast(context = activity, longToast = false)
|
||||
shouldExit = true
|
||||
|
||||
scope.launch {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.library.components.dialog
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.DeleteOutline
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -9,6 +8,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithContent
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.browse.data.BrowseEvent
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
|
|
@ -44,11 +44,8 @@ fun LibraryDeleteDialog(
|
|||
onHistoryLoadEvent(HistoryEvent.OnLoadList)
|
||||
}
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.books_deleted),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.books_deleted)
|
||||
.showToast(context = context)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.library.components.dialog
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.DriveFileMove
|
||||
|
|
@ -13,6 +12,7 @@ import ua.acclorite.book_story.domain.model.Category
|
|||
import ua.acclorite.book_story.presentation.components.customItems
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.CustomDialogWithLazyColumn
|
||||
import ua.acclorite.book_story.presentation.components.custom_dialog.SelectableDialogItem
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryState
|
||||
|
|
@ -48,11 +48,8 @@ fun LibraryMoveDialog(
|
|||
}
|
||||
)
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.books_moved),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.books_moved)
|
||||
.showToast(context = context)
|
||||
},
|
||||
withDivider = false,
|
||||
items = {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package ua.acclorite.book_story.presentation.screens.reader
|
|||
import android.annotation.SuppressLint
|
||||
import android.os.Build
|
||||
import android.view.WindowManager
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
|
|
@ -63,6 +62,7 @@ import ua.acclorite.book_story.presentation.data.MainEvent
|
|||
import ua.acclorite.book_story.presentation.data.MainState
|
||||
import ua.acclorite.book_story.presentation.data.MainViewModel
|
||||
import ua.acclorite.book_story.presentation.data.Screen
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryViewModel
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
|
|
@ -118,11 +118,8 @@ fun ReaderScreenRoot(screen: Screen.Reader) {
|
|||
historyViewModel.onEvent(HistoryEvent.OnLoadList)
|
||||
},
|
||||
onError = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
it.asString(context),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
it.asString(context)
|
||||
.showToast(context = context)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -281,11 +278,8 @@ private fun ReaderScreen(
|
|||
CustomSelectionContainer(
|
||||
onCopyRequested = {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.copied),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.copied)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
},
|
||||
onShareRequested = { textToShare ->
|
||||
|
|
@ -294,11 +288,8 @@ private fun ReaderScreen(
|
|||
textToShare = textToShare,
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_share_app),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_share_app)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -309,11 +300,8 @@ private fun ReaderScreen(
|
|||
textToSearch = textToSearch,
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_browser),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_browser)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -325,11 +313,8 @@ private fun ReaderScreen(
|
|||
translateWholeParagraph = false,
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_translator),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_translator)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -340,11 +325,8 @@ private fun ReaderScreen(
|
|||
textToDefine,
|
||||
context,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_dictionary),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_dictionary)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
@ -377,18 +359,14 @@ private fun ReaderScreen(
|
|||
toolbarHidden = toolbarHidden,
|
||||
onSettingsEvent = onSettingsEvent,
|
||||
presetChanged = {
|
||||
Toast
|
||||
.makeText(
|
||||
context,
|
||||
context.getString(
|
||||
context
|
||||
.getString(
|
||||
R.string.color_preset_selected_query,
|
||||
it
|
||||
.asString(context)
|
||||
.trim()
|
||||
),
|
||||
Toast.LENGTH_SHORT
|
||||
)
|
||||
.show()
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
),
|
||||
verticalArrangement = Arrangement.spacedBy(paragraphHeight)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package ua.acclorite.book_story.presentation.screens.reader.components
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
|
|
@ -32,6 +31,7 @@ import ua.acclorite.book_story.R
|
|||
import ua.acclorite.book_story.domain.model.Category
|
||||
import ua.acclorite.book_story.domain.util.OnNavigate
|
||||
import ua.acclorite.book_story.presentation.data.Screen
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
|
|
@ -111,11 +111,8 @@ fun ReaderEndItem(
|
|||
)
|
||||
)
|
||||
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.book_moved),
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
context.getString(R.string.book_moved)
|
||||
.showToast(context = context)
|
||||
} else {
|
||||
onEvent(
|
||||
ReaderEvent.OnGoBack(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package ua.acclorite.book_story.presentation.screens.reader.components
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
|
|
@ -24,6 +23,7 @@ import androidx.compose.ui.unit.Dp
|
|||
import androidx.compose.ui.unit.TextUnit
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.model.FontWithName
|
||||
import ua.acclorite.book_story.presentation.data.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
import ua.acclorite.book_story.presentation.screens.settings.nested.reader.data.ReaderTextAlignment
|
||||
|
||||
|
|
@ -100,11 +100,8 @@ fun LazyItemScope.ReaderTextParagraph(
|
|||
translateWholeParagraph = true,
|
||||
context = context as ComponentActivity,
|
||||
noAppsFound = {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.error_no_translator),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
context.getString(R.string.error_no_translator)
|
||||
.showToast(context = context, longToast = false)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue