Add the ability to clear all nav drawer items for appPackage
This commit is contained in:
parent
dc0ec000de
commit
87e9f06711
1 changed files with 15 additions and 1 deletions
|
@ -1202,7 +1202,11 @@ public class OsmandAidlApi {
|
|||
}
|
||||
|
||||
boolean setNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) {
|
||||
if (!TextUtils.isEmpty(appPackage) && items != null && !items.isEmpty()) {
|
||||
if (!TextUtils.isEmpty(appPackage) && items != null) {
|
||||
if (items.isEmpty()) {
|
||||
clearNavDrawerItems(appPackage);
|
||||
return true;
|
||||
}
|
||||
List<NavDrawerItem> newItems = new ArrayList<>(MAX_NAV_DRAWER_ITEMS_PER_APP);
|
||||
boolean success = true;
|
||||
for (int i = 0; i < items.size() && i <= MAX_NAV_DRAWER_ITEMS_PER_APP; i++) {
|
||||
|
@ -1262,6 +1266,16 @@ public class OsmandAidlApi {
|
|||
return -1;
|
||||
}
|
||||
|
||||
private void clearNavDrawerItems(String appPackage) {
|
||||
try {
|
||||
JSONObject allItems = new JSONObject(app.getSettings().API_NAV_DRAWER_ITEMS_JSON.get());
|
||||
allItems.put(appPackage, null);
|
||||
app.getSettings().API_NAV_DRAWER_ITEMS_JSON.set(allItems.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveNavDrawerItems(String appPackage, List<NavDrawerItem> items) {
|
||||
try {
|
||||
JSONArray jArray = new JSONArray();
|
||||
|
|
Loading…
Reference in a new issue