diff options
author | Winson Chung <winsonc@google.com> | 2011-06-20 15:41:53 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-06-20 17:14:37 -0700 |
commit | 201bc828d5a0078f505e8e37152156a0cb43c10a (patch) | |
tree | 698628a43eec7783c1d885b12aa771fd82579f93 /src | |
parent | 30faf5197983383e15728c66ee7e9a39d5b717b2 (diff) | |
download | android_packages_apps_Trebuchet-201bc828d5a0078f505e8e37152156a0cb43c10a.tar.gz android_packages_apps_Trebuchet-201bc828d5a0078f505e8e37152156a0cb43c10a.tar.bz2 android_packages_apps_Trebuchet-201bc828d5a0078f505e8e37152156a0cb43c10a.zip |
Need to remove views and not just hide them after animations.
- Removing Manage Apps button from workspace and renaming it in AppsCustomize
- Fixing foolish string play in resources from initial change for search bar
- Using proper way to get full screen dims for wallpaper fix
Change-Id: I1319d225135436468f1feb3057cd9f28eda7c89c
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/AppsCustomizePagedView.java | 20 | ||||
-rw-r--r-- | src/com/android/launcher2/DeleteDropTarget.java | 9 | ||||
-rw-r--r-- | src/com/android/launcher2/InfoDropTarget.java | 21 | ||||
-rw-r--r-- | src/com/android/launcher2/SearchDropTargetBar.java | 65 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 11 |
5 files changed, 99 insertions, 27 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 5b4f15062..c27e3759d 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -508,15 +508,17 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h, float scaleX, float scaleY) { - Canvas c = new Canvas(); - if (bitmap != null) c.setBitmap(bitmap); - c.save(); - c.scale(scaleX, scaleY); - Rect oldBounds = d.copyBounds(); - d.setBounds(x, y, x + w, y + h); - d.draw(c); - d.setBounds(oldBounds); // Restore the bounds - c.restore(); + if (bitmap != null) { + Canvas c = new Canvas(); + c.setBitmap(bitmap); + c.save(); + c.scale(scaleX, scaleY); + Rect oldBounds = d.copyBounds(); + d.setBounds(x, y, x + w, y + h); + d.draw(c); + d.setBounds(oldBounds); // Restore the bounds + c.restore(); + } } private FastBitmapDrawable getShortcutPreview(ResolveInfo info, int cellWidth, int cellHeight) { // Return the cached version if necessary diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java index 5b3fd1e16..a30c03e66 100644 --- a/src/com/android/launcher2/DeleteDropTarget.java +++ b/src/com/android/launcher2/DeleteDropTarget.java @@ -18,6 +18,7 @@ package com.android.launcher2; import android.animation.ObjectAnimator; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; @@ -56,6 +57,14 @@ public class DeleteDropTarget extends ButtonDropTarget { mHoverColor, PorterDuff.Mode.SRC_ATOP)); setBackgroundColor(mHoverColor); getBackground().setAlpha(0); + + // Remove the text in the Phone UI in landscape + int orientation = getResources().getConfiguration().orientation; + if (orientation == Configuration.ORIENTATION_LANDSCAPE) { + if (!LauncherApplication.isScreenLarge()) { + mText.setText(""); + } + } } private boolean isAllAppsApplication(DragSource source, Object info) { diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java index 7e6b700df..76a6bf926 100644 --- a/src/com/android/launcher2/InfoDropTarget.java +++ b/src/com/android/launcher2/InfoDropTarget.java @@ -19,17 +19,20 @@ package com.android.launcher2; import android.animation.ObjectAnimator; import android.content.ComponentName; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.util.AttributeSet; import android.view.View; +import android.widget.TextView; import com.android.launcher.R; public class InfoDropTarget extends ButtonDropTarget { + private TextView mText; private int mHoverColor = 0xFF0000FF; public InfoDropTarget(Context context, AttributeSet attrs) { @@ -44,6 +47,8 @@ public class InfoDropTarget extends ButtonDropTarget { protected void onFinishInflate() { super.onFinishInflate(); + mText = (TextView) findViewById(R.id.info_target_text); + // Get the hover color Resources r = getResources(); mHoverColor = r.getColor(R.color.info_target_hover_tint); @@ -51,11 +56,18 @@ public class InfoDropTarget extends ButtonDropTarget { mHoverColor, PorterDuff.Mode.SRC_ATOP)); setBackgroundColor(mHoverColor); getBackground().setAlpha(0); + + // Remove the text in the Phone UI in landscape + int orientation = getResources().getConfiguration().orientation; + if (orientation == Configuration.ORIENTATION_LANDSCAPE) { + if (!LauncherApplication.isScreenLarge()) { + mText.setText(""); + } + } } - private boolean isApplication(Object info) { - if (info instanceof ApplicationInfo) return true; - return (((ItemInfo) info).itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION); + private boolean isAllAppsApplication(DragSource source, Object info) { + return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo); } @Override @@ -77,11 +89,10 @@ public class InfoDropTarget extends ButtonDropTarget { @Override public void onDragStart(DragSource source, Object info, int dragAction) { - ItemInfo item = (ItemInfo) info; boolean isVisible = true; // If we are dragging a widget or shortcut, hide the info target - if (!isApplication(info)) { + if (!isAllAppsApplication(source, info)) { isVisible = false; } diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java index d00e2103f..943bd00bd 100644 --- a/src/com/android/launcher2/SearchDropTargetBar.java +++ b/src/com/android/launcher2/SearchDropTargetBar.java @@ -16,6 +16,9 @@ package com.android.launcher2; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; import android.content.Context; import android.util.AttributeSet; import android.view.View; @@ -32,6 +35,11 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D private static final int sTransitionInDuration = 275; private static final int sTransitionOutDuration = 100; + private ObjectAnimator mDropTargetBarFadeInAnim; + private ObjectAnimator mDropTargetBarFadeOutAnim; + private ObjectAnimator mQSBSearchBarFadeInAnim; + private ObjectAnimator mQSBSearchBarFadeOutAnim; + private boolean mIsSearchBarHidden; private View mQSBSearchBar; private View mDropTargetBar; @@ -66,23 +74,68 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D mDropTargetBar = findViewById(R.id.drag_target_bar); mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target); mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target); + + // Create the various fade animations + mDropTargetBarFadeInAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 1f); + mDropTargetBarFadeInAnim.setDuration(sTransitionInDuration); + mDropTargetBarFadeInAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mDropTargetBar.setVisibility(View.VISIBLE); + } + }); + mDropTargetBarFadeOutAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 0f); + mDropTargetBarFadeOutAnim.setDuration(sTransitionOutDuration); + mDropTargetBarFadeOutAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mDropTargetBar.setVisibility(View.GONE); + } + }); + mQSBSearchBarFadeInAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 1f); + mQSBSearchBarFadeInAnim.setDuration(sTransitionInDuration); + mQSBSearchBarFadeInAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mQSBSearchBar.setVisibility(View.VISIBLE); + } + }); + mQSBSearchBarFadeOutAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 0f); + mQSBSearchBarFadeOutAnim.setDuration(sTransitionOutDuration); + mQSBSearchBarFadeOutAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mQSBSearchBar.setVisibility(View.GONE); + } + }); + } + + private void cancelAnimations() { + mDropTargetBarFadeInAnim.cancel(); + mDropTargetBarFadeOutAnim.cancel(); + mQSBSearchBarFadeInAnim.cancel(); + mQSBSearchBarFadeOutAnim.cancel(); } /* * Shows and hides the search bar. */ public void showSearchBar(boolean animated) { + cancelAnimations(); if (animated) { - mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration); + mQSBSearchBarFadeInAnim.start(); } else { + mQSBSearchBar.setVisibility(View.VISIBLE); mQSBSearchBar.setAlpha(1f); } mIsSearchBarHidden = false; } public void hideSearchBar(boolean animated) { + cancelAnimations(); if (animated) { - mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration); + mQSBSearchBarFadeOutAnim.start(); } else { + mQSBSearchBar.setVisibility(View.GONE); mQSBSearchBar.setAlpha(0f); } mIsSearchBarHidden = true; @@ -104,18 +157,18 @@ public class SearchDropTargetBar extends FrameLayout implements DragController.D @Override public void onDragStart(DragSource source, Object info, int dragAction) { // Animate out the QSB search bar, and animate in the drop target bar - mDropTargetBar.animate().alpha(1f).setDuration(sTransitionInDuration); + mDropTargetBarFadeInAnim.start(); if (!mIsSearchBarHidden) { - mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration); + mQSBSearchBarFadeOutAnim.start(); } } @Override public void onDragEnd() { // Restore the QSB search bar, and animate out the drop target bar - mDropTargetBar.animate().alpha(0f).setDuration(sTransitionOutDuration); + mDropTargetBarFadeOutAnim.start(); if (!mIsSearchBarHidden) { - mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration); + mQSBSearchBarFadeInAnim.start(); } } } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 1048fd570..7165865e3 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -735,13 +735,10 @@ public class Workspace extends SmoothPagedView protected void setWallpaperDimension() { Display display = mLauncher.getWindowManager().getDefaultDisplay(); - Point displaySize = new Point(); - display.getSize(displaySize); - if (LauncherApplication.isScreenLarge()) { - displaySize.y += (int) getResources().getDimension(R.dimen.status_bar_height); - } - final int maxDim = Math.max(displaySize.x, displaySize.y); - final int minDim = Math.min(displaySize.x, displaySize.y); + DisplayMetrics displayMetrics = new DisplayMetrics(); + display.getRealMetrics(displayMetrics); + final int maxDim = Math.max(displayMetrics.widthPixels, displayMetrics.heightPixels); + final int minDim = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels); // We need to ensure that there is enough extra space in the wallpaper for the intended // parallax effects |