diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 4cd6dbe2f..d579b7529 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -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(R.layout.activity_book_source), + PopupMenu.OnMenuItemClickListener, BookSourceAdapter.CallBack, FileChooserDialog.CallBack, SearchView.OnQueryTextListener { @@ -55,6 +57,7 @@ class BookSourceActivity : VMBaseActivity(R.layout.activity private var bookSourceLiveDate: LiveData>? = null private var groups = hashSetOf() private var groupMenu: SubMenu? = null + private lateinit var selMenu: PopupMenu override fun onActivityCreated(savedInstanceState: Bundle?) { initUriScheme() @@ -83,13 +86,6 @@ class BookSourceActivity : VMBaseActivity(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(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(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() { diff --git a/app/src/main/res/layout/activity_arrange_book.xml b/app/src/main/res/layout/activity_arrange_book.xml index bafdbabe6..66642e134 100644 --- a/app/src/main/res/layout/activity_arrange_book.xml +++ b/app/src/main/res/layout/activity_arrange_book.xml @@ -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"> diff --git a/app/src/main/res/layout/activity_book_source.xml b/app/src/main/res/layout/activity_book_source.xml index f3be2d751..a913920af 100644 --- a/app/src/main/res/layout/activity_book_source.xml +++ b/app/src/main/res/layout/activity_book_source.xml @@ -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"> + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index 4a4b16d92..41c8490e1 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -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"> diff --git a/app/src/main/res/menu/book_source.xml b/app/src/main/res/menu/book_source.xml index 8df8928e4..649060e9f 100644 --- a/app/src/main/res/menu/book_source.xml +++ b/app/src/main/res/menu/book_source.xml @@ -3,49 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/menu/book_source_sel.xml b/app/src/main/res/menu/book_source_sel.xml new file mode 100644 index 000000000..dff64669a --- /dev/null +++ b/app/src/main/res/menu/book_source_sel.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + +