From dce43428275b1bcb35c04597ecf6435d7658085c Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 26 Aug 2019 16:13:41 +0800 Subject: [PATCH] up --- .../java/io/legado/app/help/IntentHelp.kt | 2 +- .../io/legado/app/service/ReadAloudService.kt | 2 +- .../io/legado/app/ui/about/AboutFragment.kt | 13 +++--- .../ui/bookinfo/edit/BookInfoEditActivity.kt | 2 +- .../io/legado/app/ui/config/ConfigFragment.kt | 1 - .../app/ui/readbook/ReadBookActivity.kt | 13 ++++++ .../main/java/io/legado/app/utils/Toasts.kt | 45 ------------------- 7 files changed, 23 insertions(+), 55 deletions(-) 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 8d77301c5..55ee61ed0 100644 --- a/app/src/main/java/io/legado/app/help/IntentHelp.kt +++ b/app/src/main/java/io/legado/app/help/IntentHelp.kt @@ -3,7 +3,7 @@ package io.legado.app.help import android.content.Context import android.content.Intent import io.legado.app.R -import io.legado.app.utils.toast +import org.jetbrains.anko.toast object IntentHelp { diff --git a/app/src/main/java/io/legado/app/service/ReadAloudService.kt b/app/src/main/java/io/legado/app/service/ReadAloudService.kt index a28fbabc6..281a3bba0 100644 --- a/app/src/main/java/io/legado/app/service/ReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/ReadAloudService.kt @@ -22,8 +22,8 @@ import io.legado.app.ui.widget.page.TextChapter import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefInt import io.legado.app.utils.postEvent -import io.legado.app.utils.toast import kotlinx.coroutines.launch +import org.jetbrains.anko.toast import java.util.* class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManager.OnAudioFocusChangeListener { 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 5f2220b07..e98523051 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 @@ -16,18 +16,19 @@ class AboutFragment : PreferenceFragmentCompat() { findPreference("version")?.summary = App.INSTANCE.versionName } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + listView.overScrollMode = View.OVER_SCROLL_NEVER + } + override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { - + "mail" -> openIntent(Intent.ACTION_SENDTO, "mailto:kunfei.ge@gmail.com") + "gitHub" -> openIntent(Intent.ACTION_VIEW, getString(R.string.this_github_url)) } return super.onPreferenceTreeClick(preference) } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - listView.overScrollMode = View.OVER_SCROLL_NEVER - } - private fun openIntent(intentName: String, address: String) { try { val intent = Intent(intentName) diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/edit/BookInfoEditActivity.kt index 779cf962a..5d79d6e1c 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/edit/BookInfoEditActivity.kt @@ -8,8 +8,8 @@ import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book import io.legado.app.utils.getViewModel -import io.legado.app.utils.toast import kotlinx.android.synthetic.main.activity_book_info_edit.* +import org.jetbrains.anko.toast class BookInfoEditActivity : VMBaseActivity(R.layout.activity_book_info_edit) { override val viewModel: BookInfoEditViewModel diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt index c33d584a5..2885572ae 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt @@ -60,7 +60,6 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange preference.context.getPrefString(preference.key, "") ) } - } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 25295a158..3c0129034 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -205,6 +205,19 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea return super.dispatchKeyEvent(event) } + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + when (keyCode) { + KeyEvent.KEYCODE_BACK -> { + if (readAloudStatus == Status.PLAY) { + ReadAloudService.pause(this) + toast(R.string.read_aloud_pause) + return true + } + } + } + return super.onKeyDown(keyCode, event) + } + /** * 书籍加载完成,开始加载章节内容 */ 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 5fea5ad08..16c032fa0 100644 --- a/app/src/main/java/io/legado/app/utils/Toasts.kt +++ b/app/src/main/java/io/legado/app/utils/Toasts.kt @@ -1,6 +1,5 @@ package io.legado.app.utils -import android.content.Context import android.widget.Toast import androidx.fragment.app.Fragment import org.jetbrains.anko.longToast @@ -14,17 +13,6 @@ import org.jetbrains.anko.toast */ inline fun Fragment.toast(message: Int) = requireActivity().toast(message) -/** - * Display the simple Toast message with the [Toast.LENGTH_SHORT] duration. - * - * @param message the message text resource. - */ -inline fun Context.toast(message: Int): Toast = Toast - .makeText(this, message, Toast.LENGTH_SHORT) - .apply { - show() - } - /** * Display the simple Toast message with the [Toast.LENGTH_SHORT] duration. * @@ -32,17 +20,6 @@ inline fun Context.toast(message: Int): Toast = Toast */ inline fun Fragment.toast(message: CharSequence) = requireActivity().toast(message) -/** - * Display the simple Toast message with the [Toast.LENGTH_SHORT] duration. - * - * @param message the message text. - */ -inline fun Context.toast(message: CharSequence): Toast = Toast - .makeText(this, message, Toast.LENGTH_SHORT) - .apply { - show() - } - /** * Display the simple Toast message with the [Toast.LENGTH_LONG] duration. * @@ -50,31 +27,9 @@ inline fun Context.toast(message: CharSequence): Toast = Toast */ inline fun Fragment.longToast(message: Int) = requireActivity().longToast(message) -/** - * Display the simple Toast message with the [Toast.LENGTH_LONG] duration. - * - * @param message the message text resource. - */ -inline fun Context.longToast(message: Int): Toast = Toast - .makeText(this, message, Toast.LENGTH_LONG) - .apply { - show() - } - /** * Display the simple Toast message with the [Toast.LENGTH_LONG] duration. * * @param message the message text. */ inline fun Fragment.longToast(message: CharSequence) = requireActivity().longToast(message) - -/** - * Display the simple Toast message with the [Toast.LENGTH_LONG] duration. - * - * @param message the message text. - */ -inline fun Context.longToast(message: CharSequence): Toast = Toast - .makeText(this, message, Toast.LENGTH_LONG) - .apply { - show() - } \ No newline at end of file