summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Shvadskiy <ashvadskiy@cyngn.com>2016-01-08 20:48:25 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-01-13 19:06:31 (GMT)
commit3c30f3ec6006c429e8751c0d0dfe7631fb161005 (patch)
tree5c8400c0a874200eb65d8f988c742fb6c205ceaa
parentd0cb9ae5d52de004ac0e326d5fbe9feb66c2c98c (diff)
downloadandroid_packages_apps_Trebuchet-3c30f3ec6006c429e8751c0d0dfe7631fb161005.zip
android_packages_apps_Trebuchet-3c30f3ec6006c429e8751c0d0dfe7631fb161005.tar.gz
android_packages_apps_Trebuchet-3c30f3ec6006c429e8751c0d0dfe7631fb161005.tar.bz2
Implement placeholder icons for remote folder.
Patch 1: Unfinished temporary commit before rebase. Patch 2: Rebase. Patch 3: 1. Add additional RemoteFolderManager hook for drawer adapter setApps(). 2. Replace method arguments in drawer adapter from ArrayList to List, which allows us to use Collections.singletonList(), which is more memory efficient. 3. Allow folders to batch remove a subset of their entries. 4. Remove unused remote flag in ShortcutInfo. Patch 4: Fix placeholder animation for folder and folder icon. Patch 5: Remove unused import. Patch 6: Move app drawer bg color to overlay. Change-Id: I5ae3b976e2d04dcfbe5ea2e563ef94dcae48b7d4 issue-id: CYNGNOS-1329
-rw-r--r--RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java14
-rw-r--r--res/values/colors.xml3
-rw-r--r--src/com/android/launcher3/AppDrawerListAdapter.java42
-rw-r--r--src/com/android/launcher3/AppInfo.java13
-rw-r--r--src/com/android/launcher3/BubbleTextView.java22
-rw-r--r--src/com/android/launcher3/Folder.java49
-rw-r--r--src/com/android/launcher3/FolderIcon.java26
-rw-r--r--src/com/android/launcher3/FolderInfo.java24
-rw-r--r--src/com/android/launcher3/ItemInfo.java7
-rw-r--r--src/com/android/launcher3/Launcher.java1
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java5
11 files changed, 146 insertions, 60 deletions
diff --git a/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java b/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
index a79791f..b3a147c 100644
--- a/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
+++ b/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
@@ -22,6 +22,15 @@ public class RemoteFolderManager {
public Folder createRemoteFolder(final FolderIcon icon, ViewGroup root) { return null; }
/**
+ * Get a drawable for the supplied item in the folder icon preview.
+ * @param items list of views in the folder.
+ * @param position index of icon to retreive.
+ * @return an icon to draw in the folder preview.
+ */
+ public Drawable getFolderIconDrawable(final ArrayList<View> items,
+ final int position) { return null; }
+
+ /**
* Called when Launcher finishes binding items from the model.
*/
public void bindFinished() { }
@@ -49,6 +58,11 @@ public class RemoteFolderManager {
public void onBindAddApps(ArrayList<AppInfo> apps) { }
/**
+ * Called when launcher loads apps and applies them to the drawer.
+ */
+ public void onSetApps() { }
+
+ /**
* Called when the info icon is clicked
*/
public void onInfoIconClicked() { }
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 302ab21..55f17a3 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -57,8 +57,5 @@
<color name="scrubber_background">#CC14191E</color>
<color name="drawer_header_text_shadow">#b0000000</color>
- <color name="drawer_container_background_default">#00000000</color>
- <color name="drawer_container_background_custom">#66000000</color>
-
<color name="folder_background">#141a1e</color>
</resources>
diff --git a/src/com/android/launcher3/AppDrawerListAdapter.java b/src/com/android/launcher3/AppDrawerListAdapter.java
index b3001e5..c68f52f 100644
--- a/src/com/android/launcher3/AppDrawerListAdapter.java
+++ b/src/com/android/launcher3/AppDrawerListAdapter.java
@@ -21,7 +21,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.ComponentName;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.provider.Settings;
@@ -34,11 +33,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
-import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
import android.widget.SectionIndexer;
-import android.widget.TextView;
import com.android.launcher3.locale.LocaleSetManager;
import com.android.launcher3.locale.LocaleUtils;
import com.android.launcher3.settings.SettingsProvider;
@@ -48,6 +44,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
/**
* AppDrawerListAdapter - list adapter for the vertical app drawer
@@ -519,7 +516,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
Collections.sort(mHeaderList);
}
- public void setApps(ArrayList<AppInfo> list) {
+ public void setApps(List<AppInfo> list) {
if (!LauncherAppState.isDisableAllApps()) {
initParams();
@@ -559,7 +556,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
processApps();
}
- public void updateApps(ArrayList<AppInfo> list) {
+ public void updateApps(List<AppInfo> list) {
if (!LauncherAppState.isDisableAllApps()) {
mAllApps.removeAll(list);
mAllApps.addAll(list);
@@ -567,11 +564,11 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
}
}
- public void addApps(ArrayList<AppInfo> list) {
+ public void addApps(List<AppInfo> list) {
updateApps(list);
}
- public void removeApps(ArrayList<AppInfo> appInfos) {
+ public void removeApps(List<AppInfo> appInfos) {
if (!LauncherAppState.isDisableAllApps()) {
mAllApps.removeAll(appInfos);
reset();
@@ -597,6 +594,11 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
icon.setOnClickListener(mLauncher);
icon.setOnLongClickListener(this);
holder.mIconLayout.addView(icon);
+
+ icon.mIcon.setPadding(mDeviceProfile.iconDrawablePaddingPx,
+ mDeviceProfile.iconDrawablePaddingPx,
+ mDeviceProfile.iconDrawablePaddingPx,
+ mDeviceProfile.iconDrawablePaddingPx);
}
if (viewType == ViewHolder.TYPE_CUSTOM) {
@@ -641,6 +643,10 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
public void onBindViewHolder(ViewHolder holder, int position) {
AppItemIndexedInfo indexedInfo = mHeaderList.get(position);
+ if (indexedInfo.isRemote()) {
+ mRemoteFolderManager.onBindViewHolder(holder, indexedInfo);
+ }
+
holder.mHeaderTextView.setVisibility(indexedInfo.isChild ? View.INVISIBLE : View.VISIBLE);
if (!indexedInfo.isChild) {
holder.mHeaderTextView.setText(indexedInfo.mStartString);
@@ -674,24 +680,22 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
} else {
icon.setVisibility(View.VISIBLE);
AppInfo info = indexedInfo.mInfo.get(i);
-
icon.setTag(info);
- Drawable d = Utilities.createIconDrawable(info.iconBitmap);
+
+ Drawable d;
+ if (info.customDrawable != null) {
+ d = info.customDrawable;
+ } else {
+ d = Utilities.createIconDrawable(info.iconBitmap);
+ }
d.setBounds(mIconRect);
icon.mIcon.setImageDrawable(d);
- icon.mIcon.setPadding(mDeviceProfile.iconDrawablePaddingPx,
- mDeviceProfile.iconDrawablePaddingPx,
- mDeviceProfile.iconDrawablePaddingPx,
- mDeviceProfile.iconDrawablePaddingPx);
+
icon.mLabel.setText(info.title);
icon.mLabel.setVisibility(mHideIconLabels ? View.INVISIBLE : View.VISIBLE);
}
}
holder.itemView.setTag(indexedInfo);
-
- if (indexedInfo.isRemote()) {
- mRemoteFolderManager.onBindViewHolder(holder, indexedInfo);
- }
}
@Override
@@ -862,7 +866,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
return index;
}
- private void filterProtectedApps(ArrayList<AppInfo> list) {
+ private void filterProtectedApps(List<AppInfo> list) {
updateProtectedAppsList(mLauncher);
Iterator<AppInfo> iterator = list.iterator();
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index 907b42c..d14b0e0 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -93,16 +93,13 @@ public class AppInfo extends ItemInfo {
this.user = user;
}
- public AppInfo(Intent intent, String title, Bitmap icon, UserHandleCompat user,
- boolean remote) {
+ public AppInfo(Intent intent, String title, UserHandleCompat user) {
this.componentName = intent.getComponent();
this.container = ItemInfo.NO_ID;
this.intent = intent;
this.title = title;
- iconBitmap = icon;
this.user = user;
- flags = remote ? REMOTE_APP_FLAG : 0;
}
public static int initFlags(LauncherActivityInfoCompat info) {
@@ -150,6 +147,14 @@ public class AppInfo extends ItemInfo {
return (flags & flag) != 0;
}
+ /**
+ * Set a flag for this app
+ * @param flag flag to apply.
+ */
+ public void setFlag(int flag) {
+ flags |= flag;
+ }
+
@Override
public String toString() {
return "ApplicationInfo(title=" + title.toString() + " id=" + this.id
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index d26577a..9bfde23 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -118,15 +118,21 @@ public class BubbleTextView extends TextView {
public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache,
boolean setDefaultPadding, boolean promiseStateChanged) {
- Bitmap b = info.getIcon(iconCache);
LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- FastBitmapDrawable iconDrawable = Utilities.createIconDrawable(b);
- iconDrawable.setGhostModeEnabled(info.isDisabled != 0);
+ Drawable iconDrawable;
+ if (info.customDrawable != null) {
+ iconDrawable = info.customDrawable;
+ } else {
+ Bitmap b = info.getIcon(iconCache);
+ iconDrawable = Utilities.createIconDrawable(b);
+ ((FastBitmapDrawable) iconDrawable).setGhostModeEnabled(info.isDisabled != 0);
+ }
+ iconDrawable.setBounds(0, 0, grid.iconSizePx, grid.iconSizePx);
setCompoundDrawables(null, iconDrawable, null, null);
if (setDefaultPadding) {
- DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
}
if (info.contentDescription != null) {
@@ -144,7 +150,12 @@ public class BubbleTextView extends TextView {
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
- Drawable topDrawable = Utilities.createIconDrawable(info.iconBitmap);
+ Drawable topDrawable;
+ if (info.customDrawable != null) {
+ topDrawable = info.customDrawable;
+ } else {
+ topDrawable = Utilities.createIconDrawable(info.iconBitmap);
+ }
topDrawable.setBounds(0, 0, grid.allAppsIconSizePx, grid.allAppsIconSizePx);
setCompoundDrawables(null, topDrawable, null, null);
setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
@@ -155,7 +166,6 @@ public class BubbleTextView extends TextView {
setTag(info);
}
-
@Override
protected boolean setFrame(int left, int top, int right, int bottom) {
if (getLeft() != left || getRight() != right || getTop() != top || getBottom() != bottom) {
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 1cad48d..486d5e5 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -1633,8 +1633,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
// If this item is being dragged from this open folder, we have already handled
// the work associated with removing the item, so we don't have to do anything here.
if (item == mCurrentDragInfo) return;
- View v = getViewForInfo(item);
- mContent.removeView(v);
+ mContent.removeView(getViewForInfo(item));
if (mState == STATE_ANIMATING) {
mRearrangeOnClose = true;
} else {
@@ -1648,21 +1647,49 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
@Override
public void onRemoveAll() {
// Clear the UX after folder contents are removed from the DB
- mContent.removeAllViews();
+ removeViewsForItems(null);
mLauncher.closeFolder(this);
replaceFolderWithFinalItem();
}
- protected View getViewForInfo(ShortcutInfo item) {
- for (int j = 0; j < mContent.getCountY(); j++) {
- for (int i = 0; i < mContent.getCountX(); i++) {
- View v = mContent.getChildAt(i, j);
- if (v.getTag() == item) {
- return v;
- }
+ @Override
+ public void onRemoveAll(ArrayList<ShortcutInfo> items) {
+ removeViewsForItems(items);
+ if (mInfo.contents.isEmpty()) {
+ mLauncher.closeFolder(this);
+ }
+ replaceFolderWithFinalItem();
+ }
+
+ /**
+ * Remove all the supplied item views from this folder.
+ * @param items info of views to remove, or null if all views should be removed.
+ */
+ protected void removeViewsForItems(ArrayList<ShortcutInfo> items) {
+ if (items == null) {
+ mContent.removeAllViews();
+ } else {
+ for (ShortcutInfo item : items) {
+ mContent.removeView(getViewForInfo(item));
}
}
- return null;
+ }
+
+ /**
+ * Update the view tied to this shortcut.
+ * @param info updated info to be applied to view.
+ */
+ public void updateViewForInfo(final ShortcutInfo info) {
+ View v = getViewForInfo(info);
+ if (v != null & v instanceof BubbleTextView) {
+ ((BubbleTextView) v).applyFromShortcutInfo(info, mIconCache, false);
+
+ mItemsInvalidated = true;
+ }
+ }
+
+ public View getViewForInfo(ShortcutInfo item) {
+ return mContent.getChildAt(item.cellX, item.cellY);
}
public void onItemsChanged() {
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index c7e0abf..a166b18 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -30,7 +30,6 @@ import android.graphics.drawable.Drawable;
import android.os.Looper;
import android.os.Parcelable;
import android.util.AttributeSet;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -698,7 +697,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
super.dispatchDraw(canvas);
if (mFolder == null) return;
- if (mFolder.getItemCount() == 0 && !mAnimating) return;
+ if (mFolder.getItemCount() == 0 && !mAnimating && !mInfo.isRemote()) return;
ArrayList<View> items = mFolder.getItemsInReadingOrder();
Drawable d;
@@ -707,13 +706,13 @@ public class FolderIcon extends FrameLayout implements FolderListener {
// Update our drawing parameters if necessary
if (mAnimating) {
computePreviewDrawingParams(mAnimParams.drawable);
- } else {
+ } else if (!items.isEmpty()) {
v = (TextView) items.get(0);
d = getTopDrawable(v);
- computePreviewDrawingParams(d);
+ if (d != null) computePreviewDrawingParams(d);
}
- int nItemsInPreview = Math.min(items.size(), NUM_ITEMS_IN_PREVIEW);
+ int ntemsInPreview = Math.min(items.size(), NUM_ITEMS_IN_PREVIEW);
// Hidden folder - don't display Preview
View folderLock = findViewById(R.id.folder_lock_image);
@@ -734,15 +733,20 @@ public class FolderIcon extends FrameLayout implements FolderListener {
if (!mAnimating) {
for (int i = 0; i < NUM_ITEMS_IN_PREVIEW; i++) {
d = null;
- if (i < items.size()) {
+ if (mInfo.isRemote()) {
+ d = mLauncher.getRemoteFolderManager().getFolderIconDrawable(items, i);
+ } else if (i < items.size()) {
v = (TextView) items.get(i);
if (!mHiddenItems.contains(v.getTag())) {
d = getTopDrawable(v);
- mParams = computePreviewItemDrawingParams(i, mParams);
- mParams.drawable = d;
}
}
+ if (d != null) {
+ mParams = computePreviewItemDrawingParams(i, mParams);
+ mParams.drawable = d;
+ }
+
ImageView appIcon = null;
switch(i) {
case 0:
@@ -847,6 +851,12 @@ public class FolderIcon extends FrameLayout implements FolderListener {
requestLayout();
}
+ @Override
+ public void onRemoveAll(ArrayList<ShortcutInfo> items) {
+ invalidate();
+ requestLayout();
+ }
+
public void onTitleChanged(CharSequence title) {
mFolderName.setText(title.toString());
setContentDescription(String.format(getContext().getString(R.string.folder_name_format),
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java
index 2050864..bed1a5d 100644
--- a/src/com/android/launcher3/FolderInfo.java
+++ b/src/com/android/launcher3/FolderInfo.java
@@ -88,6 +88,19 @@ public class FolderInfo extends ItemInfo {
}
/**
+ * Remove all supplied shortcuts. Does not change the DB unless
+ * LauncherModel.deleteFolderContentsFromDatabase(Context, FolderInfo) is called first.
+ * @param items the shortcuts to remove.
+ */
+ public void removeAll(ArrayList<ShortcutInfo> items) {
+ contents.removeAll(items);
+ for (int i = 0; i < listeners.size(); i++) {
+ listeners.get(i).onRemoveAll(items);
+ }
+ itemsChanged();
+ }
+
+ /**
* @return true if this info represents a remote folder, false otherwise
*/
public boolean isRemote() {
@@ -144,11 +157,12 @@ public class FolderInfo extends ItemInfo {
}
interface FolderListener {
- public void onAdd(ShortcutInfo item);
- public void onRemove(ShortcutInfo item);
- public void onRemoveAll();
- public void onTitleChanged(CharSequence title);
- public void onItemsChanged();
+ void onAdd(ShortcutInfo item);
+ void onRemove(ShortcutInfo item);
+ void onRemoveAll();
+ void onRemoveAll(ArrayList<ShortcutInfo> items);
+ void onTitleChanged(CharSequence title);
+ void onItemsChanged();
}
@Override
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index 91af587..5c1bc0d 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -20,6 +20,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.util.Log;
import com.android.launcher3.compat.UserHandleCompat;
@@ -125,6 +126,12 @@ public class ItemInfo {
UserHandleCompat user;
+ /**
+ * A custom drawable to use for the icon. Not persisted to the database because
+ * it is not guaranteed to be a bitmap (could be a vector).
+ */
+ Drawable customDrawable;
+
ItemInfo() {
user = UserHandleCompat.myUserHandle();
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7fc3730..6618c75 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -5290,6 +5290,7 @@ public class Launcher extends Activity
} else {
if (mAppDrawerAdapter != null) {
mAppDrawerAdapter.setApps(apps);
+ mRemoteFolderManager.onSetApps();
}
if (mAppsCustomizeContent != null) {
mAppsCustomizeContent.setApps(apps);
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 0a76284..288030d 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -59,9 +59,6 @@ public class ShortcutInfo extends ItemInfo {
*/
public static final int FLAG_RESTORE_STARTED = 8;
- /** Indicates that this shortcut is part of the remote folder **/
- public static final int FLAG_REMOTE = 16;
-
/**
* The intent used to start the application.
*/
@@ -88,7 +85,7 @@ public class ShortcutInfo extends ItemInfo {
/**
* The application icon.
*/
- private Bitmap mIcon;
+ Bitmap mIcon;
/**
* Indicates that the icon is disabled due to safe mode restrictions.