diff options
author | Winson Chung <winsonc@google.com> | 2010-09-15 20:37:09 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2010-09-15 20:51:01 -0700 |
commit | e8878e3c5ac2b426be931018493ce82bd9c90378 (patch) | |
tree | 1f6edfc56560ef44c6b1c8ff1c751a751f8a1ed5 /src | |
parent | c2e0c08c997f0a69fec5304083db479d47b59098 (diff) | |
download | android_packages_apps_Trebuchet-e8878e3c5ac2b426be931018493ce82bd9c90378.tar.gz android_packages_apps_Trebuchet-e8878e3c5ac2b426be931018493ce82bd9c90378.tar.bz2 android_packages_apps_Trebuchet-e8878e3c5ac2b426be931018493ce82bd9c90378.zip |
Adding some wallpaper buttons on the customization tray.
Also tweaking the fading algorithm for side pages.
Change-Id: Ia7743c2b71741926ff9ae52e6965d7aefc86604e
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/CustomizePagedView.java | 79 | ||||
-rw-r--r-- | src/com/android/launcher2/HolographicOutlineHelper.java | 12 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 24 |
3 files changed, 66 insertions, 49 deletions
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index 43073912f..6e7f9b6b8 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -52,7 +52,7 @@ import android.widget.TextView; import com.android.launcher.R; public class CustomizePagedView extends PagedView - implements View.OnLongClickListener, + implements View.OnLongClickListener, View.OnClickListener, DragSource { public enum CustomizationType { @@ -108,6 +108,7 @@ public class CustomizePagedView extends PagedView private List<AppWidgetProviderInfo> mWidgetList; private List<ResolveInfo> mFolderList; private List<ResolveInfo> mShortcutList; + private List<ResolveInfo> mWallpaperList; private static final int sCellCountX = 8; private static final int sCellCountY = 4; @@ -188,6 +189,11 @@ public class CustomizePagedView extends PagedView mShortcutList = mPackageManager.queryIntentActivities(shortcutsIntent, 0); Collections.sort(mShortcutList, resolveInfoComparator); + // get the list of wallpapers + Intent wallpapersIntent = new Intent(Intent.ACTION_SET_WALLPAPER); + mWallpaperList = mPackageManager.queryIntentActivities(wallpapersIntent, 0); + Collections.sort(mWallpaperList, resolveInfoComparator); + // reset the icon cache mPageViewIconCache.clear(); @@ -211,6 +217,39 @@ public class CustomizePagedView extends PagedView } @Override + public void onClick(View v) { + if (!v.isInTouchMode()) { + return; + } + + final View animView = v; + switch (mCustomizationType) { + case WallpaperCustomization: + // animate some feedback to the long press + animateClickFeedback(v, new Runnable() { + @Override + public void run() { + // add the shortcut + ResolveInfo info = (ResolveInfo) animView.getTag(); + Intent createShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT); + if (info.labelRes == R.string.group_applications) { + // Create app shortcuts is a special built-in case of shortcuts + createShortcutIntent.putExtra( + Intent.EXTRA_SHORTCUT_NAME,getContext().getString( + R.string.group_applications)); + } else { + ComponentName name = new ComponentName(info.activityInfo.packageName, + info.activityInfo.name); + createShortcutIntent.setComponent(name); + } + mLauncher.prepareAddItemFromHomeCustomizationDrawer(); + mLauncher.processShortcut(createShortcutIntent); + } + }); + } + } + + @Override public boolean onLongClick(View v) { if (!v.isInTouchMode()) { return false; @@ -476,7 +515,11 @@ public class CustomizePagedView extends PagedView PagedViewIcon icon = (PagedViewIcon) mInflater.inflate( R.layout.customize_paged_view_item, layout, false); icon.applyFromResolveInfo(info, mPackageManager, mPageViewIconCache); - icon.setOnLongClickListener(this); + if (mCustomizationType == CustomizationType.WallpaperCustomization) { + icon.setOnClickListener(this); + } else { + icon.setOnLongClickListener(this); + } final int index = i - startIndex; final int x = index % sCellCountX; @@ -486,34 +529,6 @@ public class CustomizePagedView extends PagedView } } - private void syncWallpaperPages() { - // NOT CURRENTLY IMPLEMENTED - - // we need to repopulate with PagedViewCellLayouts - removeAllViews(); - - // add any necessary pages - int numPages = 1; - for (int i = 0; i < numPages; ++i) { - PagedViewCellLayout layout = new PagedViewCellLayout(getContext()); - setupPage(layout); - addView(layout); - } - } - - private void syncWallpaperPageItems(int page) { - PagedViewCellLayout layout = (PagedViewCellLayout) getChildAt(page); - layout.removeAllViews(); - - TextView text = (TextView) mInflater.inflate( - R.layout.customize_paged_view_wallpaper_placeholder, layout, false); - // NOTE: this is just place holder text until MikeJurka implements wallpaper picker - text.setText("Wallpaper customization coming soon!"); - - setupPage(layout); - layout.addViewToCellLayout(text, -1, 0, new PagedViewCellLayout.LayoutParams(0, 0, 3, 1)); - } - @Override public void syncPages() { boolean centerPagedViewCellLayouts = false; @@ -530,7 +545,7 @@ public class CustomizePagedView extends PagedView centerPagedViewCellLayouts = true; break; case WallpaperCustomization: - syncWallpaperPages(); + syncListPages(mWallpaperList); centerPagedViewCellLayouts = true; break; default: @@ -570,7 +585,7 @@ public class CustomizePagedView extends PagedView syncListPageItems(page, mShortcutList); break; case WallpaperCustomization: - syncWallpaperPageItems(page); + syncListPageItems(page, mWallpaperList); break; } } diff --git a/src/com/android/launcher2/HolographicOutlineHelper.java b/src/com/android/launcher2/HolographicOutlineHelper.java index 621033748..d6c5484b8 100644 --- a/src/com/android/launcher2/HolographicOutlineHelper.java +++ b/src/com/android/launcher2/HolographicOutlineHelper.java @@ -59,21 +59,17 @@ public class HolographicOutlineHelper { * pages. */ public float highlightAlphaInterpolator(float r) { - final float pivot = 0.3f; - if (r < pivot) { - return Math.max(0.5f, 0.65f * cubic(r / pivot)); - } else { - return Math.min(1.0f, 0.65f * cubic(1 - (r - pivot) / (1 - pivot))); - } + float maxAlpha = 0.6f; + return (float) Math.pow(maxAlpha * (1.0f - r), 1.5f); } /** * Returns the interpolated view alpha for the effect we want when scrolling pages. */ public float viewAlphaInterpolator(float r) { - final float pivot = 0.6f; + final float pivot = 0.95f; if (r < pivot) { - return r / pivot; + return (float) Math.pow(r / pivot, 1.5f); } else { return 1.0f; } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 2cd7f206e..9dbe61d11 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -374,17 +374,23 @@ public abstract class PagedView extends ViewGroup { int childWidth = layout.getMeasuredWidth(); int halfChildWidth = (childWidth / 2); int childCenter = getChildOffset(i) + halfChildWidth; - int distanceFromScreenCenter = Math.abs(childCenter - screenCenter); - float alpha = 0.0f; - if (distanceFromScreenCenter < halfChildWidth) { - alpha = 1.0f; - } else if (distanceFromScreenCenter > childWidth) { - alpha = 0.0f; + + int d = halfChildWidth; + int distanceFromScreenCenter = childCenter - screenCenter; + if (distanceFromScreenCenter > 0) { + if (i > 0) { + d += getChildAt(i - 1).getMeasuredWidth() / 2; + } } else { - float dimAlpha = (float) (distanceFromScreenCenter - halfChildWidth) / halfChildWidth; - dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha))); - alpha = 1.0f - dimAlpha; + if (i < childCount - 1) { + d += getChildAt(i + 1).getMeasuredWidth() / 2; + } } + + float dimAlpha = (float) (Math.abs(distanceFromScreenCenter)) / d; + dimAlpha = Math.max(0.0f, Math.min(1.0f, (dimAlpha * dimAlpha))); + float alpha = 1.0f - dimAlpha; + if (Float.compare(alpha, layout.getAlpha()) != 0) { layout.setAlpha(alpha); } |