summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/trebuchet/Launcher.java
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-04-29 00:59:24 +0200
committerNebojsa Cvetkovic <nebkat@gmail.com>2013-04-29 13:48:59 +0100
commitbd9793a7c059a616745f636128c665860d78ed8d (patch)
tree7073cbedf336824693edf96dc66b8b6d6a4dcc9f /src/com/cyanogenmod/trebuchet/Launcher.java
parentb76a4e1cd7734e35b779615d337e22b6c65648ee (diff)
downloadandroid_packages_apps_Trebuchet-bd9793a7c059a616745f636128c665860d78ed8d.tar.gz
android_packages_apps_Trebuchet-bd9793a7c059a616745f636128c665860d78ed8d.tar.bz2
android_packages_apps_Trebuchet-bd9793a7c059a616745f636128c665860d78ed8d.zip
Trebuchet: Lock homescreen
Allow lock shortcuts and folders positions in the workspace, hotseat and apps and widgets drawer. When is enabled the system avoids to move any shortcut or folder, change its names and access to widgets. Patchset 2: Fixed typo Change-Id: I832da526cf1eb32752218656a7c2dafc53010236 JIRA: CYAN-686 Issue: https://jira.cyanogenmod.org/browse/CYAN-686 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/com/cyanogenmod/trebuchet/Launcher.java')
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index f90a1eb7e..c82c8fe2d 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -134,7 +134,8 @@ public final class Launcher extends Activity
private static final int MENU_GROUP_WALLPAPER = 1;
private static final int MENU_WALLPAPER_SETTINGS = Menu.FIRST + 1;
- private static final int MENU_MANAGE_APPS = MENU_WALLPAPER_SETTINGS + 1;
+ private static final int MENU_LOCK_WORKSPACE = MENU_WALLPAPER_SETTINGS + 1;
+ private static final int MENU_MANAGE_APPS = MENU_LOCK_WORKSPACE + 1;
private static final int MENU_PREFERENCES = MENU_MANAGE_APPS + 1;
private static final int MENU_SYSTEM_SETTINGS = MENU_PREFERENCES + 1;
private static final int MENU_HELP = MENU_SYSTEM_SETTINGS + 1;
@@ -319,6 +320,7 @@ public final class Launcher extends Activity
private boolean mShowDockDivider;
private boolean mHideIconLabels;
private boolean mAutoRotate;
+ private boolean mLockWorkspace;
private boolean mFullscreenMode;
private boolean mWallpaperVisible;
@@ -403,6 +405,7 @@ public final class Launcher extends Activity
mShowDockDivider = PreferencesProvider.Interface.Dock.getShowDivider() && mShowHotseat;
mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels();
mAutoRotate = PreferencesProvider.Interface.General.getAutoRotate(getResources().getBoolean(R.bool.allow_rotation));
+ mLockWorkspace = PreferencesProvider.Interface.General.getLockWorkspace(getResources().getBoolean(R.bool.lock_workspace));
mFullscreenMode = PreferencesProvider.Interface.General.getFullscreenMode();
if (PROFILE_STARTUP) {
@@ -1775,6 +1778,8 @@ public final class Launcher extends Activity
menu.add(MENU_GROUP_WALLPAPER, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper)
.setIcon(android.R.drawable.ic_menu_gallery)
.setAlphabeticShortcut('W');
+ menu.add(0, MENU_LOCK_WORKSPACE, 0, !mLockWorkspace ? R.string.menu_lock_workspace : R.string.menu_unlock_workspace)
+ .setAlphabeticShortcut('L');
menu.add(0, MENU_MANAGE_APPS, 0, R.string.menu_manage_apps)
.setIcon(android.R.drawable.ic_menu_manage)
.setIntent(manageApps)
@@ -1808,6 +1813,8 @@ public final class Launcher extends Activity
boolean allAppsVisible = (mAppsCustomizeTabHost.getVisibility() == View.VISIBLE);
menu.setGroupVisible(MENU_GROUP_WALLPAPER, !allAppsVisible);
+ menu.findItem(MENU_LOCK_WORKSPACE).setTitle(!mLockWorkspace ? R.string.menu_lock_workspace : R.string.menu_unlock_workspace);
+
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
launcherIntent.addCategory(Intent.CATEGORY_HOME);
launcherIntent.addCategory(Intent.CATEGORY_DEFAULT);
@@ -1823,11 +1830,18 @@ public final class Launcher extends Activity
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case MENU_WALLPAPER_SETTINGS:
- startWallpaper();
- return true;
+ case MENU_WALLPAPER_SETTINGS:
+ startWallpaper();
+ return true;
+ case MENU_LOCK_WORKSPACE:
+ mLockWorkspace = !mLockWorkspace;
+ SharedPreferences.Editor editor = mSharedPrefs.edit();
+ editor.putBoolean("ui_general_lock_workspace", mLockWorkspace);
+ editor.commit();
+ return true;
}
+
return super.onOptionsItemSelected(item);
}
@@ -2548,7 +2562,11 @@ public final class Launcher extends Activity
startWallpaper();
} else {
if (!(itemUnderLongClick instanceof Folder)) {
- // User long pressed on an item
+ // User long pressed on an item (only if workspace is not locked)
+ if (mLockWorkspace) {
+ Toast.makeText(this, getString(R.string.workspace_locked), Toast.LENGTH_SHORT).show();
+ return false;
+ }
mWorkspace.startDrag(longClickCellInfo);
}
}
@@ -2567,6 +2585,10 @@ public final class Launcher extends Activity
return mSearchDropTargetBar;
}
+ boolean getLockWorkspace() {
+ return mLockWorkspace;
+ }
+
/**
* Returns the CellLayout of the specified container at the specified screen.
*/