summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values-land/config.xml2
-rw-r--r--res/values-sw340dp-port/config.xml21
-rw-r--r--res/values-sw600dp/config.xml6
-rw-r--r--res/values/arrays.xml26
-rw-r--r--res/values/config.xml6
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/xml/preferences.xml10
-rw-r--r--src/com/cyanogenmod/trebuchet/PagedView.java5
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java151
-rw-r--r--src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java11
10 files changed, 183 insertions, 59 deletions
diff --git a/res/values-land/config.xml b/res/values-land/config.xml
index fc20456c3..60052f03a 100644
--- a/res/values-land/config.xml
+++ b/res/values-land/config.xml
@@ -18,8 +18,6 @@
<!-- 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>
<!-- Folder max bounds and max number of items.
Note: folder_max_count_x * folder_max_count_y >= folder_max_num_items. -->
diff --git a/res/values-sw340dp-port/config.xml b/res/values-sw340dp-port/config.xml
deleted file mode 100644
index d31ee5969..000000000
--- a/res/values-sw340dp-port/config.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<resources>
-<!-- Workspace -->
- <!-- Whether or not to fade the side pages -->
- <bool name="config_workspaceFadeAdjacentScreens">false</bool>
-</resources>
diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml
index 7a0789839..219dab832 100644
--- a/res/values-sw600dp/config.xml
+++ b/res/values-sw600dp/config.xml
@@ -8,8 +8,10 @@
<!-- Workspace -->
<!-- Whether or not the drop targets drop down as opposed to fade in -->
<bool name="config_useDropTargetDownTransition">true</bool>
- <!-- Whether or not to fade the side pages -->
- <bool name="config_workspaceFadeAdjacentScreens">true</bool>
+ <!-- Which default transition effect to use on the workspace -->
+ <string name="config_workspaceDefaultTransitionEffect">Tablet</string>
+ <!-- Whether to fade the adjacent screens when scrolling -->
+ <bool name="config_workspaceDefualtFadeInAdjacentScreens">true</bool>
<!-- When dragging items on the workspace, how much bigger (in pixels) the dragged view
should be, as compared to the original view. If 0, it will not be scaled at all.
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
new file mode 100644
index 000000000..cf34b7036
--- /dev/null
+++ b/res/values/arrays.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright (C) 2008 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.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="preferences_interface_homescreen_scrolling_transition_effect_entries">
+ <item>Standard</item>
+ <item>Tablet</item>
+ <item>Stack</item>
+ </string-array>
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index d0ff5ed1a..1a92b4716 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -44,8 +44,10 @@
<!-- Workspace -->
<!-- Whether or not the drop targets drop down as opposed to fade in -->
<bool name="config_useDropTargetDownTransition">true</bool>
- <!-- Whether or not to fade the side pages -->
- <bool name="config_workspaceFadeAdjacentScreens">false</bool>
+ <!-- Which default transition effect to use on the workspace -->
+ <string name="config_workspaceDefaultTransitionEffect">Standard</string>
+ <!-- Whether to fade the adjacent screens when scrolling -->
+ <bool name="config_workspaceDefualtFadeInAdjacentScreens">false</bool>
<!-- The transition duration for the background of the drop targets -->
<integer name="config_dropTargetBgTransitionDuration">100</integer>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 19a08435c..35f0f02d8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -292,6 +292,10 @@ s -->
<string name="preferences_interface_homescreen_general_resize_any_widget_title">Resize any widget</string>
<string name="preferences_interface_homescreen_general_resize_any_widget_summary">Allow resizing of widgets that normally aren\'t resizeable</string>
<string name="preferences_interface_homescreen_scrolling_category">Scrolling</string>
+ <string name="preferences_interface_homescreen_scrolling_transition_effect_title">Transition Effect</string>
+ <string name="preferences_interface_homescreen_scrolling_transition_effect_summary">Scrolling effect when scrolling homescreens</string>
+ <string name="preferences_interface_homescreen_scrolling_fade_adjacent_screens_title">Fade Side Pages</string>
+ <string name="preferences_interface_homescreen_scrolling_fade_adjacent_screens_summary">Fade the side pages when scrolling homescreens</string>
<string name="preferences_interface_homescreen_scrolling_scroll_wallpaper_title">Scroll Wallpaper</string>
<string name="preferences_interface_homescreen_scrolling_scroll_wallpaper_summary">Scroll wallpaper when scrolling homescreens</string>
<string name="preferences_interface_homescreen_indicator_category">Indicator</string>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 2e6e78193..c19640682 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -44,6 +44,16 @@
android:summary="@string/preferences_interface_homescreen_general_resize_any_widget_summary" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/preferences_interface_homescreen_scrolling_category">
+ <ListPreference android:key="ui_homescreen_scrolling_transition_effect"
+ android:title="@string/preferences_interface_homescreen_scrolling_transition_effect_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_transition_effect_summary"
+ android:entries="@array/preferences_interface_homescreen_scrolling_transition_effect_entries"
+ android:entryValues="@array/preferences_interface_homescreen_scrolling_transition_effect_entries"
+ android:defaultValue="@string/config_workspaceDefaultTransitionEffect" />
+ <CheckBoxPreference android:key="ui_homescreen_scrolling_fade_adjacent_screens"
+ android:title="@string/preferences_interface_homescreen_scrolling_fade_adjacent_screens_title"
+ android:summary="@string/preferences_interface_homescreen_scrolling_fade_adjacent_screens_summary"
+ android:defaultValue="@bool/config_workspaceDefualtFadeInAdjacentScreens" />
<CheckBoxPreference android:key="ui_homescreen_scrolling_scroll_wallpaper"
android:title="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_title"
android:summary="@string/preferences_interface_homescreen_scrolling_scroll_wallpaper_summary"
diff --git a/src/com/cyanogenmod/trebuchet/PagedView.java b/src/com/cyanogenmod/trebuchet/PagedView.java
index 06063c0ea..9b18ad2f2 100644
--- a/src/com/cyanogenmod/trebuchet/PagedView.java
+++ b/src/com/cyanogenmod/trebuchet/PagedView.java
@@ -155,6 +155,9 @@ public abstract class PagedView extends ViewGroup {
// If true, modify alpha of neighboring pages as user scrolls left/right
protected boolean mFadeInAdjacentScreens = true;
+ // If true, mFadeInAdjacentScreens will be handled manually
+ protected boolean mHandleFadeInAdjacentScreens = false;
+
// It true, use a different slop parameter (pagingTouchSlop = 2 * touchSlop) for deciding
// to switch to a new page
protected boolean mUsePagingTouchSlop = true;
@@ -607,7 +610,7 @@ public abstract class PagedView extends ViewGroup {
if (isScrollingIndicatorEnabled()) {
updateScrollingIndicator();
}
- if (mFadeInAdjacentScreens) {
+ if (mFadeInAdjacentScreens && !mHandleFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child != null) {
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index cd92235df..8564d3f2a 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -63,6 +63,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
@@ -239,6 +240,12 @@ public class Workspace extends PagedView
private float[] mNewRotationYs;
private float mTransitionProgress;
+ public enum TransitionEffect {
+ Standard,
+ Tablet,
+ Stack
+ }
+
// Preferences
private int mNumberHomescreens;
private int mDefaultHomescreen;
@@ -247,6 +254,7 @@ public class Workspace extends PagedView
private boolean mScrollWallpaper;
private boolean mShowScrollingIndicator;
private boolean mFadeScrollingIndicator;
+ private TransitionEffect mTransitionEffect;
/**
* Used to inflate the Workspace from XML.
@@ -272,8 +280,9 @@ public class Workspace extends PagedView
// With workspace, data is available straight from the get-go
setDataIsReady();
- mFadeInAdjacentScreens =
- getResources().getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
+ // We handle our own fading
+ mHandleFadeInAdjacentScreens = true;
+
mWallpaperManager = WallpaperManager.getInstance(context);
int cellCountX = DEFAULT_CELL_COUNT_X;
@@ -328,6 +337,10 @@ public class Workspace extends PagedView
mShowSearchBar = PreferencesProvider.Interface.Homescreen.getShowSearchBar(context);
mResizeAnyWidget = PreferencesProvider.Interface.Homescreen.getResizeAnyWidget(context);
mScrollWallpaper = PreferencesProvider.Interface.Homescreen.Scrolling.getScrollWallpaper(context);
+ mTransitionEffect = PreferencesProvider.Interface.Homescreen.Scrolling.getTransitionEffect(context,
+ res.getString(R.string.config_workspaceDefaultTransitionEffect));
+ mFadeInAdjacentScreens = PreferencesProvider.Interface.Homescreen.Scrolling.getFadeInAdjacentScreens(context,
+ res.getBoolean(R.bool.config_workspaceDefualtFadeInAdjacentScreens));
mShowScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getShowScrollingIndicator(context);
mFadeScrollingIndicator = PreferencesProvider.Interface.Homescreen.Indicator.getFadeScrollingIndicator(context);
@@ -1201,8 +1214,21 @@ public class Workspace extends PagedView
return Math.min(r / threshold, 1.0f);
}
- private void screenScrolledLargeUI(int screenScroll) {
- if (isSwitchingState()) return;
+ private void screenScrolledStandard(int screenScroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getChildAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ if (mFadeInAdjacentScreens && !isSmall()) {
+ float alpha = 1 - Math.abs(scrollProgress);
+ cl.setFastAlpha(alpha);
+ cl.fastInvalidate();
+ }
+ }
+ }
+ }
+
+ private void screenScrolledTablet(int screenScroll) {
boolean isInOverscroll = false;
for (int i = 0; i < getChildCount(); i++) {
CellLayout cl = (CellLayout) getChildAt(i);
@@ -1213,7 +1239,7 @@ public class Workspace extends PagedView
// If the current page (i) is being over scrolled, we use a different
// set of rules for setting the background alpha multiplier.
- if (!isSmall()) {
+ if (!isSmall() && LauncherApplication.isScreenLarge()) {
if ((mOverScrollX < 0 && i == 0) || (mOverScrollX > mMaxScrollX &&
i == getChildCount() -1)) {
isInOverscroll = true;
@@ -1239,15 +1265,64 @@ public class Workspace extends PagedView
cl.fastInvalidate();
}
}
- if (!isSwitchingState() && !isInOverscroll) {
- ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
- ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
+ invalidate();
+ }
+
+ private void screenScrolledStack(int screenScroll) {
+ boolean isInOverscroll = false;
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getChildAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float interpolatedProgress =
+ mZInterpolator.getInterpolation(Math.abs(Math.min(scrollProgress, 0)));
+ float scale = (1 - interpolatedProgress) + interpolatedProgress * 0.76f;
+ float translationX = Math.min(0, scrollProgress) * cl.getMeasuredWidth();
+ float alpha;
+
+ if (!LauncherApplication.isScreenLarge() || scrollProgress < 0) {
+ alpha = scrollProgress < 0 ? mAlphaInterpolator.getInterpolation(
+ 1 - Math.abs(scrollProgress)) : 1.0f;
+ } else {
+ // On large screens we need to fade the page as it nears its leftmost position
+ alpha = mLeftScreenAlphaInterpolator.getInterpolation(1 - scrollProgress);
+ }
+
+ cl.setFastTranslationX(translationX);
+ cl.setFastScaleX(scale);
+ cl.setFastScaleY(scale);
+ cl.setFastAlpha(alpha);
+
+ // If the view has 0 alpha, we set it to be invisible so as to prevent
+ // it from accepting touches
+ if (alpha <= 0) {
+ cl.setVisibility(INVISIBLE);
+ } else if (cl.getVisibility() != VISIBLE) {
+ cl.setVisibility(VISIBLE);
+ }
+ cl.fastInvalidate();
+ }
}
invalidate();
}
- private void screenScrolledStandardUI(int screenScroll) {
- if (mOverScrollX < 0 || mOverScrollX > mMaxScrollX) {
+ @Override
+ protected void screenScrolled(int screenScroll) {
+ super.screenScrolled(screenScroll);
+ if (isSwitchingState()) return;
+ if (isSmall()) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout cl = (CellLayout) getPageAt(i);
+ if (cl != null) {
+ float scrollProgress = getScrollProgress(screenScroll, cl, i);
+ float rotation = WORKSPACE_ROTATION * scrollProgress;
+ cl.setFastTranslationX(0.0f);
+ cl.setFastRotationY(rotation);
+ cl.fastInvalidate();
+ }
+ }
+ } else if ((mOverScrollX < 0 || mOverScrollX > mMaxScrollX) &&
+ (!LauncherApplication.isScreenLarge() || mTransitionEffect != TransitionEffect.Tablet)) {
int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
CellLayout cl = (CellLayout) getChildAt(index);
if (getChildCount() > 1) {
@@ -1258,6 +1333,7 @@ public class Workspace extends PagedView
cl.setPivotX(cl.getMeasuredWidth() * (index == 0 ? 0.75f : 0.25f));
cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
cl.setRotationY(rotation);
+ cl.setTranslationX(0.0f);
cl.setOverscrollTransformsDirty(true);
setFadeForOverScroll(Math.abs(scrollProgress));
}
@@ -1265,23 +1341,22 @@ public class Workspace extends PagedView
if (mOverscrollFade != 0) {
setFadeForOverScroll(0);
}
- // We don't want to mess with the translations during transitions
+ // Reset transforms when we aren't in overscroll
if (!isSwitchingState()) {
((CellLayout) getChildAt(0)).resetOverscrollTransforms();
((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
}
- }
- }
-
- @Override
- protected void screenScrolled(int screenScroll) {
- if (LauncherApplication.isScreenLarge()) {
- // We don't call super.screenScrolled() here because we handle the adjacent pages alpha
- // ourselves (for efficiency), and there are no scrolling indicators to update.
- screenScrolledLargeUI(screenScroll);
- } else {
- super.screenScrolled(screenScroll);
- screenScrolledStandardUI(screenScroll);
+ switch (mTransitionEffect) {
+ case Standard:
+ screenScrolledStandard(screenScroll);
+ break;
+ case Tablet:
+ screenScrolledTablet(screenScroll);
+ break;
+ case Stack:
+ screenScrolledStack(screenScroll);
+ break;
+ }
}
}
@@ -1562,6 +1637,10 @@ public class Workspace extends PagedView
}
private final ZoomInInterpolator mZoomInInterpolator = new ZoomInInterpolator();
+ private final ZInterpolator mZInterpolator = new ZInterpolator(0.5f);
+ private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f);
+ private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4);
+
/*
*
@@ -1697,7 +1776,7 @@ public class Workspace extends PagedView
float rotation = 0f;
float initialAlpha = cl.getAlpha();
float finalAlphaMultiplierValue = 1f;
- float finalAlpha = (!mFadeInAdjacentScreens || stateIsSpringLoaded ||
+ float finalAlpha = (mFadeInAdjacentScreens || stateIsSpringLoaded ||
(i == mCurrentPage)) ? 1f : 0f;
// Determine the pages alpha during the state transition
@@ -1714,8 +1793,8 @@ public class Workspace extends PagedView
}
}
- // Update the rotation of the screen (don't apply rotation on Phone UI)
- if (LauncherApplication.isScreenLarge()) {
+ // Update the rotation of the screen
+ if (mTransitionEffect == TransitionEffect.Tablet || stateIsSmall || stateIsSpringLoaded) {
if (i < mCurrentPage) {
rotation = WORKSPACE_ROTATION;
} else if (i > mCurrentPage) {
@@ -1723,10 +1802,20 @@ public class Workspace extends PagedView
}
}
- // If the screen is not xlarge, then don't rotate the CellLayouts
- // NOTE: If we don't update the side pages alpha, then we should not hide the side
- // pages. see unshrink().
- if (LauncherApplication.isScreenLarge()) {
+ // Make sure the pages are visible with the stack effect
+ if (mTransitionEffect == TransitionEffect.Stack) {
+ if (stateIsSmall || stateIsSpringLoaded) {
+ cl.setVisibility(VISIBLE);
+ } else if (stateIsNormal) {
+ if (i <= mCurrentPage) {
+ cl.setVisibility(VISIBLE);
+ } else {
+ cl.setVisibility(GONE);
+ }
+ }
+ }
+
+ if (mTransitionEffect == TransitionEffect.Tablet && stateIsNormal) {
translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
}
@@ -1776,7 +1865,7 @@ public class Workspace extends PagedView
// the current page is visible during (and subsequently, after) the transition
// animation. If fade adjacent pages is disabled, then re-enable the page
// visibility after the transition animation.
- if (!mFadeInAdjacentScreens && stateIsNormal && oldStateIsSmall) {
+ if (mFadeInAdjacentScreens && stateIsNormal && oldStateIsSmall) {
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setAlpha(1f);
diff --git a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
index 84e8eb0ad..bac7ff74c 100644
--- a/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
+++ b/src/com/cyanogenmod/trebuchet/preference/PreferencesProvider.java
@@ -19,6 +19,8 @@ package com.cyanogenmod.trebuchet.preference;
import android.content.Context;
import android.content.SharedPreferences;
+import static com.cyanogenmod.trebuchet.Workspace.TransitionEffect;
+
public final class PreferencesProvider {
public static final String PREFERENCES_KEY = "com.cyanogenmod.trebuchet_preferences";
@@ -47,6 +49,15 @@ public final class PreferencesProvider {
final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
return preferences.getBoolean("ui_homescreen_scrolling_scroll_wallpaper", true);
}
+ public static TransitionEffect getTransitionEffect(Context context, String def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return TransitionEffect.valueOf(
+ preferences.getString("ui_homescreen_scrolling_transition_effect", def));
+ }
+ public static boolean getFadeInAdjacentScreens(Context context, boolean def) {
+ final SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_KEY, 0);
+ return preferences.getBoolean("ui_homescreen_scrolling_fade_adjacent_screens", def);
+ }
}
public static class Indicator {
public static boolean getShowScrollingIndicator(Context context) {