diff options
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 135 |
1 files changed, 64 insertions, 71 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index eef578d8f..4be25bb17 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -18,7 +18,9 @@ package com.android.launcher3; import android.Manifest; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.annotation.TargetApi; @@ -65,6 +67,7 @@ import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.KeyboardShortcutGroup; import android.view.KeyboardShortcutInfo; +import android.view.LayoutInflater; import android.view.Menu; import android.view.MotionEvent; import android.view.View; @@ -84,13 +87,11 @@ import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.allapps.AllAppsContainerView; import com.android.launcher3.allapps.AllAppsTransitionController; -import com.android.launcher3.allapps.DefaultAppSearchController; import com.android.launcher3.anim.AnimationLayerSet; import com.android.launcher3.compat.AppWidgetManagerCompat; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.config.ProviderConfig; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragOptions; @@ -213,6 +214,8 @@ public class Launcher extends BaseActivity private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; @Thunk static int NEW_APPS_ANIMATION_DELAY = 500; + private final ExtractedColors mExtractedColors = new ExtractedColors(); + @Thunk Workspace mWorkspace; private View mLauncherView; @Thunk DragLayer mDragLayer; @@ -261,13 +264,14 @@ public class Launcher extends BaseActivity private LauncherModel mModel; private ModelWriter mModelWriter; private IconCache mIconCache; - private ExtractedColors mExtractedColors; private LauncherAccessibilityDelegate mAccessibilityDelegate; private Handler mHandler = new Handler(); private boolean mIsResumeFromActionScreenOff; private boolean mHasFocus = false; private boolean mAttached = false; + private ObjectAnimator mScrimAnimator; + private PopupDataProvider mPopupDataProvider; private View.OnTouchListener mHapticFeedbackTouchListener; @@ -393,11 +397,10 @@ public class Launcher extends BaseActivity // LauncherModel load. mPaused = false; - mLauncherView = getLayoutInflater().inflate(R.layout.launcher, null); + mLauncherView = LayoutInflater.from(this).inflate(R.layout.launcher, null); setupViews(); mDeviceProfile.layout(this, false /* notifyListeners */); - mExtractedColors = new ExtractedColors(); loadExtractedColorsAndColorItems(); mPopupDataProvider = new PopupDataProvider(this); @@ -466,6 +469,11 @@ public class Launcher extends BaseActivity @Override public void onExtractedColorsChanged() { loadExtractedColorsAndColorItems(); + mExtractedColors.notifyChange(); + } + + public ExtractedColors getExtractedColors() { + return mExtractedColors; } @Override @@ -481,9 +489,9 @@ public class Launcher extends BaseActivity mExtractedColors.load(this); mHotseat.updateColor(mExtractedColors, !mPaused); mWorkspace.getPageIndicator().updateColor(mExtractedColors); - boolean lightStatusBar = (FeatureFlags.LIGHT_STATUS_BAR - && mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX, - ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT); + boolean lightStatusBar = (FeatureFlags.LIGHT_STATUS_BAR && + mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX) == + ExtractedColors.DEFAULT_LIGHT); // It's possible that All Apps is visible when this is run, // so always use light status bar in that case. Only change nav bar color to status bar // color when All Apps is visible. @@ -550,47 +558,6 @@ public class Launcher extends BaseActivity public boolean setLauncherCallbacks(LauncherCallbacks callbacks) { mLauncherCallbacks = callbacks; - mLauncherCallbacks.setLauncherSearchCallback(new Launcher.LauncherSearchCallbacks() { - private boolean mWorkspaceImportanceStored = false; - private boolean mHotseatImportanceStored = false; - private int mWorkspaceImportanceForAccessibility = - View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; - private int mHotseatImportanceForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; - - @Override - public void onSearchOverlayOpened() { - if (mWorkspaceImportanceStored || mHotseatImportanceStored) { - return; - } - // The underlying workspace and hotseat are temporarily suppressed by the search - // overlay. So they shouldn't be accessible. - if (mWorkspace != null) { - mWorkspaceImportanceForAccessibility = - mWorkspace.getImportantForAccessibility(); - mWorkspace.setImportantForAccessibility( - View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); - mWorkspaceImportanceStored = true; - } - if (mHotseat != null) { - mHotseatImportanceForAccessibility = mHotseat.getImportantForAccessibility(); - mHotseat.setImportantForAccessibility( - View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); - mHotseatImportanceStored = true; - } - } - - @Override - public void onSearchOverlayClosed() { - if (mWorkspaceImportanceStored && mWorkspace != null) { - mWorkspace.setImportantForAccessibility(mWorkspaceImportanceForAccessibility); - } - if (mHotseatImportanceStored && mHotseat != null) { - mHotseat.setImportantForAccessibility(mHotseatImportanceForAccessibility); - } - mWorkspaceImportanceStored = false; - mHotseatImportanceStored = false; - } - }); return true; } @@ -952,6 +919,24 @@ public class Launcher extends BaseActivity if (!isWorkspaceLoading()) { NotificationListener.setNotificationsChangedListener(mPopupDataProvider); } + + if (mIsResumeFromActionScreenOff && mDragLayer.getBackground() != null) { + if (mScrimAnimator != null) { + mScrimAnimator.cancel(); + } + mDragLayer.getBackground().setAlpha(0); + mScrimAnimator = ObjectAnimator.ofInt(mDragLayer.getBackground(), + LauncherAnimUtils.DRAWABLE_ALPHA, 0, 255); + mScrimAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mScrimAnimator = null; + } + }); + mScrimAnimator.setDuration(600); + mScrimAnimator.setStartDelay(getWindow().getTransitionBackgroundFadeDuration()); + mScrimAnimator.start(); + } } @Override @@ -1130,18 +1115,6 @@ public class Launcher extends BaseActivity public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks); } - public interface LauncherSearchCallbacks { - /** - * Called when the search overlay is shown. - */ - public void onSearchOverlayOpened(); - - /** - * Called when the search overlay is dismissed. - */ - public void onSearchOverlayClosed(); - } - public interface LauncherOverlayCallbacks { public void onScrollChanged(float progress); } @@ -1334,11 +1307,6 @@ public class Launcher extends BaseActivity // Setup Apps and Widgets mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view); mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view); - if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { - mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); - } else { - mAppsView.setSearchBarController(new DefaultAppSearchController()); - } // Setup the drag controller (drop targets have to be added in reverse order in priority) mDragController.setMoveTarget(mWorkspace); @@ -1429,8 +1397,8 @@ public class Launcher extends BaseActivity * @return A View inflated from layoutResId. */ public View createShortcut(ViewGroup parent, ShortcutInfo info) { - BubbleTextView favorite = (BubbleTextView) getLayoutInflater().inflate(R.layout.app_icon, - parent, false); + BubbleTextView favorite = (BubbleTextView) LayoutInflater.from(parent.getContext()) + .inflate(R.layout.app_icon, parent, false); favorite.applyFromShortcutInfo(info); favorite.setCompoundDrawablePadding(mDeviceProfile.iconDrawablePaddingPx); favorite.setOnClickListener(this); @@ -1767,7 +1735,7 @@ public class Launcher extends BaseActivity // Reset the apps view if (!alreadyOnHome && mAppsView != null) { - mAppsView.scrollToTop(); + mAppsView.reset(); } // Reset the widgets view @@ -2469,7 +2437,13 @@ public class Launcher extends BaseActivity private void startAppShortcutOrInfoActivity(View v) { ItemInfo item = (ItemInfo) v.getTag(); - Intent intent = item.getIntent(); + Intent intent; + if (item instanceof PromiseAppInfo) { + PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item; + intent = promiseAppInfo.getMarketIntent(); + } else { + intent = item.getIntent(); + } if (intent == null) { throw new IllegalArgumentException("Input must have a valid intent"); } @@ -3397,7 +3371,7 @@ public class Launcher extends BaseActivity Object tag = v.getTag(); String desc = "Collision while binding workspace item: " + item + ". Collides with " + tag; - if (ProviderConfig.IS_DOGFOOD_BUILD) { + if (FeatureFlags.IS_DOGFOOD_BUILD) { throw (new RuntimeException(desc)); } else { Log.d(TAG, desc); @@ -3600,6 +3574,9 @@ public class Launcher extends BaseActivity LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag(); info.restoreStatus = finalRestoreFlag; + if (info.restoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED) { + info.pendingItemInfo = null; + } mWorkspace.reinflateWidgetsIfNecessary(); getModelWriter().updateItemInDatabase(info); @@ -3775,6 +3752,22 @@ public class Launcher extends BaseActivity } @Override + public void bindPromiseAppProgressUpdated(final PromiseAppInfo app) { + Runnable r = new Runnable() { + public void run() { + bindPromiseAppProgressUpdated(app); + } + }; + if (waitUntilResume(r)) { + return; + } + + if (mAppsView != null) { + mAppsView.updatePromiseAppProgress(app); + } + } + + @Override public void bindWidgetsRestored(final ArrayList<LauncherAppWidgetInfo> widgets) { Runnable r = new Runnable() { public void run() { |