diff options
author | Danesh Mondegarian <daneshm90@gmail.com> | 2013-08-16 00:57:59 -0700 |
---|---|---|
committer | Danesh Mondegarian <daneshm90@gmail.com> | 2013-08-16 00:57:59 -0700 |
commit | f46a7fc9ed2df560489e2173e655aa50ec83bd40 (patch) | |
tree | 51db7c39776f70973251be809f57a7e599430911 | |
parent | 9d9cfd033670b1d484160e8855027e002c5f3b6b (diff) | |
download | android_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
-rw-r--r-- | res/layout/user_folder.xml | 15 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 1 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Folder.java | 31 |
3 files changed, 46 insertions, 1 deletions
diff --git a/res/layout/user_folder.xml b/res/layout/user_folder.xml index 9aae1acc1..40c8fd827 100644 --- a/res/layout/user_folder.xml +++ b/res/layout/user_folder.xml @@ -37,6 +37,21 @@ launcher:cellWidth="@dimen/folder_cell_width" launcher:cellHeight="@dimen/folder_cell_height" /> + <TextView + android:id="@+id/empty_content" + android:text="@string/folder_empty_contents_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:paddingTop="@dimen/folder_name_padding" + android:paddingBottom="@dimen/folder_name_padding" + android:background="#00000000" + android:textSize="14sp" + android:textColor="#ff33b5e5" + android:textColorHighlight="#ff333333" + android:gravity="center_horizontal" + android:singleLine="true" /> + <com.cyanogenmod.trebuchet.FolderEditText android:id="@+id/folder_name" android:layout_width="match_parent" diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 774ba61c2..9f61fdf4d 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -161,6 +161,7 @@ <string name="preferences_interface_general_lock_workspace_summary">Lock shortcuts and folders positions in the homescreen, dock and apps and widgets drawer</string> <string name="preferences_interface_general_fullscreen_title">Fullscreen mode</string> <string name="preferences_interface_general_fullscreen_summary">Hide the status bar to extend the homescreen</string> + <string name="folder_empty_contents_title">No items found</string> <!-- Effects --> <string name="effects_standard">Standard</string> 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); } |