summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-02-08 16:11:19 -0800
committercretin45 <cretin45@gmail.com>2016-02-10 14:15:24 -0800
commit51c8571933879a98be336d7a32b9f06a184d30de (patch)
treeb94e54993cd61c9caf59c9f47603b1bd3b86c9de /src
parent3bf013a1eb2764fb3c12dc55739cf3c78fd3c20c (diff)
downloadandroid_packages_apps_Trebuchet-51c8571933879a98be336d7a32b9f06a184d30de.zip
android_packages_apps_Trebuchet-51c8571933879a98be336d7a32b9f06a184d30de.tar.gz
android_packages_apps_Trebuchet-51c8571933879a98be336d7a32b9f06a184d30de.tar.bz2
Trebuchet: Revise protected app folders UI
Issue-id: CYNGNOS-1881 Change-Id: I5cbc5d9fe9358fdf2708376bfe5d7bf2108a0897
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Folder.java91
-rw-r--r--src/com/android/launcher3/HiddenFolderFragment.java376
-rw-r--r--src/com/android/launcher3/Launcher.java90
3 files changed, 96 insertions, 461 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 8248816..1ac5cf8 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -73,7 +73,6 @@ import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.UiThreadCircularReveal;
import static cyanogenmod.content.Intent.ACTION_PROTECTED;
-import static cyanogenmod.content.Intent.ACTION_PROTECTED_CHANGED;
import static cyanogenmod.content.Intent.EXTRA_PROTECTED_COMPONENTS;
import static cyanogenmod.content.Intent.EXTRA_PROTECTED_STATE;
@@ -152,7 +151,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
ExtendedEditText mFolderName;
private View mFooter;
- private int mFooterHeight;
// Cell ranks used for drag and drop
@Thunk int mTargetRank, mPrevTargetRank, mEmptyCellRank;
@@ -173,7 +171,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
private boolean mIsEditingName = false;
ImageView mFolderLock;
- private int mFolderLockHeight;
private boolean mDestroyed;
@@ -184,8 +181,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
// Folder scrolling
private int mScrollAreaOffset;
- private boolean mHiddenFolder = false;
-
private Handler mHandler;
@Thunk int mScrollHintDir = DragController.SCROLL_NONE;
@@ -285,14 +280,14 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
if (v.getId() == R.id.folder_lock) {
- startHiddenFolderManager();
+ startHiddenFolderManager(mInfo.hidden ?
+ Launcher.REQUEST_UNPROTECT_FOLDER :
+ Launcher.REQUEST_PROTECT_FOLDER);
}
}
- public void startHiddenFolderManager() {
- Bundle bundle = new Bundle();
- bundle.putBoolean(HiddenFolderFragment.HIDDEN_FOLDER_STATUS, mInfo.hidden);
- mLauncher.validateLockForHiddenFolders(bundle, mFolderIcon);
+ public void startHiddenFolderManager(int action) {
+ mLauncher.validateLockForHiddenFolders(mFolderIcon, action);
}
public List<Pair<ComponentName, CharSequence>> getComponents() {
@@ -313,7 +308,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
public void modifyProtectedApps(boolean protect) {
- ArrayList<ComponentName> components = new ArrayList<ComponentName>();
+ ArrayList<ComponentName> components = new ArrayList<>();
for (Pair<ComponentName, CharSequence> item : getComponents()) {
if (item.first != null) {
components.add(item.first);
@@ -322,12 +317,35 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
Intent intent = new Intent();
intent.setAction(ACTION_PROTECTED);
- intent.putExtra(EXTRA_PROTECTED_STATE, protect);
+ // flip the boolean value to accomodate framework
+ // in framework "false" is "protected" and "true" is "visible"
+ intent.putExtra(EXTRA_PROTECTED_STATE, !protect);
intent.putExtra(EXTRA_PROTECTED_COMPONENTS, components);
mLauncher.sendBroadcast(intent);
}
+ private void removeProtectedApp(ComponentName componentName) {
+ ArrayList<ComponentName> components = new ArrayList<>();
+ components.add(componentName);
+ Intent intent = new Intent();
+ intent.setAction(ACTION_PROTECTED);
+ // flip the boolean value to accomodate framework
+ // in framework "false" is "protected" and "true" is "visible"
+ intent.putExtra(EXTRA_PROTECTED_STATE, true);
+ intent.putExtra(EXTRA_PROTECTED_COMPONENTS, components);
+
+ mLauncher.sendBroadcast(intent);
+ }
+
+ public void saveHiddenFolderState(boolean protect) {
+ mInfo.hidden = protect;
+ modifyProtectedApps(protect);
+ LauncherModel.updateItemInDatabase(mLauncher, mInfo);
+ mLauncher.mModel.flushWorkerThread();
+ rebind(mInfo);
+ }
+
public boolean onLongClick(View v) {
// Return if global dragging is not enabled
if (!mLauncher.isDraggingEnabled()) return true;
@@ -409,6 +427,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
Selection.setSelection((Spannable) mFolderName.getText(), 0, 0);
mIsEditingName = false;
+ mLauncher.notifyFolderNameChanged();
}
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
@@ -473,6 +492,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mInfo.addListener(this);
setFolderName();
+ updateLock();
+ }
+
+ public void rebind(final FolderInfo info) {
+ bind(info);
}
public void setFolderName() {
@@ -492,6 +516,14 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
});
}
+ private void updateLock() {
+ if (mInfo != null) {
+ mFolderLock.setImageResource(mInfo.hidden ?
+ R.drawable.folder_locked :
+ R.drawable.folder_unlocked);
+ }
+ }
+
/**
* Creates a new UserFolder, inflated from R.layout.user_folder.
*
@@ -1086,6 +1118,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
mScrollPauseAlarm.cancelAlarm();
completeDragExit();
+ if (successfulDrop) {
+ ShortcutInfo info = (ShortcutInfo) d.dragInfo;
+ Intent intent = info.getIntent();
+ if (intent != null && mInfo.hidden) {
+ removeProtectedApp(intent.getComponent());
+ }
+ }
}
}
@@ -1335,7 +1374,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
View child = null;
// Move the item from the folder to the workspace, in the position of the folder
- if (getItemCount() == 1) {
+ if (!mInfo.hidden && getItemCount() == 1) {
ShortcutInfo finalItem = mInfo.contents.get(0);
child = mLauncher.createShortcut(cellLayout, finalItem);
LauncherModel.addOrMoveItemInDatabase(mLauncher, finalItem, mInfo.container,
@@ -1609,32 +1648,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
return mItemsInReadingOrder;
}
- public ShortcutInfo getShortcutForComponent(ComponentName componentName) {
- for (View v : mItemsInReadingOrder) {
- Object tag = v.getTag();
- if (tag instanceof ShortcutInfo) {
- ComponentName cName = ((ShortcutInfo) tag).getIntent().getComponent();
- if (cName.equals(componentName)) {
- return (ShortcutInfo) tag;
- }
- }
- }
-
- return null;
- }
-
- public ShortcutInfo getShortcutForPosition(int position) {
- if (position < 0 || position >= mItemsInReadingOrder.size()) {
- return null;
- }
- View v = mItemsInReadingOrder.get(position);
- Object tag = v.getTag();
- if (tag instanceof ShortcutInfo) {
- return (ShortcutInfo) tag;
- }
- return null;
- }
-
public void getLocationInDragLayer(int[] loc) {
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
diff --git a/src/com/android/launcher3/HiddenFolderFragment.java b/src/com/android/launcher3/HiddenFolderFragment.java
deleted file mode 100644
index 97c4dfd..0000000
--- a/src/com/android/launcher3/HiddenFolderFragment.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3;
-
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.media.Image;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.text.InputType;
-import android.util.Pair;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class HiddenFolderFragment extends Fragment {
- public static final String HIDDEN_FOLDER_FRAGMENT = "hiddenFolderFragment";
- public static final String HIDDEN_FOLDER_NAME = "hiddenFolderName";
- public static final String HIDDEN_FOLDER_STATUS = "hiddenFolderStatus";
- public static final String HIDDEN_FOLDER_INFO = "hiddenFolderInfo";
- public static final String HIDDEN_FOLDER_INFO_TITLES = "hiddenFolderInfoTitles";
- public static final String HIDDEN_FOLDER_LAUNCH = "hiddenFolderLaunchPosition";
-
- private static final int REQ_LOCK_PATTERN = 1;
-
- private boolean mHidden;
- private PackageManager mPackageManager;
- private AppsAdapter mAppsAdapter;
- private ArrayList<AppEntry> mAppEntries;
-
- private EditText mFolderName;
- private ListView mListView;
-
- private Launcher mLauncher;
-
- private boolean mAuth = false;
- private boolean mSent = false;
-
- private OnClickListener mClicklistener = new OnClickListener() {
- @Override
- public void onClick(View v) {
- mHidden = !mHidden;
-
- ImageView mLock = (ImageView) v;
- Drawable mLockIcon = mHidden ? getResources().getDrawable(R.drawable.folder_locked)
- : getResources().getDrawable(R.drawable.folder_unlocked);
- mLock.setImageDrawable(mLockIcon);
- }
- };
-
- @Override
- public View onCreateView (LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.hidden_folder, container, false);
-
- mLauncher = (Launcher) getActivity();
- mPackageManager = mLauncher.getPackageManager();
-
- mHidden = getArguments().getBoolean(HIDDEN_FOLDER_STATUS);
- Folder folder = mLauncher.mHiddenFolderIcon.getFolder();
- String title = mLauncher.mHiddenFolderIcon.getFolderInfo().title.toString();
-
- mFolderName = (EditText) v.findViewById(R.id.folder_name);
- mFolderName.setText(title);
- mFolderName.setSelectAllOnFocus(true);
- mFolderName.setInputType(mFolderName.getInputType() |
- InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
- mFolderName.setImeOptions(EditorInfo.IME_ACTION_DONE);
- mFolderName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- doneEditingText(v);
- return true;
- }
- return false;
- }
- });
- mFolderName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (!hasFocus) {
- doneEditingText(v);
- }
- }
- });
-
- ImageView mLock = (ImageView) v.findViewById(R.id.folder_lock_icon);
- Drawable mLockIcon = mHidden ? getResources().getDrawable(R.drawable.folder_locked)
- : getResources().getDrawable(R.drawable.folder_unlocked);
- mLock.setImageDrawable(mLockIcon);
- mLock.setOnClickListener(mClicklistener);
-
- mAppsAdapter = new AppsAdapter(mLauncher, R.layout.hidden_apps_list_item);
- mAppsAdapter.setNotifyOnChange(true);
- mAppEntries = loadApps(folder.getComponents());
- mAppsAdapter.clear();
- mAppsAdapter.addAll(mAppEntries);
-
- mListView = (ListView) v.findViewById(R.id.hidden_apps_list);
- mListView.setAdapter(mAppsAdapter);
-
- // Apply insets
- Launcher launcher = (Launcher) getActivity();
- LinearLayout.LayoutParams llp =
- (LinearLayout.LayoutParams) mListView.getLayoutParams();
- // TODO: Uncomment this once the Settings for Trebuchet are merged
- /*llp.bottomMargin += ((FrameLayout.LayoutParams) launcher.getOverviewPanel()
- .findViewById(R.id.settings_container).getLayoutParams()).bottomMargin;*/
- mListView.setLayoutParams(llp);
-
- return v;
- }
-
- private void doneEditingText(View v) {
- InputMethodManager mInputMethodManager = (InputMethodManager)
- mLauncher.getSystemService(Context.INPUT_METHOD_SERVICE);
- mInputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
-
- mListView.requestFocus();
- }
-
- private ArrayList<AppEntry> loadApps(List<Pair<ComponentName, CharSequence>> items) {
- ArrayList<AppEntry> apps = new ArrayList<AppEntry>();
- int pos = 0;
- for (Pair<ComponentName, CharSequence> item : items) {
- apps.add(new AppEntry(item.first, item.second, pos));
- pos++;
- }
- return apps;
- }
-
- private void removeComponentFromFolder(AppEntry app) {
- ShortcutInfo info;
- if (app.componentName != null) {
- info = mLauncher.mHiddenFolderIcon.getFolder()
- .getShortcutForComponent(app.componentName);
- } else {
- // Shortcut does not have componentName, use position since it maps to
- // reading order position in the folder
- info = mLauncher.mHiddenFolderIcon.getFolder().getShortcutForPosition(app.position);
- }
- mLauncher.mHiddenFolderIcon.getFolderInfo().remove(info);
-
- mAppEntries.remove(app);
- mAppsAdapter.remove(app);
- mAppsAdapter.notifyDataSetInvalidated();
- }
-
- public void saveHiddenFolderStatus(int position) {
- String newTitle = mFolderName.getText().toString();
- if (mLauncher.mHiddenFolderIcon != null) {
- if (position != -1) {
- Folder folder = mLauncher.mHiddenFolderIcon.getFolder();
- View v = folder.getViewFromPosition(position);
- Object tag = v.getTag();
- if (tag instanceof ShortcutInfo) {
- ShortcutInfo shortcut = (ShortcutInfo) tag;
- mLauncher.startActivitySafely(v, shortcut.getIntent(), v.getTag());
- return;
- }
- }
-
- // Folder name
- FolderInfo info = mLauncher.mHiddenFolderIcon.getFolderInfo();
- if (!info.title.equals(newTitle)) {
- info.setTitle(newTitle);
- mLauncher.mHiddenFolderIcon.getFolder().setFolderName();
- LauncherModel.updateItemInDatabase(mLauncher, info);
- }
-
- // Folder hidden status
- if (info.hidden == mHidden) {
- return;
- } else {
- info.hidden = mHidden;
- // flip the boolean value to accomodate framework
- // in framework "false" is "protected" and "true" is "visible"
- mLauncher.mHiddenFolderIcon.getFolder().modifyProtectedApps(!info.hidden);
-
- LauncherModel.updateItemInDatabase(mLauncher, info);
- // We need to make sure this change gets written to the DB before
- // OnResume restarts the process
- mLauncher.mModel.flushWorkerThread();
- }
- }
-
- FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction
- .remove(mLauncher.mHiddenFolderFragment).commit();
- }
-
- public class AppsAdapter extends ArrayAdapter<AppEntry> {
-
- private final LayoutInflater mInflator;
-
- private ConcurrentHashMap<String, Drawable> mIcons;
- private Drawable mDefaultImg;
- private List<AppEntry> mApps;
-
- public AppsAdapter(Context context, int textViewResourceId) {
- super(context, textViewResourceId);
-
- mApps = new ArrayList<AppEntry>();
-
- mInflator = LayoutInflater.from(context);
-
- // set the default icon till the actual app icon is loaded in async
- // task
- mDefaultImg = context.getResources().getDrawable(
- android.R.mipmap.sym_def_app_icon);
- mIcons = new ConcurrentHashMap<String, Drawable>();
- }
-
- @Override
- public View getView(final int position, View convertView,
- ViewGroup parent) {
- final AppViewHolder viewHolder;
-
- if (convertView == null) {
- convertView = mInflator.inflate(
- R.layout.hidden_folder_apps_list_item, parent, false);
- viewHolder = new AppViewHolder(convertView, position);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (AppViewHolder) convertView.getTag();
- }
-
- final AppEntry app = getItem(position);
-
- viewHolder.title.setText(app.title);
-
- Drawable icon = null;
- if (app.componentName != null) {
- icon = mIcons.get(app.componentName.getPackageName());
- }
- viewHolder.icon.setImageDrawable(icon != null ? icon : mDefaultImg);
- viewHolder.remove.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- removeComponentFromFolder(app);
- }
- });
-
- convertView.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- saveHiddenFolderStatus(position);
- }
- });
-
- return convertView;
- }
-
- @Override
- public boolean hasStableIds() {
- return true;
- }
-
- @Override
- public void notifyDataSetChanged() {
- super.notifyDataSetChanged();
- // If we have new items, we have to load their icons
- // If items were deleted, remove them from our mApps
- List<AppEntry> newApps = new ArrayList<AppEntry>(getCount());
- List<AppEntry> oldApps = new ArrayList<AppEntry>(getCount());
- for (int i = 0; i < getCount(); i++) {
- AppEntry app = getItem(i);
- if (mApps.contains(app)) {
- oldApps.add(app);
- } else {
- newApps.add(app);
- }
- }
-
- if (newApps.size() > 0) {
- new LoadIconsTask().execute(newApps.toArray(new AppEntry[] {}));
- newApps.addAll(oldApps);
- mApps = newApps;
- } else {
- mApps = oldApps;
- }
- }
-
- /**
- * An asynchronous task to load the icons of the installed applications.
- */
- private class LoadIconsTask extends AsyncTask<AppEntry, Void, Void> {
- @Override
- protected Void doInBackground(AppEntry... apps) {
- for (AppEntry app : apps) {
- try {
- // Widget icons do not have a
- if (app.componentName == null ||
- mIcons.containsKey(app.componentName.getPackageName())) {
- continue;
- }
- Drawable icon = mPackageManager
- .getApplicationIcon(app.componentName
- .getPackageName());
- mIcons.put(app.componentName.getPackageName(), icon);
- publishProgress();
- } catch (PackageManager.NameNotFoundException e) {
- // ignored; app will show up with default image
- }
- }
-
- return null;
- }
-
- @Override
- protected void onProgressUpdate(Void... progress) {
- notifyDataSetChanged();
- }
- }
- }
-
- private final class AppEntry {
- public final ComponentName componentName;
- public final CharSequence title;
- public final int position;
-
- public AppEntry(ComponentName component, CharSequence title, int position) {
- this.componentName = component;
- this.title = title;
- this.position = position;
- }
- }
-
- private static class AppViewHolder {
- public final TextView title;
- public final ImageView icon;
- public final ImageView remove;
- public final int position;
-
- public AppViewHolder(View parentView, int position) {
- icon = (ImageView) parentView.findViewById(R.id.icon);
- remove = (ImageView) parentView.findViewById(R.id.remove);
- title = (TextView) parentView.findViewById(R.id.title);
- this.position = position;
- }
- }
-}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bc1b578..929e393 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -160,7 +160,9 @@ public class Launcher extends Activity
private static final int REQUEST_PERMISSION_CALL_PHONE = 13;
- private static final int REQUEST_LOCK_PATTERN = 14;
+ public static final int REQUEST_OPEN_PROTECTED_FOLDER = 14;
+ public static final int REQUEST_PROTECT_FOLDER = 15;
+ public static final int REQUEST_UNPROTECT_FOLDER = 16;
private static final int WORKSPACE_BACKGROUND_GRADIENT = 0;
private static final int WORKSPACE_BACKGROUND_TRANSPARENT = 1;
@@ -265,7 +267,6 @@ public class Launcher extends Activity
@Thunk DragLayer mDragLayer;
private DragController mDragController;
private View mWeightWatcher;
- protected HiddenFolderFragment mHiddenFolderFragment;
private DynamicGridSizeFragment mDynamicGridSizeFragment;
private static RemoteFolderManager sRemoteFolderManager;
@@ -848,23 +849,28 @@ public class Launcher extends Activity
showWorkspace(false);
}
return;
- } else if (requestCode == REQUEST_LOCK_PATTERN) {
- mHiddenFolderAuth = true;
- switch (resultCode) {
- case RESULT_OK:
- FragmentManager fragmentManager = getFragmentManager();
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
-
- fragmentTransaction.setCustomAnimations(0, 0);
- fragmentTransaction.replace(R.id.launcher, mHiddenFolderFragment,
- HiddenFolderFragment.HIDDEN_FOLDER_FRAGMENT);
- fragmentTransaction.commit();
- break;
- case RESULT_CANCELED:
- // User failed to enter/confirm a lock pattern, back out
- break;
+ } else if (requestCode == REQUEST_OPEN_PROTECTED_FOLDER) {
+ mHiddenFolderAuth = resultCode == RESULT_OK;
+ if (mHiddenFolderIcon != null && mHiddenFolderAuth) {
+ openFolder(mHiddenFolderIcon, null);
+ } else {
+ mHiddenFolderAuth = false;
}
return;
+ } else if (requestCode == REQUEST_PROTECT_FOLDER) {
+ mHiddenFolderAuth = resultCode == RESULT_OK;
+ if (mHiddenFolderIcon != null && mHiddenFolderAuth) {
+ mHiddenFolderIcon.getFolder().saveHiddenFolderState(true);
+ } else {
+ mHiddenFolderAuth = false;
+ }
+ } else if (requestCode == REQUEST_UNPROTECT_FOLDER) {
+ mHiddenFolderAuth = resultCode == RESULT_OK;
+ if (mHiddenFolderIcon != null && mHiddenFolderAuth) {
+ mHiddenFolderIcon.getFolder().saveHiddenFolderState(false);
+ } else {
+ mHiddenFolderAuth = false;
+ }
}
boolean isWidgetDrop = (requestCode == REQUEST_PICK_APPWIDGET ||
@@ -1207,16 +1213,6 @@ public class Launcher extends Activity
if (gridFragment != null) {
mDynamicGridSizeFragment.setSize();
}
-
- Fragment hiddenFolderFragment = getFragmentManager().findFragmentByTag(
- HiddenFolderFragment.HIDDEN_FOLDER_FRAGMENT);
- if (hiddenFolderFragment != null && !mHiddenFolderAuth) {
- mHiddenFolderFragment.saveHiddenFolderStatus(-1);
- FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction.remove(mHiddenFolderFragment).commit();
- } else {
- mHiddenFolderAuth = false;
- }
}
@Override
@@ -2316,7 +2312,9 @@ public class Launcher extends Activity
outState.putInt(RUNTIME_STATE, mState.ordinal());
// We close any open folder since it will not be re-opened, and we need to make sure
// this state is reflected.
- closeFolder();
+ if (mHiddenFolderIcon == null) {
+ closeFolder();
+ }
if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
mWaitingForResult) {
@@ -2393,18 +2391,21 @@ public class Launcher extends Activity
return mDragController;
}
- public void validateLockForHiddenFolders(Bundle bundle, FolderIcon info) {
+ public void validateLockForHiddenFolders(FolderIcon info, int action) {
+ mHiddenFolderIcon = info;
// Validate Lock Pattern
Intent lockPatternActivity = new Intent();
lockPatternActivity.setClassName(
"com.android.settings",
"com.android.settings.applications.LockPatternActivity");
- startActivityForResult(lockPatternActivity, REQUEST_LOCK_PATTERN);
+ startActivityForResult(lockPatternActivity, action);
mHiddenFolderAuth = false;
+ }
- mHiddenFolderIcon = info;
- mHiddenFolderFragment = new HiddenFolderFragment();
- mHiddenFolderFragment.setArguments(bundle);
+ public void notifyFolderNameChanged() {
+ // Reload
+ mModel.resetLoadedState(true, true);
+ mModel.startLoader(mWorkspace.getCurrentPage(), LauncherModel.LOADER_FLAG_NONE);
}
@Override
@@ -2808,15 +2809,6 @@ public class Launcher extends Activity
return;
}
- Fragment f1 = getFragmentManager().findFragmentByTag(
- HiddenFolderFragment.HIDDEN_FOLDER_FRAGMENT);
- if (f1 != null) {
- mHiddenFolderFragment.saveHiddenFolderStatus(-1);
- FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction
- .remove(mHiddenFolderFragment).commit();
- }
-
if (isAppsViewVisible()) {
showWorkspace(true);
} else if (isWidgetsViewVisible()) {
@@ -2848,6 +2840,7 @@ public class Launcher extends Activity
}
}
+
/**
* Re-listen when widget host is reset.
*/
@@ -3531,7 +3524,7 @@ public class Launcher extends Activity
* is animated relative to the specified View. If the View is null, no animation
* is played.
*
- * @param folderInfo The FolderInfo describing the folder to open.
+ * @param folderIcon The FolderIcon describing the folder to open.
*/
public void openFolder(FolderIcon folderIcon, int[] folderTouch) {
Folder folder = folderIcon.getFolder();
@@ -3548,8 +3541,8 @@ public class Launcher extends Activity
FolderInfo info = folder.mInfo;
- if (info.hidden) {
- folder.startHiddenFolderManager();
+ if (info.hidden && !mHiddenFolderAuth) {
+ folder.startHiddenFolderManager(REQUEST_OPEN_PROTECTED_FOLDER);
return;
}
@@ -3596,7 +3589,12 @@ public class Launcher extends Activity
}
public void closeFolder(Folder folder, boolean animate) {
- folder.getInfo().opened = false;
+ final FolderInfo info = folder.getInfo();
+ info.opened = false;
+ if (info.hidden) {
+ mHiddenFolderAuth = false;
+ mHiddenFolderIcon = null;
+ }
ViewGroup parent = (ViewGroup) folder.getParent().getParent();
if (parent != null) {