mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
优化
This commit is contained in:
parent
272232291f
commit
e5d8441c54
@ -7,6 +7,7 @@ import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.SubMenu
|
||||
import android.widget.PopupMenu
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
@ -43,6 +44,7 @@ import org.jetbrains.anko.toast
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity_book_source),
|
||||
PopupMenu.OnMenuItemClickListener,
|
||||
BookSourceAdapter.CallBack,
|
||||
FileChooserDialog.CallBack,
|
||||
SearchView.OnQueryTextListener {
|
||||
@ -55,6 +57,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
|
||||
private var bookSourceLiveDate: LiveData<List<BookSource>>? = null
|
||||
private var groups = hashSetOf<String>()
|
||||
private var groupMenu: SubMenu? = null
|
||||
private lateinit var selMenu: PopupMenu
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
initUriScheme()
|
||||
@ -83,13 +86,6 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
|
||||
R.id.menu_group_manage ->
|
||||
GroupManageDialog().show(supportFragmentManager, "groupManage")
|
||||
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()
|
||||
}
|
||||
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.clearFocus()
|
||||
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) {
|
||||
@ -171,7 +170,22 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
|
||||
btn_revert_selection.onClick {
|
||||
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() {
|
||||
|
@ -23,7 +23,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/background"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="6dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:elevation="2dp">
|
||||
|
||||
<io.legado.app.lib.theme.view.ATECheckBox
|
||||
@ -42,7 +45,7 @@
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:gravity="center"
|
||||
android:minWidth="90dp"
|
||||
android:minWidth="80dp"
|
||||
android:text="@string/move_to_group" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView
|
||||
@ -51,7 +54,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:minWidth="90dp"
|
||||
android:minWidth="80dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/delete" />
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
|
||||
<io.legado.app.ui.widget.TitleBar
|
||||
@ -32,7 +33,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/background"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="6dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:elevation="2dp">
|
||||
|
||||
<io.legado.app.lib.theme.view.ATECheckBox
|
||||
@ -51,7 +55,7 @@
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:gravity="center"
|
||||
android:minWidth="90dp"
|
||||
android:minWidth="80dp"
|
||||
android:text="@string/revert_selection" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView
|
||||
@ -60,10 +64,20 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:minWidth="90dp"
|
||||
android:minWidth="80dp"
|
||||
android:gravity="center"
|
||||
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>
|
@ -74,7 +74,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/background"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="6dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:elevation="2dp">
|
||||
|
||||
<io.legado.app.lib.theme.view.ATECheckBox
|
||||
@ -93,7 +96,7 @@
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:gravity="center"
|
||||
android:minWidth="90dp"
|
||||
android:minWidth="80dp"
|
||||
android:text="@string/add_to_shelf" />
|
||||
|
||||
<io.legado.app.lib.theme.view.ATEAccentStrokeTextView
|
||||
@ -102,7 +105,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:padding="5dp"
|
||||
android:minWidth="90dp"
|
||||
android:minWidth="80dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/delete" />
|
||||
|
||||
|
@ -3,49 +3,6 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
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
|
||||
android:id="@+id/menu_group"
|
||||
android:icon="@drawable/ic_groups"
|
||||
@ -119,10 +76,4 @@
|
||||
android:title="@string/import_by_qr_code"
|
||||
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>
|
||||
|
41
app/src/main/res/menu/book_source_sel.xml
Normal file
41
app/src/main/res/menu/book_source_sel.xml
Normal file
@ -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…
Reference in New Issue
Block a user