summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java6
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java9
-rw-r--r--src/com/android/launcher3/CheckLongPressHelper.java12
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java2
-rw-r--r--src/com/android/launcher3/DragLayer.java31
-rw-r--r--src/com/android/launcher3/FocusHelper.java12
-rw-r--r--src/com/android/launcher3/FolderIcon.java4
-rw-r--r--src/com/android/launcher3/Hotseat.java24
-rw-r--r--src/com/android/launcher3/IconCache.java5
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java2
-rw-r--r--src/com/android/launcher3/Launcher.java100
-rw-r--r--src/com/android/launcher3/LauncherAnimatorUpdateListener.java30
-rw-r--r--src/com/android/launcher3/LauncherAppState.java35
-rw-r--r--src/com/android/launcher3/LauncherModel.java10
-rw-r--r--src/com/android/launcher3/LauncherProvider.java2
-rw-r--r--src/com/android/launcher3/SettingsActivity.java22
-rw-r--r--src/com/android/launcher3/UninstallDropTarget.java2
-rw-r--r--src/com/android/launcher3/Utilities.java3
-rw-r--r--src/com/android/launcher3/Workspace.java4
-rw-r--r--src/com/android/launcher3/WorkspaceStateTransitionAnimation.java11
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java1
-rw-r--r--src/com/android/launcher3/allapps/AllAppsGridAdapter.java3
-rw-r--r--src/com/android/launcher3/model/WidgetsModel.java1
23 files changed, 121 insertions, 210 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 9a59feb04..6c13b4a9b 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -183,6 +183,12 @@ public class BubbleTextView extends TextView {
verifyHighRes();
}
+ /**
+ * Overrides the default long press timeout.
+ */
+ public void setLongPressTimeout(int longPressTimeout) {
+ mLongPressHelper.setLongPressTimeout(longPressTimeout);
+ }
@Override
protected boolean setFrame(int left, int top, int right, int bottom) {
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 09a71b0cc..b7f89d02a 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -51,7 +51,6 @@ public abstract class ButtonDropTarget extends TextView
protected Launcher mLauncher;
private int mBottomDragPadding;
- protected TextView mText;
protected SearchDropTargetBar mSearchDropTargetBar;
/** Whether this drop target is active for the current drag */
@@ -82,11 +81,9 @@ public abstract class ButtonDropTarget extends TextView
mOriginalTextColor = getTextColors();
// Remove the text in the Phone UI in landscape
- int orientation = getResources().getConfiguration().orientation;
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- if (!LauncherAppState.getInstance().isScreenLarge()) {
- setText("");
- }
+ DeviceProfile grid = ((Launcher) getContext()).getDeviceProfile();
+ if (grid.isVerticalBarLayout()) {
+ setText("");
}
}
diff --git a/src/com/android/launcher3/CheckLongPressHelper.java b/src/com/android/launcher3/CheckLongPressHelper.java
index 381b678f9..483c62249 100644
--- a/src/com/android/launcher3/CheckLongPressHelper.java
+++ b/src/com/android/launcher3/CheckLongPressHelper.java
@@ -21,9 +21,11 @@ import android.view.View;
import com.android.launcher3.util.Thunk;
public class CheckLongPressHelper {
+
@Thunk View mView;
@Thunk View.OnLongClickListener mListener;
@Thunk boolean mHasPerformedLongPress;
+ private int mLongPressTimeout = 300;
private CheckForLongPress mPendingCheckForLongPress;
class CheckForLongPress implements Runnable {
@@ -53,14 +55,20 @@ public class CheckLongPressHelper {
mListener = listener;
}
+ /**
+ * Overrides the default long press timeout.
+ */
+ public void setLongPressTimeout(int longPressTimeout) {
+ mLongPressTimeout = longPressTimeout;
+ }
+
public void postCheckForLongPress() {
mHasPerformedLongPress = false;
if (mPendingCheckForLongPress == null) {
mPendingCheckForLongPress = new CheckForLongPress();
}
- mView.postDelayed(mPendingCheckForLongPress,
- LauncherAppState.getInstance().getLongPressTimeout());
+ mView.postDelayed(mPendingCheckForLongPress, mLongPressTimeout);
}
public void cancelLongPress() {
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index fa6e74fd1..9c8659c29 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -43,7 +43,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
// Get the hover color
mHoverColor = getResources().getColor(R.color.delete_target_hover_tint);
- setDrawable(R.drawable.ic_launcher_remove_normal);
+ setDrawable(R.drawable.ic_remove_launcher);
}
public static boolean supportsDrop(Object info) {
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index 41e053eed..aaa14e6a6 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -50,7 +50,6 @@ import java.util.ArrayList;
public class DragLayer extends InsettableFrameLayout {
public static final int ANIMATION_END_DISAPPEAR = 0;
- public static final int ANIMATION_END_FADE_OUT = 1;
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
// Scrim color without any alpha component.
@@ -70,7 +69,6 @@ public class DragLayer extends InsettableFrameLayout {
// Variables relating to animation of views after drop
private ValueAnimator mDropAnim = null;
- private ValueAnimator mFadeOutAnim = null;
private final TimeInterpolator mCubicEaseOutInterpolator = new DecelerateInterpolator(1.5f);
@Thunk DragView mDropView = null;
@Thunk int mAnchorViewInitialScrollX = 0;
@@ -762,7 +760,6 @@ public class DragLayer extends InsettableFrameLayout {
final int animationEndStyle, View anchorView) {
// Clean up the previous animations
if (mDropAnim != null) mDropAnim.cancel();
- if (mFadeOutAnim != null) mFadeOutAnim.cancel();
// Show the drop view if it was previously hidden
mDropView = view;
@@ -790,9 +787,6 @@ public class DragLayer extends InsettableFrameLayout {
case ANIMATION_END_DISAPPEAR:
clearAnimatedView();
break;
- case ANIMATION_END_FADE_OUT:
- fadeOutDragView();
- break;
case ANIMATION_END_REMAIN_VISIBLE:
break;
}
@@ -816,31 +810,6 @@ public class DragLayer extends InsettableFrameLayout {
return mDropView;
}
- @Thunk void fadeOutDragView() {
- mFadeOutAnim = new ValueAnimator();
- mFadeOutAnim.setDuration(150);
- mFadeOutAnim.setFloatValues(0f, 1f);
- mFadeOutAnim.removeAllUpdateListeners();
- mFadeOutAnim.addUpdateListener(new AnimatorUpdateListener() {
- public void onAnimationUpdate(ValueAnimator animation) {
- final float percent = (Float) animation.getAnimatedValue();
-
- float alpha = 1 - percent;
- mDropView.setAlpha(alpha);
- }
- });
- mFadeOutAnim.addListener(new AnimatorListenerAdapter() {
- public void onAnimationEnd(Animator animation) {
- if (mDropView != null) {
- mDragController.onDeferredEndDrag(mDropView);
- }
- mDropView = null;
- invalidate();
- }
- });
- mFadeOutAnim.start();
- }
-
@Override
public void onChildViewAdded(View parent, View child) {
super.onChildViewAdded(parent, child);
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index 70bb01af0..57aec3280 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -222,8 +222,8 @@ public class FocusHelper {
if (keyCode == KeyEvent.KEYCODE_DPAD_UP &&
!profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout,
- true /* hotseat horizontal */, hotseat.getAllAppsButtonRank(),
- iconRank == hotseat.getAllAppsButtonRank() /* include all apps icon */);
+ true /* hotseat horizontal */, profile.inv.hotseatAllAppsRank,
+ iconRank == profile.inv.hotseatAllAppsRank /* include all apps icon */);
iconIndex += iconParent.getChildCount();
countX = iconLayout.getCountX();
countY = iconLayout.getCountY() + hotseatLayout.getCountY();
@@ -231,8 +231,8 @@ public class FocusHelper {
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT &&
profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout,
- false /* hotseat horizontal */, hotseat.getAllAppsButtonRank(),
- iconRank == hotseat.getAllAppsButtonRank() /* include all apps icon */);
+ false /* hotseat horizontal */, profile.inv.hotseatAllAppsRank,
+ iconRank == profile.inv.hotseatAllAppsRank /* include all apps icon */);
iconIndex += iconParent.getChildCount();
countX = iconLayout.getCountX() + hotseatLayout.getCountX();
countY = iconLayout.getCountY();
@@ -316,13 +316,13 @@ public class FocusHelper {
// with the hotseat.
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && !profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout, true /* horizontal */,
- hotseat.getAllAppsButtonRank(),
+ profile.inv.hotseatAllAppsRank,
!hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */);
countY = countY + 1;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT &&
profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout, false /* horizontal */,
- hotseat.getAllAppsButtonRank(),
+ profile.inv.hotseatAllAppsRank,
!hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */);
countX = countX + 1;
} else if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) {
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index f1e9dc83b..8d534d2fe 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -222,8 +222,8 @@ public class FolderIcon extends FrameLayout implements FolderListener {
DeviceProfile grid = launcher.getDeviceProfile();
sPreviewSize = grid.folderIconSizePx;
sPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding);
- sSharedOuterRingDrawable = res.getDrawable(R.drawable.portal_ring_outer_holo);
- sSharedInnerRingDrawable = res.getDrawable(R.drawable.portal_ring_inner_nolip_holo);
+ sSharedOuterRingDrawable = res.getDrawable(R.drawable.portal_ring_outer);
+ sSharedInnerRingDrawable = res.getDrawable(R.drawable.portal_ring_inner_nolip);
sSharedFolderLeaveBehind = res.getDrawable(R.drawable.portal_ring_rest);
sStaticValuesDirty = false;
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 6e33d1014..ff4c93ab7 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -36,8 +36,7 @@ public class Hotseat extends FrameLayout
private int mAllAppsButtonRank;
- private boolean mTransposeLayoutWithOrientation;
- private boolean mIsLandscape;
+ private final boolean mHasVerticalHotseat;
public Hotseat(Context context) {
this(context, null);
@@ -49,13 +48,8 @@ public class Hotseat extends FrameLayout
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
-
- Resources r = context.getResources();
- mTransposeLayoutWithOrientation =
- r.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
- mIsLandscape = context.getResources().getConfiguration().orientation ==
- Configuration.ORIENTATION_LANDSCAPE;
mLauncher = (Launcher) context;
+ mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
}
CellLayout getLayout() {
@@ -77,26 +71,18 @@ public class Hotseat extends FrameLayout
mContent.setOnLongClickListener(l);
}
- private boolean hasVerticalHotseat() {
- return (mIsLandscape && mTransposeLayoutWithOrientation);
- }
-
/* Get the orientation invariant order of the item in the hotseat for persistence. */
int getOrderInHotseat(int x, int y) {
- return hasVerticalHotseat() ? (mContent.getCountY() - y - 1) : x;
+ return mHasVerticalHotseat ? (mContent.getCountY() - y - 1) : x;
}
/* Get the orientation specific coordinates given an invariant order in the hotseat. */
int getCellXFromOrder(int rank) {
- return hasVerticalHotseat() ? 0 : rank;
+ return mHasVerticalHotseat ? 0 : rank;
}
int getCellYFromOrder(int rank) {
- return hasVerticalHotseat() ? (mContent.getCountY() - (rank + 1)) : 0;
- }
-
- public int getAllAppsButtonRank() {
- return mAllAppsButtonRank;
+ return mHasVerticalHotseat ? (mContent.getCountY() - (rank + 1)) : 0;
}
public boolean isAllAppsButtonRank(int rank) {
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index fe25bb9a0..3165337c2 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -275,6 +275,7 @@ public class IconCache {
ComponentName component = ComponentName.unflattenFromString(cn);
PackageInfo info = pkgInfoMap.get(component.getPackageName());
if (info == null) {
+ remove(component, user);
itemsToRemove.add(c.getInt(rowIndex));
continue;
}
@@ -291,6 +292,7 @@ public class IconCache {
continue;
}
if (app == null) {
+ remove(component, user);
itemsToRemove.add(c.getInt(rowIndex));
} else {
appsToUpdate.add(app);
@@ -562,9 +564,10 @@ public class IconCache {
*/
private CacheEntry getEntryForPackageLocked(String packageName, UserHandleCompat user,
boolean useLowResIcon) {
- ComponentName cn = new ComponentName(packageName, EMPTY_CLASS_NAME);
+ ComponentName cn = new ComponentName(packageName, packageName + EMPTY_CLASS_NAME);
ComponentKey cacheKey = new ComponentKey(cn, user);
CacheEntry entry = mCache.get(cacheKey);
+
if (entry == null || (entry.isLowResIcon && !useLowResIcon)) {
entry = new CacheEntry();
boolean entryUpdated = true;
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index 0f139fa98..0ede2fc11 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -41,7 +41,7 @@ public class InfoDropTarget extends ButtonDropTarget {
// Get the hover color
mHoverColor = getResources().getColor(R.color.info_target_hover_tint);
- setDrawable(R.drawable.ic_launcher_info_normal);
+ setDrawable(R.drawable.ic_info_launcher);
}
public static void startDetailsActivityForInfo(Object info, Launcher launcher) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index dc63a761b..2be2d9d5b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -403,22 +403,34 @@ public class Launcher extends Activity
FocusIndicatorView mFocusHandler;
@Thunk boolean mRotationEnabled = false;
- private boolean mPreferenceObserverRegistered = false;
+ private boolean mScreenOrientationSettingReceiverRegistered = false;
- final private SharedPreferences.OnSharedPreferenceChangeListener mSettingsObserver =
- new SharedPreferences.OnSharedPreferenceChangeListener() {
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (Utilities.ALLOW_ROTATION_PREFERENCE_KEY.equals(key)) {
- if (mRotationEnabled = sharedPreferences.getBoolean(
- Utilities.ALLOW_ROTATION_PREFERENCE_KEY, false)) {
- unlockScreenOrientation(true);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
+ final private BroadcastReceiver mScreenOrientationSettingReceiver =
+ new BroadcastReceiver() {
+ @Thunk Runnable mUpdateOrientationRunnable = new Runnable() {
+ public void run() {
+ setOrientation();
+ }
+ };
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mRotationEnabled = intent.getBooleanExtra(
+ Utilities.SCREEN_ROTATION_SETTING_EXTRA, false);
+ if (!waitUntilResume(mUpdateOrientationRunnable, true)) {
+ setOrientation();
+ }
}
- }
+ };
+
+ @Thunk void setOrientation() {
+ if (mRotationEnabled) {
+ unlockScreenOrientation(true);
+ } else {
+ setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
}
- };
+ }
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -520,16 +532,18 @@ public class Launcher extends Activity
// In case we are on a device with locked rotation, we should look at preferences to check
// if the user has specifically allowed rotation.
if (!mRotationEnabled) {
- getSharedPreferences(LauncherFiles.ROTATION_PREF_FILE,
- Context.MODE_MULTI_PROCESS).registerOnSharedPreferenceChangeListener(
- mSettingsObserver);
- mPreferenceObserverRegistered = true;
+ String updateOrientationBroadcastPermission = getResources().getString(
+ R.string.receive_update_orientation_broadcasts_permission);
+ registerReceiver(mScreenOrientationSettingReceiver,
+ new IntentFilter(Utilities.SCREEN_ROTATION_SETTING_INTENT),
+ updateOrientationBroadcastPermission, null);
+ mScreenOrientationSettingReceiverRegistered = true;
mRotationEnabled = Utilities.isAllowRotationPrefEnabled(getApplicationContext());
}
// On large interfaces, or on devices that a user has specifically enabled screen rotation,
// we want the screen to auto-rotate based on the current orientation
- unlockScreenOrientation(true);
+ setOrientation();
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onCreate(savedInstanceState);
@@ -1796,16 +1810,17 @@ public class Launcher extends Activity
}
}
- private final Handler mHandler = new Handler() {
+ @Thunk final Handler mHandler = new Handler(new Handler.Callback() {
+
@Override
- public void handleMessage(Message msg) {
+ public boolean handleMessage(Message msg) {
if (msg.what == ADVANCE_MSG) {
int i = 0;
for (View key: mWidgetsToAdvance.keySet()) {
final View v = key.findViewById(mWidgetsToAdvance.get(key).autoAdvanceViewId);
final int delay = mAdvanceStagger * i;
if (v instanceof Advanceable) {
- postDelayed(new Runnable() {
+ mHandler.postDelayed(new Runnable() {
public void run() {
((Advanceable) v).advance();
}
@@ -1815,8 +1830,9 @@ public class Launcher extends Activity
}
sendAdvanceMessage(mAdvanceInterval);
}
+ return true;
}
- };
+ });
void addWidgetToAutoAdvanceIfNeeded(View hostView, AppWidgetProviderInfo appWidgetInfo) {
if (appWidgetInfo == null || appWidgetInfo.autoAdvanceViewId == -1) return;
@@ -2016,11 +2032,9 @@ public class Launcher extends Activity
public void onDestroy() {
super.onDestroy();
- if (mPreferenceObserverRegistered) {
- getSharedPreferences(LauncherFiles.ROTATION_PREF_FILE,
- Context.MODE_MULTI_PROCESS).unregisterOnSharedPreferenceChangeListener(
- mSettingsObserver);
- mPreferenceObserverRegistered = false;
+ if (mScreenOrientationSettingReceiverRegistered) {
+ unregisterReceiver(mScreenOrientationSettingReceiver);
+ mScreenOrientationSettingReceiverRegistered = false;
}
// Remove all pending runnables
@@ -2333,7 +2347,7 @@ public class Launcher extends Activity
Intent createShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
createShortcutIntent.setComponent(componentName);
- processShortcut(createShortcutIntent);
+ Utilities.startActivityForResultSafely(this, createShortcutIntent, REQUEST_CREATE_SHORTCUT);
}
/**
@@ -2390,14 +2404,6 @@ public class Launcher extends Activity
}
}
- void processShortcut(Intent intent) {
- Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT);
- }
-
- void processWallpaper(Intent intent) {
- startActivityForResult(intent, REQUEST_PICK_WALLPAPER);
- }
-
FolderIcon addFolder(CellLayout layout, long container, final long screenId, int cellX,
int cellY) {
final FolderInfo folderInfo = new FolderInfo();
@@ -2799,20 +2805,10 @@ public class Launcher extends Activity
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onClickSettingsButton(v);
} else {
- showSettingsActivity();
+ startActivity(new Intent(this, SettingsActivity.class));
}
}
- public void onTouchDownAllAppsButton(View v) {
- // Provide the same haptic feedback that the system offers for virtual keys.
- v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
- }
-
- public void performHapticFeedbackOnTouchDown(View v) {
- // Provide the same haptic feedback that the system offers for virtual keys.
- v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
- }
-
public View.OnTouchListener getHapticFeedbackTouchListener() {
if (mHapticFeedbackTouchListener == null) {
mHapticFeedbackTouchListener = new View.OnTouchListener() {
@@ -3663,7 +3659,7 @@ public class Launcher extends Activity
*
* @return {@code true} if we are currently paused. The caller might be able to skip some work
*/
- private boolean waitUntilResume(Runnable run, boolean deletePreviousRunnables) {
+ @Thunk boolean waitUntilResume(Runnable run, boolean deletePreviousRunnables) {
if (mPaused) {
if (LOGD) Log.d(TAG, "Deferring update until onResume");
if (deletePreviousRunnables) {
@@ -3762,10 +3758,6 @@ public class Launcher extends Activity
@Override
public void bindAddScreens(ArrayList<Long> orderedScreenIds) {
- // Log to disk
- Launcher.addDumpLog(TAG, "11683562 - bindAddScreens()", true);
- Launcher.addDumpLog(TAG, "11683562 - orderedScreenIds: " +
- TextUtils.join(", ", orderedScreenIds), true);
int count = orderedScreenIds.size();
for (int i = 0; i < count; i++) {
mWorkspace.insertNewWorkspaceScreenBeforeEmptyScreen(orderedScreenIds.get(i));
@@ -4523,10 +4515,6 @@ public class Launcher extends Activity
editor.apply();
}
- private void showSettingsActivity() {
- startActivity(new Intent(this, SettingsActivity.class));
- }
-
/**
* To be overridden by subclasses to indicate that there is an in-activity full-screen intro
* screen that must be displayed and dismissed.
diff --git a/src/com/android/launcher3/LauncherAnimatorUpdateListener.java b/src/com/android/launcher3/LauncherAnimatorUpdateListener.java
deleted file mode 100644
index ec9fd4d16..000000000
--- a/src/com/android/launcher3/LauncherAnimatorUpdateListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2011 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.android.launcher3;
-
-import android.animation.ValueAnimator;
-import android.animation.ValueAnimator.AnimatorUpdateListener;
-
-abstract class LauncherAnimatorUpdateListener implements AnimatorUpdateListener {
- public void onAnimationUpdate(ValueAnimator animation) {
- final float b = (Float) animation.getAnimatedValue();
- final float a = 1f - b;
- onAnimationUpdate(a, b);
- }
-
- abstract void onAnimationUpdate(float a, float b);
-} \ No newline at end of file
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index d4b41e671..81d595aaf 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -25,6 +25,7 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.Log;
+import android.view.ViewConfiguration;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PackageInstallerCompat;
@@ -40,10 +41,6 @@ public class LauncherAppState {
private final IconCache mIconCache;
private final WidgetPreviewLoader mWidgetCache;
- private final boolean mIsScreenLarge;
- private final float mScreenDensity;
- private final int mLongPressTimeout = 300;
-
private boolean mWallpaperChangedSinceLastCheck;
private static WeakReference<LauncherProvider> sLauncherProvider;
@@ -87,9 +84,6 @@ public class LauncherAppState {
MemoryTracker.startTrackingMe(sContext, "L");
}
- // set sIsScreenXLarge and mScreenDensity *before* creating icon cache
- mIsScreenLarge = isScreenLarge(sContext.getResources());
- mScreenDensity = sContext.getResources().getDisplayMetrics().density;
mInvariantDeviceProfile = new InvariantDeviceProfile(sContext);
mIconCache = new IconCache(sContext, mInvariantDeviceProfile);
mWidgetCache = new WidgetPreviewLoader(sContext, mInvariantDeviceProfile, mIconCache);
@@ -151,6 +145,9 @@ public class LauncherAppState {
return mModel;
}
+ /**
+ * TODO(winsonc, hyunyoungs): We need to respect this
+ */
boolean shouldShowAppOrWidgetProvider(ComponentName componentName) {
return mAppFilter == null || mAppFilter.shouldShowApp(componentName);
}
@@ -170,29 +167,7 @@ public class LauncherAppState {
public WidgetPreviewLoader getWidgetCache() {
return mWidgetCache;
}
-
- public boolean isScreenLarge() {
- return mIsScreenLarge;
- }
-
- // Need a version that doesn't require an instance of LauncherAppState for the wallpaper picker
- public static boolean isScreenLarge(Resources res) {
- return res.getBoolean(R.bool.is_large_tablet);
- }
-
- public static boolean isScreenLandscape(Context context) {
- return context.getResources().getConfiguration().orientation ==
- Configuration.ORIENTATION_LANDSCAPE;
- }
-
- public float getScreenDensity() {
- return mScreenDensity;
- }
-
- public int getLongPressTimeout() {
- return mLongPressTimeout;
- }
-
+
public void onWallpaperChanged() {
mWallpaperChangedSinceLastCheck = true;
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 4974dafab..10b8648de 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1140,10 +1140,6 @@ public class LauncherModel extends BroadcastReceiver
* a list of screen ids in the order that they should appear.
*/
void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
- // Log to disk
- Launcher.addDumpLog(TAG, "11683562 - updateWorkspaceScreenOrder()", true);
- Launcher.addDumpLog(TAG, "11683562 - screens: " + TextUtils.join(", ", screens), true);
-
final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
final ContentResolver cr = context.getContentResolver();
final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;
@@ -1764,9 +1760,6 @@ public class LauncherModel extends BroadcastReceiver
}
private void loadWorkspace() {
- // Log to disk
- Launcher.addDumpLog(TAG, "11683562 - loadWorkspace()", true);
-
final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
final Context context = mContext;
@@ -2932,6 +2925,9 @@ public class LauncherModel extends BroadcastReceiver
}
});
}
+
+ // Reload widget list. No need to refresh, as we only want to update the icons and labels.
+ loadAndBindWidgetsAndShortcuts(mApp.getContext(), callbacks, false);
}
void enqueuePackageUpdated(PackageUpdatedTask task) {
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 45070d190..b5901265c 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -868,8 +868,6 @@ public class LauncherProvider extends ContentProvider {
throw new RuntimeException("Error: max screen id was not initialized");
}
mMaxScreenId += 1;
- // Log to disk
- Launcher.addDumpLog(TAG, "11683562 - generateNewScreenId(): " + mMaxScreenId, true);
return mMaxScreenId;
}
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index a1da1b6fd..27763f545 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -18,12 +18,14 @@ package com.android.launcher3;
import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
+import android.preference.Preference;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
/**
- * Settings activity for Launcher. Currently implements the following setting:
- * LockToPortrait
+ * Settings activity for Launcher. Currently implements the following setting: Allow rotation
*/
public class SettingsActivity extends Activity {
@Override
@@ -41,13 +43,25 @@ public class SettingsActivity extends Activity {
*/
@SuppressWarnings("WeakerAccess")
public static class LauncherSettingsFragment extends PreferenceFragment {
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getPreferenceManager().setSharedPreferencesMode(Context.MODE_PRIVATE);
+ getPreferenceManager().setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
getPreferenceManager().setSharedPreferencesName(LauncherFiles.ROTATION_PREF_FILE);
addPreferencesFromResource(R.xml.launcher_preferences);
}
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
+ Preference preference) {
+ boolean allowRotation = getPreferenceManager().getSharedPreferences().getBoolean(
+ Utilities.ALLOW_ROTATION_PREFERENCE_KEY, false);
+ Intent rotationSetting = new Intent(Utilities.SCREEN_ROTATION_SETTING_INTENT);
+ String launchBroadcastPermission = getResources().getString(
+ R.string.receive_update_orientation_broadcasts_permission);
+ rotationSetting.putExtra(Utilities.SCREEN_ROTATION_SETTING_EXTRA, allowRotation);
+ getActivity().sendBroadcast(rotationSetting, launchBroadcastPermission);
+ return true;
+ }
}
}
diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java
index 419939000..0819f8ce0 100644
--- a/src/com/android/launcher3/UninstallDropTarget.java
+++ b/src/com/android/launcher3/UninstallDropTarget.java
@@ -28,7 +28,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
// Get the hover color
mHoverColor = getResources().getColor(R.color.uninstall_target_hover_tint);
- setDrawable(R.drawable.ic_launcher_uninstall_normal);
+ setDrawable(R.drawable.ic_uninstall_launcher);
}
@Override
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 0877b4527..0cd980cb2 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -92,6 +92,9 @@ public final class Utilities {
private static boolean sForceEnableRotation = isPropertyEnabled(FORCE_ENABLE_ROTATION_PROPERTY);
public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation";
+ public static final String SCREEN_ROTATION_SETTING_INTENT =
+ "come.android.launcher3.SCREEN_ORIENTATION_PREF_CHANGED";
+ public static final String SCREEN_ROTATION_SETTING_EXTRA = "screenRotationPref";
public static boolean isPropertyEnabled(String propertyName) {
return Log.isLoggable(propertyName, Log.VERBOSE);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 193a0af6f..19195b421 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1620,7 +1620,7 @@ public class Workspace extends PagedView
// We should only update the drag layer background alpha if we are not in all apps or the
// widgets tray
if (mState == State.NORMAL) {
- mLauncher.getDragLayer().setBackgroundAlpha(progress * 0.8f);
+ mLauncher.getDragLayer().setBackgroundAlpha(progress == 1 ? 0 : progress * 0.8f);
}
if (mLauncher.getHotseat() != null) {
@@ -3969,7 +3969,7 @@ public class Workspace extends PagedView
@Override
public boolean onEnterScrollArea(int x, int y, int direction) {
// Ignore the scroll area if we are dragging over the hot seat
- boolean isPortrait = !LauncherAppState.isScreenLandscape(getContext());
+ boolean isPortrait = !mLauncher.getDeviceProfile().isLandscape;
if (mLauncher.getHotseat() != null && isPortrait) {
Rect r = new Rect();
mLauncher.getHotseat().getHitRect(r);
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 340066d64..e360e889b 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -335,17 +336,11 @@ public class WorkspaceStateTransitionAnimation {
}
if (mOldBackgroundAlphas[i] != 0 ||
mNewBackgroundAlphas[i] != 0) {
- ValueAnimator bgAnim =
+ ValueAnimator bgAnim = ObjectAnimator.ofFloat(cl, "backgroundAlpha",
+ mOldBackgroundAlphas[i], mNewBackgroundAlphas[i]);
LauncherAnimUtils.ofFloat(cl, 0f, 1f);
bgAnim.setInterpolator(mZoomInInterpolator);
bgAnim.setDuration(duration);
- bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
- public void onAnimationUpdate(float a, float b) {
- cl.setBackgroundAlpha(
- a * mOldBackgroundAlphas[i] +
- b * mNewBackgroundAlphas[i]);
- }
- });
mStateAnimator.play(bgAnim);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 76ca9633d..855a4430d 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -433,6 +433,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
icon = (BubbleTextView) mLayoutInflater.inflate(
R.layout.all_apps_prediction_bar_icon, mPredictionBarView, false);
icon.setFocusable(true);
+ icon.setLongPressTimeout(ViewConfiguration.get(getContext()).getLongPressTimeout());
mPredictionBarView.addView(icon);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 102e7ae8d..4b8b2dfc8 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -27,6 +27,7 @@ import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.launcher3.AppInfo;
@@ -421,6 +422,8 @@ class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.ViewHol
icon.setOnTouchListener(mTouchListener);
icon.setOnClickListener(mIconClickListener);
icon.setOnLongClickListener(mIconLongClickListener);
+ icon.setLongPressTimeout(ViewConfiguration.get(parent.getContext())
+ .getLongPressTimeout());
icon.setFocusable(true);
return new ViewHolder(icon);
default:
diff --git a/src/com/android/launcher3/model/WidgetsModel.java b/src/com/android/launcher3/model/WidgetsModel.java
index 76e6a9dd5..625d4d696 100644
--- a/src/com/android/launcher3/model/WidgetsModel.java
+++ b/src/com/android/launcher3/model/WidgetsModel.java
@@ -8,7 +8,6 @@ import android.util.Log;
import com.android.launcher3.IconCache;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
-
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AlphabeticIndexCompat;
import com.android.launcher3.compat.UserHandleCompat;