From d2f8f8f41f5d625e4db3503d1fb042b615939278 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Tue, 4 Dec 2012 14:38:20 -0800 Subject: This is causing a lot of weirdness on tablets' hotseats, + mild weirdness (such as roaming AllApps icon) on phones Revert "Trebuchet : Add a pref to set hotseat icon's number" This reverts commit e74a54343ce7896b5005154e8bcbc7d5f06c7808 --- .../cyanogenmod/trebuchet/AllAppsButtonInfo.java | 35 ------------------ .../cyanogenmod/trebuchet/DeleteDropTarget.java | 7 ---- src/com/cyanogenmod/trebuchet/DragController.java | 10 ++--- src/com/cyanogenmod/trebuchet/Hotseat.java | 43 +++------------------- src/com/cyanogenmod/trebuchet/ItemInfo.java | 1 - src/com/cyanogenmod/trebuchet/Launcher.java | 2 +- src/com/cyanogenmod/trebuchet/LauncherModel.java | 13 ++----- .../cyanogenmod/trebuchet/LauncherSettings.java | 5 --- .../cyanogenmod/trebuchet/SearchDropTargetBar.java | 10 ----- src/com/cyanogenmod/trebuchet/Workspace.java | 19 ++-------- .../trebuchet/preference/Preferences.java | 4 -- .../trebuchet/preference/PreferencesProvider.java | 14 +------ 12 files changed, 18 insertions(+), 145 deletions(-) delete mode 100644 src/com/cyanogenmod/trebuchet/AllAppsButtonInfo.java (limited to 'src/com') diff --git a/src/com/cyanogenmod/trebuchet/AllAppsButtonInfo.java b/src/com/cyanogenmod/trebuchet/AllAppsButtonInfo.java deleted file mode 100644 index 3d0d91601..000000000 --- a/src/com/cyanogenmod/trebuchet/AllAppsButtonInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.cyanogenmod.trebuchet; - -/** - * Represents the AllApps button in hotseat - */ -class AllAppsButtonInfo extends ItemInfo { - - AllAppsButtonInfo() { - itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_ALLAPPS; - } - - @Override - public String toString() { - return "AllAppsButtonInfo(id=" + this.id + " type=" + this.itemType - + " container=" + this.container + " screen=" + screen - + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY - + " dropPos=" + dropPos + ")"; - } -} diff --git a/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java b/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java index c4bacfeb8..2cc872a56 100644 --- a/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java +++ b/src/com/cyanogenmod/trebuchet/DeleteDropTarget.java @@ -131,9 +131,6 @@ public class DeleteDropTarget extends ButtonDropTarget { private boolean isWorkspaceFolder(DragSource source, Object info) { return (source instanceof Workspace) && (info instanceof FolderInfo); } - private boolean isAllAppsButton(Object info) { - return (info instanceof AllAppsButtonInfo); - } private void setHoverColor() { setTextColor(mHoverColor); @@ -150,10 +147,6 @@ public class DeleteDropTarget extends ButtonDropTarget { @Override public void onDragStart(DragSource source, Object info, int dragAction) { - // If it's the AllApps button, from Hotseat, don't do anything. - if (isAllAppsButton(info)) { - return; - } boolean isUninstall = false; // If we are dragging an application from AppsCustomize, only show the uninstall control if we diff --git a/src/com/cyanogenmod/trebuchet/DragController.java b/src/com/cyanogenmod/trebuchet/DragController.java index b7709373f..047c45548 100644 --- a/src/com/cyanogenmod/trebuchet/DragController.java +++ b/src/com/cyanogenmod/trebuchet/DragController.java @@ -34,7 +34,6 @@ import android.view.ViewConfiguration; import android.view.inputmethod.InputMethodManager; import com.cyanogenmod.trebuchet.R; -import com.cyanogenmod.trebuchet.DropTarget.DragObject; import java.util.ArrayList; @@ -441,7 +440,7 @@ public class DragController { case MotionEvent.ACTION_UP: mLastTouchUpTime = System.currentTimeMillis(); if (mDragging) { - PointF vec = isFlingingToDelete(mDragObject); + PointF vec = isFlingingToDelete(mDragObject.dragSource); if (vec != null) { dropOnFlingToDeleteTarget(dragLayerX, dragLayerY, vec); } else { @@ -583,7 +582,7 @@ public class DragController { mHandler.removeCallbacks(mScrollRunnable); if (mDragging) { - PointF vec = isFlingingToDelete(mDragObject); + PointF vec = isFlingingToDelete(mDragObject.dragSource); if (vec != null) { dropOnFlingToDeleteTarget(dragLayerX, dragLayerY, vec); } else { @@ -606,10 +605,9 @@ public class DragController { * * @return the vector at which the item was flung, or null if no fling was detected. */ - private PointF isFlingingToDelete(DragObject object) { + private PointF isFlingingToDelete(DragSource source) { if (mFlingToDeleteDropTarget == null) return null; - if (!object.dragSource.supportsFlingToDelete()) return null; - if (object.dragInfo instanceof AllAppsButtonInfo) return null; + if (!source.supportsFlingToDelete()) return null; ViewConfiguration config = ViewConfiguration.get(mLauncher); mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity()); diff --git a/src/com/cyanogenmod/trebuchet/Hotseat.java b/src/com/cyanogenmod/trebuchet/Hotseat.java index d196cf074..46eb6d701 100644 --- a/src/com/cyanogenmod/trebuchet/Hotseat.java +++ b/src/com/cyanogenmod/trebuchet/Hotseat.java @@ -27,8 +27,6 @@ import android.view.View; import android.widget.FrameLayout; import com.cyanogenmod.trebuchet.R; -import com.cyanogenmod.trebuchet.preference.Preferences; -import com.cyanogenmod.trebuchet.preference.PreferencesProvider; public class Hotseat extends FrameLayout { @SuppressWarnings("unused") @@ -60,29 +58,14 @@ public class Hotseat extends FrameLayout { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Hotseat, defStyle, 0); - - int numberHotseatIcons = PreferencesProvider.Interface.Dock.getNumberHotseatIcons(context); - int defaultHotseatIcon = PreferencesProvider.Interface.Dock.getDefaultHotseatIcon(context, - context.getResources().getInteger(R.integer.hotseat_all_apps_index)); - if (defaultHotseatIcon >= numberHotseatIcons) { - defaultHotseatIcon = numberHotseatIcons - 1; - PreferencesProvider.Interface.Dock.setDefaultHotseatIcon(context, defaultHotseatIcon); - } - - mTransposeLayoutWithOrientation = - getResources().getBoolean(R.bool.hotseat_transpose_layout_with_orientation); - + Resources r = context.getResources(); + mCellCountX = a.getInt(R.styleable.Hotseat_cellCountX, -1); + mCellCountY = a.getInt(R.styleable.Hotseat_cellCountY, -1); + mAllAppsButtonRank = r.getInteger(R.integer.hotseat_all_apps_index); + mTransposeLayoutWithOrientation = + r.getBoolean(R.bool.hotseat_transpose_layout_with_orientation); mIsLandscape = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; - - if (mIsLandscape) { - mCellCountX = a.getInt(R.styleable.Hotseat_cellCountX, -1); - mCellCountY = numberHotseatIcons; - } else { - mCellCountX = numberHotseatIcons; - mCellCountY = a.getInt(R.styleable.Hotseat_cellCountY, -1); - } - mAllAppsButtonRank = defaultHotseatIcon; } public void setup(Launcher launcher) { @@ -156,24 +139,10 @@ public class Hotseat extends FrameLayout { } }); - allAppsButton.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View v) { - if (mLauncher != null) { - return mLauncher.onLongClick(v); - } - return false; - } - }); - // Note: We do this to ensure that the hotseat is always laid out in the orientation of // the hotseat in order regardless of which orientation they were added int x = getCellXFromOrder(mAllAppsButtonRank); int y = getCellYFromOrder(mAllAppsButtonRank); - AllAppsButtonInfo allAppsButtonInfo = new AllAppsButtonInfo(); - allAppsButtonInfo.cellX = x; - allAppsButtonInfo.cellY = y; - allAppsButton.setTag(allAppsButtonInfo); CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1); lp.canReorder = false; mContent.addViewToCellLayout(allAppsButton, -1, 0, lp, true); diff --git a/src/com/cyanogenmod/trebuchet/ItemInfo.java b/src/com/cyanogenmod/trebuchet/ItemInfo.java index 061cdf869..34c7364c8 100644 --- a/src/com/cyanogenmod/trebuchet/ItemInfo.java +++ b/src/com/cyanogenmod/trebuchet/ItemInfo.java @@ -39,7 +39,6 @@ class ItemInfo { /** * One of {@link LauncherSettings.Favorites#ITEM_TYPE_APPLICATION}, * {@link LauncherSettings.Favorites#ITEM_TYPE_SHORTCUT}, - * {@link LauncherSettings.Favorites#ITEM_TYPE_ALLAPPS}, * {@link LauncherSettings.Favorites#ITEM_TYPE_FOLDER}, or * {@link LauncherSettings.Favorites#ITEM_TYPE_APPWIDGET}. */ diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java index e5ef20e2d..0de10632b 100644 --- a/src/com/cyanogenmod/trebuchet/Launcher.java +++ b/src/com/cyanogenmod/trebuchet/Launcher.java @@ -2451,7 +2451,7 @@ public final class Launcher extends Activity } public boolean isAllAppsButtonRank(int rank) { - return (mHotseat != null) ? mHotseat.isAllAppsButtonRank(rank) : false; + return mHotseat.isAllAppsButtonRank(rank); } /** diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java index f3face7b8..6f1ab5656 100644 --- a/src/com/cyanogenmod/trebuchet/LauncherModel.java +++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java @@ -49,7 +49,6 @@ import android.util.Log; import com.cyanogenmod.trebuchet.R; import com.cyanogenmod.trebuchet.InstallWidgetReceiver.WidgetMimeTypeHandlerData; -import com.cyanogenmod.trebuchet.preference.PreferencesProvider; import java.lang.ref.WeakReference; import java.net.URISyntaxException; @@ -1182,15 +1181,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[PreferencesProvider.Interface.Homescreen.getNumberHomescreens(mContext)] - [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.MAX_SCREEN_COUNT][item.screen][0]); return false; } else { - occupied[PreferencesProvider.Interface.Homescreen.getNumberHomescreens(mContext)] - [item.screen][0] = item; + occupied[Launcher.MAX_SCREEN_COUNT][item.screen][0] = item; return true; } } else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) { @@ -1247,10 +1244,8 @@ public class LauncherModel extends BroadcastReceiver { // +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) - int numberHotseatIcons = PreferencesProvider.Interface.Dock.getNumberHotseatIcons(mContext); final ItemInfo occupied[][][] = - new ItemInfo[PreferencesProvider.Interface.Homescreen.getNumberHomescreens(mContext) + 1] - [Math.max(mCellCountX, numberHotseatIcons)][mCellCountY]; + new ItemInfo[Launcher.MAX_SCREEN_COUNT + 1][mCellCountX + 1][mCellCountY + 1]; try { final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID); @@ -1338,8 +1333,6 @@ public class LauncherModel extends BroadcastReceiver { // check & update map of what's occupied if (!checkItemPlacement(occupied, info)) { - id = c.getLong(idIndex); - itemsToRemove.add(id); break; } diff --git a/src/com/cyanogenmod/trebuchet/LauncherSettings.java b/src/com/cyanogenmod/trebuchet/LauncherSettings.java index 1cc13037d..361dd69a0 100644 --- a/src/com/cyanogenmod/trebuchet/LauncherSettings.java +++ b/src/com/cyanogenmod/trebuchet/LauncherSettings.java @@ -55,11 +55,6 @@ class LauncherSettings { */ static final int ITEM_TYPE_SHORTCUT = 1; - /** - * The gesture is the All Apps button - */ - static final int ITEM_TYPE_ALLAPPS = 5; - /** * The icon type. *

Type: INTEGER

diff --git a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java index e9ec7dddd..00b5f389e 100644 --- a/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java +++ b/src/com/cyanogenmod/trebuchet/SearchDropTargetBar.java @@ -188,21 +188,11 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D return sTransitionOutDuration; } - private boolean isAllAppsButton(Object info) { - return (info instanceof AllAppsButtonInfo); - } - /* * DragController.DragListener implementation */ @Override public void onDragStart(DragSource source, Object info, int dragAction) { - // If it's the AllApps button, from Hotseat, don't do anything. - if (isAllAppsButton(info)) { - deferOnDragEnd(); - return; - } - // Animate out the QSB search bar, and animate in the drop target bar prepareStartAnimation(mDropTargetBar); mDropTargetBarAnim.start(); diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java index b7fdf36bb..b3771cba0 100644 --- a/src/com/cyanogenmod/trebuchet/Workspace.java +++ b/src/com/cyanogenmod/trebuchet/Workspace.java @@ -2453,17 +2453,8 @@ public class Workspace extends SmoothPagedView } } - // No_id check required as the AllApps button doesn't have an item info id - if (info.id != ItemInfo.NO_ID) { - LauncherModel.moveItemInDatabase(mLauncher, info, container, screen, lp.cellX, - lp.cellY); - } else if (info instanceof AllAppsButtonInfo) { - if (!LauncherApplication.isScreenLandscape(getContext())) { - PreferencesProvider.Interface.Dock.setDefaultHotseatIcon(getContext(), lp.cellX); - } else { - PreferencesProvider.Interface.Dock.setDefaultHotseatIcon(getContext(), lp.cellY); - } - } + LauncherModel.moveItemInDatabase(mLauncher, info, container, screen, lp.cellX, + lp.cellY); } else { // If we can't find a drop location, we return the item to its original position CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams(); @@ -2913,10 +2904,6 @@ public class Workspace extends SmoothPagedView return d.dragSource != this && isDragWidget(d); } - private boolean isDragAllAppsButton(DragObject d) { - return (d.dragInfo instanceof AllAppsButtonInfo); - } - public void onDragOver(DragObject d) { // Skip drag over events while we are dragging over side pages if (mInScrollArea || mIsSwitchingState || mState == State.SMALL) return; @@ -2960,7 +2947,7 @@ public class Workspace extends SmoothPagedView // Test to see if we are over the hotseat otherwise just use the current page if (mLauncher.getHotseat() != null && !isDragWidget(d)) { mLauncher.getHotseat().getHitRect(r); - if (r.contains(d.x, d.y) || isDragAllAppsButton(d)) { + if (r.contains(d.x, d.y)) { layout = mLauncher.getHotseat().getLayout(); } } diff --git a/src/com/cyanogenmod/trebuchet/preference/Preferences.java b/src/com/cyanogenmod/trebuchet/preference/Preferences.java index a4e806f37..8f90c4f47 100644 --- a/src/com/cyanogenmod/trebuchet/preference/Preferences.java +++ b/src/com/cyanogenmod/trebuchet/preference/Preferences.java @@ -22,7 +22,6 @@ import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; -import com.cyanogenmod.trebuchet.LauncherApplication; import com.cyanogenmod.trebuchet.R; public class Preferences extends PreferenceActivity @@ -36,9 +35,6 @@ public class Preferences extends PreferenceActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); - if (LauncherApplication.isScreenLarge()) { - findPreference("ui_dock").setEnabled(false); - } mPrefs = getSharedPreferences(PreferencesProvider.PREFERENCES_KEY, Context.MODE_PRIVATE); diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java index 0af36bd40..d66bab20e 100644 --- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java +++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.SharedPreferences; import com.cyanogenmod.trebuchet.LauncherApplication; -import com.cyanogenmod.trebuchet.R; import com.cyanogenmod.trebuchet.Workspace; import com.cyanogenmod.trebuchet.AppsCustomizePagedView; @@ -122,18 +121,7 @@ public final class PreferencesProvider { } public static class Dock { - public static int getNumberHotseatIcons(Context context) { - final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); - return preferences.getInt("ui_dock_hotseat_size", context.getResources().getInteger(R.integer.hotseat_cell_count)); - } - public static int getDefaultHotseatIcon(Context context, int def) { - final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); - return preferences.getInt("ui_dock_hotseat_apps_index", def); - } - public static void setDefaultHotseatIcon(Context context, int val) { - final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0); - preferences.edit().putInt("ui_dock_hotseat_apps_index", val).apply(); - } + } public static class Icons { -- cgit v1.2.3