diff options
author | Tyson Miller <tmiller@cyngn.com> | 2016-01-06 16:00:48 -0800 |
---|---|---|
committer | Tyson Miller <tmiller@cyngn.com> | 2016-01-08 15:50:39 -0800 |
commit | 80d4ff8dcbb28f3880c312568945b55294f25a4b (patch) | |
tree | 150ade3236916696a48b43cd94a0041c2bd6f2e3 /src | |
parent | 1a75f660937c99d39110c3f1335ae3bea1a85914 (diff) | |
download | android_packages_apps_Trebuchet-80d4ff8dcbb28f3880c312568945b55294f25a4b.tar.gz android_packages_apps_Trebuchet-80d4ff8dcbb28f3880c312568945b55294f25a4b.tar.bz2 android_packages_apps_Trebuchet-80d4ff8dcbb28f3880c312568945b55294f25a4b.zip |
Trebuchet: Remote Folder UX & early badge code
Patch 8: Fixed manifest & makefile config
9: Updated caching for RemoteFolder info
12: FolderIcon updates for RemoteFolder
13: RemoteFolder UX and minor code fixes
15: UX and rebase on metrics code
19: Fix content clicks and clean up
20: Wi-Fi check added
Issue-Id: :CYNGNOS-1332
Change-Id: I3b86ed71b95da69488a4eee6c7c4b5fae4411388
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/Folder.java | 87 | ||||
-rw-r--r-- | src/com/android/launcher3/FolderIcon.java | 18 | ||||
-rw-r--r-- | src/com/android/launcher3/FolderInfo.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 15 |
4 files changed, 70 insertions, 63 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index b3b690042..dfd4fd35a 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -37,7 +37,6 @@ import android.support.v4.widget.AutoScrollHelper; import android.text.InputType; import android.text.Selection; import android.text.Spannable; -import android.text.TextUtils; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; @@ -49,6 +48,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateInterpolator; @@ -102,7 +102,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private int mMaterialExpandDuration; private int mMaterialExpandStagger; protected CellLayout mContent; - private ScrollView mScrollView; + protected ScrollView mScrollView; private final LayoutInflater mInflater; private final IconCache mIconCache; private int mState = STATE_NONE; @@ -132,7 +132,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private boolean mDeleteFolderOnDropCompleted = false; private boolean mSuppressFolderDeletion = false; private boolean mItemAddedBackToSelfViaIcon = false; - View mFolderNameLockContainer; + protected View mFolderNameLockContainer; FolderEditText mFolderName; ImageView mFolderLock; private int mScreenWidth; @@ -218,7 +218,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList super.onFinishInflate(); mScrollView = (ScrollView) findViewById(R.id.scroll_view); mContent = (CellLayout) findViewById(R.id.folder_content); - int measureSpec = MeasureSpec.UNSPECIFIED; mFocusIndicatorHandler = new FocusIndicatorView(getContext()); mContent.addView(mFocusIndicatorHandler, 0); @@ -237,11 +236,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderName.setFolder(this); mFolderName.setOnFocusChangeListener(this); - // We find out how tall the text view wants to be (it is set to wrap_content), so that - // we can allocate the appropriate amount of space for it. - mFolderName.measure(measureSpec, measureSpec); - mFolderNameHeight = mFolderName.getMeasuredHeight(); - // We disable action mode for now since it messes up the view on phones mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback); mFolderName.setOnEditorActionListener(this); @@ -262,9 +256,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList // Could be null if this Folder an instance of the RemoteFolder subclass if (mFolderLock != null) { - mFolderLock.measure(measureSpec, measureSpec); mFolderLock.setOnClickListener(this); - mFolderLockHeight = mFolderLock.getMeasuredHeight(); } DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics(); mScreenWidth = displayMetrics.widthPixels; @@ -482,8 +474,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList void bind(final FolderInfo info) { mInfo = info; - final ArrayList<ShortcutInfo> children = info.contents; - + ArrayList<ShortcutInfo> children = info.contents; ArrayList<ShortcutInfo> overflow = new ArrayList<ShortcutInfo>(); setupContentForNumItems(children.size()); placeInReadingOrder(children); @@ -538,11 +529,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList * Creates a new UserFolder, inflated from R.layout.user_folder. * * @param context The application's context. + * @param root The {@link View} parent of this folder. * * @return A new UserFolder. */ - static Folder fromXml(Context context) { - return (Folder) LayoutInflater.from(context).inflate(R.layout.user_folder, null); + static Folder fromXml(Context context, ViewGroup root) { + return (Folder) LayoutInflater.from(context).inflate(R.layout.user_folder, root, false); } /** @@ -663,19 +655,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList Animator circReveal = LauncherAnimUtils.createCircularReveal(this, circX, circY, 0, mScreenWidth); - final View[] alphaViewSet; - if (mInfo.isRemote()) { - alphaViewSet = new View[] { mContent, mFolderName }; - } else { - alphaViewSet = new View[] { mFolderNameLockContainer, + final View[] alphaViewSet = new View[] { mFolderNameLockContainer, mContent, mFolderName, mFolderLock }; - } for (View view : alphaViewSet) { view.setAlpha(0f); } - circReveal.setDuration(150); circReveal.addListener(new AnimatorListenerAdapter() { @Override @@ -1285,7 +1271,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList return true; } - private void setupContentDimensions(int count) { + protected void setupContentDimensions(int count) { ArrayList<View> list = getItemsInReadingOrder(); int countX = mContent.getCountX(); @@ -1322,12 +1308,19 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList return mMaxNumItems; } - private void centerAboutIcon() { + protected void centerAboutIcon() { + requestLayout(); + int width = getMeasuredWidth(); + int height = getMeasuredHeight(); + if (width > 0 && height > 0) { + centerAboutIcon(width, height); + } + } + + private void centerAboutIcon(int width, int height) { DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer); - int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); - int height = getFolderHeight(); float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect); @@ -1386,14 +1379,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private void setupContentForNumItems(int count) { setupContentDimensions(count); - - DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams(); - if (lp == null) { - lp = new DragLayer.LayoutParams(0, 0); - lp.customPosition = true; - setLayoutParams(lp); - } - centerAboutIcon(); } protected int getContentAreaHeight() { @@ -1404,20 +1389,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList return Math.max(mContent.getDesiredWidth(), MIN_CONTENT_DIMEN); } - protected int getFolderHeight() { - int height = getPaddingTop() + getPaddingBottom() + mFolderNameHeight - + getContentAreaHeight(); - return height; - } - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); - int height = getFolderHeight(); - int contentAreaWidthSpec = MeasureSpec.makeMeasureSpec(getContentAreaWidth(), - MeasureSpec.EXACTLY); - int contentAreaHeightSpec = MeasureSpec.makeMeasureSpec(getContentAreaHeight(), - MeasureSpec.EXACTLY); - if (LauncherAppState.isDisableAllApps()) { // Don't cap the height of the content to allow scrolling. mContent.setFixedSize(getContentAreaWidth(), mContent.getDesiredHeight()); @@ -1425,16 +1397,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mContent.setFixedSize(getContentAreaWidth(), getContentAreaHeight()); } - mScrollView.measure(contentAreaWidthSpec, contentAreaHeightSpec); - if (TextUtils.isEmpty(mInfo.title)) { - mFolderName.measure(contentAreaWidthSpec, MeasureSpec.makeMeasureSpec( - mFolderNameHeight, MeasureSpec.EXACTLY)); - } - - mFolderNameLockContainer.measure(contentAreaWidthSpec, - MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY)); - - setMeasuredDimension(width, height); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); } private void arrangeChildren(ArrayList<View> list) { @@ -1680,7 +1643,15 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } } - private View getViewForInfo(ShortcutInfo item) { + @Override + public void onRemoveAll() { + // Clear the UX after folder contents are removed from the DB + mContent.removeAllViews(); + 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); diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java index 17ea4899d..c7e0abfb6 100644 --- a/src/com/android/launcher3/FolderIcon.java +++ b/src/com/android/launcher3/FolderIcon.java @@ -30,6 +30,7 @@ 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; @@ -172,9 +173,9 @@ public class FolderIcon extends FrameLayout implements FolderListener { folderInfo.title)); Folder folder; if (folderInfo.isRemote()) { - folder = launcher.getRemoteFolderManager().createRemoteFolder(icon); + folder = launcher.getRemoteFolderManager().createRemoteFolder(icon, launcher.getDragLayer()); } else { - folder = Folder.fromXml(launcher); + folder = Folder.fromXml(launcher, launcher.getDragLayer()); } folder.setDragController(launcher.getDragController()); folder.setFolderIcon(icon); @@ -237,6 +238,11 @@ public class FolderIcon extends FrameLayout implements FolderListener { } } + // Create an overlay badge if this FolderIcon is for a RemoteFolder + if (folderInfo.isRemote()) { + icon = RemoteFolderManager.addBadgeToFolderIcon(icon); + } + return icon; } @@ -726,7 +732,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { } if (!mAnimating) { - for (int i = NUM_ITEMS_IN_PREVIEW; i >= 0; i--) { + for (int i = 0; i < NUM_ITEMS_IN_PREVIEW; i++) { d = null; if (i < items.size()) { v = (TextView) items.get(i); @@ -835,6 +841,12 @@ public class FolderIcon extends FrameLayout implements FolderListener { requestLayout(); } + @Override + public void onRemoveAll() { + 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 abc6c2736..2050864da 100644 --- a/src/com/android/launcher3/FolderInfo.java +++ b/src/com/android/launcher3/FolderInfo.java @@ -76,6 +76,18 @@ public class FolderInfo extends ItemInfo { } /** + * Remove all apps and shortcuts. Does not change the DB unless + * LauncherModel.deleteFolderContentsFromDatabase(Context, FolderInfo) is called first. + */ + public void removeAll() { + contents.clear(); + for (int i = 0; i < listeners.size(); i++) { + listeners.get(i).onRemoveAll(); + } + itemsChanged(); + } + + /** * @return true if this info represents a remote folder, false otherwise */ public boolean isRemote() { @@ -134,6 +146,7 @@ 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(); } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 8fe2e841b..5eecf1b19 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -36,14 +36,14 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; -import android.graphics.Paint.Style; import android.graphics.PaintFlagsDrawFilter; import android.graphics.Rect; import android.graphics.RectF; -import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.os.Build; import android.util.DisplayMetrics; import android.util.Log; @@ -627,4 +627,15 @@ public final class Utilities { return false; } } + + public static boolean isNetworkConnected(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); + return activeNetwork != null && activeNetwork.isConnected(); + } + + public static boolean isConnectedToWiFi(Context context) { + ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); + return connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); + } } |