diff options
Diffstat (limited to 'src/com/android/launcher3/Folder.java')
-rw-r--r-- | src/com/android/launcher3/Folder.java | 112 |
1 files changed, 106 insertions, 6 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 1890af47d..fa34e6327 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -21,10 +21,13 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; +import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; +import android.os.Bundle; import android.os.SystemClock; import android.support.v4.widget.AutoScrollHelper; import android.text.InputType; @@ -44,7 +47,9 @@ import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.TextView; @@ -62,6 +67,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList View.OnFocusChangeListener { private static final String TAG = "Launcher.Folder"; + private static final String PROTECTED_ACTION = "cyanogenmod.intent.action.PACKAGE_PROTECTED"; + private static final String PROTECTED_STATE = + "cyanogenmod.intent.action.PACKAGE_PROTECTED_STATE"; + private static final String PROTECTED_COMPONENT = + "cyanogenmod.intent.action.PACKAGE_PROTECTED_COMPONENT"; + protected DragController mDragController; protected Launcher mLauncher; protected FolderInfo mInfo; @@ -107,6 +118,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private boolean mSuppressFolderDeletion = false; private boolean mItemAddedBackToSelfViaIcon = false; FolderEditText mFolderName; + ImageView mFolderLock; + RelativeLayout mFolderTitleSection; private float mFolderIconPivotX; private float mFolderIconPivotY; @@ -131,6 +144,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private boolean mDeferDropAfterUninstall; private boolean mUninstallSuccessful; + private boolean mHiddenFolder = false; + /** * Used to inflate the Workspace from XML. * @@ -181,6 +196,7 @@ 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); @@ -200,7 +216,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList // 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. - int measureSpec = MeasureSpec.UNSPECIFIED; mFolderName.measure(measureSpec, measureSpec); mFolderNameHeight = mFolderName.getMeasuredHeight(); @@ -211,6 +226,19 @@ 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); mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView); + + if (SettingsProvider.getBoolean(mLauncher, + SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, + R.bool.preferences_interface_homescreen_hide_icon_labels_default)) { + mFolderName.setVisibility(View.GONE); + mFolderNameHeight = getPaddingBottom(); + } + + mFolderLock = (ImageView) findViewById(R.id.folder_lock); + mFolderTitleSection = (RelativeLayout) findViewById(R.id.folder_title_section); + mFolderLock.measure(measureSpec, measureSpec); + mFolderLock.setOnClickListener(this); + mFolderTitleSection.measure(measureSpec, measureSpec); } private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() { @@ -235,6 +263,60 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList if (tag instanceof ShortcutInfo) { mLauncher.onClick(v); } + + if (v.getId() == R.id.folder_lock) { + startHiddenFolderManager(); + } + } + + public void startHiddenFolderManager() { + Bundle bundle = new Bundle(); + bundle.putBoolean(HiddenFolderFragment.HIDDEN_FOLDER_STATUS, mInfo.hidden); + mLauncher.validateLockForHiddenFolders(bundle, mFolderIcon); + } + + public String[] getComponentTitles() { + int size = mItemsInReadingOrder.size(); + String[] componentsTitles = new String[size]; + for (int i = 0; i < size; i++) { + View v = mItemsInReadingOrder.get(i); + Object tag = v.getTag(); + if (tag instanceof ShortcutInfo) { + componentsTitles[i] = ((ShortcutInfo) tag).title.toString(); + } + } + return componentsTitles; + } + + public String[] getComponents() { + String components = getComponentString(); + return components.split("\\|"); + } + + public void modifyProtectedApps(boolean protect) { + String components = getComponentString(); + + Intent intent = new Intent(); + intent.setAction(PROTECTED_ACTION); + intent.putExtra(PROTECTED_STATE, protect); + intent.putExtra(PROTECTED_COMPONENT, components); + + mLauncher.sendBroadcast(intent); + } + + private String getComponentString() { + int size = mItemsInReadingOrder.size(); + String components = ""; + for (int i = 0; i < size; i++) { + View v = mItemsInReadingOrder.get(i); + Object tag = v.getTag(); + if (tag instanceof ShortcutInfo) { + ComponentName componentName = ((ShortcutInfo) tag).getIntent().getComponent(); + components += componentName.flattenToString() + "|"; + } + } + + return components; } public boolean onLongClick(View v) { @@ -270,6 +352,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void startEditingFolderName() { mFolderName.setHint(""); mIsEditingName = true; + + mInputMethodManager.showSoftInput(mFolderName, 0); } public void dismissEditingName() { @@ -409,6 +493,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList updateTextViewFocus(); mInfo.addListener(this); + setFolderName(); + updateItemLocationsInDatabase(); + } + + public void setFolderName() { if (!sDefaultFolderName.contentEquals(mInfo.title)) { mFolderName.setText(mInfo.title); } else { @@ -1085,13 +1174,16 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } private int getFolderHeight() { - int height = getPaddingTop() + getPaddingBottom() - + getContentAreaHeight() + mFolderNameHeight; + int height = getPaddingTop() + getPaddingBottom() + mFolderNameHeight + + getContentAreaHeight(); return height; } protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); + int width = getPaddingLeft() + + getPaddingRight() + + Math.max(mContent.getDesiredWidth(), + mFolderTitleSection.getMeasuredWidth()); int height = getFolderHeight(); int contentAreaWidthSpec = MeasureSpec.makeMeasureSpec(getContentAreaWidth(), MeasureSpec.EXACTLY); @@ -1106,8 +1198,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } mScrollView.measure(contentAreaWidthSpec, contentAreaHeightSpec); - mFolderName.measure(contentAreaWidthSpec, - MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY)); + mFolderName.measure(contentAreaWidthSpec, MeasureSpec.makeMeasureSpec( + mFolderNameHeight, MeasureSpec.EXACTLY)); + mFolderLock.measure(contentAreaWidthSpec, MeasureSpec.makeMeasureSpec( + mFolderNameHeight, MeasureSpec.EXACTLY)); + mFolderTitleSection.measure(contentAreaWidthSpec, MeasureSpec + .makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY)); setMeasuredDimension(width, height); } @@ -1392,4 +1488,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList public void getHitRectRelativeToDragLayer(Rect outRect) { getHitRect(outRect); } + + public View getViewFromPosition(int position) { + return mItemsInReadingOrder.get(position); + } } |