Blacklist: Add select & remove all action
This commit is contained in:
@@ -127,7 +127,7 @@ class BlacklistFragment : BaseFragment<FragmentGenericWithSearchBinding>() {
|
||||
)
|
||||
|
||||
val inflater: MenuInflater = popupMenu.menuInflater
|
||||
inflater.inflate(R.menu.menu_import_export, popupMenu.menu)
|
||||
inflater.inflate(R.menu.menu_blacklist, popupMenu.menu)
|
||||
|
||||
popupMenu.setOnMenuItemClickListener { menuItem: MenuItem ->
|
||||
when (menuItem.itemId) {
|
||||
@@ -143,6 +143,18 @@ class BlacklistFragment : BaseFragment<FragmentGenericWithSearchBinding>() {
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_select_all -> {
|
||||
viewModel.selectAll()
|
||||
binding.recycler.requestModelBuild()
|
||||
true
|
||||
}
|
||||
|
||||
R.id.action_remove_all -> {
|
||||
viewModel.removeAll()
|
||||
binding.recycler.requestModelBuild()
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,14 @@ class BlacklistViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun selectAll() {
|
||||
selected.addAll(packages.value?.map { it.packageName } ?: emptyList())
|
||||
}
|
||||
|
||||
fun removeAll() {
|
||||
selected.clear()
|
||||
}
|
||||
|
||||
fun importBlacklist(context: Context, uri: Uri) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
|
||||
33
app/src/main/res/menu/menu_blacklist.xml
Normal file
33
app/src/main/res/menu/menu_blacklist.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Aurora Store
|
||||
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||
~
|
||||
~ Aurora Store is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 2 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ Aurora Store is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_select_all"
|
||||
android:title="@string/action_select_all" />
|
||||
<item
|
||||
android:id="@+id/action_remove_all"
|
||||
android:title="@string/action_remove_all" />
|
||||
<item
|
||||
android:id="@+id/action_import"
|
||||
android:title="@string/action_import" />
|
||||
<item
|
||||
android:id="@+id/action_export"
|
||||
android:title="@string/action_export" />
|
||||
</menu>
|
||||
@@ -85,10 +85,12 @@
|
||||
<string name="action_pause">"Pause"</string>
|
||||
<string name="action_pending">"Pending"</string>
|
||||
<string name="action_post">"Post"</string>
|
||||
<string name="action_remove_all">"Remove all"</string>
|
||||
<string name="action_request_analysis">Request new analysis</string>
|
||||
<string name="action_restart">"Restart"</string>
|
||||
<string name="action_resume">"Resume"</string>
|
||||
<string name="action_search">"Search"</string>
|
||||
<string name="action_select_all">"Select all"</string>
|
||||
<string name="action_share">"Share"</string>
|
||||
<string name="action_uninstall">"Uninstall"</string>
|
||||
<string name="action_uninstall_success">"Successfully uninstalled"</string>
|
||||
|
||||
Reference in New Issue
Block a user