pull/94/head
kunfei 5 years ago
parent 272232291f
commit e5d8441c54
  1. 28
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  2. 9
      app/src/main/res/layout/activity_arrange_book.xml
  3. 20
      app/src/main/res/layout/activity_book_source.xml
  4. 9
      app/src/main/res/layout/activity_import_book.xml
  5. 49
      app/src/main/res/menu/book_source.xml
  6. 41
      app/src/main/res/menu/book_source_sel.xml

@ -7,6 +7,7 @@ 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 android.view.SubMenu
import android.widget.PopupMenu
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
@ -43,6 +44,7 @@ import org.jetbrains.anko.toast
import java.io.FileNotFoundException import java.io.FileNotFoundException
class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity_book_source), class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity_book_source),
PopupMenu.OnMenuItemClickListener,
BookSourceAdapter.CallBack, BookSourceAdapter.CallBack,
FileChooserDialog.CallBack, FileChooserDialog.CallBack,
SearchView.OnQueryTextListener { SearchView.OnQueryTextListener {
@ -55,6 +57,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
private var bookSourceLiveDate: LiveData<List<BookSource>>? = null private var bookSourceLiveDate: LiveData<List<BookSource>>? = null
private var groups = hashSetOf<String>() private var groups = hashSetOf<String>()
private var groupMenu: SubMenu? = null private var groupMenu: SubMenu? = null
private lateinit var selMenu: PopupMenu
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
initUriScheme() initUriScheme()
@ -83,13 +86,6 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
R.id.menu_group_manage -> R.id.menu_group_manage ->
GroupManageDialog().show(supportFragmentManager, "groupManage") GroupManageDialog().show(supportFragmentManager, "groupManage")
R.id.menu_import_source_local -> selectFileSys() R.id.menu_import_source_local -> selectFileSys()
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.getSelection())
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection())
R.id.menu_enable_explore -> viewModel.enableSelectExplore(adapter.getSelection())
R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelection())
R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection())
R.id.menu_export_selection -> viewModel.exportSelection(adapter.getSelection())
R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection())
R.id.menu_import_source_onLine -> showImportDialog() R.id.menu_import_source_onLine -> showImportDialog()
} }
if (item.groupId == R.id.source_group) { if (item.groupId == R.id.source_group) {
@ -132,6 +128,9 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
search_view.queryHint = getString(R.string.search_book_source) search_view.queryHint = getString(R.string.search_book_source)
search_view.clearFocus() search_view.clearFocus()
search_view.setOnQueryTextListener(this) search_view.setOnQueryTextListener(this)
selMenu = PopupMenu(this, iv_menu_more)
selMenu.inflate(R.menu.book_source_sel)
selMenu.setOnMenuItemClickListener(this)
} }
private fun initLiveDataBookSource(searchKey: String? = null) { private fun initLiveDataBookSource(searchKey: String? = null) {
@ -171,7 +170,22 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
btn_revert_selection.onClick { btn_revert_selection.onClick {
adapter.revertSelection() adapter.revertSelection()
} }
iv_menu_more.onClick {
selMenu.show()
}
}
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.getSelection())
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelection())
R.id.menu_enable_explore -> viewModel.enableSelectExplore(adapter.getSelection())
R.id.menu_disable_explore -> viewModel.disableSelectExplore(adapter.getSelection())
R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelection())
R.id.menu_export_selection -> viewModel.exportSelection(adapter.getSelection())
R.id.menu_check_source -> CheckSource.start(this, adapter.getSelection())
}
return true
} }
private fun upGroupMenu() { private fun upGroupMenu() {

@ -23,7 +23,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background" android:background="@color/background"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="6dp" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:elevation="2dp"> android:elevation="2dp">
<io.legado.app.lib.theme.view.ATECheckBox <io.legado.app.lib.theme.view.ATECheckBox
@ -42,7 +45,7 @@
android:layout_margin="5dp" android:layout_margin="5dp"
android:padding="5dp" android:padding="5dp"
android:gravity="center" android:gravity="center"
android:minWidth="90dp" android:minWidth="80dp"
android:text="@string/move_to_group" /> android:text="@string/move_to_group" />
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView <io.legado.app.lib.theme.view.ATEAccentStrokeTextView
@ -51,7 +54,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="5dp" android:layout_margin="5dp"
android:padding="5dp" android:padding="5dp"
android:minWidth="90dp" android:minWidth="80dp"
android:gravity="center" android:gravity="center"
android:text="@string/delete" /> android:text="@string/delete" />

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"> android:orientation="vertical">
<io.legado.app.ui.widget.TitleBar <io.legado.app.ui.widget.TitleBar
@ -32,7 +33,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background" android:background="@color/background"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="6dp" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:elevation="2dp"> android:elevation="2dp">
<io.legado.app.lib.theme.view.ATECheckBox <io.legado.app.lib.theme.view.ATECheckBox
@ -51,7 +55,7 @@
android:layout_margin="5dp" android:layout_margin="5dp"
android:padding="5dp" android:padding="5dp"
android:gravity="center" android:gravity="center"
android:minWidth="90dp" android:minWidth="80dp"
android:text="@string/revert_selection" /> android:text="@string/revert_selection" />
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView <io.legado.app.lib.theme.view.ATEAccentStrokeTextView
@ -60,10 +64,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="5dp" android:layout_margin="5dp"
android:padding="5dp" android:padding="5dp"
android:minWidth="90dp" android:minWidth="80dp"
android:gravity="center" android:gravity="center"
android:text="@string/delete" /> android:text="@string/delete" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_menu_more"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="6dp"
android:src="@drawable/ic_more_vert"
android:tint="@color/tv_text_default"
tools:ignore="RtlHardcoded" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

@ -74,7 +74,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/background" android:background="@color/background"
android:gravity="center_vertical" android:gravity="center_vertical"
android:padding="6dp" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:elevation="2dp"> android:elevation="2dp">
<io.legado.app.lib.theme.view.ATECheckBox <io.legado.app.lib.theme.view.ATECheckBox
@ -93,7 +96,7 @@
android:layout_margin="5dp" android:layout_margin="5dp"
android:padding="5dp" android:padding="5dp"
android:gravity="center" android:gravity="center"
android:minWidth="90dp" android:minWidth="80dp"
android:text="@string/add_to_shelf" /> android:text="@string/add_to_shelf" />
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView <io.legado.app.lib.theme.view.ATEAccentStrokeTextView
@ -102,7 +105,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="5dp" android:layout_margin="5dp"
android:padding="5dp" android:padding="5dp"
android:minWidth="90dp" android:minWidth="80dp"
android:gravity="center" android:gravity="center"
android:text="@string/delete" /> android:text="@string/delete" />

@ -3,49 +3,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/menu_select_action"
android:icon="@drawable/ic_select_all"
android:title="@string/select_action"
app:showAsAction="always"
tools:ignore="AlwaysShowAction">
<menu>
<item
android:id="@+id/menu_enable_selection"
android:title="@string/enable_selection"
app:showAsAction="never" />
<item
android:id="@+id/menu_disable_selection"
android:title="@string/disable_selection"
app:showAsAction="never" />
<item
android:id="@+id/menu_enable_explore"
android:title="@string/enable_explore"
app:showAsAction="never" />
<item
android:id="@+id/menu_disable_explore"
android:title="@string/disable_explore"
app:showAsAction="never" />
<item
android:id="@+id/menu_del_selection"
android:title="@string/del_select"
app:showAsAction="never" />
<item
android:id="@+id/menu_export_selection"
android:title="@string/export_selection"
app:showAsAction="never" />
</menu>
</item>
<item <item
android:id="@+id/menu_group" android:id="@+id/menu_group"
android:icon="@drawable/ic_groups" android:icon="@drawable/ic_groups"
@ -119,10 +76,4 @@
android:title="@string/import_by_qr_code" android:title="@string/import_by_qr_code"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_check_source"
android:icon="@drawable/ic_check_source"
android:title="@string/check_select_source"
app:showAsAction="never" />
</menu> </menu>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_enable_selection"
android:title="@string/enable_selection"
app:showAsAction="never" />
<item
android:id="@+id/menu_disable_selection"
android:title="@string/disable_selection"
app:showAsAction="never" />
<item
android:id="@+id/menu_enable_explore"
android:title="@string/enable_explore"
app:showAsAction="never" />
<item
android:id="@+id/menu_disable_explore"
android:title="@string/disable_explore"
app:showAsAction="never" />
<item
android:id="@+id/menu_del_selection"
android:title="@string/del_select"
app:showAsAction="never" />
<item
android:id="@+id/menu_export_selection"
android:title="@string/export_selection"
app:showAsAction="never" />
<item
android:id="@+id/menu_check_source"
android:icon="@drawable/ic_check_source"
android:title="@string/check_select_source"
app:showAsAction="never" />
</menu>
Loading…
Cancel
Save