Loading quickstep/res/layout/overview_panel.xml +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ android:theme="@style/HomeScreenElementTheme" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:clipChildren="false" android:clipToPadding="false" android:alpha="0.0" Loading quickstep/res/layout/task.xml +3 −3 Original line number Diff line number Diff line Loading @@ -23,14 +23,14 @@ android:id="@+id/snapshot" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="24dp" android:layout_marginTop="@dimen/task_thumbnail_top_margin" android:scaleType="matrix" android:background="@drawable/task_thumbnail_background" android:elevation="4dp" /> <ImageView android:id="@+id/icon" android:layout_width="48dp" android:layout_height="48dp" android:layout_width="@dimen/task_thumbnail_icon_size" android:layout_height="@dimen/task_thumbnail_icon_size" android:layout_gravity="top|center_horizontal" android:elevation="5dp"/> </com.android.quickstep.TaskView> No newline at end of file quickstep/res/values/dimens.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 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> <dimen name="task_thumbnail_top_margin">24dp</dimen> <dimen name="task_thumbnail_icon_size">48dp</dimen> <dimen name="quickstep_fling_threshold_velocity">500dp</dimen> <dimen name="quickstep_fling_min_velocity">250dp</dimen> </resources> quickstep/src/com/android/quickstep/AnimatedFloat.java 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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. */ package com.android.quickstep; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.util.FloatProperty; /** * A mutable float which allows animating the value */ public class AnimatedFloat { public static FloatProperty<AnimatedFloat> VALUE = new FloatProperty<AnimatedFloat>("value") { @Override public void setValue(AnimatedFloat obj, float v) { obj.updateValue(v); } @Override public Float get(AnimatedFloat obj) { return obj.value; } }; private final Runnable mUpdateCallback; private ObjectAnimator mValueAnimator; public float value; public AnimatedFloat(Runnable updateCallback) { mUpdateCallback = updateCallback; } public ObjectAnimator animateToValue(float v) { if (mValueAnimator != null) { mValueAnimator.cancel(); } mValueAnimator = ObjectAnimator.ofFloat(this, VALUE, v); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (mValueAnimator == animator) { mValueAnimator = null; } } }); return mValueAnimator; } /** * Changes the value and calls the callback. * Note that the value can be directly accessed as well to avoid notifying the callback. */ public void updateValue(float v) { if (Float.compare(v, value) != 0) { value = v; mUpdateCallback.run(); } } public ObjectAnimator getCurrentAnimation() { return mValueAnimator; } } quickstep/src/com/android/quickstep/MultiStateCallback.java 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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. */ package com.android.quickstep; import android.util.SparseArray; /** * Utility class to help manage multiple callbacks based on different states. */ public class MultiStateCallback { private final SparseArray<Runnable> mCallbacks = new SparseArray<>(); private int mState = 0; /** * Adds the provided state flags to the global state and executes any callbacks as a result. * @param stateFlag */ public void setState(int stateFlag) { mState = mState | stateFlag; int count = mCallbacks.size(); for (int i = 0; i < count; i++) { int state = mCallbacks.keyAt(i); if ((mState & state) == state) { Runnable callback = mCallbacks.valueAt(i); if (callback != null) { // Set the callback to null, so that it does not run again. mCallbacks.setValueAt(i, null); callback.run(); } } } } /** * Sets the callbacks to be run when the provided states are enabled. * The callback is only run once. */ public void addCallback(int stateMask, Runnable callback) { mCallbacks.put(stateMask, callback); } } Loading
quickstep/res/layout/overview_panel.xml +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ android:theme="@style/HomeScreenElementTheme" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:clipChildren="false" android:clipToPadding="false" android:alpha="0.0" Loading
quickstep/res/layout/task.xml +3 −3 Original line number Diff line number Diff line Loading @@ -23,14 +23,14 @@ android:id="@+id/snapshot" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="24dp" android:layout_marginTop="@dimen/task_thumbnail_top_margin" android:scaleType="matrix" android:background="@drawable/task_thumbnail_background" android:elevation="4dp" /> <ImageView android:id="@+id/icon" android:layout_width="48dp" android:layout_height="48dp" android:layout_width="@dimen/task_thumbnail_icon_size" android:layout_height="@dimen/task_thumbnail_icon_size" android:layout_gravity="top|center_horizontal" android:elevation="5dp"/> </com.android.quickstep.TaskView> No newline at end of file
quickstep/res/values/dimens.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2017 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> <dimen name="task_thumbnail_top_margin">24dp</dimen> <dimen name="task_thumbnail_icon_size">48dp</dimen> <dimen name="quickstep_fling_threshold_velocity">500dp</dimen> <dimen name="quickstep_fling_min_velocity">250dp</dimen> </resources>
quickstep/src/com/android/quickstep/AnimatedFloat.java 0 → 100644 +79 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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. */ package com.android.quickstep; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.util.FloatProperty; /** * A mutable float which allows animating the value */ public class AnimatedFloat { public static FloatProperty<AnimatedFloat> VALUE = new FloatProperty<AnimatedFloat>("value") { @Override public void setValue(AnimatedFloat obj, float v) { obj.updateValue(v); } @Override public Float get(AnimatedFloat obj) { return obj.value; } }; private final Runnable mUpdateCallback; private ObjectAnimator mValueAnimator; public float value; public AnimatedFloat(Runnable updateCallback) { mUpdateCallback = updateCallback; } public ObjectAnimator animateToValue(float v) { if (mValueAnimator != null) { mValueAnimator.cancel(); } mValueAnimator = ObjectAnimator.ofFloat(this, VALUE, v); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (mValueAnimator == animator) { mValueAnimator = null; } } }); return mValueAnimator; } /** * Changes the value and calls the callback. * Note that the value can be directly accessed as well to avoid notifying the callback. */ public void updateValue(float v) { if (Float.compare(v, value) != 0) { value = v; mUpdateCallback.run(); } } public ObjectAnimator getCurrentAnimation() { return mValueAnimator; } }
quickstep/src/com/android/quickstep/MultiStateCallback.java 0 → 100644 +58 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 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. */ package com.android.quickstep; import android.util.SparseArray; /** * Utility class to help manage multiple callbacks based on different states. */ public class MultiStateCallback { private final SparseArray<Runnable> mCallbacks = new SparseArray<>(); private int mState = 0; /** * Adds the provided state flags to the global state and executes any callbacks as a result. * @param stateFlag */ public void setState(int stateFlag) { mState = mState | stateFlag; int count = mCallbacks.size(); for (int i = 0; i < count; i++) { int state = mCallbacks.keyAt(i); if ((mState & state) == state) { Runnable callback = mCallbacks.valueAt(i); if (callback != null) { // Set the callback to null, so that it does not run again. mCallbacks.setValueAt(i, null); callback.run(); } } } } /** * Sets the callbacks to be run when the provided states are enabled. * The callback is only run once. */ public void addCallback(int stateMask, Runnable callback) { mCallbacks.put(stateMask, callback); } }