summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod
diff options
context:
space:
mode:
authorDanesh Mondegarian <daneshm90@gmail.com>2013-08-16 00:57:59 -0700
committerDanesh Mondegarian <daneshm90@gmail.com>2013-08-16 00:57:59 -0700
commitf46a7fc9ed2df560489e2173e655aa50ec83bd40 (patch)
tree51db7c39776f70973251be809f57a7e599430911 /src/com/cyanogenmod
parent9d9cfd033670b1d484160e8855027e002c5f3b6b (diff)
downloadandroid_packages_apps_Trebuchet-f46a7fc9ed2df560489e2173e655aa50ec83bd40.tar.gz
android_packages_apps_Trebuchet-f46a7fc9ed2df560489e2173e655aa50ec83bd40.tar.bz2
android_packages_apps_Trebuchet-f46a7fc9ed2df560489e2173e655aa50ec83bd40.zip
Trebuchet : Empty view for live folders
Live folders are dynamically populated, hence allow the state of having no items present in its folder. This commit adds a view to show when that happens, rather than the current situation which looks broken. Change-Id: I5777e208e5f0d5a3e42c1d65afdc2121d45d983a
Diffstat (limited to 'src/com/cyanogenmod')
-rw-r--r--src/com/cyanogenmod/trebuchet/Folder.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Folder.java b/src/com/cyanogenmod/trebuchet/Folder.java
index d55338b4d..1ce8ba2d3 100644
--- a/src/com/cyanogenmod/trebuchet/Folder.java
+++ b/src/com/cyanogenmod/trebuchet/Folder.java
@@ -93,7 +93,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private int[] mEmptyCell = new int[2];
private Alarm mReorderAlarm = new Alarm();
private Alarm mOnExitAlarm = new Alarm();
- private int mFolderNameHeight;
+ private int mFolderNameHeight, mFolderNameWidth;
private Rect mTempRect = new Rect();
private boolean mDragInProgress = false;
private boolean mDeleteFolderOnDropCompleted = false;
@@ -112,6 +112,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private boolean mDestroyed;
+ // Empty folder filler
+ private TextView mEmptyTitle;
+ private int mEmptyTitleWidth, mEmptyTitleHeight;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -172,6 +176,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
int measureSpec = MeasureSpec.UNSPECIFIED;
mFolderName.measure(measureSpec, measureSpec);
mFolderNameHeight = mFolderName.getMeasuredHeight();
+ mFolderNameWidth = mFolderName.getMeasuredWidth();
// We disable action mode for now since it messes up the view on phones
mFolderName.setCustomSelectionActionModeCallback(mActionModeCallback);
@@ -180,6 +185,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mFolderName.setInputType(mFolderName.getInputType() |
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
+ mEmptyTitle = (TextView) findViewById(R.id.empty_content);
+ mEmptyTitle.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
+ mEmptyTitleWidth = mEmptyTitle.getMeasuredWidth();
+ mEmptyTitleHeight = mEmptyTitle.getMeasuredHeight();
+
if (PreferencesProvider.Interface.Homescreen.getHideIconLabels()){
mFolderName.setVisibility(View.GONE);
mFolderNameHeight = getPaddingBottom();
@@ -837,6 +847,15 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
int height = getPaddingTop() + getPaddingBottom() + mContent.getDesiredHeight()
+ mFolderNameHeight;
+
+ if (mContent.getDesiredWidth() == 0) {
+ width += Math.min(mEmptyTitleWidth, mFolderNameWidth);
+ height += mEmptyTitle.getMeasuredHeight();
+ mEmptyTitle.setVisibility(View.VISIBLE);
+ } else {
+ mEmptyTitle.setVisibility(View.GONE);
+ }
+
DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
float scale = parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect);
@@ -916,8 +935,18 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
MeasureSpec.EXACTLY);
mContent.measure(contentWidthSpec, contentHeightSpec);
+ if (mContent.getDesiredWidth() == 0) {
+ width += Math.min(mEmptyTitleWidth, mFolderNameWidth);
+ contentWidthSpec = MeasureSpec.makeMeasureSpec(
+ Math.min(mEmptyTitleWidth, mFolderNameWidth), MeasureSpec.EXACTLY);
+ }
+
mFolderName.measure(contentWidthSpec,
MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY));
+
+ mEmptyTitle.measure(contentWidthSpec,
+ MeasureSpec.makeMeasureSpec(mEmptyTitleHeight, MeasureSpec.EXACTLY));
+
setMeasuredDimension(width, height);
}