summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2014-11-10 18:35:01 (GMT)
committerAdnan <adnan@cyngn.com>2014-11-19 23:53:58 (GMT)
commit988cbecc57ef0b25dda5e483299e7c215bcce6da (patch)
treeaeac50171d00f9b5eef2aa62a087d6c547ceabb1
parentea3b5e62a45fb70041ac52f06608acbb96f6af30 (diff)
downloadandroid_packages_apps_Trebuchet-988cbecc57ef0b25dda5e483299e7c215bcce6da.zip
android_packages_apps_Trebuchet-988cbecc57ef0b25dda5e483299e7c215bcce6da.tar.gz
android_packages_apps_Trebuchet-988cbecc57ef0b25dda5e483299e7c215bcce6da.tar.bz2
Protected Folder Fragment: Add remove Shortcut from list.
Change-Id: I0e9f141bc34bcfa955d7f5f3535d9d437e94b1da
-rw-r--r--res/drawable-hdpi/ic_remove.pngbin0 -> 931 bytes
-rw-r--r--res/drawable-mdpi/ic_remove.pngbin0 -> 646 bytes
-rw-r--r--res/drawable-xhdpi/ic_remove.pngbin0 -> 1403 bytes
-rw-r--r--res/drawable-xxhdpi/ic_remove.pngbin0 -> 2177 bytes
-rw-r--r--res/layout/hidden_folder_apps_list_item.xml9
-rw-r--r--src/com/android/launcher3/Folder.java14
-rw-r--r--src/com/android/launcher3/HiddenFolderFragment.java20
7 files changed, 40 insertions, 3 deletions
diff --git a/res/drawable-hdpi/ic_remove.png b/res/drawable-hdpi/ic_remove.png
new file mode 100644
index 0000000..d26b12b
--- /dev/null
+++ b/res/drawable-hdpi/ic_remove.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_remove.png b/res/drawable-mdpi/ic_remove.png
new file mode 100644
index 0000000..48c82fa
--- /dev/null
+++ b/res/drawable-mdpi/ic_remove.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_remove.png b/res/drawable-xhdpi/ic_remove.png
new file mode 100644
index 0000000..38a8705
--- /dev/null
+++ b/res/drawable-xhdpi/ic_remove.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_remove.png b/res/drawable-xxhdpi/ic_remove.png
new file mode 100644
index 0000000..ac36b34
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_remove.png
Binary files differ
diff --git a/res/layout/hidden_folder_apps_list_item.xml b/res/layout/hidden_folder_apps_list_item.xml
index 1344194..f3af4ad 100644
--- a/res/layout/hidden_folder_apps_list_item.xml
+++ b/res/layout/hidden_folder_apps_list_item.xml
@@ -5,8 +5,7 @@
android:minHeight="48dp"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize"
- android:background="?android:attr/selectableItemBackground"
- android:descendantFocusability="blocksDescendants">
+ android:background="?android:attr/selectableItemBackground">
<ImageView android:id="@+id/icon"
android:layout_width="40dp"
@@ -25,4 +24,10 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
+
+ <ImageView android:id="@+id/remove"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_gravity="center"
+ android:src="@drawable/ic_remove"/>
</LinearLayout> \ No newline at end of file
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 7f3f47f..dc33552 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -1482,6 +1482,20 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
return mItemsInReadingOrder;
}
+ public ShortcutInfo getShortcutForComponent(ComponentName componentName) {
+ for (View v : mItemsInReadingOrder) {
+ Object tag = v.getTag();
+ if (tag instanceof ShortcutInfo) {
+ ComponentName cName = ((ShortcutInfo) tag).getIntent().getComponent();
+ if (cName.equals(componentName)) {
+ return (ShortcutInfo) tag;
+ }
+ }
+ }
+
+ return null;
+ }
+
public void getLocationInDragLayer(int[] loc) {
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
diff --git a/src/com/android/launcher3/HiddenFolderFragment.java b/src/com/android/launcher3/HiddenFolderFragment.java
index d43f61d..07b0e4a 100644
--- a/src/com/android/launcher3/HiddenFolderFragment.java
+++ b/src/com/android/launcher3/HiddenFolderFragment.java
@@ -140,6 +140,16 @@ public class HiddenFolderFragment extends Fragment {
return apps;
}
+ private void removeComponentFromFolder(AppEntry app) {
+ mLauncher.mHiddenFolderIcon.getFolderInfo().remove(
+ mLauncher.mHiddenFolderIcon.getFolder()
+ .getShortcutForComponent(app.componentName));
+
+ mAppEntries.remove(app);
+ mAppsAdapter.remove(app);
+ mAppsAdapter.notifyDataSetInvalidated();
+ }
+
public void saveHiddenFolderStatus(int position) {
String newTitle = mFolderName.getText().toString();
if (mLauncher.mHiddenFolderIcon != null) {
@@ -221,12 +231,18 @@ public class HiddenFolderFragment extends Fragment {
viewHolder = (AppViewHolder) convertView.getTag();
}
- AppEntry app = getItem(position);
+ final AppEntry app = getItem(position);
viewHolder.title.setText(app.title);
Drawable icon = mIcons.get(app.componentName.getPackageName());
viewHolder.icon.setImageDrawable(icon != null ? icon : mDefaultImg);
+ viewHolder.remove.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ removeComponentFromFolder(app);
+ }
+ });
convertView.setOnClickListener(new OnClickListener() {
@Override
@@ -314,10 +330,12 @@ public class HiddenFolderFragment extends Fragment {
private static class AppViewHolder {
public final TextView title;
public final ImageView icon;
+ public final ImageView remove;
public final int position;
public AppViewHolder(View parentView, int position) {
icon = (ImageView) parentView.findViewById(R.id.icon);
+ remove = (ImageView) parentView.findViewById(R.id.remove);
title = (TextView) parentView.findViewById(R.id.title);
this.position = position;
}