summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNebojsa Cvetkovic <nebkat@gmail.com>2014-11-10 18:35:00 (GMT)
committerAdnan <adnan@cyngn.com>2014-11-19 23:53:56 (GMT)
commit3ada0966559cd9fee535a40686e049cd0d6f15c0 (patch)
tree0b06557595d3c49e1ff826ffa2053824c3dc2031
parent0daed36da7dab3172f05aa3dc29b7facac01ce6e (diff)
downloadandroid_packages_apps_Trebuchet-3ada0966559cd9fee535a40686e049cd0d6f15c0.zip
android_packages_apps_Trebuchet-3ada0966559cd9fee535a40686e049cd0d6f15c0.tar.gz
android_packages_apps_Trebuchet-3ada0966559cd9fee535a40686e049cd0d6f15c0.tar.bz2
PagedView: Transition Effects
Conflicts: res/layout/overview_panel.xml res/values/cm_arrays.xml res/values/cm_strings.xml res/values/dimens.xml res/values/preferences_defaults.xml src/com/android/launcher3/AppsCustomizePagedView.java src/com/android/launcher3/Launcher.java src/com/android/launcher3/PagedView.java src/com/android/launcher3/Workspace.java src/com/android/launcher3/settings/SettingsProvider.java Change-Id: Ib134705952877165c334181548d577b3dceece68
-rw-r--r--Android.mk1
-rw-r--r--res/layout-port/launcher.xml9
-rw-r--r--res/layout/overview_panel.xml1
-rw-r--r--res/layout/settings_pane.xml1
-rw-r--r--res/menu/apps_customize_sort_mode.xml11
-rw-r--r--res/menu/scrolling_settings.xml10
-rw-r--r--res/values/cm_arrays.xml2
-rw-r--r--res/values/config.xml5
-rw-r--r--res/values/preferences_defaults.xml15
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java148
-rw-r--r--src/com/android/launcher3/DeviceProfile.java12
-rw-r--r--src/com/android/launcher3/DragLayer.java18
-rw-r--r--src/com/android/launcher3/Launcher.java41
-rw-r--r--src/com/android/launcher3/LauncherModel.java16
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java2
-rw-r--r--src/com/android/launcher3/PagedView.java426
-rw-r--r--src/com/android/launcher3/Stats.java24
-rw-r--r--src/com/android/launcher3/Workspace.java170
18 files changed, 784 insertions, 128 deletions
diff --git a/Android.mk b/Android.mk
index 63e85ae..59bc896 100644
--- a/Android.mk
+++ b/Android.mk
@@ -44,6 +44,7 @@ LOCAL_PACKAGE_NAME := Launcher3
LOCAL_OVERRIDES_PACKAGES := Launcher2
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 9e98d42..ad10278 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -48,10 +48,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
- <include layout="@layout/overview_panel"
- android:id="@+id/overview_panel"
- android:visibility="gone" />
-
<!-- Keep these behind the workspace so that they are not visible when
we go into AllApps -->
<include
@@ -82,5 +78,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
+
+ <include layout="@layout/overview_panel"
+ android:id="@+id/overview_panel"
+ android:visibility="gone" />
+
</com.android.launcher3.DragLayer>
</FrameLayout>
diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml
index ea12aef..8fed477 100644
--- a/res/layout/overview_panel.xml
+++ b/res/layout/overview_panel.xml
@@ -22,7 +22,6 @@
android:gravity="bottom"
slidingpanel:overlay="false"
slidingpanel:panelHeight="@dimen/sliding_panel_padding" >
-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/default_home_screen_panel"
diff --git a/res/layout/settings_pane.xml b/res/layout/settings_pane.xml
index cb79e37..e12839e 100644
--- a/res/layout/settings_pane.xml
+++ b/res/layout/settings_pane.xml
@@ -4,6 +4,7 @@
android:layout_height="match_parent" >
<LinearLayout
+ android:id="@+id/settings_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|bottom"
diff --git a/res/menu/apps_customize_sort_mode.xml b/res/menu/apps_customize_sort_mode.xml
new file mode 100644
index 0000000..cb5f8fa
--- /dev/null
+++ b/res/menu/apps_customize_sort_mode.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <group android:checkableBehavior="single">
+ <item android:id="@+id/sort_mode_title"
+ android:title="@string/sort_mode_title" />
+ <item android:id="@+id/sort_mode_launch_count"
+ android:title="@string/sort_mode_launch_count" />
+ <item android:id="@+id/sort_mode_install_time"
+ android:title="@string/sort_mode_install_time" />
+ </group>
+</menu> \ No newline at end of file
diff --git a/res/menu/scrolling_settings.xml b/res/menu/scrolling_settings.xml
new file mode 100644
index 0000000..e29a3ca
--- /dev/null
+++ b/res/menu/scrolling_settings.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/scrolling_page_outlines"
+ android:checkable="true"
+ android:title="@string/scrolling_page_outlines"/>
+ <item android:id="@+id/scrolling_fade_adjacent"
+ android:checkable="true"
+ android:title="@string/scrolling_fade_adjacent"/>
+</menu> \ No newline at end of file
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml
index 2320f18..de89b53 100644
--- a/res/values/cm_arrays.xml
+++ b/res/values/cm_arrays.xml
@@ -74,4 +74,4 @@
<item>@drawable/transition_carousel</item>
<item>@drawable/transition_overview</item>
</string-array>
-</resources> \ No newline at end of file
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 8e19e37..52d0871 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -13,6 +13,7 @@
<bool name="is_tablet">false</bool>
<bool name="is_large_tablet">false</bool>
<bool name="allow_rotation">false</bool>
+ <bool name="config_largeIcons">false</bool>
<!-- Max number of page indicators to show -->
<integer name="config_maxNumberOfPageIndicatorsToShow">21</integer>
@@ -64,6 +65,10 @@
<!-- Workspace -->
<!-- Whether or not the drop targets drop down as opposed to fade in -->
<bool name="config_useDropTargetDownTransition">false</bool>
+ <!-- Whether or not to fade the side pages -->
+ <bool name="config_workspaceFadeAdjacentScreens">false</bool>
+ <!-- Whether to show outlines on the screens when scrolling -->
+ <bool name="config_workspaceDefaultShowOutlines">false</bool>
<!-- The transition duration for the background of the drop targets -->
<integer name="config_dropTargetBgTransitionDuration">0</integer>
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml
new file mode 100644
index 0000000..6d6d1b2
--- /dev/null
+++ b/res/values/preferences_defaults.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <bool name="preferences_interface_homescreen_search_default">true</bool>
+ <string name="preferences_interface_homescreen_scrolling_transition_effect">none</string>
+ <bool name="preferences_interface_homescreen_scrolling_wallpaper_scroll_default">true</bool>
+ <bool name="preferences_interface_homescreen_scrolling_page_outlines_default">@bool/config_workspaceDefaultShowOutlines</bool>
+ <bool name="preferences_interface_homescreen_scrolling_fade_adjacent_default">@@bool/config_workspaceFadeAdjacentScreens</bool>
+ <bool name="preferences_interface_homescreen_hide_icon_labels_default">false</bool>
+ <string name="preferences_interface_drawer_scrolling_transition_effect">stack</string>
+ <bool name="preferences_interface_drawer_scrolling_fade_adjacent_default">false</bool>
+ <bool name="preferences_interface_drawer_hide_icon_labels_default">false</bool>
+ <bool name="preferences_interface_general_icons_large_default">@bool/config_largeIcons</bool>
+ <string name="preferences_interface_general_icons_text_font_family_default">sans-serif-condensed</string>
+ <integer name="preferences_interface_general_icons_text_font_style_default">0</integer>
+</resources>
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 1bd2907..eac84dd 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -49,9 +49,11 @@ import android.widget.Toast;
import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.compat.AppWidgetManagerCompat;
+import com.android.launcher3.settings.SettingsProvider;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -157,6 +159,36 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
private ContentType mContentType = ContentType.Applications;
+ /**
+ * The different sort modes than can be used to order items.
+ */
+ public enum SortMode {
+ Title(0),
+ LaunchCount(1),
+ InstallTime(2);
+
+ private final int mValue;
+ private SortMode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SortMode getModeForValue(int value) {
+ switch (value) {
+ case 1:
+ return LaunchCount;
+ case 2:
+ return InstallTime;
+ default :
+ return Title;
+ }
+ }
+ }
+ private SortMode mSortMode = SortMode.Title;
+
// Refs
private Launcher mLauncher;
private DragController mDragController;
@@ -181,6 +213,26 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private int mNumWidgetPages;
private Rect mAllAppsPadding = new Rect();
+ // Animation states
+ enum State { NORMAL, OVERVIEW};
+ private State mState = State.NORMAL;
+ private boolean mIsSwitchingState = false;
+
+ // Animation values
+ private float mNewScale;
+ private float[] mOldBackgroundAlphas;
+ private float[] mOldAlphas;
+ private float[] mNewBackgroundAlphas;
+ private float[] mNewAlphas;
+
+ // Relating to the scroll and overscroll effects
+ private static float TRANSITION_MAX_ROTATION = 22;
+ private static final float ALPHA_CUTOFF_THRESHOLD = 0.01f;
+ private boolean mOverscrollTransformsSet;
+ private float mLastOverscrollPivotX;
+
+ public static boolean DISABLE_ALL_APPS = false;
+
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
private static final int sPageSleepDelay = 200;
@@ -231,6 +283,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// (top + bottom)
mFadeInAdjacentScreens = false;
+ TransitionEffect.setFromString(this, SettingsProvider.getString(context,
+ SettingsProvider.SETTINGS_UI_DRAWER_SCROLLING_TRANSITION_EFFECT,
+ R.string.preferences_interface_drawer_scrolling_transition_effect));
+
// Unless otherwise specified this view is important for accessibility.
if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
@@ -245,6 +301,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Context context = getContext();
Resources r = context.getResources();
+ mCameraDistance = (int) CAMERA_DISTANCE;//r.getInteger(R.integer.config_cameraDistance);
setDragSlopeThreshold(r.getInteger(R.integer.config_appsCustomizeDragSlopeThreshold)/100f);
}
@@ -1321,8 +1378,54 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// In apps customize, we have a scrolling effect which emulates pulling cards off of a stack.
@Override
protected void screenScrolled(int screenCenter) {
+ final boolean isRtl = isLayoutRtl();
+
+ mUseTransitionEffect = !mIsSwitchingState;
+
super.screenScrolled(screenCenter);
enableHwLayersOnVisiblePages();
+
+ boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
+
+ if (isInOverscroll) {
+ int index = 0;
+ float pivotX = 0f;
+ final float leftBiasedPivot = 0.35f;
+ final float rightBiasedPivot = 0.65f;
+ final int lowerIndex = 0;
+ final int upperIndex = getChildCount() - 1;
+
+ final boolean isLeftPage = mOverScrollX < 0;
+ index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex;
+ pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot;
+
+ View v = getPageAt(index);
+
+ if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) {
+ mOverscrollTransformsSet = true;
+ mLastOverscrollPivotX = pivotX;
+ v.setCameraDistance(mDensity * mCameraDistance);
+ v.setPivotX(v.getMeasuredWidth() * pivotX);
+ }
+
+ float scrollProgress = getScrollProgress(screenCenter, v, index);
+ float rotation = -TRANSITION_MAX_ROTATION * scrollProgress;
+ v.setRotationY(rotation);
+ } else {
+ if (mOverscrollTransformsSet) {
+ mOverscrollTransformsSet = false;
+ View v0 = getPageAt(0);
+ View v1 = getPageAt(getChildCount() - 1);
+ v0.setRotationY(0);
+ v1.setRotationY(0);
+ v0.setCameraDistance(mDensity * mCameraDistance);
+ v1.setCameraDistance(mDensity * mCameraDistance);
+ v0.setPivotX(v0.getMeasuredWidth() / 2);
+ v1.setPivotX(v1.getMeasuredWidth() / 2);
+ v0.setPivotY(v0.getMeasuredHeight() / 2);
+ v1.setPivotY(v1.getMeasuredHeight() / 2);
+ }
+ }
}
private void enableHwLayersOnVisiblePages() {
@@ -1352,17 +1455,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
layout.setLayerType(LAYER_TYPE_NONE, null);
}
}
-
- for (int i = 0; i < screenCount; i++) {
- final View layout = (View) getPageAt(i);
-
- if (leftScreen <= i && i <= rightScreen &&
- (i == forceDrawScreen || shouldDrawChild(layout))) {
- if (layout.getLayerType() != LAYER_TYPE_HARDWARE) {
- layout.setLayerType(LAYER_TYPE_HARDWARE, null);
- }
- }
- }
}
protected void overScroll(float amount) {
@@ -1561,4 +1653,38 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
return String.format(getContext().getString(stringId), page + 1, count);
}
+
+ public Comparator<AppInfo> getComparatorForSortMode() {
+ switch (mSortMode) {
+ case Title:
+ return LauncherModel.getAppNameComparator();
+ case LaunchCount:
+ return LauncherModel.getAppLaunchCountComparator(mLauncher.getStats());
+ case InstallTime:
+ return LauncherModel.APP_INSTALL_TIME_COMPARATOR;
+ }
+ return LauncherModel.getAppNameComparator();
+ }
+
+ public void setSortMode(SortMode sortMode) {
+ if (mSortMode == sortMode) return;
+
+ mSortMode = sortMode;
+
+ sortApps();
+ }
+
+ public void sortApps() {
+ Collections.sort(new ArrayList<AppInfo>(), getComparatorForSortMode());
+
+ if (mContentType == ContentType.Applications) {
+ for (int i = 0; i < getChildCount(); i++) {
+ syncAppsPageItems(i, true);
+ }
+ }
+ }
+
+ public SortMode getSortMode() {
+ return mSortMode;
+ }
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index daf5556..c5f51d8 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -870,17 +870,5 @@ public class DeviceProfile {
}
}
-
- // Layout the Overview Mode
- ViewGroup overviewMode = launcher.getOverviewPanel();
- if (overviewMode != null) {
- Rect r = getOverviewModeButtonBarRect();
- lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams();
- lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
- lp.width = Math.min(availableWidthPx,
- calculateOverviewModeWidth(getVisibleChildCount(overviewMode)));
- lp.height = r.height();
- overviewMode.setLayoutParams(lp);
- }
}
}
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index e751b07..4b40f4b 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -36,6 +36,7 @@ import android.view.accessibility.AccessibilityManager;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
@@ -126,11 +127,17 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
final int n = getChildCount();
for (int i = 0; i < n; i++) {
final View child = getChildAt(i);
- setInsets(child, insets, mInsets);
- final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
if (child.getId() == R.id.overview_panel) {
+ LinearLayout layout = (LinearLayout)
+ child.findViewById(R.id.settings_container);
+ FrameLayout.LayoutParams lp =
+ (FrameLayout.LayoutParams) layout.getLayoutParams();
+ lp.bottomMargin += insets.bottom - mInsets.bottom;
+ layout.setLayoutParams(lp);
continue;
}
+ setInsets(child, insets, mInsets);
+ final FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) child.getLayoutParams();
if (child instanceof Insettable) {
((Insettable)child).setInsets(insets);
} else {
@@ -895,13 +902,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
invalidate();
}
- /**
- * Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api.
- */
- private boolean isLayoutRtl() {
- return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
- }
-
@Override
protected void dispatchDraw(Canvas canvas) {
// Draw the background gradient below children.
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d04c423..dcc87b8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1,4 +1,3 @@
-
/*
* Copyright (C) 2008 The Android Open Source Project
*
@@ -32,6 +31,7 @@ import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
+import android.app.Dialog;
import android.app.SearchManager;
import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager;
@@ -42,6 +42,7 @@ import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -82,6 +83,7 @@ import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
+import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
@@ -100,6 +102,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
@@ -314,6 +317,8 @@ public class Launcher extends Activity
private Bundle mSavedInstanceState;
+ private Dialog mTransitionEffectDialog;
+
private LauncherModel mModel;
private IconCache mIconCache;
private boolean mUserPresent = true;
@@ -371,6 +376,9 @@ public class Launcher extends Activity
private BubbleTextView mWaitingForResume;
+ // Preferences
+ private boolean mHideIconLabels;
+
private Runnable mBuildLayersRunnable = new Runnable() {
public void run() {
if (mWorkspace != null) {
@@ -397,10 +405,6 @@ public class Launcher extends Activity
FocusIndicatorView mFocusHandler;
- static boolean isPropertyEnabled(String propertyName) {
- return Log.isLoggable(propertyName, Log.VERBOSE);
- }
-
public Animator.AnimatorListener mAnimatorListener = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator arg0) {}
@@ -414,7 +418,7 @@ public class Launcher extends Activity
public void onAnimationCancel(Animator arg0) {}
};
- private static boolean isPropertyEnabled(String propertyName) {
+ public static boolean isPropertyEnabled(String propertyName) {
return Log.isLoggable(propertyName, Log.VERBOSE);
}
@@ -544,11 +548,6 @@ public class Launcher extends Activity
mIconCache.flushInvalidIcons(mGrid);
}
- protected void onUserLeaveHint() {
- super.onUserLeaveHint();
- sPausedFromUserAction = true;
- }
-
/** To be overriden by subclasses to hint to Launcher that we have custom content */
protected boolean hasCustomContentToLeft() {
return false;
@@ -1486,7 +1485,7 @@ public class Launcher extends Activity
mHotseat.setOnLongClickListener(this);
}
- mOverviewPanel = findViewById(R.id.overview_panel);
+ mOverviewPanel = (ViewGroup) findViewById(R.id.overview_panel);
mOverviewSettingsPanel = new OverviewSettingsPanel(
this, mOverviewPanel);
mOverviewSettingsPanel.initializeAdapter();
@@ -2027,6 +2026,10 @@ public class Launcher extends Activity
// also will cancel mWaitingForResult.
closeSystemDialogs();
+ if (mTransitionEffectDialog != null) {
+ mTransitionEffectDialog.cancel();
+ }
+
final boolean alreadyOnHome = mHasFocus && ((intent.getFlags() &
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
@@ -3247,18 +3250,10 @@ public class Launcher extends Activity
return mHotseat != null && layout != null &&
(layout instanceof CellLayout) && (layout == mHotseat.getLayout());
}
- Hotseat getHotseat() {
- return mHotseat;
- }
- View getOverviewPanel() {
- return mOverviewPanel;
- }
+
View getDarkPanel() {
return mDarkPanel;
}
- SearchDropTargetBar getSearchBar() {
- return mSearchDropTargetBar;
- }
/**
* Returns the CellLayout of the specified container at the specified screen.
@@ -3275,10 +3270,6 @@ public class Launcher extends Activity
}
}
- protected Workspace getWorkspace() {
- return mWorkspace;
- }
-
protected AppsCustomizePagedView getAppsCustomizeContent() {
return mAppsCustomizeContent;
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index c64506d..39035cd 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -3663,6 +3663,22 @@ public class LauncherModel extends BroadcastReceiver
}
};
}
+ public static final Comparator<AppInfo> getAppLaunchCountComparator(final Stats stats) {
+ final Collator collator = Collator.getInstance();
+ return new Comparator<AppInfo>() {
+ public final int compare(AppInfo a, AppInfo b) {
+ int result = stats.launchCount(b.intent) - stats.launchCount(a.intent);
+ if (result == 0) {
+ result = collator.compare(a.title.toString().trim(),
+ b.title.toString().trim());
+ if (result == 0) {
+ result = a.componentName.compareTo(b.componentName);
+ }
+ }
+ return result;
+ }
+ };
+ }
public static final Comparator<AppInfo> APP_INSTALL_TIME_COMPARATOR
= new Comparator<AppInfo>() {
public final int compare(AppInfo a, AppInfo b) {
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index 2c1a7da..76faff0 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -88,7 +88,7 @@ public class OverviewSettingsPanel {
wallpaperButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
- mLauncher.startWallpaper();
+ mLauncher.onClickWallpaperPicker(arg0);
}
});
wallpaperButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 248f985..4388cd9 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -50,7 +50,10 @@ import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
+import android.view.animation.AccelerateDecelerateInterpolator;
+import android.view.animation.AccelerateInterpolator;
+import java.lang.reflect.Array;
import java.util.ArrayList;
interface Page {
@@ -262,6 +265,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected final Rect mInsets = new Rect();
+ protected int mFirstChildLeft;
+
+ protected Runnable mDelayedSnapToPageRunnable;
+
+ // Relating to the scroll and overscroll effects
+ protected static float CAMERA_DISTANCE = 6500;
+ protected static final float TRANSITION_SCALE_FACTOR = 0.74f;
+ protected static final float TRANSITION_SCREEN_ROTATION = 12.5f;
+ protected int mCameraDistance;
+ private boolean mScrollTransformsSet;
+ protected TransitionEffect mTransitionEffect;
+ protected boolean mUseTransitionEffect = true;
+
public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex);
}
@@ -625,6 +641,10 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// a method that subclasses can override to add behavior
protected void onPageEndMoving() {
+ if (mDelayedSnapToPageRunnable != null) {
+ mDelayedSnapToPageRunnable.run();
+ mDelayedSnapToPageRunnable = null;
+ }
}
/**
@@ -1026,25 +1046,77 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
}
+ public void setFadeInAdjacentScreens(boolean fade) {
+ mFadeInAdjacentScreens = fade;
+ }
+
public void setPageSpacing(int pageSpacing) {
mPageSpacing = pageSpacing;
requestLayout();
}
+ public TransitionEffect getTransitionEffect() {
+ return mTransitionEffect;
+ }
+
+ public void setTransitionEffect(TransitionEffect effect) {
+ mTransitionEffect = effect;
+
+ // Reset scroll transforms
+ if (mScrollTransformsSet) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View v = getPageAt(i);
+ if (v != null) {
+ v.setPivotX(v.getMeasuredWidth() * 0.5f);
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotation(0);
+ v.setRotationX(0);
+ v.setRotationY(0);
+ v.setScaleX(1f);
+ v.setScaleY(1f);
+ v.setTranslationX(0f);
+ v.setTranslationY(0f);
+ v.setVisibility(VISIBLE);
+ setChildAlpha(v, 1f);
+ }
+ }
+
+ mScrollTransformsSet = false;
+ }
+ }
+
protected void screenScrolled(int screenCenter) {
boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
-
- if (mFadeInAdjacentScreens && !isInOverscroll) {
+ // Apply transition effect and adjacent screen fade if enabled
+ if (mFadeInAdjacentScreens || (mTransitionEffect != null && mUseTransitionEffect) || mScrollTransformsSet) {
for (int i = 0; i < getChildCount(); i++) {
- View child = getChildAt(i);
- if (child != null) {
- float scrollProgress = getScrollProgress(screenCenter, child, i);
- float alpha = 1 - Math.abs(scrollProgress);
- child.setAlpha(alpha);
+ View v = getPageAt(i);
+ if (v != null) {
+ float scrollProgress = getScrollProgress(screenCenter, v, i);
+ // Fade first to allow transition effects to override alpha
+ if (mFadeInAdjacentScreens && !isInOverscroll) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ setChildAlpha(v, alpha);
+ }
+ if (mTransitionEffect != null && mUseTransitionEffect && !isInOverscroll) {
+ mTransitionEffect.screenScrolled(v, i, scrollProgress);
+ } else if (mScrollTransformsSet) {
+ v.setPivotX(v.getMeasuredWidth() * 0.5f);
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotation(0);
+ v.setRotationX(0);
+ v.setRotationY(0);
+ v.setScaleX(1f);
+ v.setScaleY(1f);
+ v.setTranslationX(0f);
+ v.setTranslationY(0f);
+ v.setVisibility(VISIBLE);
+ setChildAlpha(v, 1f);
+ }
}
}
- invalidate();
}
+ mScrollTransformsSet = mTransitionEffect != null && mUseTransitionEffect && !isInOverscroll;
}
protected void enablePagedViewAnimations() {
@@ -1055,6 +1127,42 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mAllowPagedViewAnimations = false;
}
+ /*
+ * This interpolator emulates the rate at which the perceived scale of an object changes
+ * as its distance from a camera increases. When this interpolator is applied to a scale
+ * animation on a view, it evokes the sense that the object is shrinking due to moving away
+ * from the camera.
+ */
+ static class ZInterpolator implements TimeInterpolator {
+ private float focalLength;
+
+ public ZInterpolator(float foc) {
+ focalLength = foc;
+ }
+
+ public float getInterpolation(float input) {
+ return (1.0f - focalLength / (focalLength + input)) /
+ (1.0f - focalLength / (focalLength + 1.0f));
+ }
+ }
+
+ /*
+ * The exact reverse of ZInterpolator.
+ */
+ static class InverseZInterpolator implements TimeInterpolator {
+ private ZInterpolator zInterpolator;
+ public InverseZInterpolator(float foc) {
+ zInterpolator = new ZInterpolator(foc);
+ }
+ public float getInterpolation(float input) {
+ return 1 - zInterpolator.getInterpolation(1 - input);
+ }
+ }
+
+ protected void setChildAlpha(View child, float alpha) {
+ child.setAlpha(alpha);
+ }
+
@Override
public void onChildViewAdded(View parent, View child) {
// Update the page indicator, we don't update the page indicator as we
@@ -1663,10 +1771,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
setEnableFreeScroll(false);
}
- protected void disableFreeScroll(int snapPage) {
- setEnableFreeScroll(false, snapPage);
- }
-
void updateFreescrollBounds() {
getFreeScrollPageRange(mTempVisiblePagesRange);
if (isLayoutRtl()) {
@@ -2212,6 +2316,14 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
snapToPage(whichPage, delta, duration);
}
+ protected void snapToPage(int whichPage, Runnable r) {
+ if (mDelayedSnapToPageRunnable != null) {
+ mDelayedSnapToPageRunnable.run();
+ }
+ mDelayedSnapToPageRunnable = r;
+ snapToPage(whichPage, SLOW_PAGE_SNAP_ANIMATION_DURATION);
+ }
+
protected void snapToPage(int whichPage) {
snapToPage(whichPage, getPageSnapDuration());
}
@@ -2888,4 +3000,294 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
public boolean onHoverEvent(android.view.MotionEvent event) {
return true;
}
+
+ protected static abstract class TransitionEffect {
+ public static final String TRANSITION_EFFECT_NONE = "none";
+ public static final String TRANSITION_EFFECT_ZOOM_IN = "zoom-in";
+ public static final String TRANSITION_EFFECT_ZOOM_OUT = "zoom-out";
+ public static final String TRANSITION_EFFECT_ROTATE_UP = "rotate-up";
+ public static final String TRANSITION_EFFECT_ROTATE_DOWN = "rotate-down";
+ public static final String TRANSITION_EFFECT_CUBE_IN = "cube-in";
+ public static final String TRANSITION_EFFECT_CUBE_OUT = "cube-out";
+ public static final String TRANSITION_EFFECT_STACK = "stack";
+ public static final String TRANSITION_EFFECT_ACCORDION = "accordion";
+ public static final String TRANSITION_EFFECT_FLIP = "flip";
+ public static final String TRANSITION_EFFECT_CYLINDER_IN = "cylinder-in";
+ public static final String TRANSITION_EFFECT_CYLINDER_OUT = "cylinder-out";
+ public static final String TRANSITION_EFFECT_CAROUSEL = "carousel";
+ public static final String TRANSITION_EFFECT_OVERVIEW = "overview";
+
+ protected final PagedView mPagedView;
+ private final String mName;
+
+ public TransitionEffect(PagedView pagedView, String name) {
+ mPagedView = pagedView;
+ mName = name;
+ }
+
+ public abstract void screenScrolled(View v, int i, float scrollProgress);
+
+ public final String getName() {
+ return mName;
+ }
+
+ public static void setFromString(PagedView pagedView, String effect) {
+ if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_NONE)) {
+ pagedView.setTransitionEffect(null);
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_ZOOM_IN)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Zoom(pagedView, true));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_ZOOM_OUT)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Zoom(pagedView, false));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_CUBE_IN)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Cube(pagedView, true));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_CUBE_OUT)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Cube(pagedView, false));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_ROTATE_UP)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Rotate(pagedView, true));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_ROTATE_DOWN)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Rotate(pagedView, false));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_STACK)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Stack(pagedView));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_ACCORDION)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Accordion(pagedView));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_FLIP)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Flip(pagedView));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_CYLINDER_IN)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Cylinder(pagedView, true));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_CYLINDER_OUT)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Cylinder(pagedView, false));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_CAROUSEL)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Carousel(pagedView));
+ } else if (effect.equals(PagedView.TransitionEffect.TRANSITION_EFFECT_OVERVIEW)) {
+ pagedView.setTransitionEffect(new PagedView.TransitionEffect.Overview(pagedView));
+ }
+ }
+
+ public static class Zoom extends TransitionEffect {
+ private boolean mIn;
+
+ public Zoom(PagedView pagedView, boolean in) {
+ super(pagedView, in ? TRANSITION_EFFECT_ZOOM_IN : TRANSITION_EFFECT_ZOOM_OUT);
+ mIn = in;
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float scale = 1.0f + (mIn ? -0.2f : 0.1f) * Math.abs(scrollProgress);
+
+ // Extra translation to account for the increase in size
+ if (!mIn) {
+ float translationX = v.getMeasuredWidth() * 0.1f * -scrollProgress;
+ v.setTranslationX(translationX);
+ }
+
+ v.setScaleX(scale);
+ v.setScaleY(scale);
+ }
+ }
+
+ public static class Rotate extends TransitionEffect {
+ private boolean mUp;
+
+ public Rotate(PagedView pagedView, boolean up) {
+ super(pagedView, up ? TRANSITION_EFFECT_ROTATE_UP : TRANSITION_EFFECT_ROTATE_DOWN);
+ mUp = up;
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float rotation =
+ (mUp ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress;
+
+ float translationX = v.getMeasuredWidth() * scrollProgress;
+
+ float rotatePoint =
+ (v.getMeasuredWidth() * 0.5f) /
+ (float) Math.tan(Math.toRadians((double) (TRANSITION_SCREEN_ROTATION * 0.5f)));
+
+ v.setPivotX(v.getMeasuredWidth() * 0.5f);
+ if (mUp) {
+ v.setPivotY(-rotatePoint);
+ } else {
+ v.setPivotY(v.getMeasuredHeight() + rotatePoint);
+ }
+ v.setRotation(rotation);
+ v.setTranslationX(translationX);
+ }
+ }
+
+ public static class Cube extends TransitionEffect {
+ private boolean mIn;
+
+ public Cube(PagedView pagedView, boolean in) {
+ super(pagedView, in ? TRANSITION_EFFECT_CUBE_IN : TRANSITION_EFFECT_CUBE_OUT);
+ mIn = in;
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float rotation = (mIn ? 90.0f : -90.0f) * scrollProgress;
+
+ if (mIn) {
+ v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
+ }
+
+ v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotationY(rotation);
+ }
+ }
+
+ public static class Stack extends TransitionEffect {
+ private ZInterpolator mZInterpolator = new ZInterpolator(0.5f);
+ private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
+ protected AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
+
+ public Stack(PagedView pagedView) {
+ super(pagedView, TRANSITION_EFFECT_STACK);
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ final boolean isRtl = mPagedView.isLayoutRtl();
+ float interpolatedProgress;
+ float translationX;
+ float maxScrollProgress = Math.max(0, scrollProgress);
+ float minScrollProgress = Math.min(0, scrollProgress);
+
+ if (mPagedView.isLayoutRtl()) {
+ translationX = maxScrollProgress * v.getMeasuredWidth();
+ interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(maxScrollProgress));
+ } else {
+ translationX = minScrollProgress * v.getMeasuredWidth();
+ interpolatedProgress = mZInterpolator.getInterpolation(Math.abs(minScrollProgress));
+ }
+ float scale = (1 - interpolatedProgress) +
+ interpolatedProgress * TRANSITION_SCALE_FACTOR;
+
+ float alpha;
+ if (isRtl && (scrollProgress > 0)) {
+ alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(maxScrollProgress));
+ } else if (!isRtl && (scrollProgress < 0)) {
+ alpha = mAlphaInterpolator.getInterpolation(1 - Math.abs(scrollProgress));
+ } else {
+ // On large screens we need to fade the page as it nears its leftmost position
+ alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
+ }
+
+ v.setTranslationX(translationX);
+ v.setScaleX(scale);
+ v.setScaleY(scale);
+ if (v instanceof CellLayout) {
+ ((CellLayout) v).getShortcutsAndWidgets().setAlpha(alpha);
+ } else {
+ v.setAlpha(alpha);
+ }
+
+ // If the view has 0 alpha, we set it to be invisible so as to prevent
+ // it from accepting touches
+ if (alpha == 0) {
+ v.setVisibility(INVISIBLE);
+ } else if (v.getVisibility() != VISIBLE) {
+ v.setVisibility(VISIBLE);
+ }
+ }
+ }
+
+ public static class Accordion extends TransitionEffect {
+ public Accordion(PagedView pagedView) {
+ super(pagedView, TRANSITION_EFFECT_ACCORDION);
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float scale = 1.0f - Math.abs(scrollProgress);
+
+ v.setScaleX(scale);
+ v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
+ v.setPivotY(v.getMeasuredHeight() / 2f);
+ }
+ }
+
+ public static class Flip extends TransitionEffect {
+ public Flip(PagedView pagedView) {
+ super(pagedView, TRANSITION_EFFECT_FLIP);
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float rotation = -180.0f * Math.max(-1f, Math.min(1f, scrollProgress));
+
+ v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
+ v.setPivotX(v.getMeasuredWidth() * 0.5f);
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotationY(rotation);
+
+ if (scrollProgress >= -0.5f && scrollProgress <= 0.5f) {
+ v.setTranslationX(v.getMeasuredWidth() * scrollProgress);
+ if (v.getVisibility() != VISIBLE) {
+ v.setVisibility(VISIBLE);
+ }
+ } else {
+ v.setTranslationX(0f);
+ v.setVisibility(INVISIBLE);
+ }
+ }
+ }
+
+ public static class Cylinder extends TransitionEffect {
+ private boolean mIn;
+
+ public Cylinder(PagedView pagedView, boolean in) {
+ super(pagedView, in ? TRANSITION_EFFECT_CYLINDER_IN : TRANSITION_EFFECT_CYLINDER_OUT);
+ mIn = in;
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float rotation = (mIn ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress;
+
+ v.setPivotX((scrollProgress + 1) * v.getMeasuredWidth() * 0.5f);
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setRotationY(rotation);
+ }
+ }
+
+ public static class Carousel extends TransitionEffect {
+ public Carousel(PagedView pagedView) {
+ super(pagedView, TRANSITION_EFFECT_CAROUSEL);
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float rotation = 90.0f * scrollProgress;
+
+ v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
+ v.setTranslationX(v.getMeasuredWidth() * scrollProgress);
+ v.setPivotX(!mPagedView.isLayoutRtl() ? 0f : v.getMeasuredWidth());
+ v.setPivotY(v.getMeasuredHeight() / 2);
+ v.setRotationY(-rotation);
+ }
+ }
+
+ public static class Overview extends TransitionEffect {
+ private AccelerateDecelerateInterpolator mScaleInterpolator = new AccelerateDecelerateInterpolator();
+
+ public Overview(PagedView pagedView) {
+ super(pagedView, TRANSITION_EFFECT_OVERVIEW);
+ }
+
+ @Override
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ float scale = 1.0f - 0.1f *
+ mScaleInterpolator.getInterpolation(Math.min(0.3f, Math.abs(scrollProgress)) / 0.3f);
+
+ v.setPivotX(scrollProgress < 0 ? 0 : v.getMeasuredWidth());
+ v.setPivotY(v.getMeasuredHeight() * 0.5f);
+ v.setScaleX(scale);
+ v.setScaleY(scale);
+ mPagedView.setChildAlpha(v, scale);
+ }
+ }
+ }
}
diff --git a/src/com/android/launcher3/Stats.java b/src/com/android/launcher3/Stats.java
index f3977e4..6ba1c19 100644
--- a/src/com/android/launcher3/Stats.java
+++ b/src/com/android/launcher3/Stats.java
@@ -32,6 +32,7 @@ public class Stats {
private static final boolean LOCAL_LAUNCH_LOG = true;
public static final String ACTION_LAUNCH = "com.android.launcher3.action.LAUNCH";
+ public static final String PERM_LAUNCH = "com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS";
public static final String EXTRA_INTENT = "intent";
public static final String EXTRA_CONTAINER = "container";
public static final String EXTRA_SCREEN = "screen";
@@ -52,8 +53,6 @@ public class Stats {
private final Launcher mLauncher;
- private final String mLaunchBroadcastPermission;
-
DataOutputStream mLog;
ArrayList<String> mIntents;
@@ -62,9 +61,6 @@ public class Stats {
public Stats(Launcher launcher) {
mLauncher = launcher;
- mLaunchBroadcastPermission =
- launcher.getResources().getString(R.string.receive_launch_broadcasts_permission);
-
loadStats();
if (LOCAL_LAUNCH_LOG) {
@@ -91,7 +87,7 @@ public class Stats {
}
},
new IntentFilter(ACTION_LAUNCH),
- mLaunchBroadcastPermission,
+ PERM_LAUNCH,
null
);
}
@@ -107,6 +103,20 @@ public class Stats {
}
}
+ public int launchCount(Intent intent) {
+ intent = new Intent(intent);
+ intent.setSourceBounds(null);
+
+ final String flat = intent.toUri(0);
+
+ int pos = mIntents.indexOf(flat);
+ if (pos < 0) {
+ return 0;
+ } else {
+ return mHistogram.get(pos);
+ }
+ }
+
public void recordLaunch(Intent intent) {
recordLaunch(intent, null);
}
@@ -124,7 +134,7 @@ public class Stats {
.putExtra(EXTRA_CELLX, shortcut.cellX)
.putExtra(EXTRA_CELLY, shortcut.cellY);
}
- mLauncher.sendBroadcast(broadcastIntent, mLaunchBroadcastPermission);
+ mLauncher.sendBroadcast(broadcastIntent, PERM_LAUNCH);
incrementLaunch(flat);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index a3000d7..0820457 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -60,6 +60,9 @@ import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewPropertyAnimator;
+import android.view.animation.AccelerateDecelerateInterpolator;
+
import android.view.accessibility.AccessibilityManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@@ -132,6 +135,7 @@ public class Workspace extends SmoothPagedView
private int mOriginalDefaultPage;
private int mDefaultPage;
+ private long mDefaultScreenId;
private ShortcutAndWidgetContainer mDragSourceInternal;
private static boolean sAccessibilityEnabled;
@@ -223,12 +227,13 @@ public class Workspace extends SmoothPagedView
private boolean mWorkspaceFadeInAdjacentScreens;
WallpaperOffsetInterpolator mWallpaperOffset;
+ private boolean mScrollWallpaper;
private boolean mWallpaperIsLiveWallpaper;
private int mNumPagesForWallpaperParallax;
private float mLastSetWallpaperOffsetSteps = 0;
private Runnable mDelayedResizeRunnable;
- private Runnable mDelayedSnapToPageRunnable;
+
private Point mDisplaySize = new Point();
private int mCameraDistance;
@@ -299,6 +304,9 @@ public class Workspace extends SmoothPagedView
}
};
+ private boolean mShowSearchBar;
+ private boolean mShowOutlines;
+ private boolean mHideIconLabels;
/**
* Used to inflate the Workspace from XML.
*
@@ -326,6 +334,18 @@ public class Workspace extends SmoothPagedView
// With workspace, data is available straight from the get-go
setDataIsReady();
+ mShowSearchBar = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
+ R.bool.preferences_interface_homescreen_search_default);
+ mShowOutlines = SettingsProvider.getBoolean(context,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_PAGE_OUTLINES,
+ R.bool.preferences_interface_homescreen_scrolling_page_outlines_default);
+ mScrollWallpaper = SettingsProvider.getBoolean(context,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
+ R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
+ TransitionEffect.setFromString(this, SettingsProvider.getString(context,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_TRANSITION_EFFECT,
+ R.string.preferences_interface_homescreen_scrolling_transition_effect));
+
mLauncher = (Launcher) context;
final Resources res = getResources();
mWorkspaceFadeInAdjacentScreens = LauncherAppState.getInstance().getDynamicGrid().
@@ -342,6 +362,8 @@ public class Workspace extends SmoothPagedView
mOverviewModeShrinkFactor = grid.getOverviewModeScale();
mCameraDistance = res.getInteger(R.integer.config_cameraDistance);
mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1);
+ mDefaultScreenId = SettingsProvider.getLongCustomDefault(context,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID, -1);
a.recycle();
setOnHierarchyChangeListener(this);
@@ -490,6 +512,11 @@ public class Workspace extends SmoothPagedView
}
@Override
+ public void setChildAlpha(View child, float alpha) {
+ ((CellLayout) child).setShortcutAndWidgetAlpha(alpha);
+ }
+
+ @Override
public void onChildViewAdded(View parent, View child) {
if (!(child instanceof CellLayout)) {
throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
@@ -583,6 +610,13 @@ public class Workspace extends SmoothPagedView
mWorkspaceScreens.put(screenId, newScreen);
mScreenOrder.add(insertIndex, screenId);
addView(newScreen, insertIndex);
+
+ if (mDefaultScreenId == screenId) {
+ int defaultPage = getPageIndexForScreenId(screenId);
+ moveToScreen(defaultPage, false);
+ Launcher.setScreen(defaultPage);
+ }
+
return screenId;
}
@@ -1246,10 +1280,6 @@ public class Workspace extends SmoothPagedView
mDelayedResizeRunnable = null;
}
- if (mDelayedSnapToPageRunnable != null) {
- mDelayedSnapToPageRunnable.run();
- mDelayedSnapToPageRunnable = null;
- }
if (mStripScreensOnPageStopMoving) {
stripEmptyScreens();
mStripScreensOnPageStopMoving = false;
@@ -1683,9 +1713,27 @@ public class Workspace extends SmoothPagedView
return listener;
}
+ public void setShowOutlines(boolean show) {
+ mShowOutlines = show;
+ }
+
+ @Override
+ public void setFadeInAdjacentScreens(boolean fade) {
+ mWorkspaceFadeInAdjacentScreens = fade;
+ }
+
@Override
protected void screenScrolled(int screenCenter) {
final boolean isRtl = isLayoutRtl();
+
+ boolean isOnLastPageBeforeCustomContent = false;
+ if (hasCustomContent()) {
+ int customContentWidth = mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).getMeasuredWidth();
+ isOnLastPageBeforeCustomContent = (mOverScrollX < customContentWidth && (!hasCustomContent() || isLayoutRtl())) ||
+ (mOverScrollX > mMaxScrollX - customContentWidth && (!hasCustomContent() || !isLayoutRtl()));
+ }
+ mUseTransitionEffect = !isOnLastPageBeforeCustomContent && mState == State.NORMAL && !mIsSwitchingState;
+
super.screenScrolled(screenCenter);
updatePageAlphaValues(screenCenter);
@@ -1922,38 +1970,6 @@ public class Workspace extends SmoothPagedView
}
/*
- * This interpolator emulates the rate at which the perceived scale of an object changes
- * as its distance from a camera increases. When this interpolator is applied to a scale
- * animation on a view, it evokes the sense that the object is shrinking due to moving away
- * from the camera.
- */
- static class ZInterpolator implements TimeInterpolator {
- private float focalLength;
-
- public ZInterpolator(float foc) {
- focalLength = foc;
- }
-
- public float getInterpolation(float input) {
- return (1.0f - focalLength / (focalLength + input)) /
- (1.0f - focalLength / (focalLength + 1.0f));
- }
- }
-
- /*
- * The exact reverse of ZInterpolator.
- */
- static class InverseZInterpolator implements TimeInterpolator {
- private ZInterpolator zInterpolator;
- public InverseZInterpolator(float foc) {
- zInterpolator = new ZInterpolator(foc);
- }
- public float getInterpolation(float input) {
- return 1 - zInterpolator.getInterpolation(1 - input);
- }
- }
-
- /*
* ZInterpolator compounded with an ease-out.
*/
static class ZoomOutInterpolator implements TimeInterpolator {
@@ -2063,6 +2079,15 @@ public class Workspace extends SmoothPagedView
getOverviewModePages(range);
}
+ private void updateDefaultScreenButton() {
+ View overviewPanel = mLauncher.getOverviewPanel();
+ if (overviewPanel != null) {
+ View defaultPageButton = overviewPanel.findViewById(R.id.default_screen_button);
+ defaultPageButton.setActivated(
+ getScreenIdForPageIndex(getPageNearestToCenterOfScreen()) == mDefaultScreenId);
+ }
+ }
+
public void onClickDefaultScreenButton() {
if (!isInOverviewMode()) return;
@@ -2249,7 +2274,7 @@ public class Workspace extends SmoothPagedView
final boolean stateIsOverview = (state == State.OVERVIEW);
float finalBackgroundAlpha = (stateIsSpringLoaded || stateIsOverview) ? 1.0f : 0f;
float finalHotseatAndPageIndicatorAlpha = (stateIsNormal || stateIsSpringLoaded) ? 1f : 0f;
- float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
+ final float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f;
float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ?
getOverviewModeTranslationY() : 0;
@@ -2257,8 +2282,8 @@ public class Workspace extends SmoothPagedView
boolean workspaceToAllApps = (oldStateIsNormal && stateIsNormalHidden);
boolean overviewToAllApps = (oldStateIsOverview && stateIsOverviewHidden);
boolean allAppsToWorkspace = (stateIsNormalHidden && stateIsNormal);
- boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview);
- boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal);
+ final boolean workspaceToOverview = (oldStateIsNormal && stateIsOverview);
+ final boolean overviewToWorkspace = (oldStateIsOverview && stateIsNormal);
mNewScale = 1.0f;
@@ -2303,6 +2328,20 @@ public class Workspace extends SmoothPagedView
finalAlpha = 1f;
}
+ if (stateIsOverview) {
+ cl.setVisibility(VISIBLE);
+ cl.setTranslationX(0f);
+ cl.setTranslationY(0f);
+ cl.setPivotX(cl.getMeasuredWidth() * 0.5f);
+ cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
+ cl.setRotation(0f);
+ cl.setRotationY(0f);
+ cl.setRotationX(0f);
+ cl.setScaleX(1f);
+ cl.setScaleY(1f);
+ cl.setShortcutAndWidgetAlpha(1f);
+ }
+
// If we are animating to/from the small state, then hide the side pages and fade the
// current page in
if (!mIsSwitchingState) {
@@ -2423,10 +2462,51 @@ public class Workspace extends SmoothPagedView
hotseatAlpha.setDuration(duration);
searchBarAlpha.setDuration(duration);
- overviewPanel.setAlpha(finalOverviewPanelAlpha);
- AlphaUpdateListener.updateVisibility(overviewPanel);
- Animation animation = AnimationUtils.loadAnimation(mLauncher, R.anim.drop_down);
- overviewPanel.startAnimation(animation);
+ float mOverviewPanelSlideScale = 1.0f;
+
+ if (overviewToWorkspace || stateIsNormal) {
+ ((SlidingUpPanelLayout) overviewPanel).collapsePane();
+ overviewPanel.setScaleY(1.0f);
+ mOverviewPanelSlideScale = 3.0f;
+ } else if (workspaceToOverview || stateIsOverview) {
+ overviewPanel.setScaleY(3.0f);
+ mOverviewPanelSlideScale = 1.0f;
+ }
+
+ final ViewPropertyAnimator overviewPanelScale = overviewPanel.animate();
+ overviewPanelScale.scaleY(mOverviewPanelSlideScale)
+ .alpha(finalOverviewPanelAlpha)
+ .setInterpolator(new AccelerateDecelerateInterpolator());
+ overviewPanelScale.setListener(new AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ if (workspaceToOverview || stateIsOverview) {
+ overviewPanel.setAlpha(finalOverviewPanelAlpha);
+ AlphaUpdateListener.updateVisibility(overviewPanel);
+ }
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (overviewToWorkspace || stateIsNormal) {
+ overviewPanel.setAlpha(finalOverviewPanelAlpha);
+ AlphaUpdateListener.updateVisibility(overviewPanel);
+ }
+ overviewPanelScale.setListener(null);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ overviewPanel.setAlpha(finalOverviewPanelAlpha);
+ AlphaUpdateListener.updateVisibility(overviewPanel);
+ overviewPanelScale.setListener(null);
+ }
+ @Override
+ public void onAnimationRepeat(Animator animation) {}
+ });
+
+ // Animation animation = AnimationUtils.loadAnimation(mLauncher, R.anim.drop_down);
+ // overviewPanel.startAnimation(animation);
anim.play(hotseatAlpha);
anim.play(searchBarAlpha);
anim.play(pageIndicatorAlpha);
@@ -5086,7 +5166,7 @@ public class Workspace extends SmoothPagedView
}
void moveToDefaultScreen(boolean animate) {
- moveToScreen(mDefaultPage, animate);
+ moveToScreen(getPageIndexForScreenId(mDefaultScreenId), animate);
}
void moveToCustomContentScreen(boolean animate) {