From 4c0bc940fe207021cbab7332f67127ce75e0536c Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 4 Feb 2021 11:27:50 +0800 Subject: [PATCH] delete anko:anko-sdk27-coroutines --- .../java/io/legado/app/base/BaseViewModel.kt | 10 +++---- .../io/legado/app/help/ContentProcessor.kt | 6 ++-- .../java/io/legado/app/help/IntentHelp.kt | 6 ++-- .../io/legado/app/help/LauncherIconHelp.kt | 4 +-- .../java/io/legado/app/help/SourceHelp.kt | 6 ++-- .../app/help/permission/PermissionActivity.kt | 4 +-- .../io/legado/app/help/storage/BookWebDav.kt | 6 ++-- .../legado/app/help/storage/ImportOldData.kt | 28 +++++++++---------- .../io/legado/app/help/storage/Restore.kt | 2 +- .../io/legado/app/service/AudioPlayService.kt | 10 +++---- .../io/legado/app/service/CacheBookService.kt | 4 +-- .../legado/app/service/CheckSourceService.kt | 4 +-- .../io/legado/app/service/DownloadService.kt | 4 +-- .../app/service/HttpReadAloudService.kt | 6 ++-- .../legado/app/service/TTSReadAloudService.kt | 4 +-- .../java/io/legado/app/service/WebService.kt | 4 +-- .../io/legado/app/service/help/CheckSource.kt | 4 +-- .../io/legado/app/service/help/ReadBook.kt | 4 +-- .../io/legado/app/ui/about/AboutFragment.kt | 4 +-- .../ui/association/FileAssociationActivity.kt | 4 +-- .../association/ImportBookSourceActivity.kt | 4 +-- .../association/ImportReplaceRuleActivity.kt | 4 +-- .../ui/association/ImportRssSourceActivity.kt | 4 +-- .../legado/app/ui/audio/AudioPlayViewModel.kt | 4 +-- .../app/ui/book/info/BookInfoActivity.kt | 8 +++--- .../app/ui/book/info/BookInfoViewModel.kt | 16 +++++------ .../ui/book/info/edit/BookInfoEditActivity.kt | 2 +- .../app/ui/book/local/ImportBookActivity.kt | 2 +- .../app/ui/book/read/ReadBookActivity.kt | 4 +-- .../app/ui/book/read/ReadBookViewModel.kt | 2 +- .../legado/app/ui/book/read/TextActionMenu.kt | 6 ++-- .../ui/book/read/config/BgTextConfigDialog.kt | 8 +++--- .../source/debug/BookSourceDebugActivity.kt | 4 +-- .../source/edit/BookSourceEditActivity.kt | 4 +-- .../source/edit/BookSourceEditViewModel.kt | 8 +++--- .../book/source/manage/BookSourceActivity.kt | 4 +-- .../book/source/manage/BookSourceViewModel.kt | 2 +- .../legado/app/ui/config/BackupRestoreUi.kt | 10 +++---- .../app/ui/config/OtherConfigFragment.kt | 4 +-- .../app/ui/config/ThemeConfigFragment.kt | 14 +++++----- .../legado/app/ui/config/ThemeListDialog.kt | 2 +- .../app/ui/filepicker/FilePickerDialog.kt | 4 +-- .../io/legado/app/ui/main/MainActivity.kt | 4 +-- .../ui/main/bookshelf/BookshelfFragment.kt | 2 +- .../ui/main/bookshelf/BookshelfViewModel.kt | 10 +++---- .../app/ui/replace/ReplaceRuleActivity.kt | 2 +- .../app/ui/replace/ReplaceRuleViewModel.kt | 8 +++--- .../ui/replace/edit/ReplaceEditActivity.kt | 4 +-- .../ui/rss/article/RssArticlesViewModel.kt | 2 +- .../app/ui/rss/read/ReadRssViewModel.kt | 6 ++-- .../source/debug/RssSourceDebugActivity.kt | 4 +-- .../rss/source/edit/RssSourceEditActivity.kt | 2 +- .../rss/source/edit/RssSourceEditViewModel.kt | 8 +++--- .../ui/rss/source/manage/RssSourceActivity.kt | 2 +- .../rss/source/manage/RssSourceViewModel.kt | 10 +++---- .../legado/app/ui/widget/font/FontAdapter.kt | 2 +- .../app/ui/widget/font/FontSelectDialog.kt | 4 +-- .../io/legado/app/utils/ContextExtensions.kt | 18 ++++++------ .../main/java/io/legado/app/utils/Toasts.kt | 4 +-- 59 files changed, 168 insertions(+), 168 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseViewModel.kt b/app/src/main/java/io/legado/app/base/BaseViewModel.kt index 44ea2884b..88ddc4b5e 100644 --- a/app/src/main/java/io/legado/app/base/BaseViewModel.kt +++ b/app/src/main/java/io/legado/app/base/BaseViewModel.kt @@ -6,7 +6,7 @@ import androidx.annotation.CallSuper import androidx.lifecycle.AndroidViewModel import io.legado.app.App import io.legado.app.help.coroutine.Coroutine -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.* import kotlin.coroutines.CoroutineContext @@ -38,12 +38,12 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio cancel() } - open fun toastOnUI(message: Int) { - context.toastOnUI(message) + open fun toastOnUi(message: Int) { + context.toastOnUi(message) } - open fun toastOnUI(message: CharSequence?) { - context.toastOnUI(message ?: toString()) + open fun toastOnUi(message: CharSequence?) { + context.toastOnUi(message ?: toString()) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index b3424ad46..78abc66af 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -4,7 +4,7 @@ import com.hankcs.hanlp.HanLP import io.legado.app.App import io.legado.app.data.entities.Book import io.legado.app.data.entities.ReplaceRule -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -40,7 +40,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str } } catch (e: Exception) { withContext(Dispatchers.Main) { - App.INSTANCE.toastOnUI("${item.name}替换出错") + App.INSTANCE.toastOnUi("${item.name}替换出错") } } } @@ -57,7 +57,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str } } catch (e: Exception) { withContext(Dispatchers.Main) { - App.INSTANCE.toastOnUI("简繁转换出错") + App.INSTANCE.toastOnUi("简繁转换出错") } } } diff --git a/app/src/main/java/io/legado/app/help/IntentHelp.kt b/app/src/main/java/io/legado/app/help/IntentHelp.kt index ac44e893c..10e1c53ac 100644 --- a/app/src/main/java/io/legado/app/help/IntentHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentHelp.kt @@ -5,7 +5,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import io.legado.app.R -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi @Suppress("unused") object IntentHelp { @@ -19,7 +19,7 @@ object IntentHelp { intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK context.startActivity(intent) }.onFailure { - context.toastOnUI(R.string.tip_cannot_jump_setting_page) + context.toastOnUi(R.string.tip_cannot_jump_setting_page) } } @@ -30,7 +30,7 @@ object IntentHelp { intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK context.startActivity(intent) }.onFailure { - context.toastOnUI("无法打开设置") + context.toastOnUi("无法打开设置") } } diff --git a/app/src/main/java/io/legado/app/help/LauncherIconHelp.kt b/app/src/main/java/io/legado/app/help/LauncherIconHelp.kt index d149f4464..15d19d071 100644 --- a/app/src/main/java/io/legado/app/help/LauncherIconHelp.kt +++ b/app/src/main/java/io/legado/app/help/LauncherIconHelp.kt @@ -6,7 +6,7 @@ import android.os.Build import io.legado.app.App import io.legado.app.R import io.legado.app.ui.welcome.* -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi /** * Created by GKF on 2018/2/27. @@ -26,7 +26,7 @@ object LauncherIconHelp { fun changeIcon(icon: String?) { if (icon.isNullOrEmpty()) return if (Build.VERSION.SDK_INT < 26) { - App.INSTANCE.toastOnUI(R.string.change_icon_error) + App.INSTANCE.toastOnUi(R.string.change_icon_error) return } var hasEnabled = false diff --git a/app/src/main/java/io/legado/app/help/SourceHelp.kt b/app/src/main/java/io/legado/app/help/SourceHelp.kt index 5783b371a..21c1b1b58 100644 --- a/app/src/main/java/io/legado/app/help/SourceHelp.kt +++ b/app/src/main/java/io/legado/app/help/SourceHelp.kt @@ -8,7 +8,7 @@ import io.legado.app.data.entities.RssSource import io.legado.app.utils.EncoderUtils import io.legado.app.utils.NetworkUtils import io.legado.app.utils.splitNotBlank -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi object SourceHelp { @@ -26,7 +26,7 @@ object SourceHelp { rssSources.forEach { rssSource -> if (is18Plus(rssSource.sourceUrl)) { handler.post { - App.INSTANCE.toastOnUI("${rssSource.sourceName}是18+网址,禁止导入.") + App.INSTANCE.toastOnUi("${rssSource.sourceName}是18+网址,禁止导入.") } } else { App.db.rssSourceDao.insert(rssSource) @@ -38,7 +38,7 @@ object SourceHelp { bookSources.forEach { bookSource -> if (is18Plus(bookSource.bookSourceUrl)) { handler.post { - App.INSTANCE.toastOnUI("${bookSource.bookSourceName}是18+网址,禁止导入.") + App.INSTANCE.toastOnUi("${bookSource.bookSourceName}是18+网址,禁止导入.") } } else { App.db.bookSourceDao.insert(bookSource) diff --git a/app/src/main/java/io/legado/app/help/permission/PermissionActivity.kt b/app/src/main/java/io/legado/app/help/permission/PermissionActivity.kt index dcee55e64..bd27e56e9 100644 --- a/app/src/main/java/io/legado/app/help/permission/PermissionActivity.kt +++ b/app/src/main/java/io/legado/app/help/permission/PermissionActivity.kt @@ -8,7 +8,7 @@ import android.view.KeyEvent import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import io.legado.app.R -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi class PermissionActivity : AppCompatActivity() { @@ -32,7 +32,7 @@ class PermissionActivity : AppCompatActivity() { settingIntent.data = Uri.fromParts("package", packageName, null) startActivityForResult(settingIntent, Request.TYPE_REQUEST_SETTING) } catch (e: Exception) { - toastOnUI(R.string.tip_cannot_jump_setting_page) + toastOnUi(R.string.tip_cannot_jump_setting_page) finish() } diff --git a/app/src/main/java/io/legado/app/help/storage/BookWebDav.kt b/app/src/main/java/io/legado/app/help/storage/BookWebDav.kt index 77b5b0fad..3d85424ef 100644 --- a/app/src/main/java/io/legado/app/help/storage/BookWebDav.kt +++ b/app/src/main/java/io/legado/app/help/storage/BookWebDav.kt @@ -79,7 +79,7 @@ object BookWebDav { Coroutine.async { restoreWebDav(names[index]) }.onError { - App.INSTANCE.toastOnUI("WebDavError:${it.localizedMessage}") + App.INSTANCE.toastOnUi("WebDavError:${it.localizedMessage}") } } } @@ -117,7 +117,7 @@ object BookWebDav { } } catch (e: Exception) { Handler(Looper.getMainLooper()).post { - App.INSTANCE.toastOnUI("WebDav\n${e.localizedMessage}") + App.INSTANCE.toastOnUi("WebDav\n${e.localizedMessage}") } } } @@ -138,7 +138,7 @@ object BookWebDav { } } catch (e: Exception) { Handler(Looper.getMainLooper()).post { - App.INSTANCE.toastOnUI("WebDav导出\n${e.localizedMessage}") + App.INSTANCE.toastOnUi("WebDav导出\n${e.localizedMessage}") } } } diff --git a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt index f6bbcef1e..14428d5c8 100644 --- a/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt +++ b/app/src/main/java/io/legado/app/help/storage/ImportOldData.kt @@ -8,7 +8,7 @@ import io.legado.app.data.entities.BookSource import io.legado.app.utils.DocumentUtils import io.legado.app.utils.FileUtils import io.legado.app.utils.isContentScheme -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import java.io.File object ImportOldData { @@ -21,28 +21,28 @@ object ImportOldData { kotlin.runCatching { DocumentUtils.readText(context, doc.uri)?.let { json -> val importCount = importOldBookshelf(json) - context.toastOnUI("成功导入书籍${importCount}") + context.toastOnUi("成功导入书籍${importCount}") } }.onFailure { - context.toastOnUI("导入书籍失败\n${it.localizedMessage}") + context.toastOnUi("导入书籍失败\n${it.localizedMessage}") } "myBookSource.json" -> kotlin.runCatching { DocumentUtils.readText(context, doc.uri)?.let { json -> val importCount = importOldSource(json) - context.toastOnUI("成功导入书源${importCount}") + context.toastOnUi("成功导入书源${importCount}") } }.onFailure { - context.toastOnUI("导入源失败\n${it.localizedMessage}") + context.toastOnUi("导入源失败\n${it.localizedMessage}") } "myBookReplaceRule.json" -> kotlin.runCatching { DocumentUtils.readText(context, doc.uri)?.let { json -> val importCount = importOldReplaceRule(json) - context.toastOnUI("成功导入替换规则${importCount}") + context.toastOnUi("成功导入替换规则${importCount}") } }.onFailure { - context.toastOnUI("导入替换规则失败\n${it.localizedMessage}") + context.toastOnUi("导入替换规则失败\n${it.localizedMessage}") } } } @@ -54,9 +54,9 @@ object ImportOldData { FileUtils.createFileIfNotExist(file, "myBookShelf.json") val json = shelfFile.readText() val importCount = importOldBookshelf(json) - context.toastOnUI("成功导入书籍${importCount}") + context.toastOnUi("成功导入书籍${importCount}") }.onFailure { - context.toastOnUI("导入书籍失败\n${it.localizedMessage}") + context.toastOnUi("导入书籍失败\n${it.localizedMessage}") } kotlin.runCatching {// Book source @@ -64,9 +64,9 @@ object ImportOldData { FileUtils.getFile(file, "myBookSource.json") val json = sourceFile.readText() val importCount = importOldSource(json) - context.toastOnUI("成功导入书源${importCount}") + context.toastOnUi("成功导入书源${importCount}") }.onFailure { - context.toastOnUI("导入源失败\n${it.localizedMessage}") + context.toastOnUi("导入源失败\n${it.localizedMessage}") } kotlin.runCatching {// Replace rules @@ -74,12 +74,12 @@ object ImportOldData { if (ruleFile.exists()) { val json = ruleFile.readText() val importCount = importOldReplaceRule(json) - context.toastOnUI("成功导入替换规则${importCount}") + context.toastOnUi("成功导入替换规则${importCount}") } else { - context.toastOnUI("未找到替换规则") + context.toastOnUi("未找到替换规则") } }.onFailure { - context.toastOnUI("导入替换规则失败\n${it.localizedMessage}") + context.toastOnUi("导入替换规则失败\n${it.localizedMessage}") } } } diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index ac90d7f91..217c9e143 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -223,7 +223,7 @@ object Restore { ReadBook.loadContent(resetPageOffset = false) } withContext(Main) { - App.INSTANCE.toastOnUI(R.string.restore_success) + App.INSTANCE.toastOnUi(R.string.restore_success) if (!BuildConfig.DEBUG) { LauncherIconHelp.changeIcon(App.INSTANCE.getPrefString(PreferKey.launcherIcon)) } diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index d350c4850..7e987abb8 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -31,7 +31,7 @@ import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.service.help.AudioPlay import io.legado.app.ui.audio.AudioPlayActivity import io.legado.app.utils.postEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -133,7 +133,7 @@ class AudioPlayService : BaseService(), }.onFailure { it.printStackTrace() launch { - toastOnUI("$url ${it.localizedMessage}") + toastOnUi("$url ${it.localizedMessage}") stopSelf() } } @@ -219,7 +219,7 @@ class AudioPlayService : BaseService(), if (!mediaPlayer.isPlaying) { AudioPlay.status = Status.STOP postEvent(EventBus.AUDIO_STATE, Status.STOP) - launch { toastOnUI("error: $what $extra $url") } + launch { toastOnUi("error: $what $extra $url") } } return true } @@ -274,7 +274,7 @@ class AudioPlayService : BaseService(), .onSuccess { content -> if (content.isEmpty()) { withContext(Main) { - toastOnUI("未获取到资源链接") + toastOnUi("未获取到资源链接") } } else { contentLoadFinish(chapter, content) @@ -286,7 +286,7 @@ class AudioPlayService : BaseService(), } } else { removeLoading(chapter.index) - toastOnUI("book or source is null") + toastOnUi("book or source is null") } } } diff --git a/app/src/main/java/io/legado/app/service/CacheBookService.kt b/app/src/main/java/io/legado/app/service/CacheBookService.kt index 2454f6c4e..dbf8db06c 100644 --- a/app/src/main/java/io/legado/app/service/CacheBookService.kt +++ b/app/src/main/java/io/legado/app/service/CacheBookService.kt @@ -20,7 +20,7 @@ import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.webBook.WebBook import io.legado.app.service.help.CacheBook import io.legado.app.utils.postEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.isActive import java.util.concurrent.ConcurrentHashMap @@ -128,7 +128,7 @@ class CacheBookService : BaseService() { if (downloadMap.containsKey(bookUrl)) { notificationContent = getString(R.string.already_in_download) upNotification() - toastOnUI(notificationContent) + toastOnUi(notificationContent) return } downloadCount[bookUrl] = DownloadCount() diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 0af7bd698..f38b1c9ce 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -16,7 +16,7 @@ import io.legado.app.model.webBook.WebBook import io.legado.app.service.help.CheckSource import io.legado.app.ui.book.source.manage.BookSourceActivity import io.legado.app.utils.postEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.asCoroutineDispatcher import java.util.concurrent.Executors import kotlin.math.min @@ -70,7 +70,7 @@ class CheckSourceService : BaseService() { private fun check(ids: List) { if (allIds.isNotEmpty()) { - toastOnUI("已有书源在校验,等完成后再试") + toastOnUi("已有书源在校验,等完成后再试") return } tasks.clear() diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index 71b71b3f7..4b3f11b6f 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -21,7 +21,7 @@ import io.legado.app.help.IntentHelp import io.legado.app.utils.RealPathUtil import io.legado.app.utils.downloadManager import io.legado.app.utils.msg -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import java.io.File @@ -149,7 +149,7 @@ class DownloadService : BaseService() { try { startActivity(intent) } catch (e: Exception) { - toastOnUI(e.msg) + toastOnUi(e.msg) } } } diff --git a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt index 29bb84efb..562e80ce0 100644 --- a/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/HttpReadAloudService.kt @@ -119,17 +119,17 @@ class HttpReadAloudService : BaseReadAloudService(), } } catch (e: SocketTimeoutException) { removeSpeakCacheFile(fileName) - runOnUiThread { toastOnUI("tts接口超时,尝试重新获取") } + runOnUiThread { toastOnUi("tts接口超时,尝试重新获取") } downloadAudio() } catch (e: ConnectException) { removeSpeakCacheFile(fileName) - runOnUiThread { toastOnUI("网络错误") } + runOnUiThread { toastOnUi("网络错误") } } catch (e: IOException) { val file = getSpeakFileAsMd5(fileName) if (file.exists()) { FileUtils.deleteFile(file.absolutePath) } - runOnUiThread { toastOnUI("tts文件解析错误") } + runOnUiThread { toastOnUi("tts文件解析错误") } } catch (e: Exception) { removeSpeakCacheFile(fileName) } diff --git a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt index 170ea4af7..60cb11bdf 100644 --- a/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/TTSReadAloudService.kt @@ -13,7 +13,7 @@ import io.legado.app.help.MediaHelp import io.legado.app.service.help.ReadBook import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.postEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.launch import java.util.* @@ -64,7 +64,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener } } else { launch { - toastOnUI(R.string.tts_init_failed) + toastOnUi(R.string.tts_init_failed) } } } diff --git a/app/src/main/java/io/legado/app/service/WebService.kt b/app/src/main/java/io/legado/app/service/WebService.kt index 23077b707..441a718de 100644 --- a/app/src/main/java/io/legado/app/service/WebService.kt +++ b/app/src/main/java/io/legado/app/service/WebService.kt @@ -13,7 +13,7 @@ import io.legado.app.help.IntentHelp import io.legado.app.utils.NetworkUtils import io.legado.app.utils.getPrefInt import io.legado.app.utils.postEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import io.legado.app.web.HttpServer import io.legado.app.web.WebSocketServer import org.jetbrains.anko.startService @@ -91,7 +91,7 @@ class WebService : BaseService() { notificationContent = hostAddress upNotification() } catch (e: IOException) { - toastOnUI(e.localizedMessage ?: "") + toastOnUi(e.localizedMessage ?: "") stopSelf() } } else { diff --git a/app/src/main/java/io/legado/app/service/help/CheckSource.kt b/app/src/main/java/io/legado/app/service/help/CheckSource.kt index 856202fba..725c303e7 100644 --- a/app/src/main/java/io/legado/app/service/help/CheckSource.kt +++ b/app/src/main/java/io/legado/app/service/help/CheckSource.kt @@ -6,14 +6,14 @@ import io.legado.app.R import io.legado.app.constant.IntentAction import io.legado.app.data.entities.BookSource import io.legado.app.service.CheckSourceService -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi object CheckSource { var keyword = "我的" fun start(context: Context, sources: List) { if (sources.isEmpty()) { - context.toastOnUI(R.string.non_select) + context.toastOnUi(R.string.non_select) return } val selectedIds: ArrayList = arrayListOf() diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 1ee12fe94..88440d47c 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -14,7 +14,7 @@ import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.book.read.page.provider.ChapterProvider import io.legado.app.ui.book.read.page.provider.ImageProvider -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay @@ -437,7 +437,7 @@ object ReadBook { } }.onError { it.printStackTrace() - App.INSTANCE.toastOnUI("ChapterProvider ERROR:\n${it.getStackTraceString()}") + App.INSTANCE.toastOnUi("ChapterProvider ERROR:\n${it.getStackTraceString()}") }.onSuccess { success?.invoke() } diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index 5f89f34aa..934c7f4d1 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -15,7 +15,7 @@ import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.openUrl import io.legado.app.utils.sendMail import io.legado.app.utils.sendToClip -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi class AboutFragment : PreferenceFragmentCompat() { @@ -105,7 +105,7 @@ class AboutFragment : PreferenceFragmentCompat() { startActivity(intent) return true }.onFailure { - toastOnUI("添加失败,请手动添加") + toastOnUi("添加失败,请手动添加") } return false } diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt index 3269b22b1..446d0c042 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt @@ -7,7 +7,7 @@ import io.legado.app.constant.Theme import io.legado.app.databinding.ActivityTranslucenceBinding import io.legado.app.ui.main.MainActivity import io.legado.app.utils.getViewModel -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import org.jetbrains.anko.startActivity @@ -27,7 +27,7 @@ class FileAssociationActivity : binding.rotateLoading.show() viewModel.errorLiveData.observe(this, { binding.rotateLoading.hide() - toastOnUI(it) + toastOnUi(it) finish() }) viewModel.successLiveData.observe(this, { diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt index 458a98933..e9a638456 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt @@ -8,7 +8,7 @@ import io.legado.app.databinding.ActivityTranslucenceBinding import io.legado.app.help.IntentDataHelp import io.legado.app.lib.dialogs.alert import io.legado.app.utils.getViewModel -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi class ImportBookSourceActivity : @@ -66,7 +66,7 @@ class ImportBookSourceActivity : } else -> { binding.rotateLoading.hide() - toastOnUI(R.string.wrong_format) + toastOnUi(R.string.wrong_format) finish() } } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt index f7c9dc783..bff45583b 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt @@ -9,7 +9,7 @@ import io.legado.app.databinding.ActivityTranslucenceBinding import io.legado.app.help.IntentDataHelp import io.legado.app.lib.dialogs.alert import io.legado.app.utils.getViewModel -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi class ImportReplaceRuleActivity : VMBaseActivity( @@ -66,7 +66,7 @@ class ImportReplaceRuleActivity : } else -> { binding.rotateLoading.hide() - toastOnUI("格式不对") + toastOnUi("格式不对") finish() } } diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt index 928279d63..69105cfba 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt @@ -8,7 +8,7 @@ import io.legado.app.databinding.ActivityTranslucenceBinding import io.legado.app.help.IntentDataHelp import io.legado.app.lib.dialogs.alert import io.legado.app.utils.getViewModel -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi class ImportRssSourceActivity : VMBaseActivity( @@ -65,7 +65,7 @@ class ImportRssSourceActivity : } else -> { binding.rotateLoading.hide() - toastOnUI(R.string.wrong_format) + toastOnUi(R.string.wrong_format) finish() } } diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt index 80680f82d..1ccb7757f 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt @@ -75,10 +75,10 @@ class AudioPlayViewModel(application: Application) : BaseViewModel(application) } AudioPlay.upDurChapter(book) } else { - toastOnUI(R.string.error_load_toc) + toastOnUi(R.string.error_load_toc) } }?.onError { - toastOnUI(R.string.error_load_toc) + toastOnUi(R.string.error_load_toc) } } } diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 7e54a5111..13c2c8dd1 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -90,7 +90,7 @@ class BookInfoActivity : ) } } else { - toastOnUI(R.string.after_add_bookshelf) + toastOnUi(R.string.after_add_bookshelf) } } R.id.menu_share_it -> { @@ -111,7 +111,7 @@ class BookInfoActivity : } R.id.menu_copy_url -> viewModel.bookData.value?.bookUrl?.let { sendToClip(it) - } ?: toastOnUI(R.string.no_book) + } ?: toastOnUi(R.string.no_book) R.id.menu_can_update -> { if (viewModel.inBookshelf) { viewModel.bookData.value?.let { @@ -119,7 +119,7 @@ class BookInfoActivity : viewModel.saveBook() } } else { - toastOnUI(R.string.after_add_bookshelf) + toastOnUi(R.string.after_add_bookshelf) } } R.id.menu_clear_cache -> viewModel.clearCache() @@ -291,7 +291,7 @@ class BookInfoActivity : private fun openChapterList() { if (viewModel.chapterListData.value.isNullOrEmpty()) { - toastOnUI(R.string.chapter_list_empty) + toastOnUi(R.string.chapter_list_empty) return } viewModel.bookData.value?.let { diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index cb768d081..3e315b941 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -65,11 +65,11 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { } loadChapter(it, changeDruChapterIndex) }.onError { - toastOnUI(R.string.error_get_book_info) + toastOnUi(R.string.error_get_book_info) } } ?: let { chapterListData.postValue(null) - toastOnUI(R.string.error_no_source) + toastOnUi(R.string.error_no_source) } } } @@ -101,19 +101,19 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { changeDruChapterIndex(it) } } else { - toastOnUI(R.string.chapter_list_empty) + toastOnUi(R.string.chapter_list_empty) } }.onError { chapterListData.postValue(null) - toastOnUI(R.string.error_get_chapter_list) + toastOnUi(R.string.error_get_chapter_list) } } ?: let { chapterListData.postValue(null) - toastOnUI(R.string.error_no_source) + toastOnUi(R.string.error_no_source) } } }.onError { - toastOnUI("LoadTocError:${it.localizedMessage}") + toastOnUi("LoadTocError:${it.localizedMessage}") } } @@ -238,9 +238,9 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { execute { BookHelp.clearCache(bookData.value!!) }.onSuccess { - toastOnUI(R.string.clear_cache_success) + toastOnUi(R.string.clear_cache_success) }.onError { - toastOnUI(it.stackTraceToString()) + toastOnUi(it.stackTraceToString()) } } diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index bd40994aa..02dc70c1e 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -119,7 +119,7 @@ class BookInfoEditActivity : }.getOrNull()?.let { byteArray -> file.writeBytes(byteArray) coverChangeTo(file.absolutePath) - } ?: toastOnUI("获取文件出错") + } ?: toastOnUi("获取文件出错") } } else { PermissionsCompat.Builder(this) diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index ce921cebe..fcd9b0699 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -251,7 +251,7 @@ class ImportBookActivity : VMBaseActivity binding.readView.curPage.let { val bookmark = it.createBookmark() if (bookmark == null) { - toastOnUI(R.string.create_bookmark_error) + toastOnUi(R.string.create_bookmark_error) } else { showBookMark(bookmark) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 9174aa62d..c5222dfb8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -226,7 +226,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { }.onStart { ReadBook.upMsg(context.getString(R.string.source_auto_changing)) }.onError { - toastOnUI(it.msg) + toastOnUi(it.msg) }.onFinally { ReadBook.upMsg(null) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt index 2ebc2ea02..416b69132 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt @@ -119,7 +119,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac R.id.menu_share_str -> context.share(callBack.selectedText) R.id.menu_aloud -> { if (BaseReadAloudService.isRun) { - context.toastOnUI(R.string.alouding_disable) + context.toastOnUi(R.string.alouding_disable) return } readAloud(callBack.selectedText) @@ -138,7 +138,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac context.startActivity(intent) }.onFailure { it.printStackTrace() - context.toastOnUI(it.localizedMessage ?: "ERROR") + context.toastOnUi(it.localizedMessage ?: "ERROR") } } else -> item.intent?.let { @@ -214,7 +214,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac ).intent = createProcessTextIntentForResolveInfo(resolveInfo) } }.onFailure { - context.toastOnUI("获取文字操作菜单出错:${it.localizedMessage}") + context.toastOnUi("获取文字操作菜单出错:${it.localizedMessage}") } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 57fd4c59a..ca489c093 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -185,7 +185,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack { postEvent(EventBus.UP_CONFIG, true) dismiss() } else { - toastOnUI("数量已是最少,不能删除.") + toastOnUi("数量已是最少,不能删除.") } } } @@ -267,7 +267,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack { } } }.onSuccess { - toastOnUI("导出成功, 文件名为 $exportFileName") + toastOnUi("导出成功, 文件名为 $exportFileName") }.onError { it.printStackTrace() longToast("导出失败:${it.localizedMessage}") @@ -363,7 +363,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack { ReadBookConfig.durConfig = config postEvent(EventBus.UP_CONFIG, true) }.onSuccess { - toastOnUI("导入成功") + toastOnUi("导入成功") }.onError { it.printStackTrace() longToast("导入失败:${it.localizedMessage}") @@ -404,7 +404,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FilePickerDialog.CallBack { ReadBookConfig.durConfig.setCurBg(2, file.absolutePath) ReadBookConfig.upBg() postEvent(EventBus.UP_CONFIG, false) - } ?: toastOnUI("获取文件出错") + } ?: toastOnUi("获取文件出错") } } else { PermissionsCompat.Builder(this) diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt index 9ff85ebc0..515ebabca 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt @@ -14,7 +14,7 @@ import io.legado.app.lib.theme.accentColor import io.legado.app.ui.qrcode.QrCodeActivity import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.getViewModel -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.launch import org.jetbrains.anko.startActivityForResult @@ -83,7 +83,7 @@ class BookSourceDebugActivity : VMBaseActivity getSource().let { if (checkSource(it)) { if (it.loginUrl.isNullOrEmpty()) { - toastOnUI(R.string.source_no_login) + toastOnUi(R.string.source_no_login) } else { startActivity( Pair("sourceUrl", it.bookSourceUrl), @@ -357,7 +357,7 @@ class BookSourceEditActivity : private fun checkSource(source: BookSource): Boolean { if (source.bookSourceUrl.isBlank() || source.bookSourceName.isBlank()) { - toastOnUI(R.string.non_null_name_url) + toastOnUi(R.string.non_null_name_url) return false } return true diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt index aba8afa5e..2705dc6fa 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt @@ -45,7 +45,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat }.onSuccess { success?.invoke() }.onError { - toastOnUI(it.localizedMessage) + toastOnUi(it.localizedMessage) it.printStackTrace() } } @@ -58,13 +58,13 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat } source }.onError { - toastOnUI(it.localizedMessage) + toastOnUi(it.localizedMessage) it.printStackTrace() }.onSuccess { if (it != null) { onSuccess(it) } else { - toastOnUI("格式不对") + toastOnUi("格式不对") } } } @@ -76,7 +76,7 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat finally.invoke(it) } }.onError { - toastOnUI(it.localizedMessage ?: "Error") + toastOnUi(it.localizedMessage ?: "Error") } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 2ae2773c8..c2b739cd2 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -411,7 +411,7 @@ class BookSourceActivity : VMBaseActivity if (group.contains("失效")) { searchView.setQuery("失效", true) - toastOnUI("发现有失效书源,已为您自动筛选!") + toastOnUi("发现有失效书源,已为您自动筛选!") } } } @@ -473,7 +473,7 @@ class BookSourceActivity : VMBaseActivity("dataKey" to dataKey) } } catch (e: Exception) { - toastOnUI("readTextError:${e.localizedMessage}") + toastOnUi("readTextError:${e.localizedMessage}") } } } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 8ef8cc50f..e8bf52ec8 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -181,7 +181,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) }.onSuccess { success.invoke(it) }.onError { - toastOnUI(it.msg) + toastOnUi(it.msg) } } diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index 970267735..b880a25be 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -20,7 +20,7 @@ import io.legado.app.ui.filepicker.FilePicker import io.legado.app.utils.getPrefString import io.legado.app.utils.isContentScheme import io.legado.app.utils.longToast -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers.Main object BackupRestoreUi { @@ -41,7 +41,7 @@ object BackupRestoreUi { Coroutine.async { Backup.backup(fragment.requireContext(), backupPath) }.onSuccess { - fragment.toastOnUI(R.string.backup_success) + fragment.toastOnUi(R.string.backup_success) } } else { selectBackupFolder(fragment, backupSelectRequestCode) @@ -64,7 +64,7 @@ object BackupRestoreUi { AppConfig.backupPath = path Backup.backup(fragment.requireContext(), path) }.onSuccess { - fragment.toastOnUI(R.string.backup_success) + fragment.toastOnUi(R.string.backup_success) } } .request() @@ -134,7 +134,7 @@ object BackupRestoreUi { Coroutine.async { Backup.backup(App.INSTANCE, uri.toString()) }.onSuccess { - App.INSTANCE.toastOnUI(R.string.backup_success) + App.INSTANCE.toastOnUi(R.string.backup_success) } } else { uri.path?.let { path -> @@ -142,7 +142,7 @@ object BackupRestoreUi { Coroutine.async { Backup.backup(App.INSTANCE, path) }.onSuccess { - App.INSTANCE.toastOnUI(R.string.backup_success) + App.INSTANCE.toastOnUi(R.string.backup_success) } } } diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 06eadc149..3c226c8c6 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -177,7 +177,7 @@ class OtherConfigFragment : BasePreferenceFragment(), okButton { BookHelp.clearCache() FileUtils.deleteFile(requireActivity().cacheDir.absolutePath) - toastOnUI(R.string.clear_cache_success) + toastOnUi(R.string.clear_cache_success) } noButton() }.show() @@ -221,7 +221,7 @@ class OtherConfigFragment : BasePreferenceFragment(), file.writeBytes(byteArray) putPrefString(PreferKey.defaultCover, file.absolutePath) CoverImageView.upDefaultCover() - } ?: toastOnUI("获取文件出错") + } ?: toastOnUi("获取文件出错") } } else { PermissionsCompat.Builder(this) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt index d4b88d855..4450905e5 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt @@ -60,7 +60,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), findPreference(PreferKey.cBackground)?.let { it.onSaveColor = { color -> if (!ColorUtils.isColorLight(color)) { - toastOnUI(R.string.day_background_too_dark) + toastOnUi(R.string.day_background_too_dark) true } else { false @@ -70,7 +70,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), findPreference(PreferKey.cNBackground)?.let { it.onSaveColor = { color -> if (ColorUtils.isColorLight(color)) { - toastOnUI(R.string.night_background_too_light) + toastOnUi(R.string.night_background_too_light) true } else { false @@ -84,11 +84,11 @@ class ThemeConfigFragment : BasePreferenceFragment(), val textColor = getCompatColor(R.color.primaryText) when { ColorUtils.getColorDifference(color, background) <= 60 -> { - toastOnUI(R.string.accent_background_diff) + toastOnUi(R.string.accent_background_diff) true } ColorUtils.getColorDifference(color, textColor) <= 60 -> { - toastOnUI(R.string.accent_text_diff) + toastOnUi(R.string.accent_text_diff) true } else -> false @@ -102,11 +102,11 @@ class ThemeConfigFragment : BasePreferenceFragment(), val textColor = getCompatColor(R.color.primaryText) when { ColorUtils.getColorDifference(color, background) <= 60 -> { - toastOnUI(R.string.accent_background_diff) + toastOnUi(R.string.accent_background_diff) true } ColorUtils.getColorDifference(color, textColor) <= 60 -> { - toastOnUI(R.string.accent_text_diff) + toastOnUi(R.string.accent_text_diff) true } else -> false @@ -277,7 +277,7 @@ class ThemeConfigFragment : BasePreferenceFragment(), putPrefString(preferenceKey, file.absolutePath) upPreferenceSummary(preferenceKey, file.absolutePath) success() - } ?: toastOnUI("获取文件出错") + } ?: toastOnUi("获取文件出错") } } else { PermissionsCompat.Builder(this) diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt index f6b722c1a..3aadc8b25 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt @@ -72,7 +72,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { if (ThemeConfig.addConfig(it)) { initData() } else { - toastOnUI("格式不对,添加失败") + toastOnUi("格式不对,添加失败") } } } diff --git a/app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt b/app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt index 00e9a7f31..2f574f2cd 100644 --- a/app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt +++ b/app/src/main/java/io/legado/app/ui/filepicker/FilePickerDialog.kt @@ -170,14 +170,14 @@ class FilePickerDialog : DialogFragment(), } else { fileItem?.path?.let { path -> if (mode == DIRECTORY) { - toastOnUI("这是文件夹选择,不能选择文件,点击右上角的确定选择文件夹") + toastOnUi("这是文件夹选择,不能选择文件,点击右上角的确定选择文件夹") } else if (allowExtensions.isNullOrEmpty() || allowExtensions?.contains(FileUtils.getExtension(path)) == true ) { setData(path) dismiss() } else { - toastOnUI("不能打开此文件") + toastOnUi("不能打开此文件") } } } diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 964164b98..17005f2cc 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -32,7 +32,7 @@ import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.getViewModel import io.legado.app.utils.hideSoftInput import io.legado.app.utils.observeEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi class MainActivity : VMBaseActivity(), @@ -144,7 +144,7 @@ class MainActivity : VMBaseActivity(), return true } if (System.currentTimeMillis() - exitTime > 2000) { - toastOnUI(R.string.double_click_exit) + toastOnUi(R.string.double_click_exit) exitTime = System.currentTimeMillis() } else { if (BaseReadAloudService.pause) { diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 83e23e3e8..6cbf4a678 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -205,7 +205,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b override fun onTabReselected(tab: TabLayout.Tab) { fragmentMap[selectedGroup.groupId]?.let { - toastOnUI("${selectedGroup.groupName}(${it.getBooksCount()})") + toastOnUi("${selectedGroup.groupName}(${it.getBooksCount()})") } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index 5f464c8ac..2cfcb2b2e 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -57,12 +57,12 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) } }.onSuccess { if (successCount > 0) { - toastOnUI(R.string.success) + toastOnUi(R.string.success) } else { - toastOnUI("ERROR") + toastOnUi("ERROR") } }.onError { - toastOnUI(it.localizedMessage ?: "ERROR") + toastOnUi(it.localizedMessage ?: "ERROR") } } @@ -98,7 +98,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) } } }.onError { - toastOnUI(it.localizedMessage ?: "ERROR") + toastOnUi(it.localizedMessage ?: "ERROR") } } @@ -121,7 +121,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) } } }.onFinally { - toastOnUI(R.string.success) + toastOnUi(R.string.success) } } diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt index 8d1cb0889..edeafbe3a 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt @@ -269,7 +269,7 @@ class ReplaceRuleActivity : VMBaseActivity("dataKey" to dataKey) } }.onFailure { - toastOnUI("readTextError:${it.localizedMessage}") + toastOnUi("readTextError:${it.localizedMessage}") } } } diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt index e93debb74..0e678c9b4 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt @@ -79,9 +79,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application FileUtils.createFileIfNotExist(file, "exportReplaceRule.json") .writeText(json) }.onSuccess { - context.toastOnUI("成功导出至\n${file.absolutePath}") + context.toastOnUi("成功导出至\n${file.absolutePath}") }.onError { - context.toastOnUI("导出失败\n${it.localizedMessage}") + context.toastOnUi("导出失败\n${it.localizedMessage}") } } @@ -92,9 +92,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application doc.createFile("", "exportReplaceRule.json") ?.writeText(context, json) }.onSuccess { - context.toastOnUI("成功导出至\n${doc.uri.path}") + context.toastOnUi("成功导出至\n${doc.uri.path}") }.onError { - context.toastOnUI("导出失败\n${it.localizedMessage}") + context.toastOnUi("导出失败\n${it.localizedMessage}") } } diff --git a/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt b/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt index c9fe46b03..caba20753 100644 --- a/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt @@ -20,7 +20,7 @@ import io.legado.app.ui.widget.KeyboardToolPop import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.getViewModel import io.legado.app.utils.postEvent -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import org.jetbrains.anko.displayMetrics import org.jetbrains.anko.selector import kotlin.math.abs @@ -82,7 +82,7 @@ class ReplaceEditActivity : R.id.menu_save -> { val rule = getReplaceRule() if (!rule.isValid()) { - toastOnUI(R.string.replace_rule_invalid) + toastOnUi(R.string.replace_rule_invalid) } else { viewModel.save(rule) { postEvent(EventBus.REPLACE_RULE_SAVE, "") diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt index 0f45b14b6..af3577f3d 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt @@ -51,7 +51,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application }.onError { loadFinally.postValue(false) it.printStackTrace() - toastOnUI(it.localizedMessage) + toastOnUi(it.localizedMessage) } } diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index 24aafe19d..114efd950 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -137,9 +137,9 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), } } ?: throw Throwable("NULL") }.onError { - toastOnUI("保存图片失败:${it.localizedMessage}") + toastOnUi("保存图片失败:${it.localizedMessage}") }.onSuccess { - toastOnUI("保存成功") + toastOnUi("保存成功") } } @@ -186,7 +186,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), play() } else { launch { - toastOnUI(R.string.tts_init_failed) + toastOnUi(R.string.tts_init_failed) } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt index 5b9560a39..2a54205cc 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt @@ -9,7 +9,7 @@ import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor import io.legado.app.utils.getViewModel import io.legado.app.utils.gone -import io.legado.app.utils.toastOnUI +import io.legado.app.utils.toastOnUi import kotlinx.coroutines.launch @@ -56,7 +56,7 @@ class RssSourceDebugActivity : VMBaseActivity("dataKey" to dataKey) } }.onFailure { - toastOnUI("readTextError:${it.localizedMessage}") + toastOnUi("readTextError:${it.localizedMessage}") } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt index 5a4ea13c3..03793a4f9 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt @@ -85,9 +85,9 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) FileUtils.createFileIfNotExist(file, "exportRssSource.json") .writeText(json) }.onSuccess { - context.toastOnUI("成功导出至\n${file.absolutePath}") + context.toastOnUi("成功导出至\n${file.absolutePath}") }.onError { - context.toastOnUI("导出失败\n${it.localizedMessage}") + context.toastOnUi("导出失败\n${it.localizedMessage}") } } @@ -98,9 +98,9 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) doc.createFile("", "exportRssSource.json") ?.writeText(context, json) }.onSuccess { - context.toastOnUI("成功导出至\n${doc.uri.path}") + context.toastOnUi("成功导出至\n${doc.uri.path}") }.onError { - context.toastOnUI("导出失败\n${it.localizedMessage}") + context.toastOnUi("导出失败\n${it.localizedMessage}") } } @@ -122,7 +122,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) }.onSuccess { success.invoke(it) }.onError { - toastOnUI(it.msg) + toastOnUi(it.msg) } } diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt index 088401abb..5e9e5b4a9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt @@ -42,7 +42,7 @@ class FontAdapter(context: Context, val callBack: CallBack) : tvFont.typeface = typeface }.onFailure { it.printStackTrace() - context.toastOnUI("Read ${item.name} Error: ${it.localizedMessage}") + context.toastOnUi("Read ${item.name} Error: ${it.localizedMessage}") } tvFont.text = item.name root.setOnClickListener { callBack.onClick(item) } diff --git a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt index 1eeda60a6..dd406024e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt @@ -157,7 +157,7 @@ class FontSelectDialog : BaseDialogFragment(), }.onSuccess { adapter?.setItems(it) }.onError { - toastOnUI("getFontFiles:${it.localizedMessage}") + toastOnUi("getFontFiles:${it.localizedMessage}") } } @@ -192,7 +192,7 @@ class FontSelectDialog : BaseDialogFragment(), }.onSuccess { adapter?.setItems(it) }.onError { - toastOnUI("getFontFiles:${it.localizedMessage}") + toastOnUi("getFontFiles:${it.localizedMessage}") } } diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 49e57cd84..6b31409ac 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -35,25 +35,25 @@ val Context.downloadManager val Context.connectivityManager get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager -fun Context.toastOnUI(message: Int) { +fun Context.toastOnUi(message: Int) { runOnUiThread { Toast.makeText(this, message, Toast.LENGTH_SHORT).show() } } -fun Context.toastOnUI(message: CharSequence?) { +fun Context.toastOnUi(message: CharSequence?) { runOnUiThread { Toast.makeText(this, message, Toast.LENGTH_SHORT).show() } } -fun Context.longToastOnUI(message: Int) { +fun Context.longToastOnUi(message: Int) { runOnUiThread { Toast.makeText(this, message, Toast.LENGTH_LONG).show() } } -fun Context.longToastOnUI(message: CharSequence?) { +fun Context.longToastOnUi(message: CharSequence?) { runOnUiThread { Toast.makeText(this, message, Toast.LENGTH_LONG).show() } @@ -139,7 +139,7 @@ val Context.navigationBarHeight: Int fun Context.shareWithQr(title: String, text: String) { val bitmap = QRCodeUtils.createQRCode(text) if (bitmap == null) { - toastOnUI(R.string.text_too_long_qr_error) + toastOnUi(R.string.text_too_long_qr_error) } else { try { val file = File(externalCacheDir, "qr.png") @@ -159,7 +159,7 @@ fun Context.shareWithQr(title: String, text: String) { intent.type = "image/png" startActivity(Intent.createChooser(intent, title)) } catch (e: Exception) { - toastOnUI(e.localizedMessage ?: "ERROR") + toastOnUi(e.localizedMessage ?: "ERROR") } } } @@ -191,7 +191,7 @@ fun Context.sendMail(mail: String) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(intent) } catch (e: Exception) { - toastOnUI(e.localizedMessage ?: "Error") + toastOnUi(e.localizedMessage ?: "Error") } } @@ -231,13 +231,13 @@ fun Context.openUrl(uri: Uri) { try { startActivity(intent) } catch (e: Exception) { - toastOnUI(e.localizedMessage ?: "open url error") + toastOnUi(e.localizedMessage ?: "open url error") } } else { try { startActivity(Intent.createChooser(intent, "请选择浏览器")) } catch (e: Exception) { - toastOnUI(e.localizedMessage ?: "open url error") + toastOnUi(e.localizedMessage ?: "open url error") } } } diff --git a/app/src/main/java/io/legado/app/utils/Toasts.kt b/app/src/main/java/io/legado/app/utils/Toasts.kt index 5516fa3a2..b0fea3e38 100644 --- a/app/src/main/java/io/legado/app/utils/Toasts.kt +++ b/app/src/main/java/io/legado/app/utils/Toasts.kt @@ -12,14 +12,14 @@ import org.jetbrains.anko.longToast * * @param message the message text resource. */ -fun Fragment.toastOnUI(message: Int) = requireActivity().toastOnUI(message) +fun Fragment.toastOnUi(message: Int) = requireActivity().toastOnUi(message) /** * Display the simple Toast message with the [Toast.LENGTH_SHORT] duration. * * @param message the message text. */ -fun Fragment.toastOnUI(message: CharSequence) = requireActivity().toastOnUI(message) +fun Fragment.toastOnUi(message: CharSequence) = requireActivity().toastOnUi(message) /** * Display the simple Toast message with the [Toast.LENGTH_LONG] duration.