diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher3/AppsCustomizePagedView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/DragLayer.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher3/DynamicGridSizeFragment.java | 235 | ||||
-rw-r--r-- | src/com/android/launcher3/Folder.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher3/GelIntegrationHelper.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 64 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherAnimUtils.java | 21 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherViewPropertyAnimator.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/OverviewSettingsPanel.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/TransitionEffectsFragment.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 300 |
14 files changed, 440 insertions, 296 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index f2c08a3e1..4dcf22f34 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -1937,6 +1937,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mSortMode = sortMode; + sortApps(); + } + + public void sortApps() { Collections.sort(mFilteredApps, getComparatorForSortMode()); if (mContentType == ContentType.Applications) { diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 99819caf3..ec6e47f49 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -297,7 +297,7 @@ public class DeviceProfile { searchBarVisible = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, R.bool.preferences_interface_homescreen_search_default); searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx); - searchBarSpaceHeightPx = 2 * edgeMarginPx + (searchBarVisible ? searchBarHeightPx : 2 * edgeMarginPx); + searchBarSpaceHeightPx = 2 * edgeMarginPx + (searchBarVisible ? searchBarHeightPx : 3 * edgeMarginPx); } void addCallback(DeviceProfileCallbacks cb) { @@ -382,9 +382,9 @@ public class DeviceProfile { hotseatIconSizePx = (int) (DynamicGrid.pxFromDp(hotseatIconSize, dm) * scale); // Search Bar - searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx); searchBarSpaceMaxWidthPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width); searchBarHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height); + searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx); searchBarSpaceHeightPx = searchBarHeightPx + getSearchBarTopOffset(); // Calculate the actual text height @@ -707,15 +707,19 @@ public class DeviceProfile { // Update search bar for live settings searchBarVisible = SettingsProvider.getBoolean(launcher, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, R.bool.preferences_interface_homescreen_search_default); - searchBarSpaceHeightPx = 2 * edgeMarginPx + (searchBarVisible ? searchBarHeightPx : 2 * edgeMarginPx); + searchBarSpaceHeightPx = 2 * edgeMarginPx + (searchBarVisible ? searchBarHeightPx : 3 * edgeMarginPx); FrameLayout.LayoutParams lp; Resources res = launcher.getResources(); boolean hasVerticalBarLayout = isVerticalBarLayout(); // Layout the search bar space View searchBar = launcher.getSearchBar(); + LinearLayout dropTargetBar = (LinearLayout) launcher.getSearchBar().getDropTargetBar(); lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); if (hasVerticalBarLayout) { + // If search bar is invisible add some extra padding for the drop targets + searchBarSpaceHeightPx = searchBarVisible ? searchBarSpaceHeightPx + : searchBarSpaceHeightPx + 5 * edgeMarginPx; // Vertical search bar space lp.gravity = Gravity.TOP | Gravity.LEFT; lp.width = searchBarSpaceHeightPx; @@ -724,9 +728,7 @@ public class DeviceProfile { 0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx); - searchBar.setVisibility(searchBarVisible ? View.VISIBLE : View.GONE); - LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar); - targets.setOrientation(LinearLayout.VERTICAL); + dropTargetBar.setOrientation(LinearLayout.VERTICAL); } else { // Horizontal search bar space lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; @@ -740,7 +742,6 @@ public class DeviceProfile { searchBar.setLayoutParams(lp); // Layout the drop target icons - LinearLayout dropTargetBar = (LinearLayout) launcher.getSearchBar().getDropTargetBar(); if (hasVerticalBarLayout) { dropTargetBar.setOrientation(LinearLayout.VERTICAL); } else { diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index 2dde8e402..5ab56149c 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -36,6 +36,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.TextView; import java.util.ArrayList; @@ -109,6 +110,12 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang for (int i = 0; i < n; i++) { final View child = getChildAt(i); if (child.getId() == R.id.overview_panel) { + LinearLayout layout = (LinearLayout) + child.findViewById(R.id.settings_container); + FrameLayout.LayoutParams lp = + (FrameLayout.LayoutParams) layout.getLayoutParams(); + lp.bottomMargin += insets.bottom - mInsets.bottom; + layout.setLayoutParams(lp); continue; } setInsets(child, insets, mInsets); diff --git a/src/com/android/launcher3/DynamicGridSizeFragment.java b/src/com/android/launcher3/DynamicGridSizeFragment.java index 490335ddf..69720a5a2 100644 --- a/src/com/android/launcher3/DynamicGridSizeFragment.java +++ b/src/com/android/launcher3/DynamicGridSizeFragment.java @@ -1,6 +1,23 @@ +/* + * Copyright (C) 2014 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.android.launcher3; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.app.Dialog; import android.app.Fragment; @@ -8,30 +25,35 @@ import android.content.Context; import android.content.DialogInterface; import android.content.res.Resources; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; -import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.NumberPicker; import android.widget.TextView; + import com.android.launcher3.settings.SettingsProvider; -public class DynamicGridSizeFragment extends Fragment implements NumberPicker.OnValueChangeListener, Dialog.OnDismissListener{ - public static final String DYNAMIC_GRID_SIZE_FRAGMENT = "dynamicGridSizeFragment"; +public class DynamicGridSizeFragment extends Fragment + implements NumberPicker.OnValueChangeListener, Dialog.OnDismissListener { + public static final String DYNAMIC_GRID_SIZE_FRAGMENT = "DynamicGridSizeFragment"; + public static final int MIN_DYNAMIC_GRID_ROWS = 2; public static final int MIN_DYNAMIC_GRID_COLUMNS = 3; - ImageView mDynamicGridImage; + + GridSizeView mDynamicGrid; + ListView mListView; View mCurrentSelection; GridSizeArrayAdapter mAdapter; @@ -43,11 +65,9 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On int mCustomGridColumns = 0; View.OnClickListener mSettingsItemListener = new View.OnClickListener() { - @Override public void onClick(View v) { - mCurrentSize = DeviceProfile.GridSize - .getModeForValue((Integer) v.getTag()); + mCurrentSize = DeviceProfile.GridSize.getModeForValue((Integer) v.getTag()); setCleared(mCurrentSelection); setSelected(v); @@ -60,16 +80,23 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On ((GridSizeArrayAdapter) mListView.getAdapter()).notifyDataSetChanged(); mAdapter.notifyDataSetInvalidated(); - setCurrentImage(); + updateGridMetrics(); } }; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dynamic_grid_size_screen, container, false); - mDynamicGridImage = (ImageView) v.findViewById(R.id.dynamic_grid_size_image); - mDynamicGridImage.setBackground(getResources().getDrawable(R.drawable.grid)); + mDynamicGrid = (GridSizeView) v.findViewById(R.id.dynamic_grid_size_image); + mListView = (ListView) v.findViewById(R.id.dynamic_grid_list); + + Launcher launcher = (Launcher) getActivity(); + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) + mListView.getLayoutParams(); + lp.bottomMargin = ((FrameLayout.LayoutParams) launcher.getOverviewPanel() + .findViewById(R.id.settings_container).getLayoutParams()).bottomMargin; + mListView.setLayoutParams(lp); LinearLayout titleLayout = (LinearLayout) v.findViewById(R.id.dynamic_grid_title); titleLayout.setOnClickListener(new View.OnClickListener() { @@ -83,11 +110,10 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On SettingsProvider.getIntCustomDefault(getActivity(), SettingsProvider.SETTINGS_UI_DYNAMIC_GRID_SIZE, 0)); - setCurrentImage(); + updateGridMetrics(); - mListView = (ListView) v.findViewById(R.id.dynamic_grid_list); Resources res = getResources(); - String [] values = { + String[] values = { res.getString(R.string.grid_size_comfortable), res.getString(R.string.grid_size_cozy), res.getString(R.string.grid_size_condensed), @@ -99,64 +125,16 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On return v; } - private void setCurrentImage() { - Drawable d = null; - boolean custom = false; - - switch (mCurrentSize) { - case Comfortable: - d = getResources().getDrawable(R.drawable.grid_comfortable); - break; - case Cozy: - d = getResources().getDrawable(R.drawable.grid_cozy); - break; - case Condensed: - d = getResources().getDrawable(R.drawable.grid_condensed); - break; - default: - - custom = true; - break; - } - - if (d != null && !custom) { - mDynamicGridImage.setImageBitmap(null); - mDynamicGridImage.setBackground(d); - } else if (custom) { - mDynamicGridImage.setBackground(null); - mDynamicGridImage.setImageBitmap(writeOnDrawable(R.drawable.grid)); + private void updateGridMetrics() { + if (mCurrentSize == DeviceProfile.GridSize.Custom) { + mDynamicGrid.setMetrics(mCustomGridRows, mCustomGridColumns); + } else { + DeviceProfile grid = getGrid(); + mDynamicGrid.setMetrics(grid.numRowsBase + mCurrentSize.getValue(), + grid.numColumnsBase + mCurrentSize.getValue()); } } - public Bitmap writeOnDrawable(int drawableId){ - LauncherAppState app = LauncherAppState.getInstance(); - DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - - int rows = mCustomGridRows == 0 ? (int) grid.numRows : mCustomGridRows; - int columns = mCustomGridColumns == 0 ? (int) grid.numColumns : mCustomGridColumns; - - String text = rows + " " + "\u00d7" + " " + columns; - - Bitmap bm = BitmapFactory.decodeResource(getResources(), - drawableId).copy(Bitmap.Config.ARGB_8888, true); - - Paint paint = new Paint(); - paint.setStyle(Paint.Style.FILL); - paint.setColor(Color.BLACK); - int px = getResources().getDimensionPixelOffset(R.dimen.grid_custom_text); - paint.setTextSize(px); - - Canvas canvas = new Canvas(bm); - - float canvasWidth = canvas.getWidth(); - float sentenceWidth = paint.measureText(text); - float startPositionX = (canvasWidth - sentenceWidth) / 2; - - canvas.drawText(text, startPositionX, bm.getHeight()/2, paint); - - return bm; - } - @Override public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) { if (enter) { @@ -167,21 +145,14 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On final View darkPanel = ((Launcher) getActivity()).getDarkPanel(); darkPanel.setVisibility(View.VISIBLE); - ObjectAnimator anim2 = ObjectAnimator.ofFloat( - darkPanel , "alpha", 0.0f, 0.3f); + ObjectAnimator anim2 = ObjectAnimator.ofFloat(darkPanel, "alpha", 0.0f, 0.3f); anim2.start(); - anim.addListener(new Animator.AnimatorListener() { - @Override - public void onAnimationStart(Animator arg0) {} + anim.addListener(new AnimatorListenerAdapter() { @Override - public void onAnimationRepeat(Animator arg0) {} - @Override - public void onAnimationEnd(Animator arg0) { + public void onAnimationEnd (Animator animation) { darkPanel.setVisibility(View.GONE); } - @Override - public void onAnimationCancel(Animator arg0) {} }); return anim; @@ -208,23 +179,23 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On private void showNumberPicker() { mDialog = new Dialog(getActivity()); - mDialog.setTitle(getResources().getString(R.string.preferences_interface_homescreen_custom)); + mDialog.setTitle(getResources().getString( + R.string.preferences_interface_homescreen_custom)); mDialog.setContentView(R.layout.custom_grid_size_dialog); - NumberPicker nPRows= (NumberPicker) mDialog.findViewById(R.id.custom_rows); + NumberPicker nPRows = (NumberPicker) mDialog.findViewById(R.id.custom_rows); NumberPicker nPColumns = (NumberPicker) mDialog.findViewById(R.id.custom_columns); - LauncherAppState app = LauncherAppState.getInstance(); - DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - + DeviceProfile grid = getGrid(); int rows = grid.numRowsBase; int columns = grid.numColumnsBase; - if (mCustomGridColumns == 0) { - mCustomGridColumns = (int) grid.numColumns; - } + if (mCustomGridRows == 0) { mCustomGridRows = (int) grid.numRows; } + if (mCustomGridColumns == 0) { + mCustomGridColumns = (int) grid.numColumns; + } nPRows.setMinValue(Math.max(MIN_DYNAMIC_GRID_ROWS, rows - DeviceProfile.GRID_SIZE_MIN)); nPRows.setMaxValue(rows + DeviceProfile.GRID_SIZE_MAX); @@ -233,15 +204,16 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On nPRows.setOnValueChangedListener(this); nPRows.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); - nPColumns.setMinValue(Math.max(MIN_DYNAMIC_GRID_COLUMNS, columns - DeviceProfile.GRID_SIZE_MIN)); + nPColumns.setMinValue(Math.max(MIN_DYNAMIC_GRID_COLUMNS, + columns - DeviceProfile.GRID_SIZE_MIN)); nPColumns.setMaxValue(columns + DeviceProfile.GRID_SIZE_MAX); nPColumns.setValue(mCustomGridColumns); nPColumns.setWrapSelectorWheel(false); nPColumns.setOnValueChangedListener(this); nPColumns.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); - Button b = (Button) mDialog.findViewById(R.id.dialog_confirm_button); - b.setOnClickListener(new View.OnClickListener() { + Button button = (Button) mDialog.findViewById(R.id.dialog_confirm_button); + button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mDialog != null) { @@ -249,6 +221,7 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On } } }); + mDialog.setOnDismissListener(this); mDialog.show(); } @@ -278,16 +251,14 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On SettingsProvider.SETTINGS_UI_HOMESCREEN_COLUMNS, mCustomGridColumns); mAdapter.notifyDataSetInvalidated(); - - setCurrentImage(); + mDynamicGrid.setMetrics(mCustomGridRows, mCustomGridColumns); } private class GridSizeArrayAdapter extends ArrayAdapter<String> { Context mContext; String[] mTitles; - public GridSizeArrayAdapter(Context context, int textViewResourceId, - String[] objects) { + public GridSizeArrayAdapter(Context context, int textViewResourceId, String[] objects) { super(context, textViewResourceId, objects); mContext = context; @@ -296,27 +267,29 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On @Override public View getView(int position, View convertView, ViewGroup parent) { - LayoutInflater inflater = (LayoutInflater) mContext - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = inflater.inflate(R.layout.settings_pane_list_item, - parent, false); - TextView textView = (TextView) convertView - .findViewById(R.id.item_name); + if (convertView == null) { + LayoutInflater inflater = (LayoutInflater) + mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = inflater.inflate(R.layout.settings_pane_list_item, parent, false); + } + + TextView textView = (TextView) convertView.findViewById(R.id.item_name); textView.setText(mTitles[position]); - // Set Selected State + + // Set selected state if (position == mCurrentSize.getValue()) { + if (mCurrentSelection != null) { + setCleared(mCurrentSelection); + } mCurrentSelection = convertView; setSelected(mCurrentSelection); } if (position == DeviceProfile.GridSize.Custom.getValue()) { - LauncherAppState app = LauncherAppState.getInstance(); - DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - int rows = SettingsProvider.getIntCustomDefault(getActivity(), - SettingsProvider.SETTINGS_UI_HOMESCREEN_ROWS, grid.numRowsBase); + SettingsProvider.SETTINGS_UI_HOMESCREEN_ROWS, getGrid().numRowsBase); int columns = SettingsProvider.getIntCustomDefault(getActivity(), - SettingsProvider.SETTINGS_UI_HOMESCREEN_COLUMNS, grid.numColumnsBase); + SettingsProvider.SETTINGS_UI_HOMESCREEN_COLUMNS, getGrid().numColumnsBase); String gridSize = rows + " " + "\u00d7" + " " + columns; textView.setText(getString(R.string.grid_size_custom_and_size, gridSize)); @@ -327,4 +300,52 @@ public class DynamicGridSizeFragment extends Fragment implements NumberPicker.On return convertView; } } + + private DeviceProfile getGrid() { + LauncherAppState app = LauncherAppState.getInstance(); + return app.getDynamicGrid().getDeviceProfile(); + } + + private static class GridSizeView extends View { + private int mRows = 0, mColumns = 0; + private Paint mForegroundPaint; + private int mBackgroundColor; + + public GridSizeView(Context context, AttributeSet attrs) { + super(context, attrs); + Resources res = context.getResources(); + + mForegroundPaint = new Paint(); + mForegroundPaint.setColor(res.getColor(R.color.dynamic_grid_preview_foreground)); + mBackgroundColor = res.getColor(R.color.dynamic_grid_preview_background); + } + + public void setMetrics(int rows, int columns) { + mRows = rows; + mColumns = columns; + invalidate(); + } + + @Override + protected void onDraw(Canvas canvas) { + float width = getWidth() - getPaddingLeft() - getPaddingRight(); + float height = getHeight() - getPaddingTop() - getPaddingBottom(); + float xOffset = getPaddingLeft(); + float yOffset = getPaddingTop(); + + canvas.drawColor(mBackgroundColor); + + // Draw rows + for (int i = 1; i < mRows; i++) { + float yPos = yOffset + height / mRows * i; + canvas.drawLine(xOffset, yPos, xOffset + width, yPos, mForegroundPaint); + } + + // Draw columns + for (int j = 1; j < mColumns; j++) { + float xPos = xOffset + width / mColumns * j; + canvas.drawLine(xPos, yOffset, xPos, yOffset + height, mForegroundPaint); + } + } + } } diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 004fa4e5f..54d2793e0 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -121,6 +121,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList RelativeLayout mFolderTitleSection; private float mFolderIconPivotX; private float mFolderIconPivotY; + private boolean mHideLabels; private boolean mIsEditingName = false; private InputMethodManager mInputMethodManager; @@ -221,11 +222,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView); - if (SettingsProvider.getBoolean(mLauncher, + mHideLabels = SettingsProvider.getBoolean(mLauncher, SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, - R.bool.preferences_interface_homescreen_hide_icon_labels_default)) { + R.bool.preferences_interface_homescreen_hide_icon_labels_default); + if (mHideLabels) { mFolderName.setVisibility(View.GONE); - mFolderNameHeight = getPaddingBottom(); } mFolderLock = (ImageView) findViewById(R.id.folder_lock); @@ -350,11 +351,7 @@ 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(); - if (!SettingsProvider.getBoolean(mLauncher, - SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, - R.bool.preferences_interface_homescreen_hide_icon_labels_default)) { - mInfo.setTitle(newTitle); - } + mInfo.setTitle(newTitle); LauncherModel.updateItemInDatabase(mLauncher, mInfo); if (commit) { @@ -658,6 +655,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList textView.setOnClickListener(this); textView.setOnLongClickListener(this); + if (mHideLabels) { + textView.setTextVisibility(!mHideLabels); + } + // We need to check here to verify that the given item's location isn't already occupied // by another item. if (mContent.getChildAt(item.cellX, item.cellY) != null || item.cellX < 0 || item.cellY < 0 diff --git a/src/com/android/launcher3/GelIntegrationHelper.java b/src/com/android/launcher3/GelIntegrationHelper.java index 4d2c4917b..118be19db 100644 --- a/src/com/android/launcher3/GelIntegrationHelper.java +++ b/src/com/android/launcher3/GelIntegrationHelper.java @@ -23,7 +23,6 @@ public class GelIntegrationHelper { private static final int EDGE_GESTURE_SERVICE_RIGHT_EDGE = 4; private static final int EDGE_GESTURE_SERVICE_LEFT_EDGE = 1; - private static final int EDGE_GESTURE_SERVICE_NO_EDGE = -1; private EdgeGestureManager.EdgeGestureActivationListener mEdgeGestureActivationListener = null; private static GelIntegrationHelper sInstance; @@ -98,18 +97,4 @@ public class GelIntegrationHelper { return pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null; } - /** - * Handle necessary cleanup and reset tasks for GEL integration, to be called from onResume. - */ - public void handleGelResume() { - // If there is an active EdgeGestureActivationListener for GEL integration, - // it should stop listening when we have resumed the launcher. - if(mEdgeGestureActivationListener != null) { - EdgeGestureManager edgeGestureManager = EdgeGestureManager.getInstance(); - // Update the listener so it is not listening to any postions (-1) - edgeGestureManager.updateEdgeGestureActivationListener(mEdgeGestureActivationListener, - EDGE_GESTURE_SERVICE_NO_EDGE); - } - } - } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index fbb3189f9..01e3fc584 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -66,6 +66,7 @@ import android.os.Handler; import android.os.Message; import android.os.StrictMode; import android.os.SystemClock; +import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.Selection; import android.text.SpannableStringBuilder; @@ -403,6 +404,12 @@ public class Launcher extends Activity } } + public static float sAnimatorDurationScale = 1f; + + public static boolean isAnimatorScaleSafe() { + return sAnimatorDurationScale >= 1f; + } + private CustomContentMode mCustomContentMode = CustomContentMode.CUSTOM_HOME; // Preferences @@ -457,6 +464,38 @@ public class Launcher extends Activity } }; + private class AnimatorScaleObserver extends ContentObserver { + + /** + * Creates a content observer. + * + * @param handler The handler to run {@link #onChange} on, or null if none. + */ + public AnimatorScaleObserver(Handler handler) { + super(handler); + } + + @Override + public void onChange(boolean selfChange) { + onChange(selfChange, null); + } + + @Override + public void onChange(boolean selfChange, Uri uri) { + try { + Float curAnimationDurationScale = Settings.Global.getFloat(getContentResolver(), + Settings.Global.ANIMATOR_DURATION_SCALE); + if (curAnimationDurationScale != sAnimatorDurationScale) { + // the Animator Duration scale has changed, restart the Launcher to respect + // these changes + android.os.Process.killProcess(android.os.Process.myPid()); + } + } catch (Settings.SettingNotFoundException e) { + sAnimatorDurationScale = 1f; + } + } + } + @Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG_STRICT_MODE) { @@ -564,6 +603,16 @@ public class Launcher extends Activity "cyanogenmod.intent.action.PROTECTED_COMPONENT_UPDATE"); registerReceiver(protectedAppsChangedReceiver, protectedAppsFilter, "cyanogenmod.permission.PROTECTED_APP", null); + + try { + sAnimatorDurationScale = Settings.Global.getFloat(getContentResolver(), + Settings.Global.ANIMATOR_DURATION_SCALE); + } catch (Settings.SettingNotFoundException e) { + sAnimatorDurationScale = 1f; + } + + AnimatorScaleObserver obs = new AnimatorScaleObserver(new Handler()); + getContentResolver().registerContentObserver(Settings.Global.CONTENT_URI, true, obs); } public void restoreCustomContentMode() { @@ -1108,10 +1157,6 @@ public class Launcher extends Activity updateGridIfNeeded(); - if(isCustomContentModeGel() && isGelIntegrationSupported()) { - GelIntegrationHelper.getInstance().handleGelResume(); - } - // Restore the previous launcher state if (mOnResumeState == State.WORKSPACE) { showWorkspace(false); @@ -3720,6 +3765,7 @@ public class Launcher extends Activity if (resetPageToZero) { mAppsCustomizeLayout.reset(); } + mAppsCustomizeContent.sortApps(); showAppsCustomizeHelper(animated, false, contentType); mAppsCustomizeLayout.requestFocus(); @@ -4498,6 +4544,8 @@ public class Launcher extends Activity mWorkspace.getUniqueComponents(true, null); mIntentsOnWorkspaceFromUpgradePath = mWorkspace.getUniqueComponents(true, null); } + + mWorkspace.stripEmptyScreens(); } private boolean canRunNewAppsAnimation() { @@ -4977,6 +5025,10 @@ public class Launcher extends Activity } public void updateDynamicGrid() { + updateDynamicGrid(mWorkspace.getRestorePage()); + } + + public void updateDynamicGrid(int page) { mSearchDropTargetBar.setupQSB(Launcher.this); initializeDynamicGrid(); @@ -4984,7 +5036,7 @@ public class Launcher extends Activity mGrid.layout(Launcher.this); // Synchronized reload - mModel.startLoader(true, mWorkspace.getCurrentPage()); + mModel.startLoader(true, page); mWorkspace.updateCustomContentVisibility(); } @@ -4995,7 +5047,7 @@ public class Launcher extends Activity public boolean updateGridIfNeeded() { if (mDynamicGridUpdateRequired) { - updateDynamicGrid(); + updateDynamicGrid(mWorkspace.getCurrentPage()); mDynamicGridUpdateRequired = false; return true; } diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index e6c220b2a..0f58e0c4e 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -103,7 +103,12 @@ public class LauncherAnimUtils { anim.setPropertyName(propertyName); anim.setFloatValues(values); cancelOnDestroyActivity(anim); - new FirstFrameAnimatorHelper(anim, target); + // If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes causes + // the animation to not finish (e.g. opening a Folder will result in the Folder View's + // alpha being stuck somewhere between 0-1f. + if (Launcher.isAnimatorScaleSafe()) { + new FirstFrameAnimatorHelper(anim, target); + } return anim; } @@ -113,7 +118,12 @@ public class LauncherAnimUtils { anim.setTarget(target); anim.setValues(values); cancelOnDestroyActivity(anim); - new FirstFrameAnimatorHelper(anim, target); + // If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes causes + // the animation to not finish (e.g. opening a Folder will result in the Folder View's + // alpha being stuck somewhere between 0-1f. + if (Launcher.isAnimatorScaleSafe()) { + new FirstFrameAnimatorHelper(anim, target); + } return anim; } @@ -123,7 +133,12 @@ public class LauncherAnimUtils { anim.setTarget(target); anim.setValues(values); cancelOnDestroyActivity(anim); - new FirstFrameAnimatorHelper(anim, view); + // If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes causes + // the animation to not finish (e.g. opening a Folder will result in the Folder View's + // alpha being stuck somewhere between 0-1f. + if (Launcher.isAnimatorScaleSafe()) { + new FirstFrameAnimatorHelper(anim, view); + } return anim; } } diff --git a/src/com/android/launcher3/LauncherViewPropertyAnimator.java b/src/com/android/launcher3/LauncherViewPropertyAnimator.java index 4cafbbfa6..63b87be5f 100644 --- a/src/com/android/launcher3/LauncherViewPropertyAnimator.java +++ b/src/com/android/launcher3/LauncherViewPropertyAnimator.java @@ -127,7 +127,9 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi public void onAnimationStart(Animator animation) { // This is the first time we get a handle to the internal ValueAnimator // used by the ViewPropertyAnimator. - mFirstFrameHelper.onAnimationStart(animation); + if (mFirstFrameHelper != null) { + mFirstFrameHelper.onAnimationStart(animation); + } for (int i = 0; i < mListeners.size(); i++) { Animator.AnimatorListener listener = mListeners.get(i); @@ -195,7 +197,12 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi // FirstFrameAnimatorHelper hooks itself up to the updates on the animator, // and then adjusts the play time to keep the first two frames jank-free - mFirstFrameHelper = new FirstFrameAnimatorHelper(mViewPropertyAnimator, mTarget); + // HOWEVER, If the animation scale is less than 1f the FirstFrameAnimatorHelper sometimes + // causes the animation to not finish (e.g. opening a Folder will result in the Folder + // View's alpha being stuck somewhere between 0-1f. + if (Launcher.isAnimatorScaleSafe()) { + mFirstFrameHelper = new FirstFrameAnimatorHelper(mViewPropertyAnimator, mTarget); + } if (mPropertiesToSet.contains(Properties.TRANSLATION_X)) { mViewPropertyAnimator.translationX(mTranslationX); diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index e14b78942..f0a568b74 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -11,6 +11,9 @@ import android.widget.ListView; import com.android.launcher3.list.PinnedHeaderListView; import com.android.launcher3.list.SettingsPinnedHeaderAdapter; +import java.util.ArrayList; +import java.util.List; + public class OverviewSettingsPanel { public static final String ANDROID_SETTINGS = "com.android.settings"; public static final String ANDROID_PROTECTED_APPS = @@ -19,6 +22,7 @@ public class OverviewSettingsPanel { "com.android.settings.Settings$ThemeSettingsActivity"; public static final int HOME_SETTINGS_POSITION = 0; public static final int DRAWER_SETTINGS_POSITION = 1; + public static final int APP_SETTINGS_POSITION = 2; private Launcher mLauncher; private View mOverviewPanel; @@ -56,10 +60,14 @@ public class OverviewSettingsPanel { res.getString(R.string.drawer_sorting_text), res.getString(R.string.icon_labels)}; - String[] valuesApp = new String[] { - res.getString(R.string.larger_icons_text), - res.getString(R.string.protected_app_settings)}; + List<String> valuesAppList = new ArrayList<String>(); + valuesAppList.add(res.getString(R.string.larger_icons_text)); + if (!Utilities.isRestrictedProfile(mLauncher)) { + valuesAppList.add(res.getString(R.string.protected_app_settings)); + } + String[] valuesApp = new String[valuesAppList.size()]; + valuesApp = valuesAppList.toArray(valuesApp); mSettingsAdapter = new SettingsPinnedHeaderAdapter(mLauncher); mSettingsAdapter.setHeaders(headers); @@ -68,9 +76,10 @@ public class OverviewSettingsPanel { mSettingsAdapter.addPartition(false, true); mSettingsAdapter.mPinnedHeaderCount = headers.length; - mSettingsAdapter.changeCursor(0, createCursor(headers[0], mValues)); - mSettingsAdapter.changeCursor(1, createCursor(headers[1], valuesDrawer)); - mSettingsAdapter.changeCursor(2, createCursor(headers[2], valuesApp)); + mSettingsAdapter.changeCursor(HOME_SETTINGS_POSITION, createCursor(headers[0], mValues)); + mSettingsAdapter.changeCursor(DRAWER_SETTINGS_POSITION, createCursor(headers[1], + valuesDrawer)); + mSettingsAdapter.changeCursor(APP_SETTINGS_POSITION, createCursor(headers[2], valuesApp)); mListView.setAdapter(mSettingsAdapter); } @@ -208,8 +217,10 @@ public class OverviewSettingsPanel { frameAnimation.start(); if (mLauncher.updateGridIfNeeded()) { - mLauncher.getWorkspace().showOutlines(); - mLauncher.mSearchDropTargetBar.hideSearchBar(false); + if (mLauncher.getWorkspace().isInOverviewMode()) { + mLauncher.getWorkspace().showOutlines(); + mLauncher.mSearchDropTargetBar.hideSearchBar(false); + } } } diff --git a/src/com/android/launcher3/TransitionEffectsFragment.java b/src/com/android/launcher3/TransitionEffectsFragment.java index 88c6481d7..bb7c5abf2 100644 --- a/src/com/android/launcher3/TransitionEffectsFragment.java +++ b/src/com/android/launcher3/TransitionEffectsFragment.java @@ -20,6 +20,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; @@ -34,7 +35,6 @@ public class TransitionEffectsFragment extends Fragment { ImageView mTransitionIcon; ListView mListView; View mCurrentSelection; - ScrollView mScrollView; String[] mTransitionStates; TypedArray mTransitionDrawables; @@ -76,6 +76,14 @@ public class TransitionEffectsFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.settings_transitions_screen, container, false); + mListView = (ListView) v.findViewById(R.id.settings_transitions_list); + + Launcher launcher = (Launcher) getActivity(); + LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) + mListView.getLayoutParams(); + lp.bottomMargin = ((FrameLayout.LayoutParams) launcher.getOverviewPanel() + .findViewById(R.id.settings_container).getLayoutParams()).bottomMargin; + mListView.setLayoutParams(lp); mPageOrDrawer = getArguments().getBoolean(PAGE_OR_DRAWER_SCROLL_SELECT); @@ -86,8 +94,6 @@ public class TransitionEffectsFragment extends Fragment { : R.string.preferences_interface_homescreen_scrolling_transition_effect; mTransitionIcon = (ImageView) v.findViewById(R.id.settings_transition_image); - mListView = (ListView) v.findViewById(R.id.settings_transitions_list); - mScrollView = (ScrollView) v.findViewById(R.id.scroll_view); TextView title = (TextView) v.findViewById(R.id.transition_effect_title); title.setText(getResources().getString(R.string.scroll_effect_text)); LinearLayout titleLayout = (LinearLayout) v.findViewById(R.id.transition_title); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index cbc978585..d1c5a0f7f 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -33,6 +33,7 @@ import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; +import android.os.UserManager; import android.util.DisplayMetrics; import android.util.Log; import android.view.View; @@ -358,4 +359,9 @@ public final class Utilities { "or use the exported attribute for this activity.", e); } } + + public static boolean isRestrictedProfile(Context context) { + UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); + return um.getUserInfo(um.getUserHandle()).isRestricted(); + } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 7501dbf7d..c6c320df0 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -437,6 +437,8 @@ public class Workspace extends SmoothPagedView InstallShortcutReceiver.disableAndFlushInstallQueue(getContext()); UninstallShortcutReceiver.disableAndFlushUninstallQueue(getContext()); + removeExtraEmptyScreen(false, null); + mDragSourceInternal = null; mLauncher.onInteractionEnd(); } diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index a4a68fb85..b09d1d716 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -10,7 +10,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import android.widget.Toast; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.OverviewSettingsPanel; @@ -22,9 +21,22 @@ import android.view.View.OnClickListener; import android.content.SharedPreferences; public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { + private static final int PARTITION_TAG = 0; + private static final int POSITION_TAG = 1; + private Launcher mLauncher; private Context mContext; + class SettingsPosition { + int partition = 0; + int position = 0; + + SettingsPosition (int partition, int position) { + this.partition = partition; + this.position = position; + } + } + public SettingsPinnedHeaderAdapter(Context context) { super(context); mLauncher = (Launcher) context; @@ -67,81 +79,88 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { String title = cursor.getString(1); text.setText(title); + v.setTag(new SettingsPosition(partition, position)); + Resources res = mLauncher.getResources(); - if (title.equals(res - .getString(R.string.home_screen_search_text))) { - boolean current = mLauncher.isSearchBarEnabled(); - String state = current ? res.getString( - R.string.setting_state_on) : res.getString( - R.string.setting_state_off); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res - .getString(R.string.drawer_sorting_text))) { - updateDrawerSortSettingsItem(v); - } else if (title.equals(res - .getString(R.string.scroll_effect_text)) && - partition == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION) { - String state = mLauncher.getAppsCustomizeTransitionEffect(); - state = mapEffectToValue(state); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res - .getString(R.string.scroll_effect_text)) && - partition == OverviewSettingsPanel.HOME_SETTINGS_POSITION) { - String state = mLauncher.getWorkspaceTransitionEffect(); - state = mapEffectToValue(state); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res - .getString(R.string.larger_icons_text))) { - boolean current = SettingsProvider - .getBoolean( - mContext, - SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE, - R.bool.preferences_interface_general_icons_large_default); - String state = current ? res.getString( - R.string.setting_state_on) : res.getString( - R.string.setting_state_off); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res - .getString(R.string.icon_labels)) && - partition == OverviewSettingsPanel.HOME_SETTINGS_POSITION) { - boolean current = mLauncher.shouldHideWorkspaceIconLables(); - String state = current ? res.getString( - R.string.icon_labels_hide) : res.getString( - R.string.icon_labels_show); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res - .getString(R.string.icon_labels)) && - partition == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION) { - boolean current = SettingsProvider - .getBoolean( - mContext, - SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS, - R.bool.preferences_interface_drawer_hide_icon_labels_default); - String state = current ? res.getString( - R.string.icon_labels_hide) : res.getString( - R.string.icon_labels_show); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res - .getString(R.string.search_screen_left_text))) { - updateSearchPanelItem(v); - } else if (title.equals(res.getString(R.string.scrolling_wallpaper))) { - boolean current = SettingsProvider - .getBoolean( - mContext, - SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL, - R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default); - String state = current ? res.getString( - R.string.setting_state_on) : res.getString( - R.string.setting_state_off); - ((TextView) v.findViewById(R.id.item_state)).setText(state); - } else if (title.equals(res.getString(R.string.grid_size_text))) { - updateDynamicGridSizeSettingsItem(v); - } else { - ((TextView) v.findViewById(R.id.item_state)).setText(""); + boolean current = false; + String state = ""; + + switch (partition) { + case OverviewSettingsPanel.HOME_SETTINGS_POSITION: + switch (position) { + case 0: + current = mLauncher.isSearchBarEnabled(); + state = current ? res.getString(R.string.setting_state_on) + : res.getString(R.string.setting_state_off); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 1: + updateSearchPanelItem(v); + break; + case 2: + state = mLauncher.getWorkspaceTransitionEffect(); + state = mapEffectToValue(state); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 3: + current = mLauncher.shouldHideWorkspaceIconLables(); + state = current ? res.getString(R.string.icon_labels_hide) + : res.getString(R.string.icon_labels_show); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 4: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL, + R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default); + state = current ? res.getString(R.string.setting_state_on) + : res.getString(R.string.setting_state_off); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 5: + updateDynamicGridSizeSettingsItem(v); + break; + default: + ((TextView) v.findViewById(R.id.item_state)).setText(""); + } + break; + case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION: + switch (position) { + case 0: + state = mLauncher.getAppsCustomizeTransitionEffect(); + state = mapEffectToValue(state); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + case 1: + updateDrawerSortSettingsItem(v); + break; + case 2: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS, + R.bool.preferences_interface_drawer_hide_icon_labels_default); + state = current ? res.getString(R.string.icon_labels_hide) + : res.getString(R.string.icon_labels_show); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + default: + ((TextView) v.findViewById(R.id.item_state)).setText(""); + } + break; + default: + switch (position) { + case 0: + current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE, + R.bool.preferences_interface_general_icons_large_default); + state = current ? res.getString(R.string.setting_state_on) + : res.getString(R.string.setting_state_off); + ((TextView) v.findViewById(R.id.item_state)).setText(state); + break; + default: + ((TextView) v.findViewById(R.id.item_state)).setText(""); + } } - v.setTag(partition); v.setOnClickListener(mSettingsItemListener); } @@ -246,71 +265,78 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { String value = ((TextView) v.findViewById(R.id.item_name)).getText().toString(); Resources res = mLauncher.getResources(); - // Handle toggles or launch pickers - if (value.equals(res - .getString(R.string.home_screen_search_text))) { - onSettingsBooleanChanged( - v, - SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, - R.bool.preferences_interface_homescreen_search_default); - mLauncher.setUpdateDynamicGrid(); - } else if (value.equals(res - .getString(R.string.drawer_sorting_text))) { - onClickTransitionEffectButton(); - } else if (value.equals(res - .getString(R.string.scroll_effect_text)) && - ((Integer)v.getTag() == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION)) { - mLauncher.onClickTransitionEffectButton(v, true); - } else if (value.equals(res - .getString(R.string.scroll_effect_text)) && - ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) { - mLauncher.onClickTransitionEffectButton(v, false); - } else if (value.equals(res - .getString(R.string.larger_icons_text))) { - onSettingsBooleanChanged( - v, - SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE, - R.bool.preferences_interface_general_icons_large_default); - mLauncher.setUpdateDynamicGrid(); - } else if (value.equals(res - .getString(R.string.icon_labels)) && - ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) { - onIconLabelsBooleanChanged( - v, - SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, - R.bool.preferences_interface_homescreen_hide_icon_labels_default); - mLauncher.setUpdateDynamicGrid(); - } else if (value.equals(res - .getString(R.string.icon_labels)) && - ((Integer)v.getTag() == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION)) { - onIconLabelsBooleanChanged( - v, - SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS, - R.bool.preferences_interface_drawer_hide_icon_labels_default); - mLauncher.setUpdateDynamicGrid(); - } else if (value.equals(res.getString(R.string.protected_app_settings))) { - Intent intent = new Intent(); - intent.setClassName(OverviewSettingsPanel.ANDROID_SETTINGS, - OverviewSettingsPanel.ANDROID_PROTECTED_APPS); - mLauncher.startActivity(intent); - } else if (value.equals(res - .getString(R.string.scrolling_wallpaper))) { - onSettingsBooleanChanged( - v, - SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL, - R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default); - mLauncher.setUpdateDynamicGrid(); - } else if (value.equals(res - .getString(R.string.search_screen_left_text)) && - ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) { - onClickSearchPanelButton(); - boolean customContentEnabled = - mLauncher.getCustomContentMode() != Launcher.CustomContentMode.DISABLED; - mLauncher.getWorkspace().updatePageScrollForCustomPage(customContentEnabled); - mLauncher.setUpdateDynamicGrid(); - } else if (value.equals(res - .getString(R.string.grid_size_text))) { - mLauncher.onClickDynamicGridSizeButton(); + int partition = ((SettingsPosition) v.getTag()).partition; + int position = ((SettingsPosition) v.getTag()).position; + + switch (partition) { + case OverviewSettingsPanel.HOME_SETTINGS_POSITION: + switch (position) { + case 0: + onSettingsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, + R.bool.preferences_interface_homescreen_search_default); + mLauncher.setUpdateDynamicGrid(); + break; + case 1: + onClickSearchPanelButton(); + boolean customContentEnabled = mLauncher.getCustomContentMode() + != Launcher.CustomContentMode.DISABLED; + mLauncher.getWorkspace().updatePageScrollForCustomPage( + customContentEnabled); + mLauncher.setUpdateDynamicGrid(); + break; + case 2: + mLauncher.onClickTransitionEffectButton(v, false); + break; + case 3: + onIconLabelsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, + R.bool.preferences_interface_homescreen_hide_icon_labels_default); + mLauncher.setUpdateDynamicGrid(); + break; + case 4: + onSettingsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL, + R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default); + mLauncher.setUpdateDynamicGrid(); + break; + case 5: + mLauncher.onClickDynamicGridSizeButton(); + break; + + } + break; + case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION: + switch (position) { + case 0: + mLauncher.onClickTransitionEffectButton(v, true); + break; + case 1: + onClickTransitionEffectButton(); + break; + case 2: + onIconLabelsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS, + R.bool.preferences_interface_drawer_hide_icon_labels_default); + mLauncher.setUpdateDynamicGrid(); + break; + } + break; + default: + switch (position) { + case 0: + onSettingsBooleanChanged(v, + SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE, + R.bool.preferences_interface_general_icons_large_default); + mLauncher.setUpdateDynamicGrid(); + break; + case 1: + Intent intent = new Intent(); + intent.setClassName(OverviewSettingsPanel.ANDROID_SETTINGS, + OverviewSettingsPanel.ANDROID_PROTECTED_APPS); + mLauncher.startActivity(intent); + break; + } } View defaultHome = mLauncher.findViewById(R.id.default_home_screen_panel); |