diff options
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/AllAppsTabbed.java | 30 | ||||
-rw-r--r-- | src/com/android/launcher2/CustomizeTrayTabHost.java | 41 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 45 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 56 |
4 files changed, 138 insertions, 34 deletions
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java index 47a5bf7fc..36594dd34 100644 --- a/src/com/android/launcher2/AllAppsTabbed.java +++ b/src/com/android/launcher2/AllAppsTabbed.java @@ -29,16 +29,19 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.widget.TabHost; import android.widget.TabWidget; import android.widget.TextView; +import android.widget.TabHost.OnTabChangeListener; +import android.widget.TabHost.TabContentFactory; import java.util.ArrayList; /** * Implements a tabbed version of AllApps2D. */ -public class AllAppsTabbed extends TabHost implements AllAppsView { +public class AllAppsTabbed extends TabHost implements AllAppsView, LauncherAnimatable { private static final String TAG = "Launcher.AllAppsTabbed"; @@ -46,6 +49,7 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { private static final String TAG_DOWNLOADED = "DOWNLOADED"; private AllAppsPagedView mAllApps; + private View mTabBar; private Context mContext; private final LayoutInflater mInflater; private boolean mFirstLayout = true; @@ -64,6 +68,8 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { try { mAllApps = (AllAppsPagedView) findViewById(R.id.all_apps_paged_view); if (mAllApps == null) throw new Resources.NotFoundException(); + mTabBar = findViewById(R.id.all_apps_tab_bar); + if (mTabBar == null) throw new Resources.NotFoundException(); } catch (Resources.NotFoundException e) { Log.e(TAG, "Can't find necessary layout elements for AllAppsTabbed"); } @@ -164,6 +170,28 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { } @Override + public void setFastAlpha(float alpha) { + final ViewGroup allAppsParent = (ViewGroup) mAllApps.getParent(); + final ViewGroup tabBarParent = (ViewGroup) mAllApps.getParent(); + mAllApps.setFastAlpha(alpha); + allAppsParent.fastInvalidate(); + mTabBar.setFastAlpha(alpha); + tabBarParent.fastInvalidate(); + } + + @Override + public void onLauncherAnimationStart() { + mTabBar.setLayerType(LAYER_TYPE_HARDWARE, null); + mAllApps.setLayerType(LAYER_TYPE_HARDWARE, null); + } + + @Override + public void onLauncherAnimationEnd() { + mTabBar.setLayerType(LAYER_TYPE_NONE, null); + mAllApps.setLayerType(LAYER_TYPE_NONE, null); + } + + @Override public void setApps(ArrayList<ApplicationInfo> list) { mAllApps.setApps(list); } diff --git a/src/com/android/launcher2/CustomizeTrayTabHost.java b/src/com/android/launcher2/CustomizeTrayTabHost.java new file mode 100644 index 000000000..502917211 --- /dev/null +++ b/src/com/android/launcher2/CustomizeTrayTabHost.java @@ -0,0 +1,41 @@ +/* + * 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.launcher2; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.TabHost; + +public class CustomizeTrayTabHost extends TabHost implements LauncherAnimatable { + public CustomizeTrayTabHost(Context context) { + super(context); + } + + public CustomizeTrayTabHost(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void onLauncherAnimationStart() { + setLayerType(LAYER_TYPE_HARDWARE, null); + } + + @Override + public void onLauncherAnimationEnd() { + setLayerType(LAYER_TYPE_NONE, null); + } +} diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 195b671e0..63982ba30 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -418,15 +418,12 @@ public final class Launcher extends Activity // If we have a saved version of these external icons, we load them up immediately if (LauncherApplication.isScreenXLarge()) { - if (sGlobalSearchIcon != null) { - updateGlobalSearchIcon(sGlobalSearchIcon); - } - if (sVoiceSearchIcon != null) { - updateVoiceSearchIcon(sVoiceSearchIcon); - } - if (sAppMarketIcon != null) { - updateAppMarketIcon(sAppMarketIcon); + if (sGlobalSearchIcon == null || sVoiceSearchIcon == null || sAppMarketIcon == null) { + updateIconsAffectedByPackageManagerChanges(); } + updateGlobalSearchIcon(sGlobalSearchIcon); + updateVoiceSearchIcon(sVoiceSearchIcon); + updateAppMarketIcon(sAppMarketIcon); } } @@ -2245,6 +2242,10 @@ public final class Launcher extends Activity } public boolean onLongClick(View v) { + if (mState != State.WORKSPACE) { + return false; + } + switch (v.getId()) { case R.id.previous_screen: if (mState != State.ALL_APPS) { @@ -2277,7 +2278,6 @@ public final class Launcher extends Activity v = (View) v.getParent().getParent(); } - resetAddInfo(); CellLayout.CellInfo longClickCellInfo = (CellLayout.CellInfo) v.getTag(); // This happens when long clicking an item with the dpad/trackball @@ -2767,7 +2767,7 @@ public final class Launcher extends Activity }); if (toAllApps) { - toView.setAlpha(0f); + toView.setFastAlpha(0f); ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration); alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); alphaAnim.addUpdateListener(new AnimatorUpdateListener() { @@ -2781,9 +2781,8 @@ public final class Launcher extends Activity alphaAnim.start(); } - // Only use hardware layers in portrait mode, they don't give any gains in landscape - if (mWorkspace.getWidth() < mWorkspace.getHeight()) { - toView.setLayerType(View.LAYER_TYPE_HARDWARE, null); + if (toView instanceof LauncherAnimatable) { + ((LauncherAnimatable) toView).onLauncherAnimationStart(); } scaleAnim.addListener(new AnimatorListenerAdapter() { @Override @@ -2793,7 +2792,7 @@ public final class Launcher extends Activity toView.setTranslationY(0.0f); toView.setVisibility(View.VISIBLE); if (!toAllApps) { - toView.setAlpha(1.0f); + toView.setFastAlpha(1.0f); } } @Override @@ -2801,9 +2800,11 @@ public final class Launcher extends Activity // If we don't set the final scale values here, if this animation is cancelled // it will have the wrong scale value and subsequent cameraPan animations will // not fix that - toView.setLayerType(View.LAYER_TYPE_NONE, null); toView.setScaleX(1.0f); toView.setScaleY(1.0f); + if (toView instanceof LauncherAnimatable) { + ((LauncherAnimatable) toView).onLauncherAnimationEnd(); + } } }); @@ -2895,13 +2896,16 @@ public final class Launcher extends Activity fromView.setFastAlpha(a * 1f + b * 0f); } }); - - fromView.setLayerType(View.LAYER_TYPE_HARDWARE, null); + if (fromView instanceof LauncherAnimatable) { + ((LauncherAnimatable) fromView).onLauncherAnimationStart(); + } alphaAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { fromView.setVisibility(View.GONE); - fromView.setLayerType(View.LAYER_TYPE_NONE, null); + if (fromView instanceof LauncherAnimatable) { + ((LauncherAnimatable) fromView).onLauncherAnimationEnd(); + } } }); @@ -3714,3 +3718,8 @@ public final class Launcher extends Activity Log.d(TAG, "END launcher2 dump state"); } } + +interface LauncherAnimatable { + void onLauncherAnimationStart(); + void onLauncherAnimationEnd(); +} diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 3e5a96795..b1dd08807 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -76,7 +76,8 @@ import java.util.List; * interact with. A workspace is meant to be used with a fixed width only. */ public class Workspace extends SmoothPagedView - implements DropTarget, DragSource, DragScroller, View.OnTouchListener { + implements DropTarget, DragSource, DragScroller, View.OnTouchListener, + View.OnClickListener { @SuppressWarnings({"UnusedDeclaration"}) private static final String TAG = "Launcher.Workspace"; @@ -343,6 +344,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, index, params); } @@ -352,6 +355,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child); } @@ -361,6 +366,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, index); } @@ -370,6 +377,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, width, height); } @@ -379,6 +388,8 @@ public class Workspace extends SmoothPagedView throw new IllegalArgumentException("A Workspace can only have CellLayout children."); } ((CellLayout) child).setOnInterceptTouchListener(this); + child.setOnClickListener(this); + child.setClickable(true); super.addView(child, params); } @@ -521,16 +532,25 @@ public class Workspace extends SmoothPagedView return hitsPage(current + 1, x, y); } + /** + * Called directly from a CellLayout (not by the framework), after we've been added as a + * listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout + * that it should intercept touch events, which is not something that is normally supported. + */ + @Override public boolean onTouch(View v, MotionEvent event) { - // this is an intercepted event being forwarded from a cell layout - if (mIsSmall || mIsInUnshrinkAnimation) { - // Only allow clicks on a CellLayout if it is visible - if (mShrinkState != ShrinkState.BOTTOM_HIDDEN) { - mLauncher.onWorkspaceClick((CellLayout) v); - } - return true; + return (mIsSmall || mIsInUnshrinkAnimation); + } + + /** + * Handle a click event on a CellLayout. + */ + @Override + public void onClick(View cellLayout) { + // Only allow clicks on a CellLayout if it is shrunken and visible. + if ((mIsSmall || mIsInUnshrinkAnimation) && mShrinkState != ShrinkState.BOTTOM_HIDDEN) { + mLauncher.onWorkspaceClick((CellLayout) cellLayout); } - return false; } protected void onWindowVisibilityChanged (int visibility) { @@ -554,8 +574,7 @@ public class Workspace extends SmoothPagedView } if (mIsSmall || mIsInUnshrinkAnimation) { - if (mLauncher.isAllAppsVisible() && - mShrinkState == ShrinkState.BOTTOM_HIDDEN) { + if (mLauncher.isAllAppsVisible() && mShrinkState == ShrinkState.BOTTOM_HIDDEN) { // Intercept this event so we can show the workspace in full view // when it is clicked on and it is small AllAppsPagedView allApps = (AllAppsPagedView) @@ -773,7 +792,7 @@ public class Workspace extends SmoothPagedView } } if (keepUpdating) { - invalidate(); + fastInvalidate(); } } @@ -1148,8 +1167,9 @@ public class Workspace extends SmoothPagedView final long drawingTime = getDrawingTime(); for (int i = 0; i < pageCount; i++) { final View page = (View) getChildAt(i); - - drawChild(canvas, page, drawingTime); + if (page.getVisibility() == VISIBLE && page.getAlpha() != 0f) { + drawChild(canvas, page, drawingTime); + } } } else { super.dispatchDraw(canvas); @@ -2687,7 +2707,13 @@ public class Workspace extends SmoothPagedView mSpringLoadedDragController.onDragExit(); } mDragTargetLayout = layout; - if (mDragTargetLayout != null && mDragTargetLayout.getAcceptsDrops()) { + // In spring-loaded mode, we still want the user to be able to hover over a + // full screen (which is traditionally set to not accept drops) if they want to + // get to pages beyond the screen that is full. + boolean allowDragOver = (mDragTargetLayout != null) && + (mDragTargetLayout.getAcceptsDrops() || + (mShrinkState == ShrinkState.SPRING_LOADED)); + if (allowDragOver) { mDragTargetLayout.setIsDragOverlapping(true); mSpringLoadedDragController.onDragEnter( mDragTargetLayout, mShrinkState == ShrinkState.SPRING_LOADED); |