feat: webdav书籍排序选项的配置,以及事件监听

pull/2021/head
谢意帆 2 years ago
parent df128f2a84
commit 761570091a
  1. 28
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt
  2. 5
      app/src/main/res/drawable/ic_baseline_sort_24.xml
  3. 34
      app/src/main/res/menu/book_remote.xml

@ -3,6 +3,7 @@ package io.legado.app.ui.book.remote
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.SubMenu
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -12,9 +13,11 @@ import io.legado.app.databinding.ActivityImportBookBinding
import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.backgroundColor
import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.book.remote.manager.RemoteBookWebDav import io.legado.app.ui.book.remote.manager.RemoteBookWebDav
import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.ui.widget.SelectActionBar import io.legado.app.ui.widget.SelectActionBar
import io.legado.app.ui.widget.dialog.WaitDialog import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.showDialogFragment import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.flow.conflate import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -32,7 +35,7 @@ class RemoteBookActivity : VMBaseActivity<ActivityImportBookBinding, RemoteBookV
override val viewModel by viewModels<RemoteBookViewModel>() override val viewModel by viewModels<RemoteBookViewModel>()
private val adapter by lazy { RemoteBookAdapter(this, this) } private val adapter by lazy { RemoteBookAdapter(this, this) }
private val waitDialog by lazy { WaitDialog(this) } private val waitDialog by lazy { WaitDialog(this) }
private var groupMenu: SubMenu? = null
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.titleBar.setTitle(R.string.remote_book) binding.titleBar.setTitle(R.string.remote_book)
initView() initView()
@ -75,10 +78,33 @@ class RemoteBookActivity : VMBaseActivity<ActivityImportBookBinding, RemoteBookV
when (item.itemId) { when (item.itemId) {
R.id.menu_refresh -> upPath() R.id.menu_refresh -> upPath()
R.id.menu_log -> showDialogFragment<AppLogDialog>() R.id.menu_log -> showDialogFragment<AppLogDialog>()
R.id.menu_sort_auto -> {
item.isChecked = true
toastOnUi("menu_sort_auto")
//sortCheck(BookSourceActivity.Sort.Weight)
//upBookSource(searchView.query?.toString())
}
R.id.menu_sort_name -> {
item.isChecked = true
toastOnUi("menu_sort_name")
//sortCheck(BookSourceActivity.Sort.Name)
//upBookSource(searchView.query?.toString())
}
R.id.menu_sort_time -> {
item.isChecked = true
toastOnUi("menu_sort_time")
//sortCheck(BookSourceActivity.Sort.Update)
//upBookSource(searchView.query?.toString())
}
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
groupMenu = menu.findItem(R.id.menu_sort)?.subMenu
groupMenu?.setGroupCheckable(R.id.menu_group_sort, true, true)
return super.onPrepareOptionsMenu(menu)
}
override fun revertSelection() { override fun revertSelection() {
adapter.revertSelection() adapter.revertSelection()
} }

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z"/>
</vector>

@ -9,11 +9,43 @@
android:icon="@drawable/ic_refresh_black_24dp" android:icon="@drawable/ic_refresh_black_24dp"
android:title="@string/refresh" android:title="@string/refresh"
app:showAsAction="always" /> app:showAsAction="always" />
<item
android:id="@+id/menu_sort"
android:icon="@drawable/ic_baseline_sort_24"
android:title="排序"
app:showAsAction="always"
tools:ignore="AlwaysShowAction">
<menu>
<group
android:id="@+id/menu_group_sort"
android:checkableBehavior="single">
<item
android:id="@+id/menu_sort_auto"
android:checkable="true"
android:title="@string/sort_auto" />
<item
android:id="@+id/menu_sort_name"
android:checkable="true"
android:title="@string/sort_by_name" />
<item
android:id="@+id/menu_sort_time"
android:checkable="true"
android:title="@string/sort_by_lastUpdateTime" />
</group>
</menu>
</item>
<item <item
android:id="@+id/menu_log" android:id="@+id/menu_log"
android:title="@string/log"
android:icon="@drawable/ic_cfg_about" android:icon="@drawable/ic_cfg_about"
android:title="@string/log"
app:showAsAction="never" /> app:showAsAction="never" />
</menu> </menu>
Loading…
Cancel
Save