LineageParts: improve Notification light settings actionbar
Before the ´Use custom values´-toggle would toggle
search-icon instead of add-icon.
Change-Id: I40c64f449122e5a86b1dc1501e7316c2787d367a
diff --git a/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java b/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
index 200054f..b63319e 100644
--- a/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
+++ b/src/org/lineageos/lineageparts/notificationlight/NotificationLightSettings.java
@@ -76,7 +76,6 @@
public static final int ACTION_TEST = 0;
public static final int ACTION_DELETE = 1;
- private static final int MENU_ADD = 0;
private static final int DIALOG_APPS = 0;
private int mDefaultColor;
@@ -93,6 +92,7 @@
private ApplicationLightPreference mCallPref;
private ApplicationLightPreference mVoicemailPref;
private Menu mMenu;
+ private MenuItem mAddItem;
private PackageListAdapter mPackageAdapter;
private String mPackageList;
private Map<String, Package> mPackages;
@@ -492,7 +492,7 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
mMenu = menu;
- mMenu.add(0, MENU_ADD, 0, R.string.add)
+ mAddItem = mMenu.add(R.string.add)
.setIcon(R.drawable.ic_menu_add)
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
@@ -500,15 +500,14 @@
@Override
public void onPrepareOptionsMenu(Menu menu) {
boolean enableAddButton = mEnabledPref.isChecked() && mCustomEnabledPref.isChecked();
- menu.findItem(MENU_ADD).setVisible(enableAddButton);
+ mAddItem.setVisible(enableAddButton);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case MENU_ADD:
- showDialog(DIALOG_APPS);
- return true;
+ if (item == mAddItem) {
+ showDialog(DIALOG_APPS);
+ return true;
}
return false;
}