diff options
-rw-r--r-- | res/values/cm_strings.xml | 10 | ||||
-rw-r--r-- | res/values/config.xml | 1 | ||||
-rw-r--r-- | res/xml/preferences_general.xml | 6 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Folder.java | 10 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Launcher.java | 32 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java | 11 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java | 3 |
7 files changed, 65 insertions, 8 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 5446b08..0090032 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -28,6 +28,11 @@ <!-- Label for the info icon. [CHAR_LIMIT=30] --> <string name="edit_target_label">Edit</string> + <!-- Menu item used to lock workspace --> + <string name="menu_lock_workspace">Lock homescreen</string> + <!-- Menu item used to unlock workspace --> + <string name="menu_unlock_workspace">Unlock homescreen</string> + <!-- Noun, menu item used to show the launcher preferences --> <string name="menu_preferences">Trebuchet settings</string> @@ -51,6 +56,9 @@ <!-- Hidden apps --> <string name="hidden_apps_title">Hidden apps</string> + <!-- Workspace is locked --> + <string name="workspace_locked">Homescreen is locked, unlock in settings to rearrange</string> + <!-- Settings --> <string name="preferences_title">Settings</string> <!-- UI --> @@ -142,6 +150,8 @@ <!-- General --> <string name="preferences_interface_general_title">General</string> <string name="preferences_interface_general_orientation_title">Auto-rotate screen</string> + <string name="preferences_interface_general_lock_workspace_title">Lock homescreen</string> + <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> diff --git a/res/values/config.xml b/res/values/config.xml index f32e6b8..3164332 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -2,6 +2,7 @@ <bool name="config_largeHeap">false</bool> <bool name="is_large_screen">false</bool> <bool name="allow_rotation">false</bool> + <bool name="lock_workspace">false</bool> <!-- DragController --> <integer name="config_flingToDeleteMinVelocity">-1500</integer> diff --git a/res/xml/preferences_general.xml b/res/xml/preferences_general.xml index abe0cf8..61a297b 100644 --- a/res/xml/preferences_general.xml +++ b/res/xml/preferences_general.xml @@ -20,7 +20,11 @@ android:title="@string/preferences_interface_general_title"> <CheckBoxPreference android:key="ui_general_orientation" android:title="@string/preferences_interface_general_orientation_title" /> + <CheckBoxPreference android:key="ui_general_lock_workspace" + android:title="@string/preferences_interface_general_lock_workspace_title" + android:summary="@string/preferences_interface_general_lock_workspace_summary" + android:defaultValue="@bool/lock_workspace" /> <CheckBoxPreference android:key="ui_general_fullscreen" android:title="@string/preferences_interface_general_fullscreen_title" android:summary="@string/preferences_interface_general_fullscreen_summary" /> -</PreferenceScreen>
\ No newline at end of file +</PreferenceScreen> diff --git a/src/com/cyanogenmod/trebuchet/Folder.java b/src/com/cyanogenmod/trebuchet/Folder.java index cdb4dd3..28a9aef 100644 --- a/src/com/cyanogenmod/trebuchet/Folder.java +++ b/src/com/cyanogenmod/trebuchet/Folder.java @@ -158,7 +158,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false); mFolderName = (FolderEditText) findViewById(R.id.folder_name); mFolderName.setFolder(this); - mFolderName.setOnFocusChangeListener(this); + if (mLauncher.getLockWorkspace()) { + mFolderName.setKeyListener(null); + mFolderName.setFocusable(false); + } else { + mFolderName.setOnFocusChangeListener(this); + } // 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. @@ -211,6 +216,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } public boolean onLongClick(View v) { + // Only if workspace is not locked + if (mLauncher.getLockWorkspace()) return false; + // Return if global dragging is not enabled if (!mLauncher.isDraggingEnabled()) return true; diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java index f90a1eb..c82c8fe 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. */ diff --git a/src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java b/src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java index 1f0befa..1674060 100644 --- a/src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java +++ b/src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java @@ -20,6 +20,7 @@ import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; +import android.widget.Toast; /* Class that does most of the work of enabling dragging items out of a PagedView by performing a @@ -73,7 +74,10 @@ public abstract class PagedViewWithDraggableItems extends PagedView break; case MotionEvent.ACTION_MOVE: if (mTouchState != TOUCH_STATE_SCROLLING && !mIsDragging && mIsDragEnabled) { - determineDraggingStart(ev); + // Only if workspace is not locked + if (!mLauncher.getLockWorkspace()) { + determineDraggingStart(ev); + } } break; } @@ -100,6 +104,11 @@ public abstract class PagedViewWithDraggableItems extends PagedView @Override public boolean onLongClick(View v) { + // Only if workspace is not locked + if (mLauncher.getLockWorkspace()) { + Toast.makeText(mLauncher, mLauncher.getString(R.string.workspace_locked), Toast.LENGTH_SHORT).show(); + return false; + } // Return early if this is not initiated from a touch if (!v.isInTouchMode()) return false; // Return early if we are still animating the pages diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java index ca03491..c4039ff 100644 --- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java +++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java @@ -204,6 +204,9 @@ public final class PreferencesProvider { public static boolean getAutoRotate(boolean def) { return getBoolean("ui_general_orientation", def); } + public static boolean getLockWorkspace(boolean def) { + return getBoolean("ui_general_lock_workspace", def); + } public static boolean getFullscreenMode() { return getBoolean("ui_general_fullscreen", false); } |