pull/47/head
kunfei 5 years ago
parent 25d45b6b22
commit 71ddd42443
  1. 32
      app/src/main/AndroidManifest.xml
  2. 37
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt

@ -38,7 +38,9 @@
android:resource="@xml/shortcuts"
android:launchMode="singleTask" />
</activity>
<activity android:name=".ui.main.MainActivity" />
<activity
android:name=".ui.main.MainActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui.book.read.ReadBookActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
@ -56,12 +58,24 @@
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity android:name=".ui.config.ConfigActivity" />
<activity android:name=".ui.replacerule.ReplaceRuleActivity" />
<activity android:name="io.legado.app.ui.book.search.SearchActivity" />
<activity android:name=".ui.about.AboutActivity" />
<activity android:name=".ui.qrcode.QrCodeActivity" />
<activity android:name=".ui.about.DonateActivity" />
<activity
android:name=".ui.config.ConfigActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui.replacerule.ReplaceRuleActivity"
android:launchMode="singleTask" />
<activity
android:name="io.legado.app.ui.book.search.SearchActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui.about.AboutActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui.qrcode.QrCodeActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui.about.DonateActivity"
android:launchMode="singleTask" />
<activity android:name=".ui.book.info.BookInfoActivity" />
<activity android:name="io.legado.app.ui.book.info.edit.BookInfoEditActivity" />
<activity android:name=".ui.book.source.debug.BookSourceDebugActivity" />
@ -79,7 +93,9 @@
</activity>
<activity android:name=".ui.chapterlist.ChapterListActivity" />
<activity android:name=".ui.rss.read.ReadRssActivity" />
<activity android:name=".ui.audio.AudioPlayActivity" />
<activity
android:name=".ui.audio.AudioPlayActivity"
android:launchMode="singleTask" />
<activity android:name=".ui.explore.ExploreShowActivity" />
<activity android:name=".ui.rss.source.manage.RssSourceActivity" />
<activity android:name=".ui.rss.source.debug.RssSourceDebugActivity" />

@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.KeyEvent
import android.widget.SeekBar
import androidx.lifecycle.Observer
import com.bumptech.glide.RequestBuilder
@ -27,7 +26,6 @@ import io.legado.app.ui.main.MainActivity
import io.legado.app.utils.applyTint
import io.legado.app.utils.getViewModel
import io.legado.app.utils.observeEvent
import io.legado.app.utils.snackbar
import kotlinx.android.synthetic.main.activity_audio_play.*
import kotlinx.android.synthetic.main.view_title_bar.*
import org.apache.commons.lang3.time.DateFormatUtils
@ -130,37 +128,6 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
viewModel.loadContent(viewModel.durChapterIndex + 1)
}
override fun onKeyLongPress(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
title_bar.snackbar(R.string.to_backstage, R.string.ok) {
startActivity<MainActivity>()
}
return true
}
}
return super.onKeyLongPress(keyCode, event)
}
override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
event?.let {
if ((event.flags and KeyEvent.FLAG_CANCELED_LONG_PRESS == 0)
&& event.isTracking
&& !event.isCanceled
) {
if (status == Status.PLAY) {
AudioPlay.pause(this)
return true
}
}
}
}
}
return super.onKeyUp(keyCode, event)
}
override fun finish() {
viewModel.book?.let {
if (!viewModel.inBookshelf) {
@ -169,9 +136,13 @@ class AudioPlayActivity : VMBaseActivity<AudioPlayViewModel>(R.layout.activity_a
okButton { viewModel.inBookshelf = true }
noButton { viewModel.removeFromBookshelf { super.finish() } }
}.show().applyTint()
} else {
if (status == Status.PLAY) {
startActivity<MainActivity>()
} else {
super.finish()
}
}
} ?: super.finish()
}

Loading…
Cancel
Save