pull/32/head
kunfei 5 years ago
parent df9fcc0e14
commit dce4342827
  1. 2
      app/src/main/java/io/legado/app/help/IntentHelp.kt
  2. 2
      app/src/main/java/io/legado/app/service/ReadAloudService.kt
  3. 13
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  4. 2
      app/src/main/java/io/legado/app/ui/bookinfo/edit/BookInfoEditActivity.kt
  5. 1
      app/src/main/java/io/legado/app/ui/config/ConfigFragment.kt
  6. 13
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  7. 45
      app/src/main/java/io/legado/app/utils/Toasts.kt

@ -3,7 +3,7 @@ package io.legado.app.help
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.toast import org.jetbrains.anko.toast
object IntentHelp { object IntentHelp {

@ -22,8 +22,8 @@ import io.legado.app.ui.widget.page.TextChapter
import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.getPrefInt import io.legado.app.utils.getPrefInt
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import io.legado.app.utils.toast
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.jetbrains.anko.toast
import java.util.* import java.util.*
class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManager.OnAudioFocusChangeListener { class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, AudioManager.OnAudioFocusChangeListener {

@ -16,18 +16,19 @@ class AboutFragment : PreferenceFragmentCompat() {
findPreference<Preference>("version")?.summary = App.INSTANCE.versionName findPreference<Preference>("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 { override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) { 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) 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) { private fun openIntent(intentName: String, address: String) {
try { try {
val intent = Intent(intentName) val intent = Intent(intentName)

@ -8,8 +8,8 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import io.legado.app.utils.toast
import kotlinx.android.synthetic.main.activity_book_info_edit.* import kotlinx.android.synthetic.main.activity_book_info_edit.*
import org.jetbrains.anko.toast
class BookInfoEditActivity : VMBaseActivity<BookInfoEditViewModel>(R.layout.activity_book_info_edit) { class BookInfoEditActivity : VMBaseActivity<BookInfoEditViewModel>(R.layout.activity_book_info_edit) {
override val viewModel: BookInfoEditViewModel override val viewModel: BookInfoEditViewModel

@ -60,7 +60,6 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
preference.context.getPrefString(preference.key, "") preference.context.getPrefString(preference.key, "")
) )
} }
} }
} }

@ -205,6 +205,19 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
return super.dispatchKeyEvent(event) 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)
}
/** /**
* 书籍加载完成,开始加载章节内容 * 书籍加载完成,开始加载章节内容
*/ */

@ -1,6 +1,5 @@
package io.legado.app.utils package io.legado.app.utils
import android.content.Context
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import org.jetbrains.anko.longToast import org.jetbrains.anko.longToast
@ -14,17 +13,6 @@ import org.jetbrains.anko.toast
*/ */
inline fun Fragment.toast(message: Int) = requireActivity().toast(message) 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. * 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) 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. * 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) 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. * Display the simple Toast message with the [Toast.LENGTH_LONG] duration.
* *
* @param message the message text. * @param message the message text.
*/ */
inline fun Fragment.longToast(message: CharSequence) = requireActivity().longToast(message) 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()
}
Loading…
Cancel
Save