mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 12:05:53 +01:00
Add overflow menu to blacklist and whitelist all installed applications
Fixes #679
This commit is contained in:
parent
3f06a8c2a6
commit
d55d551943
@ -22,6 +22,8 @@ import android.support.v4.app.NavUtils;
|
|||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -64,12 +66,25 @@ public class AppBlacklistActivity extends AbstractGBActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.app_blacklist_menu, menu);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
NavUtils.navigateUpFromSameTask(this);
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.blacklist_all_notif:
|
||||||
|
appBlacklistAdapter.blacklistAllNotif();
|
||||||
|
return true;
|
||||||
|
case R.id.whitelist_all_notif:
|
||||||
|
appBlacklistAdapter.whitelistAllNotif();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,10 @@ import android.widget.TextView;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -127,6 +129,22 @@ public class AppBlacklistAdapter extends RecyclerView.Adapter<AppBlacklistAdapte
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void blacklistAllNotif() {
|
||||||
|
Set<String> apps_blacklist = new HashSet<>();
|
||||||
|
List<ApplicationInfo> allApps = mPm.getInstalledApplications(PackageManager.GET_META_DATA);
|
||||||
|
for (ApplicationInfo ai : allApps) {
|
||||||
|
apps_blacklist.add(ai.packageName);
|
||||||
|
}
|
||||||
|
GBApplication.setAppsNotifBlackList(apps_blacklist);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void whitelistAllNotif() {
|
||||||
|
Set<String> apps_blacklist = new HashSet<>();
|
||||||
|
GBApplication.setAppsNotifBlackList(apps_blacklist);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return applicationInfoList.size();
|
return applicationInfoList.size();
|
||||||
|
11
app/src/main/res/menu/app_blacklist_menu.xml
Normal file
11
app/src/main/res/menu/app_blacklist_menu.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/blacklist_all_notif"
|
||||||
|
android:title="@string/blacklist_all_for_notifications">
|
||||||
|
|
||||||
|
</item>
|
||||||
|
<item
|
||||||
|
android:id="@+id/whitelist_all_notif"
|
||||||
|
android:title="@string/whitelist_all_for_notifications" />
|
||||||
|
</menu>
|
@ -46,6 +46,9 @@
|
|||||||
|
|
||||||
<!-- Strings related to AppBlacklist -->
|
<!-- Strings related to AppBlacklist -->
|
||||||
<string name="title_activity_appblacklist">Notification blacklist</string>
|
<string name="title_activity_appblacklist">Notification blacklist</string>
|
||||||
|
<string name="blacklist_all_for_notifications">Blacklist all for notifications</string>
|
||||||
|
<string name="whitelist_all_for_notifications">Whitelist all for notifications</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Strings related to CalBlacklist -->
|
<!-- Strings related to CalBlacklist -->
|
||||||
<string name="title_activity_calblacklist">Blacklisted Calendars</string>
|
<string name="title_activity_calblacklist">Blacklisted Calendars</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user