summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Martinz <amartinz@shiftphones.com>2018-07-06 13:01:20 +0200
committerJoey Rizzoli <joey@lineageos.org>2018-07-14 15:36:07 +0200
commit6649f808c2c6bafc6a3b614e0b26e674de4d7619 (patch)
tree6f636a393c783c8cece0bfb8d5cd470fc54e792c /src
parent2979f2b8ab166f9433023d4797ea6b766dbc5fe0 (diff)
downloadandroid_packages_apps_Trebuchet-6649f808c2c6bafc6a3b614e0b26e674de4d7619.tar.gz
android_packages_apps_Trebuchet-6649f808c2c6bafc6a3b614e0b26e674de4d7619.tar.bz2
android_packages_apps_Trebuchet-6649f808c2c6bafc6a3b614e0b26e674de4d7619.zip
Edit dialog: dynamically apply foreground to icon
If there are no icon packs installed, we can not edit the icon, though it always applied a foreground and click listener. Only apply foreground and set click listener, if there are icon packs installed and clicking on it actually does something. Change-Id: I09ac1473c75d5edcf5e940a0e5bb2ec7f2296e8f Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9d85a64b9..8bdd8836c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3991,8 +3991,8 @@ public class Launcher extends BaseActivity
CharSequence label = mIconCache.getCacheEntry(app).title;
View dialogView = getLayoutInflater().inflate(R.layout.target_edit_dialog, null);
- ImageView editIcon = (ImageView) dialogView.findViewById(R.id.edit_dialog_icon);
- mIconEditTitle = (EditText) dialogView.findViewById(R.id.edit_dialog_title);
+ ImageView editIcon = dialogView.findViewById(R.id.edit_dialog_icon);
+ mIconEditTitle = dialogView.findViewById(R.id.edit_dialog_title);
mIconEditTitle.setText(label);
Bitmap originalIcon = mIconsHandler.getDrawableIconForPackage(component);
@@ -4007,21 +4007,29 @@ public class Launcher extends BaseActivity
}
editIcon.setImageBitmap(icon);
- Pair<List<String>, List<String>> iconPacks = mIconsHandler.getAllIconPacks();
- ListPopupWindow listPopup = new ListPopupWindow(this);
- listPopup.setAdapter(new ArrayAdapter<>(this, R.layout.target_edit_dialog_item,
- iconPacks.second));
- listPopup.setWidth(getResources().getDimensionPixelSize(R.dimen.edit_dialog_min_width));
- listPopup.setAnchorView(editIcon);
- listPopup.setModal(true);
- listPopup.setOnItemClickListener(getIconPackClickListener(info, component, label,
- iconPacks.first));
-
- editIcon.setOnClickListener(v -> {
- if (!iconPacks.second.isEmpty()) {
- listPopup.show();
- }
- });
+ final Pair<List<String>, List<String>> iconPacks = mIconsHandler.getAllIconPacks();
+ final Drawable editIconForeground;
+
+ // if no custom icon packs are installed, disallow icon editing
+ if (iconPacks.second.isEmpty()) {
+ editIconForeground = null;
+ editIcon.setEnabled(false);
+ } else {
+ editIconForeground = getDrawable(R.drawable.ic_icon_change);
+ editIcon.setEnabled(true);
+
+ ListPopupWindow listPopup = new ListPopupWindow(this);
+ listPopup.setAdapter(new ArrayAdapter<>(this, R.layout.target_edit_dialog_item,
+ iconPacks.second));
+ listPopup.setWidth(getResources().getDimensionPixelSize(R.dimen.edit_dialog_min_width));
+ listPopup.setAnchorView(editIcon);
+ listPopup.setModal(true);
+ listPopup.setOnItemClickListener(getIconPackClickListener(info, component, label,
+ iconPacks.first));
+
+ editIcon.setOnClickListener(v -> listPopup.show());
+ }
+ editIcon.setForeground(editIconForeground);
mIconEditDialog = new AlertDialog.Builder(this)
.setTitle(R.string.app_edit_drop_target_label)