summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard MacGregor <rmacgregor@cyngn.com>2015-08-31 16:06:35 (GMT)
committerRichard MacGregor <rmacgregor@cyngn.com>2015-08-31 19:30:27 (GMT)
commit531b2925211dfb2dbc22c88c3d2cac713e0e85c1 (patch)
treed64632f32b7fb4a5e57208fc389c87f89d849f03
parent4d8145d572803b288c2f2f0bd425575ced7bbcce (diff)
downloadandroid_packages_apps_Trebuchet-caf/cm-12.1.zip
android_packages_apps_Trebuchet-caf/cm-12.1.tar.gz
android_packages_apps_Trebuchet-caf/cm-12.1.tar.bz2
Reset default view camera distancecaf/cm-12.1
Several transition effects modify the views camera distance. Reset to the default camera distance so all transitions are consistent after switching between transitions (ie - Cylinder-in -> Flip -> Cylinder-in) Change-Id: Iee69feb5c954d1522d391e14c30ffa833666f90a Tickets: QRDL-340 and OPO-27 (cherry picked from commit 41106d9583cceddcb20286676640a3b21a25536b)
-rw-r--r--res/values/ids.xml19
-rw-r--r--src/com/android/launcher3/PagedView.java32
2 files changed, 41 insertions, 10 deletions
diff --git a/res/values/ids.xml b/res/values/ids.xml
new file mode 100644
index 0000000..9f55f90
--- /dev/null
+++ b/res/values/ids.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The CyanogenMod 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>
+ <item type="id" name="tag_key_default_camera_distance"/>
+</resources> \ No newline at end of file
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index cf4eb2a..a95cedb 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -3014,7 +3014,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mName = name;
}
- public abstract void screenScrolled(View v, int i, float scrollProgress);
+ public abstract void onScreenScrolled(View v, int i, float scrollProgress);
+
+ public void screenScrolled(View v, int i, float scrollProgress) {
+ // Get and set the default camera distance.
+ // Several of the TransitionEffects set a custom distance, reset it here.
+ Float defaultCameraDistance = (Float) v.getTag(R.id.tag_key_default_camera_distance);
+ if (defaultCameraDistance == null) {
+ defaultCameraDistance = v.getCameraDistance();
+ v.setTag(R.id.tag_key_default_camera_distance, defaultCameraDistance);
+ }
+ v.setCameraDistance(defaultCameraDistance);
+ onScreenScrolled(v, i, scrollProgress);
+ }
public final String getName() {
return mName;
@@ -3061,7 +3073,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(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
@@ -3084,7 +3096,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float rotation =
(mUp ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress;
@@ -3114,7 +3126,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float rotation = (mIn ? 90.0f : -90.0f) * scrollProgress;
if (mIn) {
@@ -3137,7 +3149,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
final boolean isRtl = mPagedView.isLayoutRtl();
float interpolatedProgress;
float translationX;
@@ -3189,7 +3201,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float scale = 1.0f - Math.abs(scrollProgress);
v.setScaleX(scale);
@@ -3204,7 +3216,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float rotation = -180.0f * Math.max(-1f, Math.min(1f, scrollProgress));
v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
@@ -3232,7 +3244,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float rotation = (mIn ? TRANSITION_SCREEN_ROTATION : -TRANSITION_SCREEN_ROTATION) * scrollProgress;
v.setPivotX((scrollProgress + 1) * v.getMeasuredWidth() * 0.5f);
@@ -3247,7 +3259,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float rotation = 90.0f * scrollProgress;
v.setCameraDistance(mPagedView.mDensity * PagedView.CAMERA_DISTANCE);
@@ -3266,7 +3278,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
}
@Override
- public void screenScrolled(View v, int i, float scrollProgress) {
+ public void onScreenScrolled(View v, int i, float scrollProgress) {
float scale = 1.0f - 0.1f *
mScaleInterpolator.getInterpolation(Math.min(0.3f, Math.abs(scrollProgress)) / 0.3f);