summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/cyanogenmod/trebuchet/AccessibleTabView.java (renamed from src/com/android/launcher2/AccessibleTabView.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/AddAdapter.java (renamed from src/com/android/launcher2/AddAdapter.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/Alarm.java (renamed from src/com/android/launcher2/Alarm.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/AllAppsList.java (renamed from src/com/android/launcher2/AllAppsList.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/AllAppsView.java (renamed from src/com/android/launcher2/AllAppsView.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java (renamed from src/com/android/launcher2/AppWidgetResizeFrame.java)12
-rw-r--r--src/com/cyanogenmod/trebuchet/ApplicationInfo.java (renamed from src/com/android/launcher2/ApplicationInfo.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java (renamed from src/com/android/launcher2/AppsCustomizePagedView.java)411
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java (renamed from src/com/android/launcher2/AppsCustomizeTabHost.java)115
-rw-r--r--src/com/cyanogenmod/trebuchet/BubbleTextView.java (renamed from src/com/android/launcher2/BubbleTextView.java)16
-rw-r--r--src/com/cyanogenmod/trebuchet/ButtonDropTarget.java (renamed from src/com/android/launcher2/ButtonDropTarget.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/CellLayout.java (renamed from src/com/android/launcher2/CellLayout.java)15
-rw-r--r--src/com/cyanogenmod/trebuchet/CheckLongPressHelper.java (renamed from src/com/android/launcher2/CheckLongPressHelper.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/Cling.java (renamed from src/com/android/launcher2/Cling.java)27
-rw-r--r--src/com/cyanogenmod/trebuchet/DeferredHandler.java (renamed from src/com/android/launcher2/DeferredHandler.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/DeleteDropTarget.java (renamed from src/com/android/launcher2/DeleteDropTarget.java)203
-rw-r--r--src/com/cyanogenmod/trebuchet/DragController.java (renamed from src/com/android/launcher2/DragController.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/DragLayer.java (renamed from src/com/android/launcher2/DragLayer.java)8
-rw-r--r--src/com/cyanogenmod/trebuchet/DragScroller.java (renamed from src/com/android/launcher2/DragScroller.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/DragSource.java (renamed from src/com/android/launcher2/DragSource.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/DragView.java (renamed from src/com/android/launcher2/DragView.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/DrawableStateProxyView.java (renamed from src/com/android/launcher2/DrawableStateProxyView.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/DropTarget.java (renamed from src/com/android/launcher2/DropTarget.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/FastBitmapDrawable.java (renamed from src/com/android/launcher2/FastBitmapDrawable.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/FocusHelper.java (renamed from src/com/android/launcher2/FocusHelper.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/FocusOnlyTabWidget.java (renamed from src/com/android/launcher2/FocusOnlyTabWidget.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/Folder.java (renamed from src/com/android/launcher2/Folder.java)16
-rw-r--r--src/com/cyanogenmod/trebuchet/FolderEditText.java (renamed from src/com/android/launcher2/FolderEditText.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/FolderIcon.java (renamed from src/com/android/launcher2/FolderIcon.java)20
-rw-r--r--src/com/cyanogenmod/trebuchet/FolderInfo.java (renamed from src/com/android/launcher2/FolderInfo.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/HandleView.java (renamed from src/com/android/launcher2/HandleView.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/HolographicImageView.java (renamed from src/com/android/launcher2/HolographicImageView.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/HolographicLinearLayout.java (renamed from src/com/android/launcher2/HolographicLinearLayout.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/HolographicOutlineHelper.java (renamed from src/com/android/launcher2/HolographicOutlineHelper.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/HolographicViewHelper.java (renamed from src/com/android/launcher2/HolographicViewHelper.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/Hotseat.java (renamed from src/com/android/launcher2/Hotseat.java)11
-rw-r--r--src/com/cyanogenmod/trebuchet/IconCache.java (renamed from src/com/android/launcher2/IconCache.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/InfoDropTarget.java (renamed from src/com/android/launcher2/InfoDropTarget.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java (renamed from src/com/android/launcher2/InstallShortcutReceiver.java)16
-rw-r--r--src/com/cyanogenmod/trebuchet/InstallWidgetReceiver.java (renamed from src/com/android/launcher2/InstallWidgetReceiver.java)14
-rw-r--r--src/com/cyanogenmod/trebuchet/InterruptibleInOutAnimator.java (renamed from src/com/android/launcher2/InterruptibleInOutAnimator.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/ItemInfo.java (renamed from src/com/android/launcher2/ItemInfo.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java (renamed from src/com/android/launcher2/Launcher.java)170
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherAnimatorUpdateListener.java (renamed from src/com/android/launcher2/LauncherAnimatorUpdateListener.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherAppWidgetHost.java (renamed from src/com/android/launcher2/LauncherAppWidgetHost.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherAppWidgetHostView.java (renamed from src/com/android/launcher2/LauncherAppWidgetHostView.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherAppWidgetInfo.java (renamed from src/com/android/launcher2/LauncherAppWidgetInfo.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherApplication.java (renamed from src/com/android/launcher2/LauncherApplication.java)6
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java (renamed from src/com/android/launcher2/LauncherModel.java)25
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherProvider.java (renamed from src/com/android/launcher2/LauncherProvider.java)10
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherSettings.java (renamed from src/com/android/launcher2/LauncherSettings.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherViewPropertyAnimator.java (renamed from src/com/android/launcher2/LauncherViewPropertyAnimator.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedView.java (renamed from src/com/android/launcher2/PagedView.java)33
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewCellLayout.java (renamed from src/com/android/launcher2/PagedViewCellLayout.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewCellLayoutChildren.java (renamed from src/com/android/launcher2/PagedViewCellLayoutChildren.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewGridLayout.java (renamed from src/com/android/launcher2/PagedViewGridLayout.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewIcon.java (renamed from src/com/android/launcher2/PagedViewIcon.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewIconCache.java (renamed from src/com/android/launcher2/PagedViewIconCache.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewWidget.java (renamed from src/com/android/launcher2/PagedViewWidget.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewWidgetImageView.java (renamed from src/com/android/launcher2/PagedViewWidgetImageView.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java (renamed from src/com/android/launcher2/PagedViewWithDraggableItems.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java (renamed from src/com/android/launcher2/PendingAddItemInfo.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/PreloadReceiver.java (renamed from src/com/android/launcher2/PreloadReceiver.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/RocketLauncher.java (renamed from src/com/android/launcher2/RocketLauncher.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java (renamed from src/com/android/launcher2/SearchDropTargetBar.java)53
-rw-r--r--src/com/cyanogenmod/trebuchet/ShortcutAndWidgetContainer.java (renamed from src/com/android/launcher2/ShortcutAndWidgetContainer.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/ShortcutInfo.java (renamed from src/com/android/launcher2/ShortcutInfo.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/SmoothPagedView.java (renamed from src/com/android/launcher2/SmoothPagedView.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/SpringLoadedDragController.java (renamed from src/com/android/launcher2/SpringLoadedDragController.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/StrokedTextView.java (renamed from src/com/android/launcher2/StrokedTextView.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/SymmetricalLinearTween.java (renamed from src/com/android/launcher2/SymmetricalLinearTween.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/TweenCallback.java (renamed from src/com/android/launcher2/TweenCallback.java)2
-rw-r--r--src/com/cyanogenmod/trebuchet/UninstallShortcutReceiver.java (renamed from src/com/android/launcher2/UninstallShortcutReceiver.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/Utilities.java (renamed from src/com/android/launcher2/Utilities.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/WallpaperChooser.java (renamed from src/com/android/launcher2/WallpaperChooser.java)4
-rw-r--r--src/com/cyanogenmod/trebuchet/WallpaperChooserDialogFragment.java (renamed from src/com/android/launcher2/WallpaperChooserDialogFragment.java)10
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java (renamed from src/com/android/launcher2/Workspace.java)263
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/DoubleNumberPickerPreference.java186
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/NumberPickerPreference.java104
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/Preferences.java64
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java138
81 files changed, 1627 insertions, 467 deletions
diff --git a/src/com/android/launcher2/AccessibleTabView.java b/src/com/cyanogenmod/trebuchet/AccessibleTabView.java
index 101f139..de5a689 100644
--- a/src/com/android/launcher2/AccessibleTabView.java
+++ b/src/com/cyanogenmod/trebuchet/AccessibleTabView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/com/android/launcher2/AddAdapter.java b/src/com/cyanogenmod/trebuchet/AddAdapter.java
index c2a424b..5a3d43d 100644
--- a/src/com/android/launcher2/AddAdapter.java
+++ b/src/com/cyanogenmod/trebuchet/AddAdapter.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
@@ -27,7 +27,7 @@ import android.widget.TextView;
import java.util.ArrayList;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
* Adapter showing the types of items that can be added to a {@link Workspace}.
diff --git a/src/com/android/launcher2/Alarm.java b/src/com/cyanogenmod/trebuchet/Alarm.java
index 7cd21c3..61efce4 100644
--- a/src/com/android/launcher2/Alarm.java
+++ b/src/com/cyanogenmod/trebuchet/Alarm.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.os.Handler;
diff --git a/src/com/android/launcher2/AllAppsList.java b/src/com/cyanogenmod/trebuchet/AllAppsList.java
index 051b0bd..cc0e8cf 100644
--- a/src/com/android/launcher2/AllAppsList.java
+++ b/src/com/cyanogenmod/trebuchet/AllAppsList.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/cyanogenmod/trebuchet/AllAppsView.java
index e8ca61f..d47b524 100644
--- a/src/com/android/launcher2/AllAppsView.java
+++ b/src/com/cyanogenmod/trebuchet/AllAppsView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.ArrayList;
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java
index f94ad01..0571541 100644
--- a/src/com/android/launcher2/AppWidgetResizeFrame.java
+++ b/src/com/cyanogenmod/trebuchet/AppWidgetResizeFrame.java
@@ -1,4 +1,4 @@
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
@@ -13,7 +13,8 @@ import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
public class AppWidgetResizeFrame extends FrameLayout {
private LauncherAppWidgetHostView mWidgetView;
@@ -121,6 +122,13 @@ public class AppWidgetResizeFrame extends FrameLayout {
mWidgetPaddingRight = p.right;
mWidgetPaddingBottom = p.bottom;
+ // Resize any widget
+ if (PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context)) {
+ mResizeMode = AppWidgetProviderInfo.RESIZE_BOTH;
+ mMinHSpan = 1;
+ mMinVSpan = 1;
+ }
+
if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) {
mTopHandle.setVisibility(GONE);
mBottomHandle.setVisibility(GONE);
diff --git a/src/com/android/launcher2/ApplicationInfo.java b/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
index 281d59c..ffc7a5c 100644
--- a/src/com/android/launcher2/ApplicationInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ApplicationInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.ComponentName;
import android.content.Intent;
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
index 8cb169e..f64cb72 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizePagedView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
@@ -63,8 +63,9 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
-import com.android.launcher.R;
-import com.android.launcher2.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
import java.util.Collections;
@@ -140,8 +141,9 @@ class AsyncTaskPageData {
* A generic template for an async task used in AppsCustomize.
*/
class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTaskPageData> {
- AppsCustomizeAsyncTask(int p, AsyncTaskPageData.Type ty) {
+ AppsCustomizeAsyncTask(int p, AppsCustomizePagedView.ContentType t, AsyncTaskPageData.Type ty) {
page = p;
+ pageContentType = t;
threadPriority = Process.THREAD_PRIORITY_DEFAULT;
dataType = ty;
}
@@ -168,6 +170,7 @@ class AppsCustomizeAsyncTask extends AsyncTask<AsyncTaskPageData, Void, AsyncTas
// The page that this async task is associated with
AsyncTaskPageData.Type dataType;
int page;
+ AppsCustomizePagedView.ContentType pageContentType;
int threadPriority;
}
@@ -246,6 +249,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Widgets
}
+ /**
+ * The sorting mode of the apps.
+ */
+ public enum SortMode {
+ Title,
+ InstallDate
+ }
+
// Refs
private Launcher mLauncher;
private DragController mDragController;
@@ -255,13 +266,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// Save and Restore
private int mSaveInstanceStateItemIndex = -1;
private PagedViewIcon mPressedIcon;
+ private int mRestorePage = -1;
// Content
+ private ContentType mContentType;
+ private SortMode mSortMode = SortMode.Title;
private ArrayList<ApplicationInfo> mApps;
private ArrayList<Object> mWidgets;
// Cling
private boolean mHasShownAllAppsCling;
+ private boolean mHasShownAllAppsSortCling;
private int mClingFocusedX;
private int mClingFocusedY;
@@ -274,12 +289,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private int mContentWidth;
private int mAppIconSize;
private int mMaxAppCellCountX, mMaxAppCellCountY;
+ private int mMaxWidgetSpan, mMinWidgetSpan;
private int mWidgetCountX, mWidgetCountY;
private int mWidgetWidthGap, mWidgetHeightGap;
private final float sWidgetPreviewIconPaddingPercentage = 0.25f;
private PagedViewCellLayout mWidgetSpacingLayout;
- private int mNumAppsPages;
- private int mNumWidgetPages;
+ private int mNumAppsPages = 0;
+ private int mNumWidgetPages = 0;
// Relating to the scroll and overscroll effects
Workspace.ZInterpolator mZInterpolator = new Workspace.ZInterpolator(0.5f);
@@ -324,16 +340,31 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
RectCache mCachedAppWidgetPreviewDestRect = new RectCache();
PaintCache mCachedAppWidgetPreviewPaint = new PaintCache();
+ // Preferences
+ private boolean mJoinWidgetsApps;
+ private boolean mShowScrollingIndicator;
+ private boolean mFadeScrollingIndicator;
+
public AppsCustomizePagedView(Context context, AttributeSet attrs) {
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
mPackageManager = context.getPackageManager();
+ mContentType = ContentType.Applications;
mApps = new ArrayList<ApplicationInfo>();
mWidgets = new ArrayList<Object>();
mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
mCanvas = new Canvas();
mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>();
+ // Preferences
+ mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
+ mShowScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getShowScrollingIndicator(context);
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
+
+ if (!mShowScrollingIndicator) {
+ disableScrollingIndicator();
+ }
+
// Save the default widget preview background
Resources resources = context.getResources();
mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview_holo);
@@ -353,6 +384,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
a.recycle();
mWidgetSpacingLayout = new PagedViewCellLayout(getContext());
+ // The max widget span is the length N, such that NxN is the largest bounds that the widget
+ // preview can be before applying the widget scaling
+ mMinWidgetSpan = 1;
+ mMaxWidgetSpan = 3;
+
// The padding on the non-matched dimension for the default widget preview icons
// (top + bottom)
mFadeInAdjacentScreens = false;
@@ -387,22 +423,44 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int i = -1;
if (getPageCount() > 0) {
int currentPage = getCurrentPage();
- if (currentPage < mNumAppsPages) {
- PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage);
- PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout();
- int numItemsPerPage = mCellCountX * mCellCountY;
- int childCount = childrenLayout.getChildCount();
- if (childCount > 0) {
- i = (currentPage * numItemsPerPage) + (childCount / 2);
+ if (mJoinWidgetsApps) {
+ if (currentPage < mNumAppsPages) {
+ PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage);
+ PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout();
+ int numItemsPerPage = mCellCountX * mCellCountY;
+ int childCount = childrenLayout.getChildCount();
+ if (childCount > 0) {
+ i = (currentPage * numItemsPerPage) + (childCount / 2);
+ }
+ } else {
+ int numApps = mApps.size();
+ PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage);
+ int numItemsPerPage = mWidgetCountX * mWidgetCountY;
+ int childCount = layout.getChildCount();
+ if (childCount > 0) {
+ i = numApps +
+ ((currentPage - mNumAppsPages) * numItemsPerPage) + (childCount / 2);
+ }
}
} else {
- int numApps = mApps.size();
- PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage);
- int numItemsPerPage = mWidgetCountX * mWidgetCountY;
- int childCount = layout.getChildCount();
- if (childCount > 0) {
- i = numApps +
- ((currentPage - mNumAppsPages) * numItemsPerPage) + (childCount / 2);
+ switch (mContentType) {
+ case Applications: {
+ PagedViewCellLayout layout = (PagedViewCellLayout) getPageAt(currentPage);
+ PagedViewCellLayoutChildren childrenLayout = layout.getChildrenLayout();
+ int numItemsPerPage = mCellCountX * mCellCountY;
+ int childCount = childrenLayout.getChildCount();
+ if (childCount > 0) {
+ i = (currentPage * numItemsPerPage) + (childCount / 2);
+ }}
+ break;
+ case Widgets: {
+ PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(currentPage);
+ int numItemsPerPage = mWidgetCountX * mWidgetCountY;
+ int childCount = layout.getChildCount();
+ if (childCount > 0) {
+ i = (currentPage * numItemsPerPage) + (childCount / 2);
+ }}
+ break;
}
}
}
@@ -420,14 +478,27 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
/** Returns the page in the current orientation which is expected to contain the specified
* item index. */
int getPageForComponent(int index) {
- if (index < 0) return 0;
+ if (mJoinWidgetsApps) {
+ if (index < 0) return 0;
- if (index < mApps.size()) {
- int numItemsPerPage = mCellCountX * mCellCountY;
- return (index / numItemsPerPage);
+ if (index < mApps.size()) {
+ int numItemsPerPage = mCellCountX * mCellCountY;
+ return (index / numItemsPerPage);
+ } else {
+ int numItemsPerPage = mWidgetCountX * mWidgetCountY;
+ return mNumAppsPages + ((index - mApps.size()) / numItemsPerPage);
+ }
} else {
- int numItemsPerPage = mWidgetCountX * mWidgetCountY;
- return mNumAppsPages + ((index - mApps.size()) / numItemsPerPage);
+ switch (mContentType) {
+ case Applications: {
+ int numItemsPerPage = mCellCountX * mCellCountY;
+ return (index / numItemsPerPage);
+ }
+ case Widgets: {
+ int numItemsPerPage = mWidgetCountX * mWidgetCountY;
+ return (index / numItemsPerPage);
+ }}
+ return -1;
}
}
@@ -438,9 +509,11 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
private void updatePageCounts() {
- mNumWidgetPages = (int) Math.ceil(mWidgets.size() /
- (float) (mWidgetCountX * mWidgetCountY));
- mNumAppsPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY));
+ if (mJoinWidgetsApps) {
+ mNumWidgetPages = (int) Math.ceil(mWidgets.size() /
+ (float) (mWidgetCountX * mWidgetCountY));
+ mNumAppsPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY));
+ }
}
protected void onDataReady(int width, int height) {
@@ -499,17 +572,25 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
void showAllAppsCling() {
- if (!mHasShownAllAppsCling && isDataReady()) {
- mHasShownAllAppsCling = true;
- // Calculate the position for the cling punch through
- int[] offset = new int[2];
- int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY);
- mLauncher.getDragLayer().getLocationInDragLayer(this, offset);
- // PagedViews are centered horizontally but top aligned
- pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 +
- offset[0];
- pos[1] += offset[1];
- mLauncher.showFirstRunAllAppsCling(pos);
+ AppsCustomizeTabHost tabHost = getTabHost();
+ if (tabHost != null) {
+ Cling allAppsCling = (Cling) tabHost.findViewById(R.id.all_apps_cling);
+ if (!mHasShownAllAppsCling && isDataReady()) {
+ mHasShownAllAppsCling = true;
+ // Calculate the position for the cling punch through
+ int[] offset = new int[2];
+ int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY);
+ mLauncher.getDragLayer().getLocationInDragLayer(this, offset);
+ // PagedViews are centered horizontally but top aligned
+ pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 +
+ offset[0];
+ pos[1] += offset[1];
+ mLauncher.showFirstRunAllAppsCling(pos);
+ } else if (!mHasShownAllAppsSortCling && isDataReady() &&
+ allAppsCling != null && allAppsCling.isDismissed()) {
+ mHasShownAllAppsSortCling = true;
+ mLauncher.showFirstRunAllAppsSortCling();
+ }
}
}
@@ -518,7 +599,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
if (!isDataReady()) {
- if (!mApps.isEmpty() && !mWidgets.isEmpty()) {
+ boolean isReady = false;
+ if (mContentType == AppsCustomizePagedView.ContentType.Widgets || mJoinWidgetsApps) {
+ isReady = (!mApps.isEmpty() && !mWidgets.isEmpty());
+ } else {
+ isReady = !mApps.isEmpty();
+ }
+
+ if (isReady) {
setDataIsReady();
setMeasuredDimension(width, height);
onDataReady(width, height);
@@ -990,27 +1078,34 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
public void setContentType(ContentType type) {
- if (type == ContentType.Widgets) {
- invalidatePageData(mNumAppsPages, true);
- } else if (type == ContentType.Applications) {
- invalidatePageData(0, true);
+ if (mJoinWidgetsApps) {
+ if (type == ContentType.Widgets) {
+ invalidatePageData(mNumAppsPages, true);
+ } else if (type == ContentType.Applications) {
+ invalidatePageData(0, true);
+ }
+ } else {
+ mContentType = type;
+ invalidatePageData(0, (type != ContentType.Applications));
}
}
protected void snapToPage(int whichPage, int delta, int duration) {
super.snapToPage(whichPage, delta, duration);
- updateCurrentTab(whichPage);
+ if (mJoinWidgetsApps) {
+ updateCurrentTab(whichPage);
- // Update the thread priorities given the direction lookahead
- Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
- while (iter.hasNext()) {
- AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
- int pageIndex = task.page;
- if ((mNextPage > mCurrentPage && pageIndex >= mCurrentPage) ||
- (mNextPage < mCurrentPage && pageIndex <= mCurrentPage)) {
- task.setThreadPriority(getThreadPriorityForPage(pageIndex));
- } else {
- task.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
+ // Update the thread priorities given the direction lookahead
+ Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
+ while (iter.hasNext()) {
+ AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
+ int pageIndex = task.page;
+ if ((mNextPage > mCurrentPage && pageIndex >= mCurrentPage) ||
+ (mNextPage < mCurrentPage && pageIndex <= mCurrentPage)) {
+ task.setThreadPriority(getThreadPriorityForPage(pageIndex));
+ } else {
+ task.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
+ }
}
}
}
@@ -1031,6 +1126,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ public boolean isContentType(ContentType type) {
+ return (mContentType == type);
+ }
+
+ public void setCurrentPageToWidgets() {
+ invalidatePageData(0);
+ }
+
/*
* Apps PagedView implementation
*/
@@ -1057,7 +1160,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
layout.measure(widthSpec, heightSpec);
setVisibilityOnChildren(layout, View.VISIBLE);
}
-
+ public void syncAppsPages() {
+ // Ensure that we have the right number of pages
+ Context context = getContext();
+ int numPages = (int) Math.ceil((float) mApps.size() / (mCellCountX * mCellCountY));
+ for (int i = 0; i < numPages; ++i) {
+ PagedViewCellLayout layout = new PagedViewCellLayout(context);
+ setupPage(layout);
+ addView(layout);
+ }
+ }
public void syncAppsPageItems(int page, boolean immediate) {
// ensure that we have the right number of items on the pages
int numCells = mCellCountX * mCellCountY;
@@ -1175,13 +1287,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
mRunningTasks.remove(task);
if (task.isCancelled()) return;
+ if (!mJoinWidgetsApps) {
+ if (task.page > getPageCount()) return;
+ if (task.pageContentType != mContentType) return;
+ }
// do cleanup inside onSyncWidgetPageItems
onSyncWidgetPageItems(data);
}
});
// Ensure that the task is appropriately prioritized and runs in parallel
- AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page,
+ AppsCustomizeAsyncTask t = new AppsCustomizeAsyncTask(page, mContentType,
AsyncTaskPageData.Type.LoadWidgetPreviewData);
t.setThreadPriority(getThreadPriorityForPage(page));
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageData);
@@ -1379,6 +1495,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
return preview;
}
+ public void syncWidgetPages() {
+ // Ensure that we have the right number of pages
+ Context context = getContext();
+ int numPages = (int) Math.ceil(mWidgets.size() /
+ (float) (mWidgetCountX * mWidgetCountY));
+ for (int j = 0; j < numPages; ++j) {
+ PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
+ mWidgetCountY);
+ setupPage(layout);
+ addView(layout, new PagedViewGridLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+ }
+ }
public void syncWidgetPageItems(final int page, final boolean immediate) {
int numItemsPerPage = mWidgetCountX * mWidgetCountY;
@@ -1562,28 +1691,50 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
removeAllViews();
cancelAllTasks();
- Context context = getContext();
- for (int j = 0; j < mNumWidgetPages; ++j) {
- PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
- mWidgetCountY);
- setupPage(layout);
- addView(layout, new PagedView.LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.MATCH_PARENT));
- }
+ if (mJoinWidgetsApps) {
+ Context context = getContext();
+ for (int j = 0; j < mNumWidgetPages; ++j) {
+ PagedViewGridLayout layout = new PagedViewGridLayout(context, mWidgetCountX,
+ mWidgetCountY);
+ setupPage(layout);
+ addView(layout, new PagedView.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+ }
- for (int i = 0; i < mNumAppsPages; ++i) {
- PagedViewCellLayout layout = new PagedViewCellLayout(context);
- setupPage(layout);
- addView(layout);
+ for (int i = 0; i < mNumAppsPages; ++i) {
+ PagedViewCellLayout layout = new PagedViewCellLayout(context);
+ setupPage(layout);
+ addView(layout);
+ }
+ } else {
+ switch (mContentType) {
+ case Applications:
+ syncAppsPages();
+ break;
+ case Widgets:
+ syncWidgetPages();
+ break;
+ }
}
}
@Override
public void syncPageItems(int page, boolean immediate) {
- if (page < mNumAppsPages) {
- syncAppsPageItems(page, immediate);
+ if (mJoinWidgetsApps) {
+ if (page < mNumAppsPages) {
+ syncAppsPageItems(page, immediate);
+ } else {
+ syncWidgetPageItems(page, immediate);
+ }
} else {
- syncWidgetPageItems(page, immediate);
+ switch (mContentType) {
+ case Applications:
+ syncAppsPageItems(page, immediate);
+ break;
+ case Widgets:
+ syncWidgetPageItems(page, immediate);
+ break;
+ }
}
}
@@ -1682,13 +1833,25 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
protected void onPageEndMoving() {
- super.onPageEndMoving();
+ if (mFadeScrollingIndicator) {
+ hideScrollingIndicator(false);
+ }
mForceDrawAllChildrenNextFrame = true;
+
// We reset the save index when we change pages so that it will be recalculated on next
// rotation
mSaveInstanceStateItemIndex = -1;
}
+ @Override
+ protected void flashScrollingIndicator(boolean animated) {
+ if (mFadeScrollingIndicator) {
+ super.flashScrollingIndicator(animated);
+ } else {
+ showScrollingIndicator(false);
+ }
+ }
+
/*
* AllAppsView implementation
*/
@@ -1727,10 +1890,44 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
+ public SortMode getSortMode() {
+ return mSortMode;
+ }
+
+ public void setSortMode(SortMode sortMode) {
+ if (mSortMode == sortMode) {
+ return;
+ }
+
+ mSortMode = sortMode;
+
+ if (mSortMode == SortMode.Title) {
+ Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
+ } else if (mSortMode == SortMode.InstallDate) {
+ Collections.sort(mApps, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
+ }
+
+ if (mJoinWidgetsApps) {
+ for (int i = 0; i < mNumAppsPages; i++) {
+ syncAppsPageItems(i, true);
+ }
+ } else {
+ if (mContentType == ContentType.Applications) {
+ for (int i = 0; i < getChildCount(); i++) {
+ syncAppsPageItems(i, true);
+ }
+ }
+ }
+ }
+
@Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
- Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
+ if (mSortMode == SortMode.Title) {
+ Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
+ } else if (mSortMode == SortMode.InstallDate) {
+ Collections.sort(mApps, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
+ }
updatePageCounts();
invalidateOnDataChange();
}
@@ -1739,7 +1936,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int count = list.size();
for (int i = 0; i < count; ++i) {
ApplicationInfo info = list.get(i);
- int index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
+ int index = 0;
+ if (mSortMode == SortMode.Title) {
+ index = Collections.binarySearch(mApps, info, LauncherModel.APP_NAME_COMPARATOR);
+ } else if (mSortMode == SortMode.InstallDate) {
+ index = Collections.binarySearch(mApps, info, LauncherModel.APP_INSTALL_TIME_COMPARATOR);
+ }
if (index < 0) {
mApps.add(-(index + 1), info);
}
@@ -1795,11 +1997,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// If we have reset, then we should not continue to restore the previous state
mSaveInstanceStateItemIndex = -1;
- AppsCustomizeTabHost tabHost = getTabHost();
- String tag = tabHost.getCurrentTabTag();
- if (tag != null) {
- if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
- tabHost.setCurrentTabFromContent(ContentType.Applications);
+ if (mJoinWidgetsApps) {
+ AppsCustomizeTabHost tabHost = getTabHost();
+ String tag = tabHost.getCurrentTabTag();
+ if (tag != null) {
+ if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
+ tabHost.setCurrentTabFromContent(ContentType.Applications);
+ }
+ }
+ } else {
+ if (mContentType != ContentType.Applications) {
+ // Reset to the first page of the Apps pane
+ AppsCustomizeTabHost tabs = (AppsCustomizeTabHost)
+ mLauncher.findViewById(R.id.apps_customize_pane);
+ tabs.selectAppsTab();
+ return;
}
}
@@ -1867,8 +2079,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
* We load an extra page on each side to prevent flashes from scrolling and loading of the
* widget previews in the background with the AsyncTasks.
*/
- final static int sLookBehindPageCount = 2;
- final static int sLookAheadPageCount = 2;
+ final static int sLookBehindPageCount = 3;
+ final static int sLookAheadPageCount = 3;
protected int getAssociatedLowerPageBound(int page) {
final int count = getChildCount();
int windowSize = Math.min(count, sLookBehindPageCount + sLookAheadPageCount + 1);
@@ -1887,17 +2099,30 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
protected String getCurrentPageDescription() {
int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
int stringId = R.string.default_scroll_format;
- int count = 0;
-
- if (page < mNumAppsPages) {
- stringId = R.string.apps_customize_apps_scroll_format;
- count = mNumAppsPages;
+
+ if (mJoinWidgetsApps) {
+ int count = 0;
+
+ if (page < mNumAppsPages) {
+ stringId = R.string.apps_customize_apps_scroll_format;
+ count = mNumAppsPages;
+ } else {
+ page -= mNumAppsPages;
+ stringId = R.string.apps_customize_widgets_scroll_format;
+ count = mNumWidgetPages;
+ }
+
+ return String.format(mContext.getString(stringId), page + 1, count);
} else {
- page -= mNumAppsPages;
- stringId = R.string.apps_customize_widgets_scroll_format;
- count = mNumWidgetPages;
+ switch (mContentType) {
+ case Applications:
+ stringId = R.string.apps_customize_apps_scroll_format;
+ break;
+ case Widgets:
+ stringId = R.string.apps_customize_widgets_scroll_format;
+ break;
+ }
+ return String.format(mContext.getString(stringId), page + 1, getChildCount());
}
-
- return String.format(getContext().getString(stringId), page + 1, count);
}
}
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
index 144aad9..1e1e730 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -34,7 +34,8 @@ import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
@@ -59,6 +60,10 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private Launcher mLauncher;
+ // Preferences
+ private boolean mJoinWidgetsApps;
+ private boolean mFadeScrollingIndicator;
+
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
super(context, attrs);
mLayoutInflater = LayoutInflater.from(context);
@@ -68,6 +73,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
mTabsContainer.setAlpha(1f);
}
};
+
+ mLauncher = (Launcher) context;
+
+ // Preferences
+ mJoinWidgetsApps = PreferencesProvider.Interface.Drawer.getJoinWidgetsApps(context);
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Drawer.Indicator.getFadeScrollingIndicator(context);
}
public void setup(Launcher launcher) {
@@ -92,6 +103,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
}
void selectWidgetsTab() {
setContentTypeImmediate(AppsCustomizePagedView.ContentType.Widgets);
+ mAppsCustomizePane.setCurrentPageToWidgets();
+
+ setCurrentTabByTag(WIDGETS_TAB_TAG);
}
/**
@@ -128,6 +142,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
tabView.setText(label);
tabView.setContentDescription(label);
+ tabView.setOnLongClickListener(new View.OnLongClickListener() {
+ public boolean onLongClick(View v) {
+ mLauncher.onLongClickAppsTab(v);
+ return true;
+ }
+ });
addTab(newTabSpec(APPS_TAB_TAG).setIndicator(tabView).setContent(contentFactory));
label = getContext().getString(R.string.widgets_tab_label);
tabView = (TextView) mLayoutInflater.inflate(R.layout.tab_widget_indicator, tabs, false);
@@ -209,27 +229,28 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
public void onTabChanged(String tabId) {
final AppsCustomizePagedView.ContentType type = getContentTypeForTabTag(tabId);
- // Animate the changing of the tab content by fading pages in and out
- final Resources res = getResources();
- final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
+ if (!mAppsCustomizePane.isContentType(type) || mJoinWidgetsApps) {
+
+ // Animate the changing of the tab content by fading pages in and out
+ final Resources res = getResources();
+ final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
- // We post a runnable here because there is a delay while the first page is loading and
- // the feedback from having changed the tab almost feels better than having it stick
- post(new Runnable() {
- @Override
- public void run() {
+ // We post a runnable here because there is a delay while the first page is loading and
+ // the feedback from having changed the tab almost feels better than having it stick
+ post(new Runnable() {
+ @Override
+ public void run() {
if (mAppsCustomizePane.getMeasuredWidth() <= 0 ||
- mAppsCustomizePane.getMeasuredHeight() <= 0) {
+ mAppsCustomizePane.getMeasuredHeight() <= 0) {
reloadCurrentPage();
return;
}
-
// Take the visible pages and re-parent them temporarily to mAnimatorBuffer
// and then cross fade to the new pages
int[] visiblePageRange = new int[2];
mAppsCustomizePane.getVisiblePages(visiblePageRange);
if (visiblePageRange[0] == -1 && visiblePageRange[1] == -1) {
- // If we can't get the visible page ranges, then just skip the animation
+ // If we can't get the visible page ranges, then just skip the animation
reloadCurrentPage();
return;
}
@@ -237,7 +258,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
visiblePages.add(mAppsCustomizePane.getPageAt(i));
}
-
// We want the pages to be rendered in exactly the same way as they were when
// their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
// to be exactly the same as mAppsCustomizePane, and below, set the left/top
@@ -262,39 +282,40 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
child.getMeasuredHeight());
p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
mAnimationBuffer.addView(child, p);
- }
- // Toggle the new content
- onTabChangedStart();
- onTabChangedEnd(type);
-
- // Animate the transition
- ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f);
- outAnim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mAnimationBuffer.setVisibility(View.GONE);
- mAnimationBuffer.removeAllViews();
- }
- @Override
- public void onAnimationCancel(Animator animation) {
- mAnimationBuffer.setVisibility(View.GONE);
- mAnimationBuffer.removeAllViews();
- }
- });
- ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
- inAnim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- reloadCurrentPage();
- }
- });
- AnimatorSet animSet = new AnimatorSet();
- animSet.playTogether(outAnim, inAnim);
- animSet.setDuration(duration);
- animSet.start();
- }
- });
+ // Toggle the new content
+ onTabChangedStart();
+ onTabChangedEnd(type);
+
+ // Animate the transition
+ ObjectAnimator outAnim = ObjectAnimator.ofFloat(mAnimationBuffer, "alpha", 0f);
+ outAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mAnimationBuffer.setVisibility(View.GONE);
+ mAnimationBuffer.removeAllViews();
+ }
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mAnimationBuffer.setVisibility(View.GONE);
+ mAnimationBuffer.removeAllViews();
+ }
+ });
+ ObjectAnimator inAnim = ObjectAnimator.ofFloat(mAppsCustomizePane, "alpha", 1f);
+ inAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ reloadCurrentPage();
+ }
+ });
+ AnimatorSet animSet = new AnimatorSet();
+ animSet.playTogether(outAnim, inAnim);
+ animSet.setDuration(duration);
+ animSet.start();
+ }}
+ });
+
+ }
}
public void setCurrentTabFromContent(AppsCustomizePagedView.ContentType type) {
@@ -435,7 +456,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
// prevent slowing down the animation)
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
- if (!LauncherApplication.isScreenLarge()) {
+ if (!LauncherApplication.isScreenLarge() && mFadeScrollingIndicator) {
mAppsCustomizePane.hideScrollingIndicator(false);
}
}
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/cyanogenmod/trebuchet/BubbleTextView.java
index ddc4b9f..405deab 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/cyanogenmod/trebuchet/BubbleTextView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
@@ -61,6 +61,9 @@ public class BubbleTextView extends TextView {
private boolean mStayPressed;
private CheckLongPressHelper mLongPressHelper;
+ private boolean mTextVisible = true;
+ private CharSequence mVisibleText;
+
public BubbleTextView(Context context) {
super(context);
init();
@@ -331,4 +334,15 @@ public class BubbleTextView extends TextView {
mLongPressHelper.cancelLongPress();
}
+
+ public void setTextVisible(boolean visible) {
+ if (mTextVisible == visible) return;
+ mTextVisible = visible;
+ if (visible) {
+ setText(mVisibleText);
+ } else {
+ mVisibleText = getText();
+ setText("");
+ }
+ }
}
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/cyanogenmod/trebuchet/ButtonDropTarget.java
index 1c9fa5f..8f819ea 100644
--- a/src/com/android/launcher2/ButtonDropTarget.java
+++ b/src/com/cyanogenmod/trebuchet/ButtonDropTarget.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
@@ -24,7 +24,7 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.TextView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/cyanogenmod/trebuchet/CellLayout.java
index 97d9bc1..6f1d12d 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/cyanogenmod/trebuchet/CellLayout.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -49,8 +49,8 @@ import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LayoutAnimationController;
-import com.android.launcher.R;
-import com.android.launcher2.FolderIcon.FolderRingAnimator;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.FolderIcon.FolderRingAnimator;
import java.util.ArrayList;
import java.util.Arrays;
@@ -278,7 +278,6 @@ public class CellLayout extends ViewGroup {
mForegroundRect = new Rect();
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context);
- mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
addView(mShortcutsAndWidgets);
}
@@ -938,6 +937,11 @@ public class CellLayout extends ViewGroup {
int numWidthGaps = mCountX - 1;
int numHeightGaps = mCountY - 1;
+ if (!LauncherApplication.isScreenLarge()){
+ mCellWidth = (widthSpecSize - mPaddingLeft - mPaddingRight) / mCountX;
+ mCellHeight = (heightSpecSize - mPaddingTop - mPaddingBottom) / mCountY;
+ }
+
if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) {
int hSpace = widthSpecSize - getPaddingLeft() - getPaddingRight();
int vSpace = heightSpecSize - getPaddingTop() - getPaddingBottom();
@@ -945,12 +949,13 @@ public class CellLayout extends ViewGroup {
int vFreeSpace = vSpace - (mCountY * mCellHeight);
mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
- mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
} else {
mWidthGap = mOriginalWidthGap;
mHeightGap = mOriginalHeightGap;
}
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
+
// Initial values correspond to widthSpecMode == MeasureSpec.EXACTLY
int newWidth = widthSpecSize;
int newHeight = heightSpecSize;
diff --git a/src/com/android/launcher2/CheckLongPressHelper.java b/src/com/cyanogenmod/trebuchet/CheckLongPressHelper.java
index 5c3752a..4b17fee 100644
--- a/src/com/android/launcher2/CheckLongPressHelper.java
+++ b/src/com/cyanogenmod/trebuchet/CheckLongPressHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.view.View;
diff --git a/src/com/android/launcher2/Cling.java b/src/com/cyanogenmod/trebuchet/Cling.java
index 646c54e..0913db5 100644
--- a/src/com/android/launcher2/Cling.java
+++ b/src/com/cyanogenmod/trebuchet/Cling.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
@@ -34,12 +34,13 @@ import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.widget.FrameLayout;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class Cling extends FrameLayout {
static final String WORKSPACE_CLING_DISMISSED_KEY = "cling.workspace.dismissed";
static final String ALLAPPS_CLING_DISMISSED_KEY = "cling.allapps.dismissed";
+ static final String ALLAPPS_SORT_CLING_DISMISSED_KEY = "cling.allappssort.dismissed";
static final String FOLDER_CLING_DISMISSED_KEY = "cling.folder.dismissed";
private static String WORKSPACE_PORTRAIT = "workspace_portrait";
@@ -51,9 +52,12 @@ public class Cling extends FrameLayout {
private static String ALLAPPS_LANDSCAPE = "all_apps_landscape";
private static String ALLAPPS_LARGE = "all_apps_large";
+ private static String ALLAPPS_SORT_PORTRAIT = "all_apps_sort_portrait";
+ private static String ALLAPPS_SORT_LANDSCAPE = "all_apps_sort_landscape";
private static String FOLDER_PORTRAIT = "folder_portrait";
private static String FOLDER_LANDSCAPE = "folder_landscape";
private static String FOLDER_LARGE = "folder_large";
+ private static String ALLAPPS_SORT_LARGE = "all_apps_sort_large";
private Launcher mLauncher;
private boolean mIsInitialized;
@@ -66,6 +70,7 @@ public class Cling extends FrameLayout {
private int mButtonBarHeight;
private float mRevealRadius;
private int[] mPositionData;
+ private boolean mDismissed;
private Paint mErasePaint;
@@ -89,6 +94,7 @@ public class Cling extends FrameLayout {
if (!mIsInitialized) {
mLauncher = l;
mPositionData = positionData;
+ mDismissed = false;
Resources r = getContext().getResources();
@@ -108,6 +114,14 @@ public class Cling extends FrameLayout {
}
}
+ void dismiss() {
+ mDismissed = true;
+ }
+
+ boolean isDismissed() {
+ return mDismissed;
+ }
+
void cleanup() {
mBackground = null;
mPunchThroughGraphic = null;
@@ -124,6 +138,10 @@ public class Cling extends FrameLayout {
return new int[]{getMeasuredWidth() / 2, getMeasuredHeight() - (mButtonBarHeight / 2)};
} else if (mDrawIdentifier.equals(WORKSPACE_LANDSCAPE)) {
return new int[]{getMeasuredWidth() - (mButtonBarHeight / 2), getMeasuredHeight() / 2};
+ } else if (mDrawIdentifier.equals(ALLAPPS_SORT_PORTRAIT) ||
+ mDrawIdentifier.equals(ALLAPPS_SORT_LANDSCAPE) ||
+ mDrawIdentifier.equals(ALLAPPS_SORT_LARGE)) {
+ return new int[]{mButtonBarHeight / 2, mButtonBarHeight / 2};
} else if (mDrawIdentifier.equals(WORKSPACE_LARGE)) {
final float scale = LauncherApplication.getScreenDensity();
final int cornerXOffset = (int) (scale * 15);
@@ -173,7 +191,10 @@ public class Cling extends FrameLayout {
mDrawIdentifier.equals(WORKSPACE_LARGE) ||
mDrawIdentifier.equals(ALLAPPS_PORTRAIT) ||
mDrawIdentifier.equals(ALLAPPS_LANDSCAPE) ||
- mDrawIdentifier.equals(ALLAPPS_LARGE)) {
+ mDrawIdentifier.equals(ALLAPPS_LARGE) ||
+ mDrawIdentifier.equals(ALLAPPS_SORT_PORTRAIT) ||
+ mDrawIdentifier.equals(ALLAPPS_SORT_LANDSCAPE) ||
+ mDrawIdentifier.equals(ALLAPPS_SORT_LARGE)) {
int[] positions = getPunchThroughPositions();
for (int i = 0; i < positions.length; i += 2) {
diff --git a/src/com/android/launcher2/DeferredHandler.java b/src/com/cyanogenmod/trebuchet/DeferredHandler.java
index b7e48b1..aeb82b9 100644
--- a/src/com/android/launcher2/DeferredHandler.java
+++ b/src/com/cyanogenmod/trebuchet/DeferredHandler.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.LinkedList;
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java
index 949c035..2cc872a 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java
@@ -14,20 +14,23 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.TransitionDrawable;
+import android.os.Handler;
import android.util.AttributeSet;
+import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
@@ -35,7 +38,7 @@ import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class DeleteDropTarget extends ButtonDropTarget {
private static int DELETE_ANIMATION_DURATION = 285;
@@ -46,10 +49,18 @@ public class DeleteDropTarget extends ButtonDropTarget {
private final int mFlingDeleteMode = MODE_FLING_DELETE_ALONG_VECTOR;
+ private static final int MODE_DELETE = 0;
+ private static final int MODE_UNINSTALL = 1;
+ private int mMode = MODE_DELETE;
+
private ColorStateList mOriginalTextColor;
- private TransitionDrawable mUninstallDrawable;
- private TransitionDrawable mRemoveDrawable;
- private TransitionDrawable mCurrentDrawable;
+ private Drawable mUninstallActiveDrawable;
+ private Drawable mRemoveActiveDrawable;
+ private Drawable mRemoveNormalDrawable;
+ private Drawable mCurrentDrawable;
+ private boolean mUninstall;
+
+ private final Handler mHandler = new Handler();
public DeleteDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -59,6 +70,13 @@ public class DeleteDropTarget extends ButtonDropTarget {
super(context, attrs, defStyle);
}
+ private final Runnable mShowUninstaller = new Runnable() {
+ public void run() {
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
+ switchToUninstallTarget();
+ }
+ };
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -69,16 +87,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
// Get the hover color
Resources r = getResources();
mHoverColor = r.getColor(R.color.delete_target_hover_tint);
- mUninstallDrawable = (TransitionDrawable)
- r.getDrawable(R.drawable.uninstall_target_selector);
- mRemoveDrawable = (TransitionDrawable) r.getDrawable(R.drawable.remove_target_selector);
-
- mRemoveDrawable.setCrossFadeEnabled(true);
- mUninstallDrawable.setCrossFadeEnabled(true);
-
- // The current drawable is set to either the remove drawable or the uninstall drawable
- // and is initially set to the remove drawable, as set in the layout xml.
- mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
+ mUninstallActiveDrawable = r.getDrawable(R.drawable.ic_launcher_trashcan_active_holo);
+ mRemoveActiveDrawable = r.getDrawable(R.drawable.ic_launcher_clear_active_holo);
+ mRemoveNormalDrawable = r.getDrawable(R.drawable.ic_launcher_clear_normal_holo);
// Remove the text in the Phone UI in landscape
int orientation = getResources().getConfiguration().orientation;
@@ -89,6 +100,9 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
}
+ private boolean isAllAppsItem(DragSource source, Object info) {
+ return isAllAppsApplication(source, info) || isAllAppsWidget(source, info);
+ }
private boolean isAllAppsApplication(DragSource source, Object info) {
return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo);
}
@@ -105,25 +119,23 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
return false;
}
- private boolean isDragSourceWorkspaceOrFolder(DragObject d) {
- return (d.dragSource instanceof Workspace) || (d.dragSource instanceof Folder);
+ private boolean isDragSourceWorkspaceOrFolder(DragSource source) {
+ return (source instanceof Workspace) || (source instanceof Folder);
}
- private boolean isWorkspaceOrFolderApplication(DragObject d) {
- return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof ShortcutInfo);
+ private boolean isWorkspaceOrFolderApplication(DragSource source, Object info) {
+ return isDragSourceWorkspaceOrFolder(source) && (info instanceof ShortcutInfo);
}
- private boolean isWorkspaceOrFolderWidget(DragObject d) {
- return isDragSourceWorkspaceOrFolder(d) && (d.dragInfo instanceof LauncherAppWidgetInfo);
+ private boolean isWorkspaceWidget(DragSource source, Object info) {
+ return isDragSourceWorkspaceOrFolder(source) && (info instanceof LauncherAppWidgetInfo);
}
- private boolean isWorkspaceFolder(DragObject d) {
- return (d.dragSource instanceof Workspace) && (d.dragInfo instanceof FolderInfo);
+ private boolean isWorkspaceFolder(DragSource source, Object info) {
+ return (source instanceof Workspace) && (info instanceof FolderInfo);
}
private void setHoverColor() {
- mCurrentDrawable.startTransition(mTransitionDuration);
setTextColor(mHoverColor);
}
private void resetHoverColor() {
- mCurrentDrawable.resetTransition();
setTextColor(mOriginalTextColor);
}
@@ -135,57 +147,98 @@ public class DeleteDropTarget extends ButtonDropTarget {
@Override
public void onDragStart(DragSource source, Object info, int dragAction) {
- boolean isVisible = true;
boolean isUninstall = false;
- // If we are dragging a widget from AppsCustomize, hide the delete target
- if (isAllAppsWidget(source, info)) {
- isVisible = false;
- }
-
- // If we are dragging an application from AppsCustomize, only show the control if we can
- // delete the app (it was downloaded), and rename the string to "uninstall" in such a case
+ // If we are dragging an application from AppsCustomize, only show the uninstall control if we
+ // can delete the app (it was downloaded)
if (isAllAppsApplication(source, info)) {
ApplicationInfo appInfo = (ApplicationInfo) info;
if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) != 0) {
isUninstall = true;
+ }
+ } else if (isWorkspaceOrFolderApplication(source, info)) {
+ ShortcutInfo shortcutInfo = (ShortcutInfo) info;
+ PackageManager pm = getContext().getPackageManager();
+ ResolveInfo resolveInfo = pm.resolveActivity(shortcutInfo.intent, 0);
+ if (resolveInfo != null && (resolveInfo.activityInfo.applicationInfo.flags &
+ android.content.pm.ApplicationInfo.FLAG_SYSTEM) == 0) {
+ isUninstall = true;
+ }
+ }
+
+ setCompoundDrawablesWithIntrinsicBounds(mRemoveNormalDrawable, null, null, null);
+ mCurrentDrawable = getCompoundDrawables()[0];
+
+ mUninstall = isUninstall;
+ mActive = true;
+ mMode = MODE_DELETE;
+
+ setTextColor(mOriginalTextColor);
+ resetHoverColor();
+ ((ViewGroup) getParent()).setVisibility(View.VISIBLE);
+ if (getText().length() > 0) {
+ if (isAllAppsItem(source, info)) {
+ setText(R.string.cancel_target_label);
} else {
- isVisible = false;
+ setText(R.string.delete_target_label);
}
}
+ }
- if (isUninstall) {
- setCompoundDrawablesWithIntrinsicBounds(mUninstallDrawable, null, null, null);
- } else {
- setCompoundDrawablesWithIntrinsicBounds(mRemoveDrawable, null, null, null);
+ private void switchToUninstallTarget() {
+ if (!mUninstall) {
+ return;
}
- mCurrentDrawable = (TransitionDrawable) getCurrentDrawable();
- mActive = isVisible;
- resetHoverColor();
- ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
+ mMode = MODE_UNINSTALL;
+
if (getText().length() > 0) {
- setText(isUninstall ? R.string.delete_target_uninstall_label
- : R.string.delete_target_label);
+ setText(R.string.delete_target_uninstall_label);
}
+
+ setCompoundDrawablesWithIntrinsicBounds(mUninstallActiveDrawable, null, null, null);
+ mCurrentDrawable = getCompoundDrawables()[0];
}
@Override
public void onDragEnd() {
super.onDragEnd();
+
mActive = false;
}
public void onDragEnter(DragObject d) {
super.onDragEnter(d);
+ if (mUninstall) {
+ mHandler.removeCallbacks(mShowUninstaller);
+ mHandler.postDelayed(mShowUninstaller, 1000);
+ }
+
+ setCompoundDrawablesWithIntrinsicBounds(mRemoveActiveDrawable, null, null, null);
+ mCurrentDrawable = getCompoundDrawables()[0];
+
setHoverColor();
}
public void onDragExit(DragObject d) {
super.onDragExit(d);
+ mHandler.removeCallbacks(mShowUninstaller);
+
if (!d.dragComplete) {
+ mMode = MODE_DELETE;
+
+ if (getText().length() > 0) {
+ if (isAllAppsItem(d.dragSource, d.dragInfo)) {
+ setText(R.string.cancel_target_label);
+ } else {
+ setText(R.string.delete_target_label);
+ }
+ }
+
+ setCompoundDrawablesWithIntrinsicBounds(mRemoveNormalDrawable, null, null, null);
+ mCurrentDrawable = getCompoundDrawables()[0];
resetHoverColor();
} else {
// Restore the hover color if we are deleting
@@ -219,32 +272,42 @@ public class DeleteDropTarget extends ButtonDropTarget {
private void completeDrop(DragObject d) {
ItemInfo item = (ItemInfo) d.dragInfo;
- if (isAllAppsApplication(d.dragSource, item)) {
- // Uninstall the application if it is being dragged from AppsCustomize
- mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
- } else if (isWorkspaceOrFolderApplication(d)) {
- LauncherModel.deleteItemFromDatabase(mLauncher, item);
- } else if (isWorkspaceFolder(d)) {
- // Remove the folder from the workspace and delete the contents from launcher model
- FolderInfo folderInfo = (FolderInfo) item;
- mLauncher.removeFolder(folderInfo);
- LauncherModel.deleteFolderContentsFromDatabase(mLauncher, folderInfo);
- } else if (isWorkspaceOrFolderWidget(d)) {
- // Remove the widget from the workspace
- mLauncher.removeAppWidget((LauncherAppWidgetInfo) item);
- LauncherModel.deleteItemFromDatabase(mLauncher, item);
-
- final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item;
- final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost();
- if (appWidgetHost != null) {
- // Deleting an app widget ID is a void call but writes to disk before returning
- // to the caller...
- new Thread("deleteAppWidgetId") {
- public void run() {
- appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
+ switch (mMode) {
+ case MODE_DELETE:
+ if (isWorkspaceOrFolderApplication(d.dragSource, item)) {
+ LauncherModel.deleteItemFromDatabase(mLauncher, item);
+ } else if (isWorkspaceFolder(d.dragSource, d.dragInfo)) {
+ // Remove the folder from the workspace and delete the contents from launcher model
+ FolderInfo folderInfo = (FolderInfo) item;
+ mLauncher.removeFolder(folderInfo);
+ LauncherModel.deleteFolderContentsFromDatabase(mLauncher, folderInfo);
+ } else if (isWorkspaceWidget(d.dragSource, item)) {
+ // Remove the widget from the workspace
+ mLauncher.removeAppWidget((LauncherAppWidgetInfo) item);
+ LauncherModel.deleteItemFromDatabase(mLauncher, item);
+
+ final LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) item;
+ final LauncherAppWidgetHost appWidgetHost = mLauncher.getAppWidgetHost();
+ if (appWidgetHost != null) {
+ // Deleting an app widget ID is a void call but writes to disk before returning
+ // to the caller...
+ new Thread("deleteAppWidgetId") {
+ public void run() {
+ appWidgetHost.deleteAppWidgetId(launcherAppWidgetInfo.appWidgetId);
+ }
+ }.start();
}
- }.start();
- }
+ }
+ break;
+ case MODE_UNINSTALL:
+ if (isAllAppsApplication(d.dragSource, item)) {
+ // Uninstall the application
+ mLauncher.startApplicationUninstallActivity((ApplicationInfo) item);
+ } else if (isWorkspaceOrFolderApplication(d.dragSource, item)) {
+ // Uninstall the shortcut
+ mLauncher.startShortcutUninstallActivity((ShortcutInfo) item);
+ }
+ break;
}
}
diff --git a/src/com/android/launcher2/DragController.java b/src/com/cyanogenmod/trebuchet/DragController.java
index 84f1515..cdb5060 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/cyanogenmod/trebuchet/DragController.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
@@ -33,7 +33,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.inputmethod.InputMethodManager;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.util.ArrayList;
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/cyanogenmod/trebuchet/DragLayer.java
index 4be1914..d15defd 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/cyanogenmod/trebuchet/DragLayer.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -41,7 +41,7 @@ import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.TextView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.util.ArrayList;
@@ -169,8 +169,8 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
- Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
- if (currentFolder == null) {
+ Folder currentFolder;
+ if (mLauncher.getWorkspace()==null || (currentFolder = mLauncher.getWorkspace().getOpenFolder())==null) {
return false;
} else {
AccessibilityManager accessibilityManager = (AccessibilityManager)
diff --git a/src/com/android/launcher2/DragScroller.java b/src/com/cyanogenmod/trebuchet/DragScroller.java
index a3ee6c2..5c47fc6 100644
--- a/src/com/android/launcher2/DragScroller.java
+++ b/src/com/cyanogenmod/trebuchet/DragScroller.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
/**
* Handles scrolling while dragging
diff --git a/src/com/android/launcher2/DragSource.java b/src/com/cyanogenmod/trebuchet/DragSource.java
index 5440477..3f5ef0e 100644
--- a/src/com/android/launcher2/DragSource.java
+++ b/src/com/cyanogenmod/trebuchet/DragSource.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.view.View;
-import com.android.launcher2.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.DropTarget.DragObject;
/**
* Interface defining an object that can originate a drag.
diff --git a/src/com/android/launcher2/DragView.java b/src/com/cyanogenmod/trebuchet/DragView.java
index b6645e1..9eefe29 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/cyanogenmod/trebuchet/DragView.java
@@ -15,7 +15,7 @@
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
@@ -30,7 +30,7 @@ import android.graphics.Rect;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class DragView extends View {
private static float sDragAlpha = 1f;
diff --git a/src/com/android/launcher2/DrawableStateProxyView.java b/src/com/cyanogenmod/trebuchet/DrawableStateProxyView.java
index 5d2f6e0..dcaad35 100644
--- a/src/com/android/launcher2/DrawableStateProxyView.java
+++ b/src/com/cyanogenmod/trebuchet/DrawableStateProxyView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.TypedArray;
@@ -23,7 +23,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class DrawableStateProxyView extends LinearLayout {
diff --git a/src/com/android/launcher2/DropTarget.java b/src/com/cyanogenmod/trebuchet/DropTarget.java
index d627a4c..6a929cb 100644
--- a/src/com/android/launcher2/DropTarget.java
+++ b/src/com/cyanogenmod/trebuchet/DropTarget.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.graphics.PointF;
diff --git a/src/com/android/launcher2/FastBitmapDrawable.java b/src/com/cyanogenmod/trebuchet/FastBitmapDrawable.java
index d317d33..732e4c1 100644
--- a/src/com/android/launcher2/FastBitmapDrawable.java
+++ b/src/com/cyanogenmod/trebuchet/FastBitmapDrawable.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.graphics.Bitmap;
import android.graphics.Canvas;
diff --git a/src/com/android/launcher2/FocusHelper.java b/src/com/cyanogenmod/trebuchet/FocusHelper.java
index e9f986d..d87fc67 100644
--- a/src/com/android/launcher2/FocusHelper.java
+++ b/src/com/cyanogenmod/trebuchet/FocusHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.res.Configuration;
import android.view.KeyEvent;
@@ -24,7 +24,7 @@ import android.view.ViewParent;
import android.widget.TabHost;
import android.widget.TabWidget;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/src/com/android/launcher2/FocusOnlyTabWidget.java b/src/com/cyanogenmod/trebuchet/FocusOnlyTabWidget.java
index 8e9f58c..795b621 100644
--- a/src/com/android/launcher2/FocusOnlyTabWidget.java
+++ b/src/com/cyanogenmod/trebuchet/FocusOnlyTabWidget.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/com/android/launcher2/Folder.java b/src/com/cyanogenmod/trebuchet/Folder.java
index de2e435..010091f 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/cyanogenmod/trebuchet/Folder.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -44,8 +44,9 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.TextView;
-import com.android.launcher.R;
-import com.android.launcher2.FolderInfo.FolderListener;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.FolderInfo.FolderListener;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
import java.util.Collections;
@@ -172,6 +173,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mFolderName.setSelectAllOnFocus(true);
mFolderName.setInputType(mFolderName.getInputType() |
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
+
+ if (PreferencesProvider.Interface.Homescreen.getHideIconLabels(mLauncher)){
+ mFolderName.setVisibility(View.GONE);
+ mFolderNameHeight = getPaddingBottom();
+ }
}
private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
@@ -254,7 +260,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
// Convert to a string here to ensure that no other state associated with the text field
// gets saved.
String newTitle = mFolderName.getText().toString();
- mInfo.setTitle(newTitle);
+ if (!PreferencesProvider.Interface.Homescreen.getHideIconLabels(mLauncher)) {
+ mInfo.setTitle(newTitle);
+ }
LauncherModel.updateItemInDatabase(mLauncher, mInfo);
if (commit) {
diff --git a/src/com/android/launcher2/FolderEditText.java b/src/com/cyanogenmod/trebuchet/FolderEditText.java
index 13169bd..4504460 100644
--- a/src/com/android/launcher2/FolderEditText.java
+++ b/src/com/cyanogenmod/trebuchet/FolderEditText.java
@@ -1,4 +1,4 @@
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/cyanogenmod/trebuchet/FolderIcon.java
index 4919b57..556b47f 100644
--- a/src/com/android/launcher2/FolderIcon.java
+++ b/src/com/cyanogenmod/trebuchet/FolderIcon.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -39,9 +39,9 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import com.android.launcher.R;
-import com.android.launcher2.DropTarget.DragObject;
-import com.android.launcher2.FolderInfo.FolderListener;
+import com.cyanogenmod.trebuchet.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.FolderInfo.FolderListener;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
@@ -281,7 +281,8 @@ public class FolderIcon extends LinearLayout implements FolderListener {
private boolean willAcceptItem(ItemInfo item) {
final int itemType = item.itemType;
return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
- itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) &&
+ itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT ||
+ itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) &&
!mFolder.isFull() && item != mInfo && !mInfo.opened);
}
@@ -392,6 +393,15 @@ public class FolderIcon extends LinearLayout implements FolderListener {
if (d.dragInfo instanceof ApplicationInfo) {
// Came from all apps -- make a copy
item = ((ApplicationInfo) d.dragInfo).makeShortcut();
+ } else if (d.dragInfo instanceof FolderInfo) {
+ FolderInfo folder = (FolderInfo) d.dragInfo;
+ mFolder.notifyDrop();
+ for (ShortcutInfo fItem : folder.contents) {
+ onDrop(fItem, d.dragView, null, 1.0f, mInfo.contents.size(), d.postAnimationRunnable, d);
+ }
+ mLauncher.removeFolder(folder);
+ LauncherModel.deleteItemFromDatabase(mLauncher, folder);
+ return;
} else {
item = (ShortcutInfo) d.dragInfo;
}
diff --git a/src/com/android/launcher2/FolderInfo.java b/src/com/cyanogenmod/trebuchet/FolderInfo.java
index f597076..dd896fd 100644
--- a/src/com/android/launcher2/FolderInfo.java
+++ b/src/com/cyanogenmod/trebuchet/FolderInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.ArrayList;
diff --git a/src/com/android/launcher2/HandleView.java b/src/com/cyanogenmod/trebuchet/HandleView.java
index d77138b..8944888 100644
--- a/src/com/android/launcher2/HandleView.java
+++ b/src/com/cyanogenmod/trebuchet/HandleView.java
@@ -15,7 +15,7 @@
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.TypedArray;
@@ -24,7 +24,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class HandleView extends ImageView {
private static final int ORIENTATION_HORIZONTAL = 1;
diff --git a/src/com/android/launcher2/HolographicImageView.java b/src/com/cyanogenmod/trebuchet/HolographicImageView.java
index 9e551e0..d159358 100644
--- a/src/com/android/launcher2/HolographicImageView.java
+++ b/src/com/cyanogenmod/trebuchet/HolographicImageView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.graphics.Canvas;
diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/cyanogenmod/trebuchet/HolographicLinearLayout.java
index 0f997d5..3af5415 100644
--- a/src/com/android/launcher2/HolographicLinearLayout.java
+++ b/src/com/cyanogenmod/trebuchet/HolographicLinearLayout.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.TypedArray;
@@ -25,7 +25,7 @@ import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class HolographicLinearLayout extends LinearLayout {
diff --git a/src/com/android/launcher2/HolographicOutlineHelper.java b/src/com/cyanogenmod/trebuchet/HolographicOutlineHelper.java
index 56d194d..e2d2eaa 100644
--- a/src/com/android/launcher2/HolographicOutlineHelper.java
+++ b/src/com/cyanogenmod/trebuchet/HolographicOutlineHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.graphics.Bitmap;
import android.graphics.BlurMaskFilter;
diff --git a/src/com/android/launcher2/HolographicViewHelper.java b/src/com/cyanogenmod/trebuchet/HolographicViewHelper.java
index fd49908..068a8f5 100644
--- a/src/com/android/launcher2/HolographicViewHelper.java
+++ b/src/com/cyanogenmod/trebuchet/HolographicViewHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
diff --git a/src/com/android/launcher2/Hotseat.java b/src/com/cyanogenmod/trebuchet/Hotseat.java
index 15d606d..7463d65 100644
--- a/src/com/android/launcher2/Hotseat.java
+++ b/src/com/cyanogenmod/trebuchet/Hotseat.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Configuration;
@@ -25,7 +25,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class Hotseat extends FrameLayout {
@SuppressWarnings("unused")
@@ -39,6 +39,9 @@ public class Hotseat extends FrameLayout {
private int mAllAppsButtonRank;
private boolean mIsLandscape;
+ private static final int DEFAULT_CELL_COUNT_X = 5;
+ private static final int DEFAULT_CELL_COUNT_Y = 1;
+
public Hotseat(Context context) {
this(context, null);
}
@@ -86,8 +89,8 @@ public class Hotseat extends FrameLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- if (mCellCountX < 0) mCellCountX = LauncherModel.getCellCountX();
- if (mCellCountY < 0) mCellCountY = LauncherModel.getCellCountY();
+ if (mCellCountX < 0) mCellCountX = DEFAULT_CELL_COUNT_X;
+ if (mCellCountY < 0) mCellCountY = DEFAULT_CELL_COUNT_Y;
mContent = (CellLayout) findViewById(R.id.layout);
mContent.setGridSize(mCellCountX, mCellCountY);
mContent.setIsHotseat(true);
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/cyanogenmod/trebuchet/IconCache.java
index aa19545..15b49ba 100644
--- a/src/com/android/launcher2/IconCache.java
+++ b/src/com/cyanogenmod/trebuchet/IconCache.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.app.ActivityManager;
import android.content.ComponentName;
diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/cyanogenmod/trebuchet/InfoDropTarget.java
index d6bf5f2..c24bf8b 100644
--- a/src/com/android/launcher2/InfoDropTarget.java
+++ b/src/com/cyanogenmod/trebuchet/InfoDropTarget.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.ComponentName;
import android.content.Context;
@@ -26,7 +26,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
public class InfoDropTarget extends ButtonDropTarget {
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
index a525d00..9f61430 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/cyanogenmod/trebuchet/InstallShortcutReceiver.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -25,7 +25,8 @@ import android.content.pm.PackageManager;
import android.os.Debug;
import android.widget.Toast;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.util.ArrayList;
import java.util.HashSet;
@@ -47,7 +48,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
// A mime-type representing shortcut data
public static final String SHORTCUT_MIMETYPE =
- "com.android.launcher/shortcut";
+ "com.cyanogenmod.trebuchet/shortcut";
// The set of shortcuts that are pending install
private static ArrayList<PendingInstallShortcutInfo> mInstallQueue =
@@ -137,10 +138,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
// Try adding to the workspace screens incrementally, starting at the default or center
// screen and alternating between +1, -1, +2, -2, etc. (using ~ ceil(i/2f)*(-1)^(i-1))
- final int screen = Launcher.DEFAULT_SCREEN;
- for (int i = 0; i < (2 * Launcher.SCREEN_COUNT) + 1 && !found; ++i) {
+ final int screenCount = PreferencesProvider.Interface.Homescreen.getNumberHomescreens(context);
+ final int screenDefault = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(context, screenCount / 2);
+ final int screen = (screenDefault >= screenCount) ? screenCount / 2 : screenDefault;
+
+ for (int i = 0; i <= (2 * screenCount) + 1 && !found; ++i) {
int si = screen + (int) ((i / 2f) + 0.5f) * ((i % 2 == 1) ? 1 : -1);
- if (0 <= si && si < Launcher.SCREEN_COUNT) {
+ if (0 <= si && si < screenCount) {
found = installShortcut(context, data, items, name, intent, si, exists, sp,
result);
}
diff --git a/src/com/android/launcher2/InstallWidgetReceiver.java b/src/com/cyanogenmod/trebuchet/InstallWidgetReceiver.java
index a1e9b11..a133f51 100644
--- a/src/com/android/launcher2/InstallWidgetReceiver.java
+++ b/src/com/cyanogenmod/trebuchet/InstallWidgetReceiver.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.List;
@@ -33,7 +33,7 @@ import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
@@ -42,18 +42,18 @@ import com.android.launcher.R;
*/
public class InstallWidgetReceiver {
public static final String ACTION_INSTALL_WIDGET =
- "com.android.launcher.action.INSTALL_WIDGET";
+ "com.cyanogenmod.trebuchet.action.INSTALL_WIDGET";
public static final String ACTION_SUPPORTS_CLIPDATA_MIMETYPE =
- "com.android.launcher.action.SUPPORTS_CLIPDATA_MIMETYPE";
+ "com.cyanogenmod.trebuchet.action.SUPPORTS_CLIPDATA_MIMETYPE";
// Currently not exposed. Put into Intent when we want to make it public.
// TEMP: Should we call this "EXTRA_APPWIDGET_PROVIDER"?
public static final String EXTRA_APPWIDGET_COMPONENT =
- "com.android.launcher.extra.widget.COMPONENT";
+ "com.cyanogenmod.trebuchet.extra.widget.COMPONENT";
public static final String EXTRA_APPWIDGET_CONFIGURATION_DATA_MIME_TYPE =
- "com.android.launcher.extra.widget.CONFIGURATION_DATA_MIME_TYPE";
+ "com.cyanogenmod.trebuchet.extra.widget.CONFIGURATION_DATA_MIME_TYPE";
public static final String EXTRA_APPWIDGET_CONFIGURATION_DATA =
- "com.android.launcher.extra.widget.CONFIGURATION_DATA";
+ "com.cyanogenmod.trebuchet.extra.widget.CONFIGURATION_DATA";
/**
* A simple data class that contains per-item information that the adapter below can reference.
diff --git a/src/com/android/launcher2/InterruptibleInOutAnimator.java b/src/com/cyanogenmod/trebuchet/InterruptibleInOutAnimator.java
index 135fa39..82ec2d8 100644
--- a/src/com/android/launcher2/InterruptibleInOutAnimator.java
+++ b/src/com/cyanogenmod/trebuchet/InterruptibleInOutAnimator.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/cyanogenmod/trebuchet/ItemInfo.java
index dedc0f4..c76108f 100644
--- a/src/com/android/launcher2/ItemInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ItemInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.ContentValues;
import android.content.Intent;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java
index 38085e0..f32b11c 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.accounts.Account;
import android.accounts.AccountManager;
@@ -45,6 +45,7 @@ import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
@@ -89,12 +90,14 @@ import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.ImageView;
+import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
import com.android.common.Search;
-import com.android.launcher.R;
-import com.android.launcher2.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.DropTarget.DragObject;
+import com.cyanogenmod.trebuchet.preference.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -127,7 +130,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_SYSTEM_SETTINGS = MENU_MANAGE_APPS + 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;
private static final int REQUEST_CREATE_SHORTCUT = 1;
@@ -141,7 +145,7 @@ public final class Launcher extends Activity
static final String EXTRA_SHORTCUT_DUPLICATE = "duplicate";
- static final int SCREEN_COUNT = 5;
+ static final int MAX_SCREEN_COUNT = 7;
static final int DEFAULT_SCREEN = 2;
private static final String PREFERENCES = "launcher.preferences";
@@ -149,7 +153,7 @@ public final class Launcher extends Activity
// The Intent extra that defines whether to ignore the launch animation
static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
- "com.android.launcher.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
+ "com.cyanogenmod.trebuchet.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
// Type: int
private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen";
@@ -297,6 +301,12 @@ public final class Launcher extends Activity
private BubbleTextView mWaitingForResume;
+ // Preferences
+ private boolean mShowSearchBar;
+ private boolean mShowDockDivider;
+ private boolean mHideIconLabels;
+ private boolean mAutoRotate;
+
private Runnable mBuildLayersRunnable = new Runnable() {
public void run() {
if (mWorkspace != null) {
@@ -347,6 +357,12 @@ public final class Launcher extends Activity
mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
mAppWidgetHost.startListening();
+ // Preferences
+ mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(this);
+ mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(this);
+ mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels(this);
+ mAutoRotate = PreferencesProvider.Interface.General.getAutoRotate(this, getResources().getBoolean(R.bool.allow_rotation));
+
// If we are getting an onCreate, we can actually preempt onResume and unset mPaused here,
// this also ensures that any synchronous binding below doesn't re-trigger another
// LauncherModel load.
@@ -710,6 +726,11 @@ public final class Launcher extends Activity
InstallShortcutReceiver.flushInstallQueue(this);
mPaused = false;
+ // Restart launcher when preferences are changed
+ if (preferencesChanged()) {
+ android.os.Process.killProcess(android.os.Process.myPid());
+ }
+
sPausedFromUserAction = false;
if (mRestoring || mOnResumeNeedsLoad) {
mWorkspaceLoading = true;
@@ -930,6 +951,15 @@ public final class Launcher extends Activity
// Get the search/delete bar
mSearchDropTargetBar = (SearchDropTargetBar) mDragLayer.findViewById(R.id.qsb_bar);
+ // Hide the search divider if we are hiding search bar
+ if (!mShowSearchBar && getCurrentOrientation() == Configuration.ORIENTATION_LANDSCAPE) {
+ ((View) findViewById(R.id.qsb_divider)).setVisibility(View.GONE);
+ }
+
+ if (!mShowDockDivider) {
+ ((View) findViewById(R.id.dock_divider)).setVisibility(View.GONE);
+ }
+
// Setup AppsCustomize
mAppsCustomizeTabHost = (AppsCustomizeTabHost)
findViewById(R.id.apps_customize_pane);
@@ -985,6 +1015,9 @@ public final class Launcher extends Activity
View createShortcut(int layoutResId, ViewGroup parent, ShortcutInfo info) {
BubbleTextView favorite = (BubbleTextView) mInflater.inflate(layoutResId, parent, false);
favorite.applyFromShortcutInfo(info, mIconCache);
+ if (mHideIconLabels) {
+ favorite.setTextVisible(false);
+ }
favorite.setOnClickListener(this);
return favorite;
}
@@ -1544,6 +1577,9 @@ public final class Launcher extends Activity
Intent manageApps = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
manageApps.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ Intent preferences = new Intent().setClass(this, Preferences.class);
+ preferences.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
@@ -1559,6 +1595,12 @@ public final class Launcher extends Activity
.setIcon(android.R.drawable.ic_menu_manage)
.setIntent(manageApps)
.setAlphabeticShortcut('M');
+ if (!getResources().getBoolean(R.bool.config_cyanogenmod)) {
+ menu.add(0, MENU_PREFERENCES, 0, R.string.menu_preferences)
+ .setIcon(android.R.drawable.ic_menu_preferences)
+ .setIntent(preferences)
+ .setAlphabeticShortcut('O');
+ }
menu.add(0, MENU_SYSTEM_SETTINGS, 0, R.string.menu_settings)
.setIcon(android.R.drawable.ic_menu_preferences)
.setIntent(settings)
@@ -1743,6 +1785,9 @@ public final class Launcher extends Activity
// Create the view
FolderIcon newFolder =
FolderIcon.fromXml(R.layout.folder_icon, this, layout, folderInfo, mIconCache);
+ if (mHideIconLabels) {
+ newFolder.setTextVisible(false);
+ }
mWorkspace.addInScreen(newFolder, container, screen, cellX, cellY, 1, 1,
isWorkspaceLocked());
return newFolder;
@@ -1954,6 +1999,33 @@ public final class Launcher extends Activity
}
}
+ public void onLongClickAppsTab(View v) {
+ final PopupMenu popupMenu = new PopupMenu(this, v);
+ final Menu menu = popupMenu.getMenu();
+ dismissAllAppsSortCling(null);
+ popupMenu.inflate(R.menu.apps_tab);
+ AppsCustomizePagedView.SortMode sortMode = mAppsCustomizeContent.getSortMode();
+ if (sortMode == AppsCustomizePagedView.SortMode.Title) {
+ menu.findItem(R.id.apps_sort_title).setChecked(true);
+ } else if (sortMode == AppsCustomizePagedView.SortMode.InstallDate) {
+ menu.findItem(R.id.apps_sort_install_date).setChecked(true);
+ }
+ popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ public boolean onMenuItemClick(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.apps_sort_title:
+ mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.Title);
+ break;
+ case R.id.apps_sort_install_date:
+ mAppsCustomizeContent.setSortMode(AppsCustomizePagedView.SortMode.InstallDate);
+ break;
+ }
+ return true;
+ }
+ });
+ popupMenu.show();
+ }
+
void startApplicationDetailsActivity(ComponentName componentName) {
String packageName = componentName.getPackageName();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
@@ -1979,6 +2051,26 @@ public final class Launcher extends Activity
}
}
+ void startShortcutUninstallActivity(ShortcutInfo shortcutInfo) {
+ PackageManager pm = getPackageManager();
+ ResolveInfo resolveInfo = pm.resolveActivity(shortcutInfo.intent, 0);
+ if ((resolveInfo.activityInfo.applicationInfo.flags &
+ android.content.pm.ApplicationInfo.FLAG_SYSTEM) != 0) {
+ // System applications cannot be installed. For now, show a toast explaining that.
+ // We may give them the option of disabling apps this way.
+ int messageId = R.string.uninstall_system_app_text;
+ Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
+ } else {
+ String packageName = shortcutInfo.intent.getComponent().getPackageName();
+ String className = shortcutInfo.intent.getComponent().getClassName();
+ Intent intent = new Intent(
+ Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+ Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ startActivity(intent);
+ }
+ }
+
boolean startActivity(View v, Intent intent, Object tag) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -2792,15 +2884,23 @@ public final class Launcher extends Activity
void hideDockDivider() {
if (mQsbDivider != null && mDockDivider != null) {
- mQsbDivider.setVisibility(View.INVISIBLE);
- mDockDivider.setVisibility(View.INVISIBLE);
+ if (mShowSearchBar) {
+ mQsbDivider.setVisibility(View.INVISIBLE);
+ }
+ if (mShowDockDivider) {
+ mDockDivider.setVisibility(View.INVISIBLE);
+ }
}
}
void showDockDivider(boolean animated) {
if (mQsbDivider != null && mDockDivider != null) {
- mQsbDivider.setVisibility(View.VISIBLE);
- mDockDivider.setVisibility(View.VISIBLE);
+ if (mShowSearchBar) {
+ mQsbDivider.setVisibility(View.VISIBLE);
+ }
+ if (mShowDockDivider) {
+ mDockDivider.setVisibility(View.VISIBLE);
+ }
if (mDividerAnimator != null) {
mDividerAnimator.cancel();
mQsbDivider.setAlpha(1f);
@@ -2809,8 +2909,10 @@ public final class Launcher extends Activity
}
if (animated) {
mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(mQsbDivider, "alpha", 1f),
- ObjectAnimator.ofFloat(mDockDivider, "alpha", 1f));
+ if (mShowSearchBar && mShowDockDivider) {
+ mDividerAnimator.playTogether(ObjectAnimator.ofFloat(mQsbDivider, "alpha", 1f),
+ ObjectAnimator.ofFloat(mDockDivider, "alpha", 1f));
+ }
mDividerAnimator.setDuration(mSearchDropTargetBar.getTransitionInDuration());
mDividerAnimator.start();
}
@@ -2867,10 +2969,14 @@ public final class Launcher extends Activity
}
}
+ public int getCurrentOrientation() {
+ return getResources().getConfiguration().orientation;
+ }
+
/** Maps the current orientation to an index for referencing orientation correct global icons */
private int getCurrentOrientationIndexForGlobalIcons() {
// default - 0, landscape - 1
- switch (getResources().getConfiguration().orientation) {
+ switch (getCurrentOrientation()) {
case Configuration.ORIENTATION_LANDSCAPE:
return 1;
default:
@@ -2982,7 +3088,7 @@ public final class Launcher extends Activity
final SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
ComponentName activityName = searchManager.getGlobalSearchActivity();
- if (activityName != null) {
+ if (activityName != null && mShowSearchBar) {
int coi = getCurrentOrientationIndexForGlobalIcons();
sGlobalSearchIcon[coi] = updateButtonWithIconFromExternalActivity(
R.id.search_button, activityName, R.drawable.ic_home_search_normal_holo,
@@ -3179,7 +3285,7 @@ public final class Launcher extends Activity
if (mWorkspace != null) {
return mWorkspace.getCurrentPage();
} else {
- return SCREEN_COUNT / 2;
+ return DEFAULT_SCREEN;
}
}
@@ -3257,6 +3363,9 @@ public final class Launcher extends Activity
FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this,
(ViewGroup) workspace.getChildAt(workspace.getCurrentPage()),
(FolderInfo) item, mIconCache);
+ if (!mHideIconLabels) {
+ newFolder.setTextVisible(false);
+ }
workspace.addInScreen(newFolder, item.container, item.screen, item.cellX,
item.cellY, 1, 1, false);
break;
@@ -3572,7 +3681,7 @@ public final class Launcher extends Activity
boolean forceEnableRotation = "true".equalsIgnoreCase(SystemProperties.get(
FORCE_ENABLE_ROTATION_PROPERTY, "false"));
boolean enableRotation = forceEnableRotation ||
- getResources().getBoolean(R.bool.allow_rotation);
+ getResources().getBoolean(R.bool.allow_rotation) || mAutoRotate;
return enableRotation;
}
public void lockScreenOrientation() {
@@ -3592,6 +3701,8 @@ public final class Launcher extends Activity
}
}, mRestoreScreenOrientationDelay);
}
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
}
}
@@ -3626,6 +3737,7 @@ public final class Launcher extends Activity
}
private void dismissCling(final Cling cling, final String flag, int duration) {
if (cling != null) {
+ cling.dismiss();
ObjectAnimator anim = ObjectAnimator.ofFloat(cling, "alpha", 0f);
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
@@ -3688,6 +3800,16 @@ public final class Launcher extends Activity
removeCling(R.id.all_apps_cling);
}
}
+ public void showFirstRunAllAppsSortCling() {
+ // Enable the clings only if they have not been dismissed before
+ SharedPreferences prefs =
+ getSharedPreferences(PreferencesProvider.PREFERENCES_KEY, Context.MODE_PRIVATE);
+ if (isClingsEnabled() && !prefs.getBoolean(Cling.ALLAPPS_SORT_CLING_DISMISSED_KEY, false)) {
+ initCling(R.id.all_apps_sort_cling, null, true, 0);
+ } else {
+ removeCling(R.id.all_apps_sort_cling);
+ }
+ }
public Cling showFirstRunFoldersCling() {
// Enable the clings only if they have not been dismissed before
if (isClingsEnabled() &&
@@ -3713,11 +3835,27 @@ public final class Launcher extends Activity
Cling cling = (Cling) findViewById(R.id.all_apps_cling);
dismissCling(cling, Cling.ALLAPPS_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
}
+ public void dismissAllAppsSortCling(View v) {
+ Cling cling = (Cling) findViewById(R.id.all_apps_sort_cling);
+ dismissCling(cling, Cling.ALLAPPS_SORT_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
+ }
public void dismissFolderCling(View v) {
Cling cling = (Cling) findViewById(R.id.folder_cling);
dismissCling(cling, Cling.FOLDER_CLING_DISMISSED_KEY, DISMISS_CLING_DURATION);
}
+ public boolean preferencesChanged() {
+ SharedPreferences prefs =
+ getSharedPreferences(PreferencesProvider.PREFERENCES_KEY, Context.MODE_PRIVATE);
+ boolean preferencesChanged = prefs.getBoolean(PreferencesProvider.PREFERENCES_CHANGED, false);
+ if (preferencesChanged) {
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(PreferencesProvider.PREFERENCES_CHANGED, false);
+ editor.commit();
+ }
+ return preferencesChanged;
+ }
+
/**
* Prints out out state for debugging.
*/
diff --git a/src/com/android/launcher2/LauncherAnimatorUpdateListener.java b/src/com/cyanogenmod/trebuchet/LauncherAnimatorUpdateListener.java
index dd82113..df9ded1 100644
--- a/src/com/android/launcher2/LauncherAnimatorUpdateListener.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherAnimatorUpdateListener.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
diff --git a/src/com/android/launcher2/LauncherAppWidgetHost.java b/src/com/cyanogenmod/trebuchet/LauncherAppWidgetHost.java
index 68d4903..3f12a03 100644
--- a/src/com/android/launcher2/LauncherAppWidgetHost.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherAppWidgetHost.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView;
diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/cyanogenmod/trebuchet/LauncherAppWidgetHostView.java
index 9970c76..5eea280 100644
--- a/src/com/android/launcher2/LauncherAppWidgetHostView.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherAppWidgetHostView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.appwidget.AppWidgetHostView;
import android.content.Context;
@@ -27,7 +27,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.RemoteViews;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
* {@inheritDoc}
diff --git a/src/com/android/launcher2/LauncherAppWidgetInfo.java b/src/com/cyanogenmod/trebuchet/LauncherAppWidgetInfo.java
index f001b2b..0ab5dae 100644
--- a/src/com/android/launcher2/LauncherAppWidgetInfo.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherAppWidgetInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.appwidget.AppWidgetHostView;
import android.content.ComponentName;
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/cyanogenmod/trebuchet/LauncherApplication.java
index 28362fd..7fa8817 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherApplication.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.app.Application;
import android.app.SearchManager;
@@ -26,7 +26,7 @@ import android.content.res.Configuration;
import android.database.ContentObserver;
import android.os.Handler;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.lang.ref.WeakReference;
@@ -36,7 +36,7 @@ public class LauncherApplication extends Application {
private static boolean sIsScreenLarge;
private static float sScreenDensity;
private static int sLongPressTimeout = 300;
- private static final String sSharedPreferencesKey = "com.android.launcher2.prefs";
+ private static final String sSharedPreferencesKey = "com.cyanogenmod.trebuchet.prefs";
WeakReference<LauncherProvider> mLauncherProvider;
@Override
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 92be7e4..6ada4de 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.app.SearchManager;
import android.appwidget.AppWidgetManager;
@@ -47,8 +47,8 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
-import com.android.launcher.R;
-import com.android.launcher2.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.InstallWidgetReceiver.WidgetMimeTypeHandlerData;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
@@ -1059,13 +1059,13 @@ public class LauncherModel extends BroadcastReceiver {
// We use the last index to refer to the hotseat and the screen as the rank, so
// test and update the occupied state accordingly
- if (occupied[Launcher.SCREEN_COUNT][item.screen][0] != null) {
+ if (occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0] != null) {
Log.e(TAG, "Error loading shortcut into hotseat " + item
+ " into position (" + item.screen + ":" + item.cellX + "," + item.cellY
- + ") occupied by " + occupied[Launcher.SCREEN_COUNT][item.screen][0]);
+ + ") occupied by " + occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0]);
return false;
} else {
- occupied[Launcher.SCREEN_COUNT][item.screen][0] = item;
+ occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0] = item;
return true;
}
} else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {
@@ -1114,17 +1114,14 @@ public class LauncherModel extends BroadcastReceiver {
sBgItemsIdMap.clear();
sBgDbIconCache.clear();
+ final ItemInfo occupied[][][] =
+ new ItemInfo[Launcher.MAX_SCREEN_COUNT + 1][mCellCountX + 1][mCellCountY + 1];
+
final ArrayList<Long> itemsToRemove = new ArrayList<Long>();
final Cursor c = contentResolver.query(
LauncherSettings.Favorites.CONTENT_URI, null, null, null, null);
- // +1 for the hotseat (it can be larger than the workspace)
- // Load workspace in reverse order to ensure that latest items are loaded first (and
- // before any earlier duplicates)
- final ItemInfo occupied[][][] =
- new ItemInfo[Launcher.SCREEN_COUNT + 1][mCellCountX + 1][mCellCountY + 1];
-
try {
final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);
final int intentIndex = c.getColumnIndexOrThrow
@@ -1347,7 +1344,7 @@ public class LauncherModel extends BroadcastReceiver {
Log.d(TAG, "workspace layout: ");
for (int y = 0; y < mCellCountY; y++) {
String line = "";
- for (int s = 0; s < Launcher.SCREEN_COUNT; s++) {
+ for (int s = 0; s < Launcher.MAX_SCREEN_COUNT; s++) {
if (s > 0) {
line += " | ";
}
@@ -1471,7 +1468,7 @@ public class LauncherModel extends BroadcastReceiver {
int cellCountX = LauncherModel.getCellCountX();
int cellCountY = LauncherModel.getCellCountY();
int screenOffset = cellCountX * cellCountY;
- int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); // +1 hotseat
+ int containerOffset = screenOffset * (Launcher.MAX_SCREEN_COUNT + 1); // +1 hotseat
long lr = (lhs.container * containerOffset + lhs.screen * screenOffset +
lhs.cellY * cellCountX + lhs.cellX);
long rr = (rhs.container * containerOffset + rhs.screen * screenOffset +
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/cyanogenmod/trebuchet/LauncherProvider.java
index 0720259..4cdd135 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.app.SearchManager;
import android.appwidget.AppWidgetHost;
@@ -49,8 +49,8 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
-import com.android.launcher.R;
-import com.android.launcher2.LauncherSettings.Favorites;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.LauncherSettings.Favorites;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -68,7 +68,7 @@ public class LauncherProvider extends ContentProvider {
private static final int DATABASE_VERSION = 12;
- static final String AUTHORITY = "com.android.launcher2.settings";
+ static final String AUTHORITY = "com.cyanogenmod.trebuchet.settings";
static final String TABLE_FAVORITES = "favorites";
static final String PARAMETER_NOTIFY = "notify";
@@ -76,7 +76,7 @@ public class LauncherProvider extends ContentProvider {
"DB_CREATED_BUT_DEFAULT_WORKSPACE_NOT_LOADED";
private static final String ACTION_APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE =
- "com.android.launcher.action.APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE";
+ "com.cyanogenmod.trebuchet.action.APPWIDGET_DEFAULT_WORKSPACE_CONFIGURE";
/**
* {@link Uri} triggered at any registered {@link android.database.ContentObserver} when
diff --git a/src/com/android/launcher2/LauncherSettings.java b/src/com/cyanogenmod/trebuchet/LauncherSettings.java
index ee00371..361dd69 100644
--- a/src/com/android/launcher2/LauncherSettings.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherSettings.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.net.Uri;
import android.provider.BaseColumns;
diff --git a/src/com/android/launcher2/LauncherViewPropertyAnimator.java b/src/com/cyanogenmod/trebuchet/LauncherViewPropertyAnimator.java
index 88b4cb4..d02cb25 100644
--- a/src/com/android/launcher2/LauncherViewPropertyAnimator.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherViewPropertyAnimator.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/cyanogenmod/trebuchet/PagedView.java
index ad0baf4..c031146 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/cyanogenmod/trebuchet/PagedView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -43,7 +43,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.widget.Scroller;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.util.ArrayList;
@@ -181,6 +181,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private boolean mShouldShowScrollIndicatorImmediately = false;
protected static final int sScrollIndicatorFadeInDuration = 150;
protected static final int sScrollIndicatorFadeOutDuration = 650;
+ protected static final int sScrollIndicatorFadeOutShortDuration = 150;
protected static final int sScrollIndicatorFlashDuration = 650;
// If set, will defer loading associated pages until the scrolling settles
@@ -1741,6 +1742,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
protected void showScrollingIndicator(boolean immediately) {
+ showScrollingIndicator(immediately, sScrollIndicatorFadeInDuration);
+ }
+
+ protected void showScrollingIndicator(boolean immediately, int duration) {
mShouldShowScrollIndicator = true;
mShouldShowScrollIndicatorImmediately = true;
if (getChildCount() <= 1) return;
@@ -1757,7 +1762,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mScrollIndicator.setAlpha(1f);
} else {
mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 1f);
- mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeInDuration);
+ mScrollIndicatorAnimator.setDuration(duration);
mScrollIndicatorAnimator.start();
}
}
@@ -1770,6 +1775,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
protected void hideScrollingIndicator(boolean immediately) {
+ hideScrollingIndicator(immediately, sScrollIndicatorFadeOutDuration);
+ }
+
+ protected void hideScrollingIndicator(boolean immediately, int duration) {
if (getChildCount() <= 1) return;
if (!isScrollingIndicatorEnabled()) return;
@@ -1783,7 +1792,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mScrollIndicator.setAlpha(0f);
} else {
mScrollIndicatorAnimator = ObjectAnimator.ofFloat(mScrollIndicator, "alpha", 0f);
- mScrollIndicatorAnimator.setDuration(sScrollIndicatorFadeOutDuration);
+ mScrollIndicatorAnimator.setDuration(duration);
mScrollIndicatorAnimator.addListener(new AnimatorListenerAdapter() {
private boolean cancelled = false;
@Override
@@ -1802,6 +1811,22 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
+ protected void enableScrollingIndicator() {
+ mHasScrollIndicator = true;
+ getScrollingIndicator();
+ if (mScrollIndicator != null) {
+ mScrollIndicator.setVisibility(View.VISIBLE);
+ }
+ }
+
+ protected void disableScrollingIndicator() {
+ if (mScrollIndicator != null) {
+ mScrollIndicator.setVisibility(View.GONE);
+ }
+ mHasScrollIndicator = false;
+ mScrollIndicator = null;
+ }
+
/**
* To be overridden by subclasses to determine whether the scroll indicator should stretch to
* fill its space on the track or not.
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/cyanogenmod/trebuchet/PagedViewCellLayout.java
index 6f73e63..5eaf926 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewCellLayout.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.Resources;
@@ -24,7 +24,7 @@ import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
* An abstraction of the original CellLayout which supports laying out items
diff --git a/src/com/android/launcher2/PagedViewCellLayoutChildren.java b/src/com/cyanogenmod/trebuchet/PagedViewCellLayoutChildren.java
index 187a22d..3b1a3fb 100644
--- a/src/com/android/launcher2/PagedViewCellLayoutChildren.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewCellLayoutChildren.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.graphics.Rect;
diff --git a/src/com/android/launcher2/PagedViewGridLayout.java b/src/com/cyanogenmod/trebuchet/PagedViewGridLayout.java
index 90bfe88..546912f 100644
--- a/src/com/android/launcher2/PagedViewGridLayout.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewGridLayout.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.view.MotionEvent;
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/cyanogenmod/trebuchet/PagedViewIcon.java
index d2aa31f..6296e67 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewIcon.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.graphics.Bitmap;
diff --git a/src/com/android/launcher2/PagedViewIconCache.java b/src/com/cyanogenmod/trebuchet/PagedViewIconCache.java
index d65f68b..8086fa7 100644
--- a/src/com/android/launcher2/PagedViewIconCache.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewIconCache.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/cyanogenmod/trebuchet/PagedViewWidget.java
index b804ab0..6fa0d39 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewWidget.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.appwidget.AppWidgetProviderInfo;
import android.content.Context;
@@ -29,7 +29,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
* The linear layout used strictly for the widget/wallpaper tab of the customization tray
diff --git a/src/com/android/launcher2/PagedViewWidgetImageView.java b/src/com/cyanogenmod/trebuchet/PagedViewWidgetImageView.java
index 22db0ab..8182b22 100644
--- a/src/com/android/launcher2/PagedViewWidgetImageView.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewWidgetImageView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.graphics.Canvas;
diff --git a/src/com/android/launcher2/PagedViewWithDraggableItems.java b/src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java
index 9cdd74f..1f0befa 100644
--- a/src/com/android/launcher2/PagedViewWithDraggableItems.java
+++ b/src/com/cyanogenmod/trebuchet/PagedViewWithDraggableItems.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/com/android/launcher2/PendingAddItemInfo.java b/src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java
index 9a133ed..d31c7e1 100644
--- a/src/com/android/launcher2/PendingAddItemInfo.java
+++ b/src/com/cyanogenmod/trebuchet/PendingAddItemInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
diff --git a/src/com/android/launcher2/PreloadReceiver.java b/src/com/cyanogenmod/trebuchet/PreloadReceiver.java
index d1bc639..0ce8ebe 100644
--- a/src/com/android/launcher2/PreloadReceiver.java
+++ b/src/com/cyanogenmod/trebuchet/PreloadReceiver.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.BroadcastReceiver;
import android.content.Context;
diff --git a/src/com/android/launcher2/RocketLauncher.java b/src/com/cyanogenmod/trebuchet/RocketLauncher.java
index 268769d..54da606 100644
--- a/src/com/android/launcher2/RocketLauncher.java
+++ b/src/com/cyanogenmod/trebuchet/RocketLauncher.java
@@ -18,7 +18,7 @@
// background stellar matter:
// - add some slow horizontal parallax motion, or perhaps veeeeery gradual outward drift
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
@@ -39,7 +39,7 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.util.HashMap;
import java.util.Random;
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
index a1d36cd..7811255 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -27,7 +27,8 @@ import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
/*
* Ths bar will manage the transition between the QSB search bar and the delete drop
@@ -43,6 +44,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
private static final AccelerateInterpolator sAccelerateInterpolator =
new AccelerateInterpolator();
+ private boolean mShowQSBSearchBar;
+
private boolean mIsSearchBarHidden;
private View mQSBSearchBar;
private View mDropTargetBar;
@@ -60,6 +63,8 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
public SearchDropTargetBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+
+ mShowQSBSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
}
public void setup(Launcher launcher, DragController dragController) {
@@ -108,6 +113,10 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
mEnableDropDownDropTargets =
getResources().getBoolean(R.bool.config_useDropTargetDownTransition);
+ if (!mShowQSBSearchBar) {
+ mQSBSearchBar.setVisibility(View.GONE);
+ }
+
// Create the various fade animations
if (mEnableDropDownDropTargets) {
mDropTargetBar.setTranslationY(-mBarHeight);
@@ -136,30 +145,34 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
*/
public void showSearchBar(boolean animated) {
if (!mIsSearchBarHidden) return;
- if (animated) {
- prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarAnim.reverse();
- } else {
- mQSBSearchBarAnim.cancel();
- if (mEnableDropDownDropTargets) {
- mQSBSearchBar.setTranslationY(0);
+ if (mShowQSBSearchBar) {
+ if (animated) {
+ prepareStartAnimation(mQSBSearchBar);
+ mQSBSearchBarAnim.reverse();
} else {
- mQSBSearchBar.setAlpha(1f);
+ mQSBSearchBarAnim.cancel();
+ if (mEnableDropDownDropTargets) {
+ mQSBSearchBar.setTranslationY(0);
+ } else {
+ mQSBSearchBar.setAlpha(1f);
+ }
}
}
mIsSearchBarHidden = false;
}
public void hideSearchBar(boolean animated) {
if (mIsSearchBarHidden) return;
- if (animated) {
- prepareStartAnimation(mQSBSearchBar);
- mQSBSearchBarAnim.start();
- } else {
- mQSBSearchBarAnim.cancel();
- if (mEnableDropDownDropTargets) {
- mQSBSearchBar.setTranslationY(-mBarHeight);
+ if (mShowQSBSearchBar) {
+ if (animated) {
+ prepareStartAnimation(mQSBSearchBar);
+ mQSBSearchBarAnim.start();
} else {
- mQSBSearchBar.setAlpha(0f);
+ mQSBSearchBarAnim.cancel();
+ if (mEnableDropDownDropTargets) {
+ mQSBSearchBar.setTranslationY(-mBarHeight);
+ } else {
+ mQSBSearchBar.setAlpha(0f);
+ }
}
}
mIsSearchBarHidden = true;
@@ -183,7 +196,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
// Animate out the QSB search bar, and animate in the drop target bar
prepareStartAnimation(mDropTargetBar);
mDropTargetBarAnim.start();
- if (!mIsSearchBarHidden) {
+ if (!mIsSearchBarHidden && mShowQSBSearchBar) {
prepareStartAnimation(mQSBSearchBar);
mQSBSearchBarAnim.start();
}
@@ -199,7 +212,7 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D
// Restore the QSB search bar, and animate out the drop target bar
prepareStartAnimation(mDropTargetBar);
mDropTargetBarAnim.reverse();
- if (!mIsSearchBarHidden) {
+ if (!mIsSearchBarHidden && mShowQSBSearchBar) {
prepareStartAnimation(mQSBSearchBar);
mQSBSearchBarAnim.reverse();
}
diff --git a/src/com/android/launcher2/ShortcutAndWidgetContainer.java b/src/com/cyanogenmod/trebuchet/ShortcutAndWidgetContainer.java
index 8bebdcd..8c10c94 100644
--- a/src/com/android/launcher2/ShortcutAndWidgetContainer.java
+++ b/src/com/cyanogenmod/trebuchet/ShortcutAndWidgetContainer.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.app.WallpaperManager;
import android.content.Context;
diff --git a/src/com/android/launcher2/ShortcutInfo.java b/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
index 533059f..5c77b5f 100644
--- a/src/com/android/launcher2/ShortcutInfo.java
+++ b/src/com/cyanogenmod/trebuchet/ShortcutInfo.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.ArrayList;
diff --git a/src/com/android/launcher2/SmoothPagedView.java b/src/com/cyanogenmod/trebuchet/SmoothPagedView.java
index 7e47f1a..86caf9e 100644
--- a/src/com/android/launcher2/SmoothPagedView.java
+++ b/src/com/cyanogenmod/trebuchet/SmoothPagedView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/com/android/launcher2/SpringLoadedDragController.java b/src/com/cyanogenmod/trebuchet/SpringLoadedDragController.java
index d96aab7..e5b2798 100644
--- a/src/com/android/launcher2/SpringLoadedDragController.java
+++ b/src/com/cyanogenmod/trebuchet/SpringLoadedDragController.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
public class SpringLoadedDragController implements OnAlarmListener {
// how long the user must hover over a mini-screen before it unshrinks
diff --git a/src/com/android/launcher2/StrokedTextView.java b/src/com/cyanogenmod/trebuchet/StrokedTextView.java
index 4e28d17..007ddf5 100644
--- a/src/com/android/launcher2/StrokedTextView.java
+++ b/src/com/cyanogenmod/trebuchet/StrokedTextView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.Context;
import android.content.res.TypedArray;
@@ -27,7 +27,7 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.TextView;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
* This class adds a stroke to the generic TextView allowing the text to stand out better against
diff --git a/src/com/android/launcher2/SymmetricalLinearTween.java b/src/com/cyanogenmod/trebuchet/SymmetricalLinearTween.java
index da02242..240305f 100644
--- a/src/com/android/launcher2/SymmetricalLinearTween.java
+++ b/src/com/cyanogenmod/trebuchet/SymmetricalLinearTween.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.os.Handler;
import android.os.SystemClock;
diff --git a/src/com/android/launcher2/TweenCallback.java b/src/com/cyanogenmod/trebuchet/TweenCallback.java
index 380a217..88b8dff 100644
--- a/src/com/android/launcher2/TweenCallback.java
+++ b/src/com/cyanogenmod/trebuchet/TweenCallback.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
interface TweenCallback {
void onTweenValueChanged(float value, float oldValue);
diff --git a/src/com/android/launcher2/UninstallShortcutReceiver.java b/src/com/cyanogenmod/trebuchet/UninstallShortcutReceiver.java
index 02590c9..6f4f030 100644
--- a/src/com/android/launcher2/UninstallShortcutReceiver.java
+++ b/src/com/cyanogenmod/trebuchet/UninstallShortcutReceiver.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -25,7 +25,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.widget.Toast;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.net.URISyntaxException;
import java.util.ArrayList;
diff --git a/src/com/android/launcher2/Utilities.java b/src/com/cyanogenmod/trebuchet/Utilities.java
index b27f7bb..d80cd9d 100644
--- a/src/com/android/launcher2/Utilities.java
+++ b/src/com/cyanogenmod/trebuchet/Utilities.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import java.util.Random;
@@ -35,7 +35,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.util.DisplayMetrics;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
/**
* Various utilities shared amongst the Launcher's classes.
diff --git a/src/com/android/launcher2/WallpaperChooser.java b/src/com/cyanogenmod/trebuchet/WallpaperChooser.java
index 77e1e6f..d3ca006 100644
--- a/src/com/android/launcher2/WallpaperChooser.java
+++ b/src/com/cyanogenmod/trebuchet/WallpaperChooser.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import android.app.Activity;
import android.app.DialogFragment;
diff --git a/src/com/android/launcher2/WallpaperChooserDialogFragment.java b/src/com/cyanogenmod/trebuchet/WallpaperChooserDialogFragment.java
index b99d8ec..aa323bf 100644
--- a/src/com/android/launcher2/WallpaperChooserDialogFragment.java
+++ b/src/com/cyanogenmod/trebuchet/WallpaperChooserDialogFragment.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.app.Activity;
import android.app.Dialog;
@@ -41,7 +41,7 @@ import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.SpinnerAdapter;
-import com.android.launcher.R;
+import com.cyanogenmod.trebuchet.R;
import java.io.IOException;
import java.util.ArrayList;
@@ -50,7 +50,7 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
AdapterView.OnItemSelectedListener, AdapterView.OnItemClickListener {
private static final String TAG = "Launcher.WallpaperChooserDialogFragment";
- private static final String EMBEDDED_KEY = "com.android.launcher2."
+ private static final String EMBEDDED_KEY = "com.cyanogenmod.trebuchet."
+ "WallpaperChooserDialogFragment.EMBEDDED_KEY";
private boolean mEmbedded;
@@ -194,8 +194,8 @@ public class WallpaperChooserDialogFragment extends DialogFragment implements
final Resources resources = getResources();
// Context.getPackageName() may return the "original" package name,
- // com.android.launcher2; Resources needs the real package name,
- // com.android.launcher. So we ask Resources for what it thinks the
+ // com.cyanogenmod.trebuchet; Resources needs the real package name,
+ // com.cyanogenmod.trebuchet. So we ask Resources for what it thinks the
// package name should be.
final String packageName = resources.getResourcePackageName(R.array.wallpapers);
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 44b9f68..cfe7912 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
+ * Copytight (C) 2011 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +15,7 @@
* limitations under the License.
*/
-package com.android.launcher2;
+package com.cyanogenmod.trebuchet;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -30,6 +31,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -49,6 +51,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
+import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -56,9 +59,10 @@ import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
-import com.android.launcher.R;
-import com.android.launcher2.FolderIcon.FolderRingAnimator;
-import com.android.launcher2.LauncherSettings.Favorites;
+import com.cyanogenmod.trebuchet.R;
+import com.cyanogenmod.trebuchet.FolderIcon.FolderRingAnimator;
+import com.cyanogenmod.trebuchet.LauncherSettings.Favorites;
+import com.cyanogenmod.trebuchet.preference.PreferencesProvider;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -106,8 +110,6 @@ public class Workspace extends SmoothPagedView
private IBinder mWindowToken;
private static final float WALLPAPER_SCREENS_SPAN = 2f;
- private int mDefaultPage;
-
/**
* CellInfo for the cell that is currently being dragged
*/
@@ -154,9 +156,6 @@ public class Workspace extends SmoothPagedView
private SpringLoadedDragController mSpringLoadedDragController;
private float mSpringLoadedShrinkFactor;
- private static final int DEFAULT_CELL_COUNT_X = 4;
- private static final int DEFAULT_CELL_COUNT_Y = 4;
-
// State variable that indicates whether the pages are small (ie when you're
// in all apps or customize mode)
@@ -260,6 +259,19 @@ public class Workspace extends SmoothPagedView
private float[] mNewRotationYs;
private float mTransitionProgress;
+ // Preferences
+ private int mNumberHomescreens;
+ private int mDefaultHomescreen;
+ private int mScreenPaddingVertical;
+ private int mScreenPaddingHorizontal;
+ private boolean mShowSearchBar;
+ private boolean mResizeAnyWidget;
+ private boolean mHideIconLabels;
+ private boolean mScrollWallpaper;
+ private boolean mShowScrollingIndicator;
+ private boolean mFadeScrollingIndicator;
+ private boolean mShowDockDivider;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -290,35 +302,16 @@ public class Workspace extends SmoothPagedView
mFadeInAdjacentScreens = false;
mWallpaperManager = WallpaperManager.getInstance(context);
- int cellCountX = DEFAULT_CELL_COUNT_X;
- int cellCountY = DEFAULT_CELL_COUNT_Y;
+ int cellCountX = context.getResources().getInteger(R.integer.cell_count_x);
+ int cellCountY = context.getResources().getInteger(R.integer.cell_count_y);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.Workspace, defStyle, 0);
if (LauncherApplication.isScreenLarge()) {
- // Determine number of rows/columns dynamically
- // TODO: This code currently fails on tablets with an aspect ratio < 1.3.
- // Around that ratio we should make cells the same size in portrait and
- // landscape
- TypedArray actionBarSizeTypedArray =
- context.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
- DisplayMetrics displayMetrics = res.getDisplayMetrics();
- final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
- final float systemBarHeight = res.getDimension(R.dimen.status_bar_height);
- final float smallestScreenDim = res.getConfiguration().smallestScreenWidthDp *
- displayMetrics.density;
-
- cellCountX = 1;
- while (CellLayout.widthInPortrait(res, cellCountX + 1) <= smallestScreenDim) {
- cellCountX++;
- }
-
- cellCountY = 1;
- while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1)
- <= smallestScreenDim - systemBarHeight) {
- cellCountY++;
- }
+ int[] cellCount = getCellCountsForLarge(context);
+ cellCountX = cellCount[0];
+ cellCountY = cellCount[1];
}
mSpringLoadedShrinkFactor =
@@ -330,14 +323,36 @@ public class Workspace extends SmoothPagedView
// if the value is manually specified, use that instead
cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX);
cellCountY = a.getInt(R.styleable.Workspace_cellCountY, cellCountY);
- mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
a.recycle();
setOnHierarchyChangeListener(this);
+ // if there is a value set it the preferences, use that instead
+ if ((!LauncherApplication.isScreenLarge()) || (getResources().getBoolean(R.bool.config_workspaceTabletGrid) == true)) {
+ cellCountX = PreferencesProvider.Interface.Homescreen.getCellCountX(context, cellCountX);
+ cellCountY = PreferencesProvider.Interface.Homescreen.getCellCountY(context, cellCountY);
+ }
+
LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY);
setHapticFeedbackEnabled(false);
+ // Preferences
+ mNumberHomescreens = PreferencesProvider.Interface.Homescreen.getNumberHomescreens(context);
+ mDefaultHomescreen = PreferencesProvider.Interface.Homescreen.getDefaultHomescreen(context,
+ mNumberHomescreens / 2);
+ if (mDefaultHomescreen >= mNumberHomescreens) {
+ mDefaultHomescreen = mNumberHomescreens / 2;
+ }
+ mScreenPaddingVertical = PreferencesProvider.Interface.Homescreen.getScreenPaddingVertical(context);
+ mScreenPaddingHorizontal = PreferencesProvider.Interface.Homescreen.getScreenPaddingHorizontal(context);
+ mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
+ mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context);
+ mHideIconLabels = PreferencesProvider.Interface.Homescreen.getHideIconLabels(context);
+ mScrollWallpaper = PreferencesProvider.Interface.Homescreen.Scrolling.getScrollWallpaper(context);
+ mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator(context);
+ mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator(context);
+ mShowDockDivider = PreferencesProvider.Interface.Homescreen.Indicator.getShowDockDivider(context);
+
mLauncher = (Launcher) context;
initWorkspace();
@@ -350,6 +365,35 @@ public class Workspace extends SmoothPagedView
}
}
+ public static int[] getCellCountsForLarge(Context context) {
+ int[] cellCount = new int[2];
+
+ final Resources res = context.getResources();
+ // Determine number of rows/columns dynamically
+ // TODO: This code currently fails on tablets with an aspect ratio < 1.3.
+ // Around that ratio we should make cells the same size in portrait and
+ // landscape
+ TypedArray actionBarSizeTypedArray =
+ context.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
+ DisplayMetrics displayMetrics = res.getDisplayMetrics();
+ final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f);
+ final float systemBarHeight = res.getDimension(R.dimen.status_bar_height);
+ final float smallestScreenDim = res.getConfiguration().smallestScreenWidthDp *
+ displayMetrics.density;
+
+ cellCount[0] = 1;
+ while (CellLayout.widthInPortrait(res, cellCount[0] + 1) <= smallestScreenDim) {
+ cellCount[0]++;
+ }
+
+ cellCount[1] = 1;
+ while (actionBarHeight + CellLayout.heightInLandscape(res, cellCount[1] + 1)
+ <= smallestScreenDim - systemBarHeight) {
+ cellCount[1]++;
+ }
+ return cellCount;
+ }
+
// estimate the size of a widget with spans hSpan, vSpan. return MAX_VALUE for each
// dimension if unsuccessful
public int[] estimateItemSize(int hSpan, int vSpan,
@@ -413,7 +457,7 @@ public class Workspace extends SmoothPagedView
*/
protected void initWorkspace() {
Context context = getContext();
- mCurrentPage = mDefaultPage;
+ mCurrentPage = mDefaultHomescreen;
Launcher.setScreen(mCurrentPage);
LauncherApplication app = (LauncherApplication)context.getApplicationContext();
mIconCache = app.getIconCache();
@@ -421,17 +465,42 @@ public class Workspace extends SmoothPagedView
setChildrenDrawnWithCacheEnabled(true);
final Resources res = getResources();
+
+ LayoutInflater inflater =
+ (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ for (int i = 0; i < mNumberHomescreens; i++) {
+ View screen = inflater.inflate(R.layout.workspace_screen, null);
+ screen.setPadding(screen.getPaddingLeft() + mScreenPaddingHorizontal,
+ screen.getPaddingTop() + mScreenPaddingVertical,
+ screen.getPaddingRight() + mScreenPaddingHorizontal,
+ screen.getPaddingBottom() + mScreenPaddingVertical);
+ addView(screen); }
+
try {
mBackground = res.getDrawable(R.drawable.apps_customize_bg);
} catch (Resources.NotFoundException e) {
// In this case, we will skip drawing background protection
}
+ if (!mShowSearchBar) {
+ int paddingTop = 0;
+ if (mLauncher.getCurrentOrientation() == Configuration.ORIENTATION_PORTRAIT) {
+ paddingTop = (int)res.getDimension(R.dimen.qsb_bar_hidden_inset);
+ }
+ setPadding(0, paddingTop, getPaddingRight(), getPaddingBottom());
+ }
+
+ if (!mShowScrollingIndicator) {
+ disableScrollingIndicator();
+ }
+
mWallpaperOffset = new WallpaperOffsetInterpolator();
Display display = mLauncher.getWindowManager().getDefaultDisplay();
display.getSize(mDisplaySize);
- mWallpaperTravelWidth = (int) (mDisplaySize.x *
- wallpaperTravelToScreenWidthRatio(mDisplaySize.x, mDisplaySize.y));
+ if (mScrollWallpaper) {
+ mWallpaperTravelWidth = (int) (mDisplaySize.x *
+ wallpaperTravelToScreenWidthRatio(mDisplaySize.x, mDisplaySize.y));
+ }
mMaxDistanceForFolderCreation = (0.55f * res.getDimensionPixelSize(R.dimen.app_icon_size));
mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
@@ -529,9 +598,13 @@ public class Workspace extends SmoothPagedView
layout = mLauncher.getHotseat().getLayout();
child.setOnKeyListener(null);
- // Hide folder title in the hotseat
- if (child instanceof FolderIcon) {
- ((FolderIcon) child).setTextVisible(false);
+ if (!mHideIconLabels) {
+ // Hide titles in the hotseat
+ if (child instanceof FolderIcon) {
+ ((FolderIcon) child).setTextVisible(false);
+ } else if (child instanceof BubbleTextView) {
+ ((BubbleTextView) child).setTextVisible(false);
+ }
}
if (screen < 0) {
@@ -543,9 +616,13 @@ public class Workspace extends SmoothPagedView
y = mLauncher.getHotseat().getCellYFromOrder(screen);
}
} else {
- // Show folder title if not in the hotseat
- if (child instanceof FolderIcon) {
- ((FolderIcon) child).setTextVisible(true);
+ if (!mHideIconLabels) {
+ // Show titles if not in the hotseat
+ if (child instanceof FolderIcon) {
+ ((FolderIcon) child).setTextVisible(true);
+ } else if (child instanceof BubbleTextView) {
+ ((BubbleTextView) child).setTextVisible(true);
+ }
}
layout = (CellLayout) getChildAt(screen);
@@ -773,7 +850,9 @@ public class Workspace extends SmoothPagedView
}
protected void onPageEndMoving() {
- super.onPageEndMoving();
+ if (mFadeScrollingIndicator) {
+ hideScrollingIndicator(false);
+ }
if (isHardwareAccelerated()) {
updateChildrenLayersEnabled();
@@ -795,7 +874,7 @@ public class Workspace extends SmoothPagedView
}
// Hide the scroll indicator as you pan the page
- if (!mDragController.isDragging()) {
+ if (mFadeScrollingIndicator && !mDragController.isDragging()) {
hideScrollingIndicator(false);
}
}
@@ -818,6 +897,15 @@ public class Workspace extends SmoothPagedView
Launcher.setScreen(mCurrentPage);
};
+ @Override
+ protected void flashScrollingIndicator(boolean animated) {
+ if (mFadeScrollingIndicator) {
+ super.flashScrollingIndicator(animated);
+ } else {
+ showScrollingIndicator(true);
+ }
+ }
+
// As a ratio of screen height, the total distance we want the parallax effect to span
// horizontally
private float wallpaperTravelToScreenWidthRatio(int width, int height) {
@@ -913,6 +1001,13 @@ public class Workspace extends SmoothPagedView
}
}
+ private void centerWallpaperOffset() {
+ if (mWindowToken != null) {
+ mWallpaperManager.setWallpaperOffsetSteps(0.5f, 0);
+ mWallpaperManager.setWallpaperOffsets(mWindowToken, 0.5f, 0);
+ }
+ }
+
public void updateWallpaperOffsetImmediately() {
mUpdateWallpaperOffsetImmediately = true;
}
@@ -942,13 +1037,17 @@ public class Workspace extends SmoothPagedView
@Override
protected void updateCurrentPageScroll() {
super.updateCurrentPageScroll();
- computeWallpaperScrollRatio(mCurrentPage);
+ if (mScrollWallpaper) {
+ computeWallpaperScrollRatio(mCurrentPage);
+ }
}
@Override
protected void snapToPage(int whichPage) {
super.snapToPage(whichPage);
- computeWallpaperScrollRatio(whichPage);
+ if (mScrollWallpaper) {
+ computeWallpaperScrollRatio(whichPage);
+ }
}
@Override
@@ -983,9 +1082,9 @@ public class Workspace extends SmoothPagedView
class WallpaperOffsetInterpolator {
float mFinalHorizontalWallpaperOffset = 0.0f;
- float mFinalVerticalWallpaperOffset = 0.5f;
+ float mFinalVerticalWallpaperOffset = 0.0f;
float mHorizontalWallpaperOffset = 0.0f;
- float mVerticalWallpaperOffset = 0.5f;
+ float mVerticalWallpaperOffset = 0.0f;
long mLastWallpaperOffsetUpdateTime;
boolean mIsMovingFast;
boolean mOverrideHorizontalCatchupConstant;
@@ -1095,7 +1194,9 @@ public class Workspace extends SmoothPagedView
@Override
public void computeScroll() {
super.computeScroll();
- syncWallpaperOffsetWithScroll();
+ if (mScrollWallpaper) {
+ syncWallpaperOffsetWithScroll();
+ }
}
void showOutlines() {
@@ -1271,17 +1372,19 @@ public class Workspace extends SmoothPagedView
if (mOverScrollX < 0 || mOverScrollX > mMaxScrollX) {
int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
CellLayout cl = (CellLayout) getChildAt(index);
- float scrollProgress = getScrollProgress(screenCenter, cl, index);
- cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
- float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
- cl.setRotationY(rotation);
- setFadeForOverScroll(Math.abs(scrollProgress));
- if (!mOverscrollTransformsSet) {
- mOverscrollTransformsSet = true;
- cl.setCameraDistance(mDensity * mCameraDistance);
- cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
- cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
- cl.setOverscrollTransformsDirty(true);
+ if (getChildCount() > 1) {
+ float scrollProgress = getScrollProgress(screenCenter, cl, index);
+ cl.setOverScrollAmount(Math.abs(scrollProgress), index == 0);
+ float rotation = - WORKSPACE_OVERSCROLL_ROTATION * scrollProgress;
+ cl.setRotationY(rotation);
+ setFadeForOverScroll(Math.abs(scrollProgress));
+ if (!mOverscrollTransformsSet) {
+ mOverscrollTransformsSet = true;
+ cl.setCameraDistance(mDensity * mCameraDistance);
+ cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+ cl.setOverscrollTransformsDirty(true);
+ }
}
} else {
if (mOverscrollFade != 0) {
@@ -1321,7 +1424,9 @@ public class Workspace extends SmoothPagedView
@Override
protected void onDraw(Canvas canvas) {
- updateWallpaperOffsets();
+ if (mScrollWallpaper) {
+ updateWallpaperOffsets();
+ }
// Draw the background gradient if necessary
if (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground) {
@@ -1764,11 +1869,13 @@ public class Workspace extends SmoothPagedView
d.draw(destCanvas);
} else {
if (v instanceof FolderIcon) {
- // For FolderIcons the text can bleed into the icon area, and so we need to
- // hide the text completely (which can't be achieved by clipping).
- if (((FolderIcon) v).getTextVisible()) {
- ((FolderIcon) v).setTextVisible(false);
- textVisible = true;
+ if (!mHideIconLabels) {
+ // For FolderIcons the text can bleed into the icon area, and so we need to
+ // hide the text completely (which can't be achieved by clipping).
+ if (((FolderIcon) v).getTextVisible()) {
+ ((FolderIcon) v).setTextVisible(false);
+ textVisible = true;
+ }
}
} else if (v instanceof BubbleTextView) {
final BubbleTextView tv = (BubbleTextView) v;
@@ -1784,7 +1891,7 @@ public class Workspace extends SmoothPagedView
v.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
- if (textVisible) {
+ if (!mHideIconLabels && textVisible) {
((FolderIcon) v).setTextVisible(true);
}
}
@@ -2268,7 +2375,7 @@ public class Workspace extends SmoothPagedView
final LauncherAppWidgetHostView hostView = (LauncherAppWidgetHostView) cell;
AppWidgetProviderInfo pinfo = hostView.getAppWidgetInfo();
if (pinfo != null &&
- pinfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE) {
+ pinfo.resizeMode != AppWidgetProviderInfo.RESIZE_NONE || mResizeAnyWidget) {
final Runnable addResizeFrame = new Runnable() {
public void run() {
DragLayer dragLayer = mLauncher.getDragLayer();
@@ -3099,6 +3206,9 @@ public class Workspace extends SmoothPagedView
case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:
view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher, cellLayout,
(FolderInfo) info, mIconCache);
+ if (mHideIconLabels) {
+ ((FolderIcon) view).setTextVisible(false);
+ }
break;
default:
throw new IllegalStateException("Unknown item type: " + info.itemType);
@@ -3332,6 +3442,9 @@ public class Workspace extends SmoothPagedView
// needed
updateChildrenLayersEnabled();
setWallpaperDimension();
+ if (!mScrollWallpaper) {
+ centerWallpaperOffset();
+ }
}
/**
@@ -3774,12 +3887,12 @@ public class Workspace extends SmoothPagedView
void moveToDefaultScreen(boolean animate) {
if (!isSmall()) {
if (animate) {
- snapToPage(mDefaultPage);
+ snapToPage(mDefaultHomescreen);
} else {
- setCurrentPage(mDefaultPage);
+ setCurrentPage(mDefaultHomescreen);
}
}
- getChildAt(mDefaultPage).requestFocus();
+ getChildAt(mDefaultHomescreen).requestFocus();
}
@Override
@@ -3812,8 +3925,8 @@ public class Workspace extends SmoothPagedView
final View scrollIndicator = getScrollingIndicator();
cancelScrollingIndicatorAnimations();
- if (qsbDivider != null) qsbDivider.setAlpha(reducedFade);
- if (dockDivider != null) dockDivider.setAlpha(reducedFade);
- scrollIndicator.setAlpha(1 - fade);
+ if (qsbDivider != null && mShowSearchBar) qsbDivider.setAlpha(reducedFade);
+ if (dockDivider != null && mShowDockDivider) dockDivider.setAlpha(reducedFade);
+ if (scrollIndicator != null && mShowScrollingIndicator) scrollIndicator.setAlpha(1 - fade);
}
}
diff --git a/src/com/cyanogenmod/trebuchet/preference/DoubleNumberPickerPreference.java b/src/com/cyanogenmod/trebuchet/preference/DoubleNumberPickerPreference.java
new file mode 100644
index 0000000..1a38639
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/preference/DoubleNumberPickerPreference.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod 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.cyanogenmod.trebuchet.preference;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.preference.DialogPreference;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.EditText;
+import android.widget.NumberPicker;
+import com.cyanogenmod.trebuchet.R;
+
+/*
+ * @author Danesh
+ * @author nebkat
+ */
+
+public class DoubleNumberPickerPreference extends DialogPreference {
+ private int mMin1, mMax1, mDefault1;
+ private int mMin2, mMax2, mDefault2;
+
+ private String mMaxExternalKey1, mMinExternalKey1;
+ private String mMaxExternalKey2, mMinExternalKey2;
+
+ private String mPickerTitle1;
+ private String mPickerTitle2;
+
+ private NumberPicker mNumberPicker1;
+ private NumberPicker mNumberPicker2;
+
+ public DoubleNumberPickerPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ TypedArray dialogType = context.obtainStyledAttributes(attrs,
+ com.android.internal.R.styleable.DialogPreference, 0, 0);
+ TypedArray doubleNumberPickerType = context.obtainStyledAttributes(attrs,
+ R.styleable.DoubleNumberPickerPreference, 0, 0);
+
+ mMaxExternalKey1 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_maxExternal1);
+ mMinExternalKey1 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_minExternal1);
+ mMaxExternalKey2 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_maxExternal2);
+ mMinExternalKey2 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_minExternal2);
+
+ mPickerTitle1 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_pickerTitle1);
+ mPickerTitle2 = doubleNumberPickerType.getString(R.styleable.DoubleNumberPickerPreference_pickerTitle2);
+
+ mMax1 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_max1, 5);
+ mMin1 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_min1, 0);
+ mMax2 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_max2, 5);
+ mMin2 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_min2, 0);
+
+ mDefault1 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_defaultValue1, mMin1);
+ mDefault2 = doubleNumberPickerType.getInt(R.styleable.DoubleNumberPickerPreference_defaultValue2, mMin2);
+
+ dialogType.recycle();
+ doubleNumberPickerType.recycle();
+ }
+
+ @Override
+ protected View onCreateDialogView() {
+ int max1 = mMax1;
+ int min1 = mMin1;
+ int max2 = mMax2;
+ int min2 = mMin2;
+
+ // External values
+ if (mMaxExternalKey1 != null) {
+ max1 = getSharedPreferences().getInt(mMaxExternalKey1, mMax1);
+ }
+ if (mMinExternalKey1 != null) {
+ min1 = getSharedPreferences().getInt(mMinExternalKey1, mMin1);
+ }
+ if (mMaxExternalKey2 != null) {
+ max2 = getSharedPreferences().getInt(mMaxExternalKey2, mMax2);
+ }
+ if (mMinExternalKey2 != null) {
+ min2 = getSharedPreferences().getInt(mMinExternalKey2, mMin2);
+ }
+
+ LayoutInflater inflater =
+ (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View view = inflater.inflate(R.layout.double_number_picker_dialog, null);
+
+ mNumberPicker1 = (NumberPicker) view.findViewById(R.id.number_picker_1);
+ mNumberPicker2 = (NumberPicker) view.findViewById(R.id.number_picker_2);
+
+ if (mNumberPicker1 == null || mNumberPicker2 == null) {
+ throw new RuntimeException("mNumberPicker1 or mNumberPicker2 is null!");
+ }
+
+ // Initialize state
+ mNumberPicker1.setWrapSelectorWheel(false);
+ mNumberPicker1.setMaxValue(max1);
+ mNumberPicker1.setMinValue(min1);
+ mNumberPicker1.setValue(getPersistedValue(1));
+ mNumberPicker2.setWrapSelectorWheel(false);
+ mNumberPicker2.setMaxValue(max2);
+ mNumberPicker2.setMinValue(min2);
+ mNumberPicker2.setValue(getPersistedValue(2));
+
+ // Titles
+ TextView pickerTitle1 = (TextView) view.findViewById(R.id.picker_title_1);
+ TextView pickerTitle2 = (TextView) view.findViewById(R.id.picker_title_2);
+
+ if (pickerTitle1 != null && pickerTitle2 != null) {
+ pickerTitle1.setText(mPickerTitle1);
+ pickerTitle2.setText(mPickerTitle2);
+ }
+
+ // No keyboard popup
+ EditText textInput1 = (EditText) mNumberPicker1.findViewById(com.android.internal.R.id.numberpicker_input);
+ EditText textInput2 = (EditText) mNumberPicker2.findViewById(com.android.internal.R.id.numberpicker_input);
+ if (textInput1 != null && textInput2 != null) {
+ textInput1.setCursorVisible(false);
+ textInput1.setFocusable(false);
+ textInput1.setFocusableInTouchMode(false);
+ textInput2.setCursorVisible(false);
+ textInput2.setFocusable(false);
+ textInput2.setFocusableInTouchMode(false);
+ }
+
+ return view;
+ }
+
+ private int getPersistedValue(int value) {
+ String[] values = getPersistedString(mDefault1 + "|" + mDefault2).split("\\|");
+ if (value == 1) {
+ try {
+ return Integer.parseInt(values[0]);
+ } catch (NumberFormatException e) {
+ return mDefault1;
+ }
+ } else {
+ try {
+ return Integer.parseInt(values[1]);
+ } catch (NumberFormatException e) {
+ return mDefault2;
+ }
+ }
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ if (positiveResult) {
+ persistString(mNumberPicker1.getValue() + "|" + mNumberPicker2.getValue());;
+ }
+ }
+
+ public void setMin1(int min) {
+ mMin1 = min;
+ }
+ public void setMax1(int max) {
+ mMax1 = max;
+ }
+ public void setMin2(int min) {
+ mMin2 = min;
+ }
+ public void setMax2(int max) {
+ mMax2 = max;
+ }
+ public void setDefault1(int def) {
+ mDefault1 = def;
+ }
+ public void setDefault2(int def) {
+ mDefault2 = def;
+ }
+
+}
diff --git a/src/com/cyanogenmod/trebuchet/preference/NumberPickerPreference.java b/src/com/cyanogenmod/trebuchet/preference/NumberPickerPreference.java
new file mode 100644
index 0000000..8e1058c
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/preference/NumberPickerPreference.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod 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.cyanogenmod.trebuchet.preference;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.preference.Preference;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.NumberPicker;
+
+import com.cyanogenmod.trebuchet.R;
+
+/*
+ * @author Danesh
+ * @author nebkat
+ */
+
+public class NumberPickerPreference extends DialogPreference {
+ private int mMin, mMax, mDefault;
+
+ private String mMaxExternalKey, mMinExternalKey;
+
+ private NumberPicker mNumberPicker;
+
+ public NumberPickerPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ TypedArray dialogType = context.obtainStyledAttributes(attrs,
+ com.android.internal.R.styleable.DialogPreference, 0, 0);
+ TypedArray numberPickerType = context.obtainStyledAttributes(attrs,
+ R.styleable.NumberPickerPreference, 0, 0);
+
+ mMaxExternalKey = numberPickerType.getString(R.styleable.NumberPickerPreference_maxExternal);
+ mMinExternalKey = numberPickerType.getString(R.styleable.NumberPickerPreference_minExternal);
+
+ mMax = numberPickerType.getInt(R.styleable.NumberPickerPreference_max, 5);
+ mMin = numberPickerType.getInt(R.styleable.NumberPickerPreference_min, 0);
+
+ mDefault = dialogType.getInt(com.android.internal.R.styleable.Preference_defaultValue, mMin);
+
+ dialogType.recycle();
+ numberPickerType.recycle();
+ }
+
+ @Override
+ protected View onCreateDialogView() {
+ int max = mMax;
+ int min = mMin;
+
+ // External values
+ if (mMaxExternalKey != null) {
+ max = getSharedPreferences().getInt(mMaxExternalKey, mMax);
+ }
+ if (mMinExternalKey != null) {
+ min = getSharedPreferences().getInt(mMinExternalKey, mMin);
+ }
+
+ LayoutInflater inflater =
+ (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View view = inflater.inflate(R.layout.number_picker_dialog, null);
+
+ mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);
+
+ // Initialize state
+ mNumberPicker.setMaxValue(max);
+ mNumberPicker.setMinValue(min);
+ mNumberPicker.setValue(getPersistedInt(mDefault));
+ mNumberPicker.setWrapSelectorWheel(false);
+
+ // No keyboard popup
+ EditText textInput = (EditText) mNumberPicker.findViewById(com.android.internal.R.id.numberpicker_input);
+ textInput.setCursorVisible(false);
+ textInput.setFocusable(false);
+ textInput.setFocusableInTouchMode(false);
+
+ return view;
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ if (positiveResult) {
+ persistInt(mNumberPicker.getValue());
+ }
+ }
+
+}
diff --git a/src/com/cyanogenmod/trebuchet/preference/Preferences.java b/src/com/cyanogenmod/trebuchet/preference/Preferences.java
new file mode 100644
index 0000000..8f90c4f
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/preference/Preferences.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod 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.cyanogenmod.trebuchet.preference;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+
+import com.cyanogenmod.trebuchet.R;
+
+public class Preferences extends PreferenceActivity
+ implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+ private static final String TAG = "Launcher.Preferences";
+
+ private SharedPreferences mPrefs;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.preferences);
+
+ mPrefs = getSharedPreferences(PreferencesProvider.PREFERENCES_KEY,
+ Context.MODE_PRIVATE);
+
+ Preference version = findPreference("application_version");
+ version.setTitle(getString(R.string.application_name) + " " + getString(R.string.application_version));
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mPrefs.registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ protected void onPause() {
+ mPrefs.unregisterOnSharedPreferenceChangeListener(this);
+ super.onPause();
+ }
+
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ SharedPreferences.Editor editor = mPrefs.edit();
+ editor.putBoolean(PreferencesProvider.PREFERENCES_CHANGED, true);
+ editor.commit();
+ }
+
+}
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
new file mode 100644
index 0000000..e12bf00
--- /dev/null
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod 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.cyanogenmod.trebuchet.preference;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import com.cyanogenmod.trebuchet.LauncherApplication;
+import com.cyanogenmod.trebuchet.Workspace;
+import com.cyanogenmod.trebuchet.AppsCustomizePagedView;
+
+public final class PreferencesProvider {
+ public static final String PREFERENCES_KEY = "com.cyanogenmod.trebuchet_preferences";
+
+ public static final String PREFERENCES_CHANGED = "preferences_changed";
+ public static class Interface {
+ public static class Homescreen {
+ public static int getNumberHomescreens(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getInt("ui_homescreen_screens", 5);
+ }
+ public static int getDefaultHomescreen(Context context, int def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getInt("ui_homescreen_default_screen", def + 1) - 1;
+ }
+ public static int getCellCountX(Context context, int def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ String[] values = preferences.getString("ui_homescreen_grid", "0|" + def).split("\\|");
+ try {
+ return Integer.parseInt(values[1]);
+ } catch (NumberFormatException e) {
+ return def;
+ }
+ }
+ public static int getCellCountY(Context context, int def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ String[] values = preferences.getString("ui_homescreen_grid", def + "|0").split("\\|");;
+ try {
+ return Integer.parseInt(values[0]);
+ } catch (NumberFormatException e) {
+ return def;
+ }
+ }
+ public static int getScreenPaddingVertical(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return (int)((float) preferences.getInt("ui_homescreen_screen_padding_vertical", 0) * 3.0f *
+ LauncherApplication.getScreenDensity());
+ }
+ public static int getScreenPaddingHorizontal(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return (int)((float) preferences.getInt("ui_homescreen_screen_padding_horizontal", 0) * 3.0f *
+ LauncherApplication.getScreenDensity());
+ }
+ public static boolean getShowSearchBar(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_general_search", true);
+ }
+ public static boolean getResizeAnyWidget(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_general_resize_any_widget", false);
+ }
+ public static boolean getHideIconLabels(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_general_hide_icon_labels", false);
+ }
+ public static class Scrolling {
+ public static boolean getScrollWallpaper(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true);
+ }
+ }
+ public static class Indicator {
+ public static boolean getShowScrollingIndicator(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_indicator_enable", true);
+ }
+ public static boolean getFadeScrollingIndicator(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_indicator_fade", true);
+ }
+ public static boolean getShowDockDivider(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_indicator_background", true);
+ }
+ }
+ }
+
+ public static class Drawer {
+ public static boolean getJoinWidgetsApps(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_drawer_widgets_join_apps", true);
+ }
+ public static class Indicator {
+ public static boolean getShowScrollingIndicator(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_drawer_indicator_enable", true);
+ }
+ public static boolean getFadeScrollingIndicator(Context context) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_drawer_indicator_fade", true);
+ }
+ }
+ }
+
+ public static class Dock {
+
+ }
+
+ public static class Icons {
+
+ }
+
+ public static class General {
+ public static boolean getAutoRotate(Context context, boolean def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_general_orientation", def);
+ }
+ }
+ }
+
+ public static class Application {
+
+ }
+}