summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Martinz <amartinz@shiftphones.com>2018-07-06 11:01:20 (GMT)
committerJoey Rizzoli <joey@lineageos.org>2018-07-14 13:36:07 (GMT)
commit6649f808c2c6bafc6a3b614e0b26e674de4d7619 (patch)
tree6f636a393c783c8cece0bfb8d5cd470fc54e792c
parent2979f2b8ab166f9433023d4797ea6b766dbc5fe0 (diff)
downloadandroid_packages_apps_Trebuchet-6649f808c2c6bafc6a3b614e0b26e674de4d7619.zip
android_packages_apps_Trebuchet-6649f808c2c6bafc6a3b614e0b26e674de4d7619.tar.gz
android_packages_apps_Trebuchet-6649f808c2c6bafc6a3b614e0b26e674de4d7619.tar.bz2
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>
-rw-r--r--res/layout/target_edit_dialog.xml1
-rw-r--r--src/com/android/launcher3/Launcher.java42
2 files changed, 25 insertions, 18 deletions
diff --git a/res/layout/target_edit_dialog.xml b/res/layout/target_edit_dialog.xml
index 11bfefc..7567411 100644
--- a/res/layout/target_edit_dialog.xml
+++ b/res/layout/target_edit_dialog.xml
@@ -28,7 +28,6 @@
android:layout_gravity="bottom"
android:layout_marginEnd="16dp"
android:background="?android:selectableItemBackground"
- android:foreground="@drawable/ic_icon_change"
android:scaleType="fitCenter"
tools:src="@mipmap/ic_launcher" />
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9d85a64..8bdd883 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)