Snap for 7310088 from 5caf5e66eca91df8a039952f3aa156bbdc9aaa38 to sc-v2-release
Change-Id: I4d32ef8fa92c8b71d2c43c75ad919fbf461921a8
diff --git a/quickstep/res/values-as/strings.xml b/quickstep/res/values-as/strings.xml
index c1a746f..9b22c62 100644
--- a/quickstep/res/values-as/strings.xml
+++ b/quickstep/res/values-as/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"আজি <xliff:g id="TIME">%1$s</xliff:g> বাকী আছ"</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"এপ চাজেশ্বন"</string>
<string name="all_apps_label" msgid="8542784161730910663">"সকলো এপ্"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"আপোনাৰ অনুমানিক এপ্"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"আপোনাৰ প্ৰয়োজন হ\'ব পৰা এপ্"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"আপোনাৰ গৃহ স্ক্ৰীনৰ একেবাৰে তলৰ শাৰীটোত এপৰ পৰামর্শসমূহ পাওক"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"আপোনাৰ গৃহ স্ক্ৰীনৰ প্ৰিয় সমলৰ শাৰীটোত এপৰ পৰামর্শসমূহ পাওক"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"আপোনাৰ সকলোতকৈ বেছিকৈ ব্যৱহৃত এপ্সমূহ গৃহ স্ক্ৰীনতে সহজে এক্সেছ কৰক। আপোনাৰ ৰুটিনসমূহৰ ভিত্তিত পৰামর্শসমূহ সলনি হ\'ব। একেবাৰে তলৰ শাৰীটোত থকা এপ্সমূহ ওপৰৰ আপোনাৰ গৃহ স্ক্ৰীনলৈ যাব।"</string>
diff --git a/quickstep/res/values-gl/strings.xml b/quickstep/res/values-gl/strings.xml
index 846f68a..9310d71 100644
--- a/quickstep/res/values-gl/strings.xml
+++ b/quickstep/res/values-gl/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"Tempo restante hoxe <xliff:g id="TIME">%1$s</xliff:g>"</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"Suxestións de aplicacións"</string>
<string name="all_apps_label" msgid="8542784161730910663">"Todas as aplicacións"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"As túas aplicacións preditas"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"Previsión das túas aplicacións"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"Recibe suxestións de aplicacións na fila inferior da pantalla de inicio"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"Recibe suxestións de aplicacións na fila de Favoritos da pantalla de inicio"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"Accede facilmente desde a pantalla de inicio ás aplicacións que máis usas. As suxestións irán cambiando en función das túas rutinas. As aplicacións da fila inferior pasarán á pantalla de inicio."</string>
diff --git a/quickstep/res/values-gu/strings.xml b/quickstep/res/values-gu/strings.xml
index 1ec2709..496d33b 100644
--- a/quickstep/res/values-gu/strings.xml
+++ b/quickstep/res/values-gu/strings.xml
@@ -78,8 +78,7 @@
<string name="action_screenshot" msgid="8171125848358142917">"સ્ક્રીનશૉટ"</string>
<string name="blocked_by_policy" msgid="2071401072261365546">"ઍપ કે તમારી સંસ્થા દ્વારા આ ક્રિયા કરવાની મંજૂરી નથી"</string>
<string name="skip_tutorial_dialog_title" msgid="2725643161260038458">"નૅવિગેશન ટ્યૂટૉરિઅલ છોડી દઈએ?"</string>
- <!-- no translation found for skip_tutorial_dialog_subtitle (544063326241955662) -->
- <skip />
+ <string name="skip_tutorial_dialog_subtitle" msgid="544063326241955662">"તમે આને પછીથી <xliff:g id="NAME">%1$s</xliff:g> ઍપમાં જોઈ શકો છો"</string>
<string name="gesture_tutorial_action_button_label_cancel" msgid="3809842569351264108">"રદ કરો"</string>
<string name="gesture_tutorial_action_button_label_skip" msgid="394452764989751960">"છોડો"</string>
</resources>
diff --git a/quickstep/res/values-kn/strings.xml b/quickstep/res/values-kn/strings.xml
index 31182b6..8fdba69 100644
--- a/quickstep/res/values-kn/strings.xml
+++ b/quickstep/res/values-kn/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"ಇಂದು <xliff:g id="TIME">%1$s</xliff:g> ಸಮಯ ಉಳಿದಿದೆ"</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"ಆ್ಯಪ್ ಸಲಹೆಗಳು"</string>
<string name="all_apps_label" msgid="8542784161730910663">"ಎಲ್ಲಾ ಆ್ಯಪ್ಗಳು"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"ನಿಮ್ಮ ಸಂಭವನೀಯ ಆ್ಯಪ್ಗಳು"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"ನಿಮ್ಮ ಮುನ್ಸೂಚಿತ ಆ್ಯಪ್ಗಳು"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"ನಿಮ್ಮ ಹೋಮ್ ಸ್ಕ್ರೀನ್ನ ಕೆಳಭಾಗದ ಸಾಲಿನಲ್ಲಿ ಆ್ಯಪ್ ಸಲಹೆಗಳನ್ನು ಪಡೆಯಿರಿ"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"ನಿಮ್ಮ ಹೋಮ್ ಸ್ಕ್ರೀನ್ನ ಮೆಚ್ಚಿನವುಗಳ ಸಾಲಿನಲ್ಲಿ ಆ್ಯಪ್ ಸಲಹೆಗಳನ್ನು ಪಡೆಯಿರಿ"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"ಹೋಮ್ ಸ್ಕ್ರೀನ್ನಲ್ಲಿಯೇ ನೀವು ಹೆಚ್ಚು ಬಳಸಿದ ಆ್ಯಪ್ಗಳನ್ನು ಸುಲಭವಾಗಿ ಪ್ರವೇಶಿಸಿ. ನಿಮ್ಮ ದಿನಚರಿಯನ್ನು ಆಧರಿಸಿ ಸಲಹೆಗಳು ಬದಲಾಗುತ್ತವೆ. ಕೆಳಭಾಗದ ಸಾಲಿನಲ್ಲಿನ ಆ್ಯಪ್ಗಳು ನಿಮ್ಮ ಹೋಮ್ ಸ್ಕ್ರೀನ್ ಚಲಿಸುತ್ತವೆ."</string>
@@ -78,8 +78,7 @@
<string name="action_screenshot" msgid="8171125848358142917">"ಸ್ಕ್ರೀನ್ಶಾಟ್"</string>
<string name="blocked_by_policy" msgid="2071401072261365546">"ಆ್ಯಪ್ ಅಥವಾ ನಿಮ್ಮ ಸಂಸ್ಥೆಯು ಈ ಕ್ರಿಯೆಯನ್ನು ಅನುಮತಿಸುವುದಿಲ್ಲ"</string>
<string name="skip_tutorial_dialog_title" msgid="2725643161260038458">"ನ್ಯಾವಿಗೇಷನ್ ಟ್ಯುಟೋರಿಯಲ್ ಸ್ಕಿಪ್ ಮಾಡಿ?"</string>
- <!-- no translation found for skip_tutorial_dialog_subtitle (544063326241955662) -->
- <skip />
+ <string name="skip_tutorial_dialog_subtitle" msgid="544063326241955662">"<xliff:g id="NAME">%1$s</xliff:g> ಆ್ಯಪ್ನಲ್ಲಿ ಇದನ್ನು ನಂತರ ಕಾಣಬಹುದು"</string>
<string name="gesture_tutorial_action_button_label_cancel" msgid="3809842569351264108">"ರದ್ದುಮಾಡಿ"</string>
<string name="gesture_tutorial_action_button_label_skip" msgid="394452764989751960">"ಸ್ಕಿಪ್ ಮಾಡಿ"</string>
</resources>
diff --git a/quickstep/res/values-mr/strings.xml b/quickstep/res/values-mr/strings.xml
index d31b03a..c576cf1 100644
--- a/quickstep/res/values-mr/strings.xml
+++ b/quickstep/res/values-mr/strings.xml
@@ -78,8 +78,7 @@
<string name="action_screenshot" msgid="8171125848358142917">"स्क्रीनशॉट"</string>
<string name="blocked_by_policy" msgid="2071401072261365546">"अॅप किंवा तुमच्या संस्थेद्वारे ही क्रिया करण्याची अनुमती नाही"</string>
<string name="skip_tutorial_dialog_title" msgid="2725643161260038458">"नेव्हिगेशन ट्युटोरियल वगळायचे आहे का?"</string>
- <!-- no translation found for skip_tutorial_dialog_subtitle (544063326241955662) -->
- <skip />
+ <string name="skip_tutorial_dialog_subtitle" msgid="544063326241955662">"तुम्हाला हे नंतर <xliff:g id="NAME">%1$s</xliff:g> ॲपमध्ये मिळेल"</string>
<string name="gesture_tutorial_action_button_label_cancel" msgid="3809842569351264108">"रद्द करा"</string>
<string name="gesture_tutorial_action_button_label_skip" msgid="394452764989751960">"वगळा"</string>
</resources>
diff --git a/quickstep/res/values-ne/strings.xml b/quickstep/res/values-ne/strings.xml
index 6d31422..99ad814 100644
--- a/quickstep/res/values-ne/strings.xml
+++ b/quickstep/res/values-ne/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"आज: <xliff:g id="TIME">%1$s</xliff:g> बाँकी"</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"एपसम्बन्धी सुझावहरू"</string>
<string name="all_apps_label" msgid="8542784161730910663">"सबै एपहरू"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"तपाईंका पूर्वानुमानित एपहरू"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"तपाईंलाई चाहिने एपहरू"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"तपाईंको गृह स्क्रिनको पुछारको पङ्क्तिमा सिफारिस गरिएका एपहरू प्राप्त गर्नुहोस्"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"आफ्नो होम स्क्रिनको मन पर्ने नामक पङ्क्तिमा सिफारिस गरिएका एपहरू प्राप्त गर्नुहोस्"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"गृह स्क्रिनबाटै आफूले सबैभन्दा बढी प्रयोग गर्ने एप सजिलै चलाउनुहोस्। सिफारिस गरिने एपहरूको क्रम तपाईंले एप प्रयोग गर्ने समयतालिकाअनुसार बदलिने छ। फेदको पङ्क्तिमा रहेका एपहरू तपाईंको गृह स्क्रिनको सिरानमा सर्ने छन्।"</string>
@@ -108,8 +108,7 @@
<string name="blocked_by_policy" msgid="2071401072261365546">"यो एप वा तपाईंको सङ्गठनले यो कारबाही गर्ने अनुमति दिँदैन"</string>
<!-- no translation found for skip_tutorial_dialog_title (2725643161260038458) -->
<skip />
- <!-- no translation found for skip_tutorial_dialog_subtitle (544063326241955662) -->
- <skip />
+ <string name="skip_tutorial_dialog_subtitle" msgid="544063326241955662">"तपाईं पछि <xliff:g id="NAME">%1$s</xliff:g> एपमा गई यो ट्युटोरियल भेट्टाउन सक्नुहुन्छ"</string>
<!-- no translation found for gesture_tutorial_action_button_label_cancel (3809842569351264108) -->
<skip />
<!-- no translation found for gesture_tutorial_action_button_label_skip (394452764989751960) -->
diff --git a/quickstep/res/values-te/strings.xml b/quickstep/res/values-te/strings.xml
index d1e30a2..c73c83e 100644
--- a/quickstep/res/values-te/strings.xml
+++ b/quickstep/res/values-te/strings.xml
@@ -78,8 +78,7 @@
<string name="action_screenshot" msgid="8171125848358142917">"స్క్రీన్షాట్"</string>
<string name="blocked_by_policy" msgid="2071401072261365546">"ఈ చర్యను యాప్ గానీ, మీ సంస్థ గానీ అనుమతించవు"</string>
<string name="skip_tutorial_dialog_title" msgid="2725643161260038458">"నావిగేషన్ ట్యుటోరియల్ను స్కిప్ చేయాలా?"</string>
- <!-- no translation found for skip_tutorial_dialog_subtitle (544063326241955662) -->
- <skip />
+ <string name="skip_tutorial_dialog_subtitle" msgid="544063326241955662">"<xliff:g id="NAME">%1$s</xliff:g> యాప్లో మీరు తర్వాత కనుగొనవచ్చు"</string>
<string name="gesture_tutorial_action_button_label_cancel" msgid="3809842569351264108">"రద్దు చేయి"</string>
<string name="gesture_tutorial_action_button_label_skip" msgid="394452764989751960">"స్కిప్ చేయి"</string>
</resources>
diff --git a/quickstep/res/values-ur/strings.xml b/quickstep/res/values-ur/strings.xml
index bfcc897..5ce95ad 100644
--- a/quickstep/res/values-ur/strings.xml
+++ b/quickstep/res/values-ur/strings.xml
@@ -78,8 +78,7 @@
<string name="action_screenshot" msgid="8171125848358142917">"اسکرین شاٹ"</string>
<string name="blocked_by_policy" msgid="2071401072261365546">"ایپ یا آپ کی تنظیم کی جانب سے اس کارروائی کی اجازت نہیں ہے"</string>
<string name="skip_tutorial_dialog_title" msgid="2725643161260038458">"نیویگیشن کا ٹیوٹوریل نظر انداز کریں؟"</string>
- <!-- no translation found for skip_tutorial_dialog_subtitle (544063326241955662) -->
- <skip />
+ <string name="skip_tutorial_dialog_subtitle" msgid="544063326241955662">"آپ اسے بعد میں <xliff:g id="NAME">%1$s</xliff:g> ایپ میں تلاش کر سکتے ہیں"</string>
<string name="gesture_tutorial_action_button_label_cancel" msgid="3809842569351264108">"منسوخ کریں"</string>
<string name="gesture_tutorial_action_button_label_skip" msgid="394452764989751960">"نظر انداز کریں"</string>
</resources>
diff --git a/quickstep/res/values-zh-rCN/strings.xml b/quickstep/res/values-zh-rCN/strings.xml
index 9d39100..fe5e553 100644
--- a/quickstep/res/values-zh-rCN/strings.xml
+++ b/quickstep/res/values-zh-rCN/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"今天还可使用 <xliff:g id="TIME">%1$s</xliff:g>"</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"应用建议"</string>
<string name="all_apps_label" msgid="8542784161730910663">"所有应用"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"您的预测应用"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"您可能想要使用的应用"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"在主屏幕底部获取应用建议"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"在主屏幕的收藏行获取应用建议"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"直接在主屏幕上轻松访问您最常用的应用。系统会根据您的日常安排提供不同的建议。最下面一排中的应用会向上移动到主屏幕中。"</string>
diff --git a/quickstep/res/values-zu/strings.xml b/quickstep/res/values-zu/strings.xml
index a118f1d..2ffaecf 100644
--- a/quickstep/res/values-zu/strings.xml
+++ b/quickstep/res/values-zu/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"<xliff:g id="TIME">%1$s</xliff:g> esele namhlanje"</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"Iziphakamiso zohlelo lokusebenza"</string>
<string name="all_apps_label" msgid="8542784161730910663">"Zonke izinhlelo zokusebenza"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"Izinhlelo zakho zokusebenza eziqagelwe"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"Ama-app akho aqagelwe"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"Thola iziphakamiso ze-app emgqeni ongezansi wesikrini sakho sasekhaya"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"Thola iziphakamiso zohlelo lokusebenza kumugqa wezintandokazi Zesikrini sakho sasekhaya"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"Finyelela kalula izinhlelo zakho zokusebenza ezisetshenziswa kakhulu khona kusikrini sasekhaya. Iziphakamiso zizoshintsha ngokususelwe kwimijikelezo yakho. Izinhlelo zokusebenza ezisemgqeni ongezansi zizoya phezulu kusikrini sakho sasekhaya."</string>
diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
index fb9765c..caf52e3 100644
--- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
@@ -26,10 +26,13 @@
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
+import android.app.ActivityOptions;
import android.content.Intent;
import android.content.IntentSender;
+import android.os.Binder;
import android.os.Bundle;
import android.os.CancellationSignal;
+import android.os.IBinder;
import android.view.View;
import androidx.annotation.Nullable;
@@ -37,6 +40,8 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.model.WellbeingModel;
+import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.proxy.ProxyActivityStarter;
import com.android.launcher3.proxy.StartActivityParams;
@@ -50,6 +55,7 @@
import com.android.launcher3.uioverrides.RecentsViewStateController;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.SysUINavigationMode;
@@ -67,6 +73,7 @@
import com.android.systemui.shared.system.ActivityOptionsCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
+import java.util.HashMap;
import java.util.List;
import java.util.stream.Stream;
@@ -418,18 +425,38 @@
}
@Override
- public ActivityOptionsWrapper getActivityLaunchOptions(View v) {
+ public ActivityOptionsWrapper getActivityLaunchOptions(View v, @Nullable ItemInfo item) {
ActivityOptionsWrapper activityOptions =
mAppTransitionManager.hasControlRemoteAppTransitionPermission()
? mAppTransitionManager.getActivityLaunchOptions(this, v)
- : super.getActivityLaunchOptions(v);
+ : super.getActivityLaunchOptions(v, item);
if (mLastTouchUpTime > 0) {
ActivityOptionsCompat.setLauncherSourceInfo(
activityOptions.options, mLastTouchUpTime);
}
+ addLaunchCookie(item, activityOptions.options);
return activityOptions;
}
+ /**
+ * Adds a new launch cookie for the activity launch of the given {@param info} if supported.
+ */
+ public void addLaunchCookie(ItemInfo info, ActivityOptions opts) {
+ if (info == null) {
+ return;
+ }
+ switch (info.itemType) {
+ case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
+ case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
+ case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
+ // Fall through and continue if it's an app or shortcut
+ break;
+ default:
+ return;
+ }
+ opts.setLaunchCookie(ObjectWrapper.wrap(new Integer(info.id)));
+ }
+
public void setHintUserWillBeActive() {
addActivityFlags(ACTIVITY_STATE_USER_WILL_BE_ACTIVE);
}
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index 827eb7d..62ab95a 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -172,6 +172,8 @@
private final float mClosingWindowTransY;
private final float mMaxShadowRadius;
+ private final StartingWindowListener mStartingWindowListener = new StartingWindowListener();
+
private DeviceProfile mDeviceProfile;
private RemoteAnimationProvider mRemoteAnimationProvider;
@@ -221,13 +223,9 @@
}
};
+ mStartingWindowListener.setTransitionManager(this);
SystemUiProxy.INSTANCE.get(mLauncher).setStartingWindowListener(
- new IStartingWindowListener.Stub() {
- @Override
- public void onTaskLaunching(int taskId, int supportedType) {
- mTypeForTaskId.put(taskId, supportedType);
- }
- });
+ mStartingWindowListener);
}
}
@@ -566,7 +564,6 @@
// Set the crop here so we can calculate the corner radius below.
crop.set(left, top, right, bottom);
- RectF targetBounds = new RectF(windowTargetBounds);
RectF floatingIconBounds = new RectF();
RectF tmpRectF = new RectF();
Point tmpPos = new Point();
@@ -655,12 +652,8 @@
tmpRectF.offset(dragLayerBounds[0], dragLayerBounds[1]);
tmpRectF.offset(mDx.value, mDy.value);
Utilities.scaleRectFAboutCenter(tmpRectF, mIconScaleToFitScreen.value);
- float windowTransX0 = tmpRectF.left - offsetX;
- float windowTransY0 = tmpRectF.top - offsetY;
- if (hasSplashScreen) {
- windowTransX0 -= crop.left * scale;
- windowTransY0 -= crop.top * scale;
- }
+ float windowTransX0 = tmpRectF.left - offsetX - crop.left * scale;
+ float windowTransY0 = tmpRectF.top - offsetY - crop.top * scale;
// Calculate the icon position.
floatingIconBounds.set(launcherIconBounds);
@@ -819,6 +812,7 @@
public void onActivityDestroyed() {
unregisterRemoteAnimations();
unregisterRemoteTransitions();
+ mStartingWindowListener.setTransitionManager(null);
SystemUiProxy.INSTANCE.getNoCreate().setStartingWindowListener(null);
}
@@ -1213,25 +1207,16 @@
alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION
: APP_LAUNCH_ALPHA_DOWN_DURATION;
- if (hasSplashScreen) {
- iconAlphaStart = 0;
+ iconAlphaStart = hasSplashScreen ? 0 : 1f;
- // TOOD: Share value from shell when available.
- final float windowIconSize = Utilities.pxFromSp(108, r.getDisplayMetrics());
+ // TOOD: Share value from shell when available.
+ final float windowIconSize = Utilities.pxFromSp(108, r.getDisplayMetrics());
- cropCenterXStart = windowTargetBounds.centerX();
- cropCenterYStart = windowTargetBounds.centerY();
+ cropCenterXStart = windowTargetBounds.centerX();
+ cropCenterYStart = windowTargetBounds.centerY();
- cropWidthStart = (int) windowIconSize;
- cropHeightStart = (int) windowIconSize;
- } else {
- iconAlphaStart = 1;
-
- cropWidthStart = cropHeightStart =
- Math.min(windowTargetBounds.width(), windowTargetBounds.height());
- cropCenterXStart = cropCenterYStart =
- Math.min(windowTargetBounds.centerX(), windowTargetBounds.centerY());
- }
+ cropWidthStart = (int) windowIconSize;
+ cropHeightStart = (int) windowIconSize;
cropWidthEnd = windowTargetBounds.width();
cropHeightEnd = windowTargetBounds.height();
@@ -1240,4 +1225,17 @@
cropCenterYEnd = windowTargetBounds.centerY();
}
}
+
+ private static class StartingWindowListener extends IStartingWindowListener.Stub {
+ private QuickstepTransitionManager mTransitionManager;
+
+ public void setTransitionManager(QuickstepTransitionManager transitionManager) {
+ mTransitionManager = transitionManager;
+ }
+
+ @Override
+ public void onTaskLaunching(int taskId, int supportedType) {
+ mTransitionManager.mTypeForTaskId.put(taskId, supportedType);
+ }
+ }
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 9097c8b..0652d48 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -113,7 +113,7 @@
ANIM_OVERVIEW_ACTIONS_FADE, LINEAR));
float splitPlaceholderAlpha = state.areElementsVisible(mLauncher, SPLIT_PLACHOLDER_VIEW) ?
- 0.7f : 0;
+ 0.85f : 0;
propertySetter.setFloat(mRecentsView.getSplitPlaceholder(), ALPHA_FLOAT,
splitPlaceholderAlpha, LINEAR);
}
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 1b59c49..53f1fd0 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -66,11 +66,13 @@
import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
+import android.os.IBinder;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnApplyWindowInsetsListener;
import android.view.ViewTreeObserver.OnDrawListener;
+import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.WindowInsets;
import android.view.animation.Interpolator;
import android.widget.Toast;
@@ -139,6 +141,8 @@
private final Handler mHandler = new Handler();
// Callbacks to be made once the recents animation starts
private final ArrayList<Runnable> mRecentsAnimationStartCallbacks = new ArrayList<>();
+ private final OnScrollChangedListener mOnRecentsScrollListener = this::onRecentsViewScroll;
+
protected RecentsAnimationController mRecentsAnimationController;
protected RecentsAnimationTargets mRecentsAnimationTargets;
protected T mActivity;
@@ -1043,7 +1047,8 @@
interpolator, target, velocityPxPerMs));
}
- protected abstract HomeAnimationFactory createHomeAnimationFactory(long duration);
+ protected abstract HomeAnimationFactory createHomeAnimationFactory(
+ ArrayList<IBinder> launchCookies, long duration);
private final TaskStackChangeListener mActivityRestartListener = new TaskStackChangeListener() {
@Override
@@ -1084,7 +1089,8 @@
final RemoteAnimationTargetCompat runningTaskTarget = mRecentsAnimationTargets != null
? mRecentsAnimationTargets.findTask(mGestureState.getRunningTaskId())
: null;
- HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(duration);
+ HomeAnimationFactory homeAnimFactory = createHomeAnimationFactory(
+ runningTaskTarget.taskInfo.launchCookies, duration);
mIsSwipingPipToHome = homeAnimFactory.supportSwipePipToHome()
&& runningTaskTarget != null
&& runningTaskTarget.taskInfo.pictureInPictureParams != null
@@ -1368,6 +1374,7 @@
private void invalidateHandlerWithLauncher() {
endLauncherTransitionController();
+ mRecentsView.removeOnScrollChangedListener(mOnRecentsScrollListener);
mRecentsView.onGestureAnimationEnd();
resetLauncherListeners();
}
@@ -1505,9 +1512,8 @@
SystemUiProxy.INSTANCE.get(mContext).stopSwipePipToHome(
mSwipePipToHomeAnimator.getComponentName(),
mSwipePipToHomeAnimator.getDestinationBounds());
- mRecentsAnimationController.setFinishTaskBounds(
+ mRecentsAnimationController.setFinishTaskTransaction(
mSwipePipToHomeAnimator.getTaskId(),
- mSwipePipToHomeAnimator.getDestinationBounds(),
mSwipePipToHomeAnimator.getFinishTransaction());
mIsSwipingPipToHome = false;
}
@@ -1562,17 +1568,19 @@
mRecentsAnimationTargets.addReleaseCheck(applier));
});
- mRecentsView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
- if (moveWindowWithRecentsScroll()) {
- updateFinalShift();
- }
- });
+ mRecentsView.addOnScrollChangedListener(mOnRecentsScrollListener);
runOnRecentsAnimationStart(() ->
mRecentsView.setRecentsAnimationTargets(mRecentsAnimationController,
mRecentsAnimationTargets));
mRecentsViewScrollLinked = true;
}
+ private void onRecentsViewScroll() {
+ if (moveWindowWithRecentsScroll()) {
+ updateFinalShift();
+ }
+ }
+
protected void startNewTask(Consumer<Boolean> resultCallback) {
// Launch the task user scrolled to (mRecentsView.getNextPage()).
if (!mCanceled) {
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index f5698f7..9846ee7 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -38,6 +38,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
@@ -68,6 +69,7 @@
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
import java.lang.ref.WeakReference;
+import java.util.ArrayList;
import java.util.UUID;
import java.util.function.Consumer;
@@ -126,7 +128,8 @@
}
@Override
- protected HomeAnimationFactory createHomeAnimationFactory(long duration) {
+ protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
+ long duration) {
mActiveAnimationFactory = new FallbackHomeAnimationFactory(duration);
ActivityOptions options = ActivityOptions.makeCustomAnimation(mContext, 0, 0);
Intent intent = new Intent(mGestureState.getHomeIntent());
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 5ecd385..dd35d68 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -31,6 +31,7 @@
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.RectF;
+import android.os.IBinder;
import android.os.UserHandle;
import android.view.View;
@@ -47,6 +48,7 @@
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.util.DynamicResource;
+import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.util.AppCloseConfig;
import com.android.quickstep.util.RectFSpringAnim;
@@ -56,6 +58,8 @@
import com.android.systemui.plugins.ResourceProvider;
import com.android.systemui.shared.system.InputConsumerController;
+import java.util.ArrayList;
+
/**
* Temporary class to allow easier refactoring
*/
@@ -71,20 +75,12 @@
@Override
- protected HomeAnimationFactory createHomeAnimationFactory(long duration) {
+ protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies,
+ long duration) {
HomeAnimationFactory homeAnimFactory;
if (mActivity != null) {
- final TaskView runningTaskView = mRecentsView.getRunningTaskView();
- final View workspaceView;
- if (runningTaskView != null
- && !mIsSwipingPipToHome
- && runningTaskView.getTask().key.getComponent() != null) {
- workspaceView = mActivity.getWorkspace().getFirstMatchForAppClose(
- runningTaskView.getTask().key.getComponent().getPackageName(),
- UserHandle.of(runningTaskView.getTask().key.userId));
- } else {
- workspaceView = null;
- }
+ final View workspaceView = findWorkspaceView(launchCookies,
+ mRecentsView.getRunningTaskView());
boolean canUseWorkspaceView =
workspaceView != null && workspaceView.isAttachedToWindow();
@@ -232,6 +228,37 @@
return homeAnimFactory;
}
+ /**
+ * Returns the associated view on the workspace matching one of the launch cookies, or the app
+ * associated with the running task.
+ */
+ @Nullable
+ private View findWorkspaceView(ArrayList<IBinder> launchCookies, TaskView runningTaskView) {
+ if (mIsSwipingPipToHome) {
+ // Disable if swiping to PIP
+ return null;
+ }
+ if (runningTaskView == null || runningTaskView.getTask() == null
+ || runningTaskView.getTask().key.getComponent() == null) {
+ // Disable if it's an invalid task
+ return null;
+ }
+
+ // Find the associated item info for the launch cookie (if available)
+ int launchCookieItemId = -1;
+ for (IBinder cookie : launchCookies) {
+ Integer itemId = ObjectWrapper.unwrap(cookie);
+ if (itemId != null) {
+ launchCookieItemId = itemId;
+ break;
+ }
+ }
+
+ return mActivity.getWorkspace().getFirstMatchForAppClose(launchCookieItemId,
+ runningTaskView.getTask().key.getComponent().getPackageName(),
+ UserHandle.of(runningTaskView.getTask().key.userId));
+ }
+
@Override
protected void finishRecentsControllerToHome(Runnable callback) {
mRecentsAnimationController.finish(
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index 7c453e7..ec224ed 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -37,6 +37,8 @@
import android.os.Looper;
import android.view.View;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
@@ -48,6 +50,7 @@
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.compat.AccessibilityManagerCompat;
+import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory;
import com.android.launcher3.statemanager.StateManager.StateHandler;
@@ -177,9 +180,9 @@
}
@Override
- public ActivityOptionsWrapper getActivityLaunchOptions(final View v) {
+ public ActivityOptionsWrapper getActivityLaunchOptions(final View v, @Nullable ItemInfo item) {
if (!(v instanceof TaskView)) {
- return super.getActivityLaunchOptions(v);
+ return super.getActivityLaunchOptions(v, item);
}
final TaskView taskView = (TaskView) v;
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
index 82e8a93..4560735 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
@@ -19,7 +19,6 @@
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
-import android.graphics.Rect;
import android.window.PictureInPictureSurfaceTransaction;
import androidx.annotation.NonNull;
@@ -145,18 +144,16 @@
}
/**
- * Sets the final bounds on a Task. This is used by Launcher to notify the system that
- * animating Activity to PiP has completed and the associated task surface should be updated
- * accordingly. This should be called before `finish`
+ * Sets the final surface transaction on a Task. This is used by Launcher to notify the system
+ * that animating Activity to PiP has completed and the associated task surface should be
+ * updated accordingly. This should be called before `finish`
* @param taskId for which the leash should be updated
- * @param destinationBounds bounds of the final PiP window
* @param finishTransaction leash operations for the final transform.
*/
- public void setFinishTaskBounds(int taskId, Rect destinationBounds,
+ public void setFinishTaskTransaction(int taskId,
PictureInPictureSurfaceTransaction finishTransaction) {
UI_HELPER_EXECUTOR.execute(
- () -> mController.setFinishTaskBounds(taskId, destinationBounds,
- finishTransaction));
+ () -> mController.setFinishTaskTransaction(taskId, finishTransaction));
}
/**
diff --git a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java b/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java
index 351adf4..c527be3 100644
--- a/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java
+++ b/quickstep/src/com/android/quickstep/util/NavigationModeFeatureFlag.java
@@ -46,7 +46,8 @@
}
public boolean get() {
- return mBasePredicate.get() && mSupported && mObserver.isHomeAndOverviewSame();
+ return mBasePredicate.get() && mSupported && mObserver != null
+ && mObserver.isHomeAndOverviewSame();
}
public void initialize(Context context) {
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index c1c8c1b..01d51f8 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -16,16 +16,20 @@
package com.android.quickstep.util;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
import android.animation.AnimatorSet;
import android.app.ActivityOptions;
+import android.content.res.Resources;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.util.Pair;
+import android.view.Gravity;
import android.view.SurfaceControl;
import android.window.TransitionInfo;
@@ -33,7 +37,10 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseQuickstepLauncher;
+import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.LauncherAnimationRunner;
+import com.android.launcher3.R;
import com.android.launcher3.WrappedAnimationRunnerImpl;
import com.android.launcher3.WrappedLauncherAnimationRunner;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
@@ -115,6 +122,26 @@
resetState();
}
+ /**
+ * @return {@link InsettableFrameLayout.LayoutParams} to correctly position the
+ * split placeholder view
+ */
+ public InsettableFrameLayout.LayoutParams getLayoutParamsForActivePosition(Resources resources,
+ DeviceProfile deviceProfile) {
+ InsettableFrameLayout.LayoutParams params =
+ new InsettableFrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
+ boolean topLeftPosition = mInitialPosition.mStagePosition == STAGE_POSITION_TOP_OR_LEFT;
+ if (deviceProfile.isLandscape) {
+ params.width = (int) resources.getDimension(R.dimen.split_placeholder_size);
+ params.gravity = topLeftPosition ? Gravity.START : Gravity.END;
+ } else {
+ params.height = (int) resources.getDimension(R.dimen.split_placeholder_size);
+ params.gravity = Gravity.TOP;
+ }
+
+ return params;
+ }
+
@Nullable
public SplitPositionOption getActiveSplitPositionOption() {
return mInitialPosition;
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 6ed490d..d59d120 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -42,6 +42,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN;
import static com.android.launcher3.statehandlers.DepthController.DEPTH;
+import static com.android.launcher3.touch.PagedOrientationHandler.CANVAS_TRANSLATE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
@@ -88,11 +89,13 @@
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver.OnScrollChangedListener;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
import android.widget.ListView;
+import android.widget.OverScroller;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
@@ -116,14 +119,15 @@
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.testing.TestProtocol;
+import com.android.launcher3.touch.OverScroll;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.DynamicResource;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.MultiValueAlpha;
-import com.android.launcher3.util.OverScroller;
import com.android.launcher3.util.ResourceBasedOverride.Overrides;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.Themes;
+import com.android.launcher3.util.TranslateEdgeEffect;
import com.android.launcher3.util.ViewPool;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.BaseActivityInterface;
@@ -138,9 +142,9 @@
import com.android.quickstep.TaskViewUtils;
import com.android.quickstep.ViewUtils;
import com.android.quickstep.util.LayoutUtils;
-import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.quickstep.util.RecentsOrientedState;
import com.android.quickstep.util.SplitScreenBounds;
+import com.android.quickstep.util.SplitSelectStateController;
import com.android.quickstep.util.SurfaceTransactionApplier;
import com.android.quickstep.util.TaskViewSimulator;
import com.android.quickstep.util.TransformParams;
@@ -157,6 +161,7 @@
import com.android.wm.shell.pip.IPipAnimationListener;
import java.util.ArrayList;
+import java.util.List;
import java.util.function.Consumer;
/**
@@ -296,6 +301,9 @@
}
};
+ // OverScroll constants
+ private static final int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;
+
protected final RecentsOrientedState mOrientationState;
protected final BaseActivityInterface<STATE_TYPE, ACTIVITY_TYPE> mSizeStrategy;
protected RecentsAnimationController mRecentsAnimationController;
@@ -314,9 +322,13 @@
protected final Rect mTempRect = new Rect();
protected final RectF mTempRectF = new RectF();
private final PointF mTempPointF = new PointF();
+ private final float[] mTempFloat = new float[1];
+ private final List<OnScrollChangedListener> mScrollListeners = new ArrayList<>();
private float mFullscreenScale;
private static final int DISMISS_TASK_DURATION = 300;
+ private static final int DISMISS_TASK_TRANSLATION_DURATION = 200;
+ private static final int ADDITIONAL_DISMISS_TASK_TRANSLATION_DURATION = 75;
private static final int ADDITION_TASK_DURATION = 200;
// The threshold at which we update the SystemUI flags when animating from the task into the app
public static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.85f;
@@ -354,11 +366,12 @@
protected float mTaskViewsPrimaryTranslation = 0;
// Progress from 0 to 1 where 0 is a carousel and 1 is a 2 row grid.
private float mGridProgress = 0;
+ private final IntSet mTopRowIdSet = new IntSet();
// The GestureEndTarget that is still in progress.
protected GestureState.GestureEndTarget mCurrentGestureEndTarget;
- IntSet mTopIdSet = new IntSet();
+ private int mOverScrollShift = 0;
/**
* TODO: Call reloadIdNeeded in onTaskStackChanged.
@@ -584,6 +597,72 @@
}
@Override
+ protected void initEdgeEffect() {
+ mEdgeGlowLeft = new TranslateEdgeEffect(getContext());
+ mEdgeGlowRight = new TranslateEdgeEffect(getContext());
+ }
+
+ @Override
+ protected void drawEdgeEffect(Canvas canvas) {
+ // Do not draw edge effect
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ // Draw overscroll
+ if (mAllowOverScroll && (!mEdgeGlowRight.isFinished() || !mEdgeGlowLeft.isFinished())) {
+ final int restoreCount = canvas.save();
+ final int width = getWidth();
+ final int height = getHeight();
+ int primarySize = mOrientationHandler.getPrimaryValue(width, height);
+ int secondarySize = mOrientationHandler.getSecondaryValue(width, height);
+
+ float effectiveShift = 0;
+ if (!mEdgeGlowLeft.isFinished()) {
+ mEdgeGlowLeft.setSize(secondarySize, primarySize);
+ if (((TranslateEdgeEffect) mEdgeGlowLeft).getTranslationShift(mTempFloat)) {
+ effectiveShift = mTempFloat[0];
+ postInvalidateOnAnimation();
+ }
+ }
+ if (!mEdgeGlowRight.isFinished()) {
+ mEdgeGlowRight.setSize(secondarySize, primarySize);
+ if (((TranslateEdgeEffect) mEdgeGlowRight).getTranslationShift(mTempFloat)) {
+ effectiveShift -= mTempFloat[0];
+ postInvalidateOnAnimation();
+ }
+ }
+
+ int scroll = OverScroll.dampedScroll(effectiveShift * primarySize, primarySize);
+ mOrientationHandler.set(canvas, CANVAS_TRANSLATE, scroll);
+
+ if (mOverScrollShift != scroll) {
+ mOverScrollShift = scroll;
+ dispatchScrollChanged();
+ }
+
+ super.dispatchDraw(canvas);
+ canvas.restoreToCount(restoreCount);
+ } else {
+ if (mOverScrollShift != 0) {
+ mOverScrollShift = 0;
+ dispatchScrollChanged();
+ }
+ super.dispatchDraw(canvas);
+ }
+ if (LIVE_TILE.get() && mEnableDrawingLiveTile && mLiveTileParams.getTargetSet() != null) {
+ redrawLiveTile();
+ }
+ }
+
+ /**
+ * Returns the view shift due to overscroll
+ */
+ public int getOverScrollShift() {
+ return mOverScrollShift;
+ }
+
+ @Override
public Task onTaskThumbnailChanged(int taskId, ThumbnailData thumbnailData) {
if (mHandleTaskStackChanges) {
TaskView taskView = getTaskView(taskId);
@@ -745,18 +824,16 @@
ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setDuration(RECENTS_LAUNCH_DURATION);
appAnimator.setInterpolator(ACCEL_DEACCEL);
- appAnimator.addUpdateListener(new MultiValueUpdateListener() {
- @Override
- public void onUpdate(float percent) {
- SurfaceParams.Builder builder = new SurfaceParams.Builder(
- apps[apps.length - 1].leash);
- Matrix matrix = new Matrix();
- matrix.postScale(percent, percent);
- matrix.postTranslate(mActivity.getDeviceProfile().widthPx * (1 - percent) / 2,
- mActivity.getDeviceProfile().heightPx * (1 - percent) / 2);
- builder.withAlpha(percent).withMatrix(matrix);
- surfaceApplier.scheduleApply(builder.build());
- }
+ appAnimator.addUpdateListener(valueAnimator -> {
+ float percent = valueAnimator.getAnimatedFraction();
+ SurfaceParams.Builder builder = new SurfaceParams.Builder(
+ apps[apps.length - 1].leash);
+ Matrix matrix = new Matrix();
+ matrix.postScale(percent, percent);
+ matrix.postTranslate(mActivity.getDeviceProfile().widthPx * (1 - percent) / 2,
+ mActivity.getDeviceProfile().heightPx * (1 - percent) / 2);
+ builder.withAlpha(percent).withMatrix(matrix);
+ surfaceApplier.scheduleApply(builder.build());
});
anim.play(appAnimator);
anim.addListener(new AnimatorListenerAdapter() {
@@ -936,8 +1013,30 @@
}
@Override
- protected boolean snapToPageInFreeScroll() {
- return !showAsGrid();
+ protected void onNotSnappingToPageInFreeScroll() {
+ int finalPos = mScroller.getFinalX();
+ if (!showAsGrid() && finalPos > mMinScroll && finalPos < mMaxScroll) {
+ int firstPageScroll = getScrollForPage(!mIsRtl ? 0 : getPageCount() - 1);
+ int lastPageScroll = getScrollForPage(!mIsRtl ? getPageCount() - 1 : 0);
+
+ // If scrolling ends in the half of the added space that is closer to
+ // the end, settle to the end. Otherwise snap to the nearest page.
+ // If flinging past one of the ends, don't change the velocity as it
+ // will get stopped at the end anyway.
+ int pageSnapped = finalPos < (firstPageScroll + mMinScroll) / 2
+ ? mMinScroll
+ : finalPos > (lastPageScroll + mMaxScroll) / 2
+ ? mMaxScroll
+ : getScrollForPage(mNextPage);
+
+ mScroller.setFinalX(pageSnapped);
+ // Ensure the scroll/snap doesn't happen too fast;
+ int extraScrollDuration = OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION
+ - mScroller.getDuration();
+ if (extraScrollDuration > 0) {
+ mScroller.extendDuration(extraScrollDuration);
+ }
+ }
}
@Override
@@ -1197,7 +1296,7 @@
}
mClearAllButton.setFullscreenTranslationPrimary(accumulatedTranslationX);
- updateGridProperties(/*isTaskDismissal=*/false);
+ updateGridProperties();
}
public void getTaskSize(Rect outRect) {
@@ -1267,12 +1366,6 @@
// Update the high res thumbnail loader state
mModel.getThumbnailCache().getHighResLoadingState().setFlingingFast(isFlingingFast);
-
- mLiveTileTaskViewSimulator.setScroll(getScrollOffset());
- if (LIVE_TILE.get() && mEnableDrawingLiveTile
- && mLiveTileParams.getTargetSet() != null) {
- redrawLiveTile();
- }
return scrolling;
}
@@ -1421,7 +1514,12 @@
mFocusedTaskId = -1;
if (mRecentsAnimationController != null) {
- finishRecentsAnimation(true /* toRecents */, null);
+ if (LIVE_TILE.get() && mEnableDrawingLiveTile) {
+ // We are still drawing the live tile, finish it now to clean up.
+ finishRecentsAnimation(true /* toRecents */, null);
+ } else {
+ mRecentsAnimationController = null;
+ }
}
mLiveTileParams.setTargetSet(null);
mLiveTileTaskViewSimulator.setDrawsBelowRecents(true);
@@ -1558,7 +1656,7 @@
// When switching to tasks in quick switch, ensures the snapped page's scroll maintain
// invariant between quick switch and overview grid, to ensure a smooth animation
// transition.
- updateGridProperties(/*isTaskDismissal=*/false);
+ updateGridProperties();
}
}
@@ -1571,7 +1669,6 @@
updateOrientationHandler();
}
- setOnScrollChangeListener(null);
setEnableFreeScroll(true);
setEnableDrawingLiveTile(true);
if (!LIVE_TILE.get()) {
@@ -1732,13 +1829,26 @@
}
}
+ /** Updates TaskView and ClearAllButtion scaling and translation required to turn into grid
+ * layout.
+ * This method is used when no task dismissal has occurred.
+ */
+ private void updateGridProperties() {
+ updateGridProperties(null, -1);
+ }
+
/**
* Updates TaskView and ClearAllButton scaling and translation required to turn into grid
* layout.
* This method only calculates the potential position and depends on {@link #setGridProgress} to
- * apply the actual scaling and translation.
+ * apply the actual scaling and translation. This adds task translation animations in the case
+ * of task dismissals: e.g. when dismissedTask is not null.
+ *
+ * @param dismissedTask the TaskView dismissed, possibly null
+ * @param dismissedIndex the index at which the dismissedTask was prior to dismissal, if no
+ * dismissal occurred, this is unused
*/
- private void updateGridProperties(boolean isTaskDismissal) {
+ private void updateGridProperties(TaskView dismissedTask, int dismissedIndex) {
int taskCount = getTaskViewCount();
if (taskCount == 0) {
return;
@@ -1765,8 +1875,12 @@
int snappedPage = getNextPage();
TaskView snappedTaskView = getTaskViewAtByAbsoluteIndex(snappedPage);
+ boolean isTaskDismissal = dismissedTask != null;
+ float dismissedTaskWidth =
+ isTaskDismissal ? dismissedTask.getLayoutParams().width + mPageSpacing : 0;
+
if (!isTaskDismissal) {
- mTopIdSet.clear();
+ mTopRowIdSet.clear();
}
for (int i = 0; i < taskCount; i++) {
TaskView taskView = getTaskViewAt(i);
@@ -1801,13 +1915,14 @@
// calculate the distance focused task need to shift.
focusedTaskShift += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing;
}
- boolean isTopRow = isTaskDismissal ? mTopIdSet.contains(taskView.getTask().key.id)
+ int taskId = taskView.getTask().key.id;
+ boolean isTopRow = isTaskDismissal ? mTopRowIdSet.contains(taskId)
: topRowWidth <= bottomRowWidth;
if (isTopRow) {
gridTranslations[i] += topAccumulatedTranslationX;
topRowWidth += taskWidthAndSpacing;
topSet.add(i);
- mTopIdSet.add(taskView.getTask().key.id);
+ mTopRowIdSet.add(taskId);
taskView.setGridTranslationY(taskGridVerticalDiff);
@@ -1861,17 +1976,55 @@
snappedTaskGridTranslationX = gridTranslations[snappedPage - mTaskViewStartIndex];
}
-
+ // Animate task dismissTranslationX for tasks with index >= dismissed index and in the
+ // same row as the dismissed index, or if the dismissed task was the focused task. Offset
+ // successive task dismissal durations for a staggered effect.
+ ArrayList<Animator> gridTranslationAnimators = new ArrayList<>();
+ boolean isFocusedTaskDismissed =
+ isTaskDismissal && dismissedTask.getTask().key.id == mFocusedTaskId;
for (int i = 0; i < taskCount; i++) {
TaskView taskView = getTaskViewAt(i);
+ if (isFocusedTaskDismissed || (i >= dismissedIndex && isSameGridRow(dismissedTask,
+ taskView))) {
+ Animator taskDismissAnimator = ObjectAnimator.ofFloat(taskView,
+ taskView.getPrimaryDismissTranslationProperty(),
+ mIsRtl ? -dismissedTaskWidth : dismissedTaskWidth, 0f);
+ int additionalTranslationDuration =
+ i >= dismissedIndex ? (ADDITIONAL_DISMISS_TASK_TRANSLATION_DURATION * (
+ (i - dismissedIndex) / 2)) : 0;
+ taskDismissAnimator.setDuration(
+ DISMISS_TASK_TRANSLATION_DURATION + additionalTranslationDuration);
+ gridTranslationAnimators.add(taskDismissAnimator);
+ }
taskView.setGridTranslationX(gridTranslations[i] - snappedTaskGridTranslationX);
taskView.setNonFullscreenTranslationX(snappedTaskFullscreenScrollAdjustment);
}
+ AnimatorSet gridTranslationAnimatorSet = new AnimatorSet();
+ gridTranslationAnimatorSet.playTogether(gridTranslationAnimators);
+ gridTranslationAnimatorSet.addListener(new AnimatorListenerAdapter() {
+ @Override
+ // Allow the actions view to display again once in focus mode
+ public void onAnimationEnd(Animator animation) {
+ super.onAnimationEnd(animation);
+ if (getFocusedTaskView() == null) {
+ mActionsView.getScrollAlpha().setValue(1);
+ }
+ }
- // Use the accumulated translation of the longer row.
- float clearAllAccumulatedTranslation = mIsRtl ? Math.max(topAccumulatedTranslationX,
- bottomAccumulatedTranslationX) : Math.min(topAccumulatedTranslationX,
- bottomAccumulatedTranslationX);
+ @Override
+ // Hide the actions view if not in focus mode
+ public void onAnimationStart(Animator animation) {
+ super.onAnimationStart(animation);
+ if (getFocusedTaskView() == null) {
+ mActionsView.getScrollAlpha().setValue(0);
+ }
+ }
+ });
+ gridTranslationAnimatorSet.start();
+
+ // Use the accumulated translation of the row containing the last task.
+ float clearAllAccumulatedTranslation = topSet.contains(taskCount - 1)
+ ? topAccumulatedTranslationX : bottomAccumulatedTranslationX;
// If the last task is on the shorter row, ClearAllButton will embed into the shorter row
// which is not what we want. Compensate the width difference of the 2 rows in that case.
@@ -1889,13 +2042,14 @@
mIsRtl ? -shorterRowCompensation : shorterRowCompensation;
// If the total width is shorter than one grid's width, move ClearAllButton further away
- // accordingly.
+ // accordingly. Update longRowWidth if ClearAllButton has been moved.
float clearAllShortTotalCompensation = 0;
int longRowWidth = Math.max(topRowWidth, bottomRowWidth);
if (longRowWidth < mLastComputedGridSize.width()) {
float shortTotalCompensation = mLastComputedGridSize.width() - longRowWidth;
clearAllShortTotalCompensation =
mIsRtl ? -shortTotalCompensation : shortTotalCompensation;
+ longRowWidth = mLastComputedGridSize.width();
}
float clearAllTotalTranslationX =
@@ -1928,6 +2082,19 @@
setGridProgress(mGridProgress);
}
+ private boolean isSameGridRow(TaskView taskView1, TaskView taskView2) {
+ if (taskView1 == null || taskView2 == null) {
+ return false;
+ }
+ int taskId1 = taskView1.getTask().key.id;
+ int taskId2 = taskView2.getTask().key.id;
+ if (taskId1 == mFocusedTaskId || taskId2 == mFocusedTaskId) {
+ return false;
+ }
+ return (mTopRowIdSet.contains(taskId1) && mTopRowIdSet.contains(taskId2)) || (
+ !mTopRowIdSet.contains(taskId1) && !mTopRowIdSet.contains(taskId2));
+ }
+
/**
* Moves TaskView and ClearAllButton between carousel and 2 row grid.
*
@@ -2138,8 +2305,12 @@
}
int pageToSnapTo = mCurrentPage;
- if (draggedIndex < pageToSnapTo ||
- pageToSnapTo == (getTaskViewCount() - 1)) {
+ // Snap to start if focused task was dismissed, as after quick switch it could
+ // be at any page but the focused task always displays at the start.
+ if (taskView.getTask().key.id == mFocusedTaskId) {
+ pageToSnapTo = mTaskViewStartIndex;
+ } else if (draggedIndex < pageToSnapTo || pageToSnapTo == (getTaskViewCount()
+ - 1)) {
pageToSnapTo -= 1;
}
removeViewInLayout(taskView);
@@ -2150,7 +2321,7 @@
} else {
snapToPageImmediately(pageToSnapTo);
// Grid got messed up, reapply.
- updateGridProperties(/*isTaskDismissal=*/true);
+ updateGridProperties(taskView, draggedIndex - mTaskViewStartIndex);
if (showAsGrid() && getFocusedTaskView() == null) {
animateActionsViewOut();
}
@@ -2159,7 +2330,9 @@
// immediately available.
onLayout(false /* changed */, getLeft(), getTop(), getRight(), getBottom());
}
- resetTaskVisuals();
+ if (!showAsGrid()) {
+ resetTaskVisuals();
+ }
onDismissAnimationEnds();
mPendingAnimation = null;
}
@@ -2665,9 +2838,14 @@
public void initiateSplitSelect(TaskView taskView, SplitPositionOption splitPositionOption) {
mSplitHiddenTaskView = taskView;
- mSplitPlaceholderView.getSplitController().setInitialTaskSelect(taskView,
+ SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
+ splitController.setInitialTaskSelect(taskView,
splitPositionOption);
mSplitHiddenTaskViewIndex = indexOfChild(taskView);
+ mSplitPlaceholderView.setLayoutParams(
+ splitController.getLayoutParamsForActivePosition(getResources(),
+ mActivity.getDeviceProfile()));
+ mSplitPlaceholderView.setIcon(taskView.getIconView());
}
public PendingAnimation createSplitSelectInitAnimation() {
@@ -3075,7 +3253,6 @@
}
mRecentsAnimationController.finish(toRecents, () -> {
- mRecentsAnimationController = null;
if (onFinishComplete != null) {
onFinishComplete.run();
}
@@ -3085,6 +3262,7 @@
// typical example of this is (1) user swipes up from app to Overview (2) user
// taps on QSB (3) user goes back to Overview and launch the most recent task.
setCurrentTask(-1);
+ mRecentsAnimationController = null;
});
}
@@ -3147,8 +3325,8 @@
@Override
protected boolean getPageScrolls(int[] outPageScrolls, boolean layoutChildren,
ComputePageScrollsLogic scrollLogic) {
- boolean pageScrollChanged = super.getPageScrolls(outPageScrolls, layoutChildren,
- scrollLogic);
+ int[] newPageScrolls = new int[outPageScrolls.length];
+ super.getPageScrolls(newPageScrolls, layoutChildren, scrollLogic);
boolean showAsFullscreen = showAsFullscreen();
boolean showAsGrid = showAsGrid();
@@ -3160,6 +3338,7 @@
mClearAllButton.setScrollOffsetPrimary(mIsRtl ? clearAllWidthDiff : -clearAllWidthDiff);
}
+ boolean pageScrollChanged = false;
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
@@ -3171,9 +3350,10 @@
showAsGrid);
}
- if (scrollDiff != 0) {
- outPageScrolls[i] += scrollDiff;
+ final int pageScroll = newPageScrolls[i] + (int) scrollDiff;
+ if (outPageScrolls[i] != pageScroll) {
pageScrollChanged = true;
+ outPageScrolls[i] = pageScroll;
}
}
return pageScrollChanged;
@@ -3207,13 +3387,6 @@
return mClearAllButton;
}
- @Override
- protected boolean onOverscroll(int amount) {
- // overscroll should only be accepted on -1 direction (for clear all button)
- if ((amount > 0 && !mIsRtl) || (amount < 0 && mIsRtl)) return false;
- return super.onOverscroll(amount);
- }
-
/**
* @return How many pixels the running task is offset on the currently laid out dominant axis.
*/
@@ -3228,14 +3401,8 @@
if (pageIndex == -1) {
return 0;
}
- // Unbound the scroll (due to overscroll) if the adjacent tasks are offset away from it.
- // This allows the page to move freely, given there's no visual indication why it shouldn't.
- int boundedScroll = mOrientationHandler.getPrimaryScroll(this);
- int unboundedScroll = getUnboundedScroll();
- float unboundedProgress = mAdjacentPageOffset;
- int scroll = Math.round(unboundedScroll * unboundedProgress
- + boundedScroll * (1 - unboundedProgress));
- return getScrollForPage(pageIndex) - scroll;
+ return getScrollForPage(pageIndex) - mOrientationHandler.getPrimaryScroll(this)
+ + getOverScrollShift();
}
/**
@@ -3421,6 +3588,33 @@
void onEmptyMessageUpdated(boolean isEmpty);
}
+ /**
+ * Adds a listener for scroll changes
+ */
+ public void addOnScrollChangedListener(OnScrollChangedListener listener) {
+ mScrollListeners.add(listener);
+ }
+
+ /**
+ * Removes a previously added scroll change listener
+ */
+ public void removeOnScrollChangedListener(OnScrollChangedListener listener) {
+ mScrollListeners.remove(listener);
+ }
+
+ @Override
+ protected void onScrollChanged(int l, int t, int oldl, int oldt) {
+ super.onScrollChanged(l, t, oldl, oldt);
+ dispatchScrollChanged();
+ }
+
+ private void dispatchScrollChanged() {
+ mLiveTileTaskViewSimulator.setScroll(getScrollOffset());
+ for (int i = mScrollListeners.size() - 1; i >= 0; i--) {
+ mScrollListeners.get(i).onScrollChanged();
+ }
+ }
+
private static class PinnedStackAnimationListener<T extends BaseActivity> extends
IPipAnimationListener.Stub {
private T mActivity;
diff --git a/quickstep/src/com/android/quickstep/views/SplitPlaceholderView.java b/quickstep/src/com/android/quickstep/views/SplitPlaceholderView.java
index fb9be81..bb8bc11 100644
--- a/quickstep/src/com/android/quickstep/views/SplitPlaceholderView.java
+++ b/quickstep/src/com/android/quickstep/views/SplitPlaceholderView.java
@@ -19,11 +19,12 @@
import android.content.Context;
import android.util.AttributeSet;
import android.util.FloatProperty;
-import android.view.View;
+import android.view.Gravity;
+import android.widget.FrameLayout;
import com.android.quickstep.util.SplitSelectStateController;
-public class SplitPlaceholderView extends View {
+public class SplitPlaceholderView extends FrameLayout {
public static final FloatProperty<SplitPlaceholderView> ALPHA_FLOAT =
new FloatProperty<SplitPlaceholderView>("SplitViewAlpha") {
@@ -40,6 +41,7 @@
};
private SplitSelectStateController mSplitController;
+ private IconView mIcon;
public SplitPlaceholderView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -52,4 +54,15 @@
public SplitSelectStateController getSplitController() {
return mSplitController;
}
+
+ public void setIcon(IconView icon) {
+ if (mIcon == null) {
+ mIcon = new IconView(getContext());
+ addView(mIcon);
+ }
+ mIcon.setDrawable(icon.getDrawable());
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(icon.getLayoutParams());
+ params.gravity = Gravity.CENTER;
+ mIcon.setLayoutParams(params);
+ }
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index 658d71d..f55cdac 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -121,7 +121,7 @@
};
}
- private void setPosition(float x, float y) {
+ private void setPosition(float x, float y, int overscrollShift) {
PagedOrientationHandler pagedOrientationHandler = mTaskView.getPagedOrientationHandler();
int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
float adjustedY = y + taskTopMargin;
@@ -136,8 +136,9 @@
setPivotY(0);
}
setRotation(pagedOrientationHandler.getDegreesRotated());
- setX(pagedOrientationHandler.getTaskMenuX(x, mTaskView.getThumbnail()));
- setY(pagedOrientationHandler.getTaskMenuY(adjustedY, mTaskView.getThumbnail()));
+ setX(pagedOrientationHandler.getTaskMenuX(x, mTaskView.getThumbnail(), overscrollShift));
+ setY(pagedOrientationHandler.getTaskMenuY(
+ adjustedY, mTaskView.getThumbnail(), overscrollShift));
}
public void onRotationChanged() {
@@ -169,14 +170,15 @@
return false;
}
post(this::animateOpen);
- mActivity.getRootView().getViewTreeObserver().addOnScrollChangedListener(this);
+ ((RecentsView) mActivity.getOverviewPanel()).addOnScrollChangedListener(this);
return true;
}
@Override
public void onScrollChanged() {
RecentsView rv = mTaskView.getRecentsView();
- setPosition(mTaskView.getX() - rv.getScrollX(), mTaskView.getY() - rv.getScrollY());
+ setPosition(mTaskView.getX() - rv.getScrollX(), mTaskView.getY() - rv.getScrollY(),
+ rv.getOverScrollShift());
}
/** @return true if successfully able to populate task view menu, false otherwise */
@@ -236,7 +238,7 @@
.mOrientationState.isRecentsActivityRotationAllowed();
mOptionLayout.setOrientation(orientationHandler
.getTaskMenuLayoutOrientation(canActivityRotate, mOptionLayout));
- setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top);
+ setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
}
private void animateOpen() {
@@ -282,7 +284,7 @@
private void closeComplete() {
mIsOpen = false;
mActivity.getDragLayer().removeView(this);
- mActivity.getRootView().getViewTreeObserver().removeOnScrollChangedListener(this);
+ ((RecentsView) mActivity.getOverviewPanel()).removeOnScrollChangedListener(this);
}
private RoundedRectRevealOutlineProvider createOpenCloseOutlineProvider() {
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 2bb14d2..35acdd1 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -523,7 +523,7 @@
if (mTask != null) {
TestLogging.recordEvent(
TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask);
- ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this);
+ ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null);
if (ActivityManagerWrapper.getInstance()
.startActivityFromRecents(mTask.key, opts.options)) {
return opts.onEndCallback;
diff --git a/res/values-as/strings.xml b/res/values-as/strings.xml
index 08605ef..31ac27f 100644
--- a/res/values-as/strings.xml
+++ b/res/values-as/strings.xml
@@ -97,8 +97,8 @@
<string name="folder_name_format_exact" msgid="8626242716117004803">"ফ’ল্ডাৰ: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> টা বস্তু"</string>
<string name="folder_name_format_overflow" msgid="4270108890534995199">"ফ’ল্ডাৰ: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> টা অথবা তাতকৈ অধিক বস্তু"</string>
<string name="wallpaper_button_text" msgid="8404103075899945851">"ৱালপেপাৰসমূহ"</string>
- <string name="styles_wallpaper_button_text" msgid="4342122323125579619">"ষ্টাইল & ৱালপেপাৰ"</string>
- <string name="settings_button_text" msgid="8873672322605444408">"গৃহ ছেটিংসমূহ"</string>
+ <string name="styles_wallpaper_button_text" msgid="4342122323125579619">"শৈলী আৰু ৱালপেপাৰ"</string>
+ <string name="settings_button_text" msgid="8873672322605444408">"গৃহ ছেটিং"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"আপোনাৰ প্ৰশাসকে অক্ষম কৰি ৰাখিছে"</string>
<string name="allow_rotation_title" msgid="7728578836261442095">"গৃহ স্ক্ৰীণ ঘূৰোৱাৰ অনুমতি দিয়ক"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"ফ\'নটো যেতিয়া ঘূৰোৱা হয়"</string>
diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml
index 20821d3..c2d9946 100644
--- a/res/values-be/strings.xml
+++ b/res/values-be/strings.xml
@@ -115,7 +115,7 @@
<string name="msg_missing_notification_access" msgid="281113995110910548">"Каб паказваліся значкі апавяшчэнняў, уключыце апавяшчэнні праграм для <xliff:g id="NAME">%1$s</xliff:g>"</string>
<string name="title_change_settings" msgid="1376365968844349552">"Змяніць налады"</string>
<string name="notification_dots_service_title" msgid="4284221181793592871">"Паказваць значкі апавяшчэнняў"</string>
- <string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Дадаць значкі праграм на Галоўны экран"</string>
+ <string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Дадаваць значкі праграм на Галоўны экран"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Для новых праграм"</string>
<string name="package_state_unknown" msgid="7592128424511031410">"Невядома"</string>
<string name="abandoned_clean_this" msgid="7610119707847920412">"Выдаліць"</string>
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index a38c3d2..a485a14 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -66,7 +66,7 @@
<string name="all_apps_button_work_label" msgid="7270707118948892488">"Laneko aplikazioen zerrenda"</string>
<string name="remove_drop_target_label" msgid="7812859488053230776">"Kendu"</string>
<string name="uninstall_drop_target_label" msgid="4722034217958379417">"Desinstalatu"</string>
- <string name="app_info_drop_target_label" msgid="692894985365717661">"Aplikazioaren datuak"</string>
+ <string name="app_info_drop_target_label" msgid="692894985365717661">"Aplikazioaren informazioa"</string>
<string name="install_drop_target_label" msgid="2539096853673231757">"Instalatu"</string>
<string name="dismiss_prediction_label" msgid="3357562989568808658">"Ez iradoki aplikazioa"</string>
<string name="pin_prediction" msgid="4196423321649756498">"Ainguratu iragarpena"</string>
diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml
index d7e3a5b..34ed9e0 100644
--- a/res/values-fi/strings.xml
+++ b/res/values-fi/strings.xml
@@ -103,7 +103,7 @@
<string name="allow_rotation_title" msgid="7728578836261442095">"Salli aloitusnäytön kiertäminen"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"Kun puhelinta kierretään"</string>
<string name="notification_dots_title" msgid="9062440428204120317">"Pistemerkit"</string>
- <string name="notification_dots_desc_on" msgid="1679848116452218908">"Käytössä"</string>
+ <string name="notification_dots_desc_on" msgid="1679848116452218908">"Päällä"</string>
<string name="notification_dots_desc_off" msgid="1760796511504341095">"Ei päällä"</string>
<string name="title_missing_notification_access" msgid="7503287056163941064">"Ilmoituksien käyttöoikeus tarvitaan"</string>
<string name="msg_missing_notification_access" msgid="281113995110910548">"<xliff:g id="NAME">%1$s</xliff:g> tarvitsee ilmoitusten käyttöoikeuden, jotta pistemerkkejä voidaan näyttää."</string>
diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml
index 7d65a14..382f6ff 100644
--- a/res/values-gl/strings.xml
+++ b/res/values-gl/strings.xml
@@ -27,7 +27,7 @@
<string name="safemode_widget_error" msgid="4863470563535682004">"Os widgets están desactivados no modo seguro"</string>
<string name="shortcut_not_available" msgid="2536503539825726397">"O atallo non está dispoñible"</string>
<string name="home_screen" msgid="5629429142036709174">"Inicio"</string>
- <string name="recent_task_option_split_screen" msgid="6690461455618725183">"Dividir pantalla"</string>
+ <string name="recent_task_option_split_screen" msgid="6690461455618725183">"Pantalla dividida"</string>
<string name="long_press_widget_to_add" msgid="3587712543577675817">"Mantén premido un widget para movelo."</string>
<string name="long_accessible_way_to_add" msgid="2733588281439571974">"Toca dúas veces un widget e manteno premido para movelo ou utiliza accións personalizadas."</string>
<string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string>
@@ -108,7 +108,7 @@
<string name="title_missing_notification_access" msgid="7503287056163941064">"Necesítase acceso ás notificacións"</string>
<string name="msg_missing_notification_access" msgid="281113995110910548">"Para que se mostren os puntos de notificacións, activa as notificacións da aplicación <xliff:g id="NAME">%1$s</xliff:g>"</string>
<string name="title_change_settings" msgid="1376365968844349552">"Cambiar configuración"</string>
- <string name="notification_dots_service_title" msgid="4284221181793592871">"Mostrar puntos de notificacións"</string>
+ <string name="notification_dots_service_title" msgid="4284221181793592871">"Mostra puntos de notificacións"</string>
<string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Engadir iconas de aplicacións á pantalla de inicio"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Para novas aplicacións"</string>
<string name="package_state_unknown" msgid="7592128424511031410">"Descoñecido"</string>
diff --git a/res/values-is/strings.xml b/res/values-is/strings.xml
index 2397e92..104b4ac 100644
--- a/res/values-is/strings.xml
+++ b/res/values-is/strings.xml
@@ -100,7 +100,7 @@
<string name="styles_wallpaper_button_text" msgid="4342122323125579619">"Stílar og veggfóður"</string>
<string name="settings_button_text" msgid="8873672322605444408">"Heimastillingar"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Gert óvirkt af kerfisstjóra"</string>
- <string name="allow_rotation_title" msgid="7728578836261442095">"Leyfa snúning fyrir heimaskjá"</string>
+ <string name="allow_rotation_title" msgid="7728578836261442095">"Leyfa snúning á heimaskjá"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"Þegar símanum er snúið"</string>
<string name="notification_dots_title" msgid="9062440428204120317">"Tilkynningapunktar"</string>
<string name="notification_dots_desc_on" msgid="1679848116452218908">"Kveikt"</string>
diff --git a/res/values-lo/strings.xml b/res/values-lo/strings.xml
index 967a22e..3ce2c20 100644
--- a/res/values-lo/strings.xml
+++ b/res/values-lo/strings.xml
@@ -98,7 +98,7 @@
<string name="folder_name_format_overflow" msgid="4270108890534995199">"ໂຟນເດີ: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> ຫຼື ລາຍການເພີ່ມເຕີມ"</string>
<string name="wallpaper_button_text" msgid="8404103075899945851">"ພາບພື້ນຫຼັງ"</string>
<string name="styles_wallpaper_button_text" msgid="4342122323125579619">"ຮູບແບບ ແລະ ຮູບພື້ນຫຼັງ"</string>
- <string name="settings_button_text" msgid="8873672322605444408">"ການຕັ້ງຄ່າ Home"</string>
+ <string name="settings_button_text" msgid="8873672322605444408">"ການຕັ້ງຄ່າໜ້າຫຼັກ"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"ຖືກປິດການນຳໃຊ້ໂດຍຜູ້ເບິ່ງແຍງລະບົບຂອງທ່ານ"</string>
<string name="allow_rotation_title" msgid="7728578836261442095">"ອະນຸຍາດໃຫ້ໝຸນໜ້າຈໍຢູ່ໜ້າຫຼັກໄດ້"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"ເມື່ອໝຸນໂທລະສັບ"</string>
diff --git a/res/values-mk/strings.xml b/res/values-mk/strings.xml
index 247144d..ce79bde 100644
--- a/res/values-mk/strings.xml
+++ b/res/values-mk/strings.xml
@@ -109,7 +109,7 @@
<string name="msg_missing_notification_access" msgid="281113995110910548">"За да се прикажуваат „Точки за известување“, вклучете ги известувањата за апликацијата <xliff:g id="NAME">%1$s</xliff:g>"</string>
<string name="title_change_settings" msgid="1376365968844349552">"Промени ги поставките"</string>
<string name="notification_dots_service_title" msgid="4284221181793592871">"Прикажувај точки за известување"</string>
- <string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Додавај икони за апликации на почетен екран"</string>
+ <string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Додавај икони за апликации на почетниот екран"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"За нови апликации"</string>
<string name="package_state_unknown" msgid="7592128424511031410">"Непознато"</string>
<string name="abandoned_clean_this" msgid="7610119707847920412">"Отстрани"</string>
diff --git a/res/values-or/strings.xml b/res/values-or/strings.xml
index 03519ba..8505c8e 100644
--- a/res/values-or/strings.xml
+++ b/res/values-or/strings.xml
@@ -27,7 +27,7 @@
<string name="safemode_widget_error" msgid="4863470563535682004">"ନିରାପଦ ମୋଡରେ ୱିଜେଟ୍ ଅକ୍ଷମ କରାଗଲା"</string>
<string name="shortcut_not_available" msgid="2536503539825726397">"ଶର୍ଟକଟ୍ ଉପଲବ୍ଧ ନାହିଁ"</string>
<string name="home_screen" msgid="5629429142036709174">"ମୂଳପୃଷ୍ଠା"</string>
- <string name="recent_task_option_split_screen" msgid="6690461455618725183">"ସ୍ପ୍ଲିଟ୍ ସ୍କ୍ରିନ୍"</string>
+ <string name="recent_task_option_split_screen" msgid="6690461455618725183">"ସ୍କ୍ରିନକୁ ସ୍ପ୍ଲିଟ୍ କରନ୍ତୁ"</string>
<string name="long_press_widget_to_add" msgid="3587712543577675817">"ଏକ ୱିଜେଟକୁ ମୁଭ୍ କରିବା ପାଇଁ ସ୍ପର୍ଶ କରି ଧରି ରଖନ୍ତୁ।"</string>
<string name="long_accessible_way_to_add" msgid="2733588281439571974">"ଏକ ୱିଜେଟକୁ ମୁଭ୍ କରିବା ପାଇଁ ଦୁଇଥର-ଟାପ୍ କରି ଧରି ରଖନ୍ତୁ କିମ୍ବା କଷ୍ଟମ୍ କାର୍ଯ୍ୟଗୁଡ଼ିକୁ ବ୍ୟବହାର କରନ୍ତୁ।"</string>
<string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string>
diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml
index 5879f91..9e60efb 100644
--- a/res/values-sl/strings.xml
+++ b/res/values-sl/strings.xml
@@ -106,7 +106,7 @@
<string name="styles_wallpaper_button_text" msgid="4342122323125579619">"Slogi in ozadja"</string>
<string name="settings_button_text" msgid="8873672322605444408">"Domače nastavitve"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Onemogočil skrbnik."</string>
- <string name="allow_rotation_title" msgid="7728578836261442095">"Omogočanje sukanja začetnega zaslona"</string>
+ <string name="allow_rotation_title" msgid="7728578836261442095">"Omogoči sukanje začetnega zaslona"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"Ko se telefon zasuka"</string>
<string name="notification_dots_title" msgid="9062440428204120317">"Obvestilne pike"</string>
<string name="notification_dots_desc_on" msgid="1679848116452218908">"Vklopljeno"</string>
diff --git a/res/values-sq/strings.xml b/res/values-sq/strings.xml
index f2c16b4..1ed8070 100644
--- a/res/values-sq/strings.xml
+++ b/res/values-sq/strings.xml
@@ -100,7 +100,7 @@
<string name="styles_wallpaper_button_text" msgid="4342122323125579619">"Stilet dhe imazhet e sfondit"</string>
<string name="settings_button_text" msgid="8873672322605444408">"Cilësimet e ekranit bazë"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Çaktivizuar nga administratori"</string>
- <string name="allow_rotation_title" msgid="7728578836261442095">"Lejo rrotullimin e ekranit kryesor"</string>
+ <string name="allow_rotation_title" msgid="7728578836261442095">"Lejo rrotullimin e ekranit bazë"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"Kur telefoni rrotullohet"</string>
<string name="notification_dots_title" msgid="9062440428204120317">"Pikat e njoftimeve"</string>
<string name="notification_dots_desc_on" msgid="1679848116452218908">"Aktiv"</string>
diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml
index a3c7256..344f455 100644
--- a/res/values-te/strings.xml
+++ b/res/values-te/strings.xml
@@ -100,7 +100,7 @@
<string name="styles_wallpaper_button_text" msgid="4342122323125579619">"స్టయిల్స్ & వాల్పేపర్లు"</string>
<string name="settings_button_text" msgid="8873672322605444408">"హోమ్ సెట్టింగ్లు"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"మీ నిర్వాహకులు నిలిపివేసారు"</string>
- <string name="allow_rotation_title" msgid="7728578836261442095">"హోమ్ స్క్రీన్ భ్రమణాన్ని అనుమతించండి"</string>
+ <string name="allow_rotation_title" msgid="7728578836261442095">"హోమ్ స్క్రీన్ రొటేషన్ను అనుమతించండి"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"ఫోన్ను తిప్పినప్పుడు"</string>
<string name="notification_dots_title" msgid="9062440428204120317">"నోటిఫికేషన్ డాట్లు"</string>
<string name="notification_dots_desc_on" msgid="1679848116452218908">"ఆన్"</string>
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index e9412d9..cc9f594 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -165,7 +165,7 @@
}
@NonNull
- public ActivityOptionsWrapper getActivityLaunchOptions(View v) {
+ public ActivityOptionsWrapper getActivityLaunchOptions(View v, @Nullable ItemInfo item) {
int left = 0, top = 0;
int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
if (v instanceof BubbleTextView) {
@@ -192,7 +192,7 @@
return false;
}
- Bundle optsBundle = (v != null) ? getActivityLaunchOptions(v).toBundle() : null;
+ Bundle optsBundle = (v != null) ? getActivityLaunchOptions(v, item).toBundle() : null;
UserHandle user = item == null ? null : item.user;
// Prepare intent
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 3c85564..11dc0c4 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -18,7 +18,6 @@
import static com.android.launcher3.Utilities.getDevicePrefs;
import static com.android.launcher3.Utilities.getPointString;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TWO_PANEL_HOME;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_SIZE;
@@ -262,9 +261,6 @@
if (ENABLE_TWO_PANEL_HOME.get()) {
return ENABLE_TWO_PANEL_HOME.key;
}
- if (ENABLE_FOUR_COLUMNS.get()) {
- return ENABLE_FOUR_COLUMNS.key;
- }
return Utilities.isGridOptionsEnabled(context)
? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null;
}
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 4754558..11585f9 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -17,9 +17,6 @@
package com.android.launcher3;
import static com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS;
-import static com.android.launcher3.InvariantDeviceProfile.KEY_MIGRATION_SRC_HOTSEAT_COUNT;
-import static com.android.launcher3.InvariantDeviceProfile.KEY_MIGRATION_SRC_WORKSPACE_SIZE;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
@@ -126,33 +123,6 @@
mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context);
- // b/175329686 Temporary logic to gracefully migrate group of users to the new 4x5 grid.
- String gridName = InvariantDeviceProfile.getCurrentGridName(context);
- if (ENABLE_FOUR_COLUMNS.get()
- || "reasonable".equals(gridName)
- || ENABLE_FOUR_COLUMNS.key.equals(gridName)) {
- // Reset flag and remove it from developer options to prevent it from being enabled
- // again.
- ENABLE_FOUR_COLUMNS.reset(context);
- FeatureFlags.removeFlag(ENABLE_FOUR_COLUMNS);
-
- // Force migration code to run
- Utilities.getPrefs(context).edit()
- .remove(KEY_MIGRATION_SRC_HOTSEAT_COUNT)
- .remove(KEY_MIGRATION_SRC_WORKSPACE_SIZE)
- .apply();
-
- // We make an empty call here to ensure the database is created with the old IDP grid,
- // so that when we set the new grid the migration can proceeds as expected.
- LauncherSettings.Settings.call(context.getContentResolver(), "");
-
- String newGridName = "practical";
- Utilities.getPrefs(mContext).edit().putString("idp_grid_name", newGridName).commit();
- mInvariantDeviceProfile.setCurrentGrid(context, "practical");
- } else {
- FeatureFlags.removeFlag(ENABLE_FOUR_COLUMNS);
- }
-
mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName);
mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
mModel = new LauncherModel(context, this, mIconCache, new AppFilter(mContext));
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 7496703..c9cc372 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -16,16 +16,14 @@
package com.android.launcher3;
+import static com.android.launcher3.anim.Interpolators.SCROLL;
import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
import static com.android.launcher3.compat.AccessibilityManagerCompat.isObservedEventType;
-import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.launcher3.touch.OverScroll.OVERSCROLL_DAMP_FACTOR;
-import static com.android.launcher3.touch.PagedOrientationHandler.CANVAS_TRANSLATE;
import static com.android.launcher3.touch.PagedOrientationHandler.VIEW_SCROLL_BY;
import static com.android.launcher3.touch.PagedOrientationHandler.VIEW_SCROLL_TO;
import android.animation.LayoutTransition;
-import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
@@ -46,19 +44,17 @@
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
-import android.view.animation.Interpolator;
+import android.widget.OverScroller;
import android.widget.ScrollView;
import androidx.annotation.Nullable;
-import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.pageindicators.PageIndicator;
-import com.android.launcher3.touch.OverScroll;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.PagedOrientationHandler.ChildBounds;
-import com.android.launcher3.util.OverScroller;
+import com.android.launcher3.util.EdgeEffectCompat;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.views.ActivityContext;
@@ -80,9 +76,6 @@
public static final int PAGE_SNAP_ANIMATION_DURATION = 750;
- // OverScroll constants
- private final static int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;
-
private static final float RETURN_TO_ORIGINAL_PAGE_THRESHOLD = 0.33f;
// The page is moved more than halfway, automatically move to the next page on touch up.
private static final float SIGNIFICANT_MOVE_THRESHOLD = 0.4f;
@@ -113,7 +106,6 @@
protected int mMaxScroll;
protected int mMinScroll;
protected OverScroller mScroller;
- private Interpolator mDefaultInterpolator;
private VelocityTracker mVelocityTracker;
protected int mPageSpacing = 0;
@@ -144,12 +136,6 @@
protected boolean mIsPageInTransition = false;
private Runnable mOnPageTransitionEndCallback;
- protected float mSpringOverScroll;
-
- protected boolean mWasInOverscroll = false;
-
- protected int mUnboundedScroll;
-
// Page Indicator
@Thunk int mPageIndicatorViewId;
protected T mPageIndicator;
@@ -162,6 +148,9 @@
private int[] mTmpIntPair = new int[2];
+ protected EdgeEffectCompat mEdgeGlowLeft;
+ protected EdgeEffectCompat mEdgeGlowRight;
+
public PagedView(Context context) {
this(context, null);
}
@@ -181,8 +170,7 @@
setHapticFeedbackEnabled(false);
mIsRtl = Utilities.isRtl(getResources());
- mScroller = new OverScroller(context);
- setDefaultInterpolator(Interpolators.SCROLL);
+ mScroller = new OverScroller(context, SCROLL);
mCurrentPage = 0;
final ViewConfiguration configuration = ViewConfiguration.get(context);
@@ -196,12 +184,14 @@
mMinFlingVelocity = (int) (MIN_FLING_VELOCITY * density);
mMinSnapVelocity = (int) (MIN_SNAP_VELOCITY * density);
+ initEdgeEffect();
setDefaultFocusHighlightEnabled(false);
+ setWillNotDraw(false);
}
- protected void setDefaultInterpolator(Interpolator interpolator) {
- mDefaultInterpolator = interpolator;
- mScroller.setInterpolator(mDefaultInterpolator);
+ protected void initEdgeEffect() {
+ mEdgeGlowLeft = new EdgeEffectCompat(getContext());
+ mEdgeGlowRight = new EdgeEffectCompat(getContext());
}
public void initParentViews(View parent) {
@@ -256,7 +246,7 @@
newPosition = getScrollForPage(mCurrentPage);
}
mOrientationHandler.set(this, VIEW_SCROLL_TO, newPosition);
- mOrientationHandler.scrollerStartScroll(mScroller, newPosition);
+ mScroller.startScroll(mScroller.getCurrX(), 0, newPosition - mScroller.getCurrX(), 0);
forceFinishScroller(true);
}
@@ -420,7 +410,6 @@
* to provide custom behavior during animation.
*/
protected void onPageEndTransition() {
- mWasInOverscroll = false;
AccessibilityManagerCompat.sendScrollFinishedEventToTest(getContext());
AccessibilityManagerCompat.sendCustomAccessibilityEvent(getPageAt(mCurrentPage),
AccessibilityEvent.TYPE_VIEW_FOCUSED, null);
@@ -442,56 +431,12 @@
}
}
- protected int getUnboundedScroll() {
- return mUnboundedScroll;
- }
-
- @Override
- public void scrollBy(int x, int y) {
- mOrientationHandler.delegateScrollBy(this, getUnboundedScroll(), x, y);
- }
-
@Override
public void scrollTo(int x, int y) {
- int primaryScroll = mOrientationHandler.getPrimaryValue(x, y);
- int secondaryScroll = mOrientationHandler.getSecondaryValue(x, y);
- mUnboundedScroll = primaryScroll;
-
- boolean isBeforeFirstPage = mIsRtl ?
- (primaryScroll > mMaxScroll) : (primaryScroll < mMinScroll);
- boolean isAfterLastPage = mIsRtl ?
- (primaryScroll < mMinScroll) : (primaryScroll > mMaxScroll);
- if (!isBeforeFirstPage && !isAfterLastPage) {
- mSpringOverScroll = 0;
- }
-
- if (isBeforeFirstPage) {
- mOrientationHandler.delegateScrollTo(this,
- secondaryScroll, mIsRtl ? mMaxScroll : mMinScroll);
- if (mAllowOverScroll) {
- mWasInOverscroll = true;
- overScroll(primaryScroll - (mIsRtl ? mMaxScroll : mMinScroll));
- }
- } else if (isAfterLastPage) {
- mOrientationHandler.delegateScrollTo(this,
- secondaryScroll, mIsRtl ? mMinScroll : mMaxScroll);
- if (mAllowOverScroll) {
- mWasInOverscroll = true;
- overScroll(primaryScroll - (mIsRtl ? mMinScroll : mMaxScroll));
- }
- } else {
- if (mWasInOverscroll) {
- overScroll(0);
- mWasInOverscroll = false;
- }
- super.scrollTo(x, y);
- }
- }
-
- /**
- * Helper for {@link PagedOrientationHandler} to be able to call parent's scrollTo method
- */
- public void superScrollTo(int x, int y) {
+ x = Utilities.boundToRange(x,
+ mOrientationHandler.getPrimaryValue(mMinScroll, 0), mMaxScroll);
+ y = Utilities.boundToRange(y,
+ mOrientationHandler.getPrimaryValue(0, mMinScroll), mMaxScroll);
super.scrollTo(x, y);
}
@@ -524,12 +469,22 @@
protected boolean computeScrollHelper(boolean shouldInvalidate) {
if (mScroller.computeScrollOffset()) {
// Don't bother scrolling if the page does not need to be moved
- int currentScroll = mOrientationHandler.getPrimaryScroll(this);
- if (mUnboundedScroll != mScroller.getCurrPos()
- || currentScroll != mScroller.getCurrPos()) {
- mOrientationHandler.set(this, VIEW_SCROLL_TO, mScroller.getCurrPos());
+ int oldPos = mOrientationHandler.getPrimaryScroll(this);
+ int newPos = mScroller.getCurrX();
+ if (oldPos != newPos) {
+ mOrientationHandler.set(this, VIEW_SCROLL_TO, mScroller.getCurrX());
}
if (shouldInvalidate) {
+ if (mAllowOverScroll) {
+ if (newPos < mMinScroll && oldPos >= mMinScroll) {
+ mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
+ mScroller.abortAnimation();
+ } else if (newPos > mMaxScroll && oldPos <= mMaxScroll) {
+ mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
+ mScroller.abortAnimation();
+ }
+ }
+
invalidate();
}
return true;
@@ -982,9 +937,7 @@
mTotalMotion = 0;
mAllowEasyFling = false;
mActivePointerId = ev.getPointerId(0);
-
- updateIsBeingDraggedOnTouchDown();
-
+ updateIsBeingDraggedOnTouchDown(ev);
break;
}
@@ -1009,9 +962,9 @@
/**
* If being flinged and user touches the screen, initiate drag; otherwise don't.
*/
- private void updateIsBeingDraggedOnTouchDown() {
+ private void updateIsBeingDraggedOnTouchDown(MotionEvent ev) {
// mScroller.isFinished should be false when being flinged.
- final int xDist = Math.abs(mScroller.getFinalPos() - mScroller.getCurrPos());
+ final int xDist = Math.abs(mScroller.getFinalX() - mScroller.getCurrX());
final boolean finishedScrolling = (mScroller.isFinished() || xDist < mPageSlop / 3);
if (finishedScrolling) {
@@ -1020,9 +973,20 @@
setCurrentPage(getNextPage());
pageEndTransition();
}
+ mIsBeingDragged = !mEdgeGlowLeft.isFinished() || !mEdgeGlowRight.isFinished();
} else {
mIsBeingDragged = true;
}
+
+ // Catch the edge effect if it is active.
+ float displacement = mOrientationHandler.getSecondaryValue(ev.getX(), ev.getY())
+ / mOrientationHandler.getSecondaryValue(getWidth(), getHeight());
+ if (!mEdgeGlowLeft.isFinished()) {
+ mEdgeGlowLeft.onPullDistance(0f, 1f - displacement);
+ }
+ if (!mEdgeGlowRight.isFinished()) {
+ mEdgeGlowRight.onPullDistance(0f, displacement);
+ }
}
public boolean isHandlingTouch() {
@@ -1053,7 +1017,6 @@
mTotalMotion += Math.abs(mLastMotion - primaryDirection);
mLastMotion = primaryDirection;
mLastMotionRemainder = 0;
- onScrollInteractionBegin();
pageBeginTransition();
// Stop listening for things like pinches.
requestDisallowInterceptTouchEvent(true);
@@ -1114,69 +1077,6 @@
}
}
- @Override
- protected void dispatchDraw(Canvas canvas) {
- if (mScroller.isSpringing() && mSpringOverScroll != 0) {
- int saveCount = canvas.save();
- mOrientationHandler.set(canvas, CANVAS_TRANSLATE, -mSpringOverScroll);
- super.dispatchDraw(canvas);
-
- canvas.restoreToCount(saveCount);
- } else {
- super.dispatchDraw(canvas);
- }
- }
-
- /**
- * Returns the amount of overscroll caused by the spring in {@link OverScroller}.
- */
- private int getSpringOverScroll(int amount) {
- if (mScroller.isSpringing()) {
- return amount < 0
- ? mScroller.getCurrPos() - mMinScroll
- : Math.max(0, mScroller.getCurrPos() - mMaxScroll);
- } else {
- return 0;
- }
- }
-
- protected void dampedOverScroll(int amount) {
- if (amount == 0) {
- return;
- }
-
- int size = mOrientationHandler.getMeasuredSize(this);
- int overScrollAmount = OverScroll.dampedScroll(amount, size);
- if (mScroller.isSpringing()) {
- mSpringOverScroll = getSpringOverScroll(amount);
- invalidate();
- return;
- }
-
- int primaryScroll = mOrientationHandler.getPrimaryScroll(this);
- int boundedScroll = Utilities.boundToRange(primaryScroll, mMinScroll, mMaxScroll);
- mOrientationHandler.delegateScrollTo(this, boundedScroll + overScrollAmount);
- invalidate();
- }
-
- protected void overScroll(int amount) {
- if (mScroller.isSpringing()) {
- mSpringOverScroll = getSpringOverScroll(amount);
- invalidate();
- return;
- }
-
- if (amount == 0) return;
-
- if (mFreeScroll && !mScroller.isFinished()) {
- int scrollAmount = amount < 0 ? mMinScroll + amount : mMaxScroll + amount;
- mOrientationHandler.delegateScrollTo(this, scrollAmount);
- } else {
- dampedOverScroll(amount);
- }
- }
-
-
public void setEnableFreeScroll(boolean freeScroll) {
if (mFreeScroll == freeScroll) {
return;
@@ -1209,7 +1109,7 @@
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
- updateIsBeingDraggedOnTouchDown();
+ updateIsBeingDraggedOnTouchDown(ev);
/*
* If being flinged and user touches, stop the fling. isFinished
@@ -1228,7 +1128,6 @@
mAllowEasyFling = false;
mActivePointerId = ev.getPointerId(0);
if (mIsBeingDragged) {
- onScrollInteractionBegin();
pageBeginTransition();
}
break;
@@ -1245,19 +1144,62 @@
final int pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex == -1) return true;
+ float oldScroll = mOrientationHandler.getPrimaryScroll(this);
+ float dx = ev.getX(pointerIndex);
+ float dy = ev.getY(pointerIndex);
- float direction = mOrientationHandler.getPrimaryDirection(ev, pointerIndex);
+ float direction = mOrientationHandler.getPrimaryValue(dx, dy);
float delta = mLastMotion + mLastMotionRemainder - direction;
+
+ int width = getWidth();
+ int height = getHeight();
+ int size = mOrientationHandler.getPrimaryValue(width, height);
+
+ final float displacement = mOrientationHandler.getSecondaryValue(dx, dy)
+ / mOrientationHandler.getSecondaryValue(width, height);
mTotalMotion += Math.abs(delta);
+ if (mAllowOverScroll) {
+ float consumed = 0;
+ if (delta < 0 && mEdgeGlowRight.getDistance() != 0f) {
+ consumed = size * mEdgeGlowRight.onPullDistance(delta / size, displacement);
+ } else if (delta > 0 && mEdgeGlowLeft.getDistance() != 0f) {
+ consumed = -size * mEdgeGlowLeft.onPullDistance(
+ -delta / size, 1 - displacement);
+ }
+ delta -= consumed;
+ }
+
// Only scroll and update mLastMotionX if we have moved some discrete amount. We
// keep the remainder because we are actually testing if we've moved from the last
// scrolled position (which is discrete).
- if (Math.abs(delta) >= 1.0f) {
- mLastMotion = direction;
- mLastMotionRemainder = delta - (int) delta;
+ mLastMotion = direction;
+ int movedDelta = (int) delta;
+ mLastMotionRemainder = delta - movedDelta;
- mOrientationHandler.set(this, VIEW_SCROLL_BY, (int) delta);
+ if (delta != 0) {
+ mOrientationHandler.set(this, VIEW_SCROLL_BY, movedDelta);
+
+ if (mAllowOverScroll) {
+ final float pulledToX = oldScroll + delta;
+
+ if (pulledToX < mMinScroll) {
+ mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement);
+ if (!mEdgeGlowRight.isFinished()) {
+ mEdgeGlowRight.onRelease();
+ }
+ } else if (pulledToX > mMaxScroll) {
+ mEdgeGlowRight.onPullDistance(delta / size, displacement);
+ if (!mEdgeGlowLeft.isFinished()) {
+ mEdgeGlowLeft.onRelease();
+ }
+ }
+
+ if (!mEdgeGlowLeft.isFinished() || !mEdgeGlowRight.isFinished()) {
+ postInvalidateOnAnimation();
+ }
+ }
+
} else {
awakenScrollBars();
}
@@ -1335,45 +1277,24 @@
if (((initialScroll >= maxScroll) && (isVelocityLeft || !isFling)) ||
((initialScroll <= minScroll) && (!isVelocityLeft || !isFling))) {
- mScroller.springBack(initialScroll, minScroll, maxScroll);
+ mScroller.springBack(initialScroll, 0, minScroll, maxScroll, 0, 0);
mNextPage = getDestinationPage();
} else {
- mScroller.setInterpolator(mDefaultInterpolator);
- mScroller.fling(initialScroll, -velocity,
- minScroll, maxScroll,
- Math.round(getWidth() * 0.5f * OVERSCROLL_DAMP_FACTOR));
+ int velocity1 = -velocity;
+ // Continue a scroll or fling in progress
+ mScroller.fling(initialScroll, 0, velocity1, 0, minScroll, maxScroll, 0, 0,
+ Math.round(getWidth() * 0.5f * OVERSCROLL_DAMP_FACTOR), 0);
- int finalPos = mScroller.getFinalPos();
+ int finalPos = mScroller.getFinalX();
mNextPage = getDestinationPage(finalPos);
-
- int firstPageScroll = getScrollForPage(!mIsRtl ? 0 : getPageCount() - 1);
- int lastPageScroll = getScrollForPage(!mIsRtl ? getPageCount() - 1 : 0);
- if (snapToPageInFreeScroll() && finalPos > minScroll
- && finalPos < maxScroll) {
- // If scrolling ends in the half of the added space that is closer to
- // the end, settle to the end. Otherwise snap to the nearest page.
- // If flinging past one of the ends, don't change the velocity as it
- // will get stopped at the end anyway.
- int pageSnapped = finalPos < (firstPageScroll + minScroll) / 2
- ? minScroll
- : finalPos > (lastPageScroll + maxScroll) / 2
- ? maxScroll
- : getScrollForPage(mNextPage);
-
- mScroller.setFinalPos(pageSnapped);
- // Ensure the scroll/snap doesn't happen too fast;
- int extraScrollDuration = OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION
- - mScroller.getDuration();
- if (extraScrollDuration > 0) {
- mScroller.extendDuration(extraScrollDuration);
- }
- }
+ onNotSnappingToPageInFreeScroll();
}
invalidate();
}
- onScrollInteractionEnd();
}
+ mEdgeGlowLeft.onRelease();
+ mEdgeGlowRight.onRelease();
// End any intermediate reordering states
resetTouchState();
break;
@@ -1381,8 +1302,9 @@
case MotionEvent.ACTION_CANCEL:
if (mIsBeingDragged) {
snapToDestination();
- onScrollInteractionEnd();
}
+ mEdgeGlowLeft.onRelease();
+ mEdgeGlowRight.onRelease();
resetTouchState();
break;
@@ -1395,9 +1317,7 @@
return true;
}
- protected boolean snapToPageInFreeScroll() {
- return true;
- }
+ protected void onNotSnappingToPageInFreeScroll() { }
protected boolean shouldFlingForVelocity(int velocity) {
float threshold = mAllowEasyFling ? mEasyFlingThresholdVelocity : mFlingThresholdVelocity;
@@ -1410,15 +1330,6 @@
mActivePointerId = INVALID_POINTER;
}
- /**
- * Triggered by scrolling via touch
- */
- protected void onScrollInteractionBegin() {
- }
-
- protected void onScrollInteractionEnd() {
- }
-
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
@@ -1554,19 +1465,7 @@
}
protected void snapToDestination() {
- snapToPage(getDestinationPage(), getPageSnapDuration());
- }
-
- protected boolean isInOverScroll() {
- int scroll = mOrientationHandler.getPrimaryScroll(this);
- return scroll > mMaxScroll || scroll < mMinScroll;
- }
-
- protected int getPageSnapDuration() {
- if (isInOverScroll()) {
- return OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION;
- }
- return PAGE_SNAP_ANIMATION_DURATION;
+ snapToPage(getDestinationPage(), PAGE_SNAP_ANIMATION_DURATION);
}
// We want the duration of the page snap animation to be influenced by the distance that
@@ -1584,7 +1483,7 @@
int halfScreenSize = mOrientationHandler.getMeasuredSize(this) / 2;
final int newLoc = getScrollForPage(whichPage);
- int delta = newLoc - getUnboundedScroll();
+ int delta = newLoc - mOrientationHandler.getPrimaryScroll(this);
int duration = 0;
if (Math.abs(velocity) < mMinFlingVelocity) {
@@ -1609,12 +1508,7 @@
// interpolator at zero, ie. 5. We use 4 to make it a little slower.
duration = 4 * Math.round(1000 * Math.abs(distance / velocity));
- if (QUICKSTEP_SPRINGS.get() && mCurrentPage != whichPage) {
- return snapToPage(whichPage, delta, duration, false, null,
- velocity * Math.signum(delta), true);
- } else {
- return snapToPage(whichPage, delta, duration);
- }
+ return snapToPage(whichPage, delta, duration);
}
public boolean snapToPage(int whichPage) {
@@ -1622,32 +1516,26 @@
}
public boolean snapToPageImmediately(int whichPage) {
- return snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION, true, null);
+ return snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION, true);
}
public boolean snapToPage(int whichPage, int duration) {
- return snapToPage(whichPage, duration, false, null);
+ return snapToPage(whichPage, duration, false);
}
- public boolean snapToPage(int whichPage, int duration, TimeInterpolator interpolator) {
- return snapToPage(whichPage, duration, false, interpolator);
- }
-
- protected boolean snapToPage(int whichPage, int duration, boolean immediate,
- TimeInterpolator interpolator) {
+ protected boolean snapToPage(int whichPage, int duration, boolean immediate) {
whichPage = validateNewPage(whichPage);
int newLoc = getScrollForPage(whichPage);
- final int delta = newLoc - getUnboundedScroll();
- return snapToPage(whichPage, delta, duration, immediate, interpolator, 0, false);
+ final int delta = newLoc - mOrientationHandler.getPrimaryScroll(this);
+ return snapToPage(whichPage, delta, duration, immediate);
}
protected boolean snapToPage(int whichPage, int delta, int duration) {
- return snapToPage(whichPage, delta, duration, false, null, 0, false);
+ return snapToPage(whichPage, delta, duration, false);
}
- protected boolean snapToPage(int whichPage, int delta, int duration, boolean immediate,
- TimeInterpolator interpolator, float velocity, boolean spring) {
+ protected boolean snapToPage(int whichPage, int delta, int duration, boolean immediate) {
if (mFirstLayout) {
setCurrentPage(whichPage);
return false;
@@ -1677,18 +1565,7 @@
abortScrollerAnimation(false);
}
- if (interpolator != null) {
- mScroller.setInterpolator(interpolator);
- } else {
- mScroller.setInterpolator(mDefaultInterpolator);
- }
-
- if (spring && QUICKSTEP_SPRINGS.get()) {
- mScroller.startScrollSpring(getUnboundedScroll(), delta, duration, velocity);
- } else {
- mScroller.startScroll(getUnboundedScroll(), delta, duration);
- }
-
+ mScroller.startScroll(mOrientationHandler.getPrimaryScroll(this), 0, delta, 0, duration);
updatePageIndicator();
// Trigger a compute() to finish switching pages if necessary
@@ -1706,7 +1583,7 @@
snapToPage(getNextPage() - 1);
return true;
}
- return onOverscroll(-getMeasuredWidth());
+ return mAllowOverScroll;
}
public boolean scrollRight() {
@@ -1714,15 +1591,7 @@
snapToPage(getNextPage() + 1);
return true;
}
- return onOverscroll(getMeasuredWidth());
- }
-
- protected boolean onOverscroll(int amount) {
- if (!mAllowOverScroll) return false;
- onScrollInteractionBegin();
- overScroll(amount);
- onScrollInteractionEnd();
- return true;
+ return mAllowOverScroll;
}
@Override
@@ -1866,4 +1735,38 @@
mTmpIntPair[1] = rightChild;
return mTmpIntPair;
}
+
+ @Override
+ public void draw(Canvas canvas) {
+ super.draw(canvas);
+ drawEdgeEffect(canvas);
+ }
+
+ protected void drawEdgeEffect(Canvas canvas) {
+ if (mAllowOverScroll && (!mEdgeGlowRight.isFinished() || !mEdgeGlowLeft.isFinished())) {
+ final int width = getWidth();
+ final int height = getHeight();
+ if (!mEdgeGlowLeft.isFinished()) {
+ final int restoreCount = canvas.save();
+ canvas.rotate(-90);
+ canvas.translate(-height, Math.min(mMinScroll, getScrollX()));
+ mEdgeGlowLeft.setSize(height, width);
+ if (mEdgeGlowLeft.draw(canvas)) {
+ postInvalidateOnAnimation();
+ }
+ canvas.restoreToCount(restoreCount);
+ }
+ if (!mEdgeGlowRight.isFinished()) {
+ final int restoreCount = canvas.save();
+ canvas.rotate(90, width, 0);
+ canvas.translate(width, -(Math.max(mMaxScroll, getScrollX())));
+
+ mEdgeGlowRight.setSize(height, width);
+ if (mEdgeGlowRight.draw(canvas)) {
+ postInvalidateOnAnimation();
+ }
+ canvas.restoreToCount(restoreCount);
+ }
+ }
+ }
}
diff --git a/src/com/android/launcher3/SessionCommitReceiver.java b/src/com/android/launcher3/SessionCommitReceiver.java
index 5036104..fe58da9 100644
--- a/src/com/android/launcher3/SessionCommitReceiver.java
+++ b/src/com/android/launcher3/SessionCommitReceiver.java
@@ -71,7 +71,7 @@
return;
}
- Log.i(LOG,
+ Log.d(LOG,
"Adding package name to install queue. Package name: " + info.getAppPackageName()
+ ", has app icon: " + (info.getAppIcon() != null)
+ ", has app label: " + !TextUtils.isEmpty(info.getAppLabel()));
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 5d941a7..0c3a356 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -24,7 +24,6 @@
import static com.android.launcher3.LauncherState.FLAG_WORKSPACE_INACCESSIBLE;
import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.NORMAL;
-import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_OVERLAY;
@@ -96,10 +95,12 @@
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.touch.WorkspaceTouchListener;
+import com.android.launcher3.util.EdgeEffectCompat;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSparseArrayMap;
import com.android.launcher3.util.ItemInfoMatcher;
+import com.android.launcher3.util.OverlayEdgeEffect;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.WallpaperOffsetInterpolator;
@@ -245,10 +246,7 @@
private float mTransitionProgress;
// State related to Launcher Overlay
- LauncherOverlay mLauncherOverlay;
- boolean mScrollInteractionBegan;
- boolean mStartedSendingScrollEvents;
- float mLastOverlayScroll = 0;
+ private OverlayEdgeEffect mOverlayEdgeEffect;
boolean mOverlayShown = false;
private Runnable mOnOverlayHiddenCallback;
@@ -945,47 +943,25 @@
}
}
- protected void onScrollInteractionBegin() {
- super.onScrollInteractionBegin();
- mScrollInteractionBegan = true;
- }
-
- protected void onScrollInteractionEnd() {
- super.onScrollInteractionEnd();
- mScrollInteractionBegan = false;
- if (mStartedSendingScrollEvents) {
- mStartedSendingScrollEvents = false;
- mLauncherOverlay.onScrollInteractionEnd();
- }
- }
-
public void setLauncherOverlay(LauncherOverlay overlay) {
- mLauncherOverlay = overlay;
- // A new overlay has been set. Reset event tracking
- mStartedSendingScrollEvents = false;
+ mOverlayEdgeEffect = overlay == null ? null : new OverlayEdgeEffect(getContext(), overlay);
+ EdgeEffectCompat newEffect = overlay == null
+ ? new EdgeEffectCompat(getContext()) : mOverlayEdgeEffect;
+ if (mIsRtl) {
+ mEdgeGlowRight = newEffect;
+ } else {
+ mEdgeGlowLeft = newEffect;
+ }
onOverlayScrollChanged(0);
}
public boolean hasOverlay() {
- return mLauncherOverlay != null;
- }
-
- private boolean isScrollingOverlay() {
- return mLauncherOverlay != null &&
- ((mIsRtl && getUnboundedScroll() > mMaxScroll)
- || (!mIsRtl && getUnboundedScroll() < mMinScroll));
+ return mOverlayEdgeEffect != null;
}
@Override
protected void snapToDestination() {
- // If we're overscrolling the overlay, we make sure to immediately reset the PagedView
- // to it's baseline position instead of letting the overscroll settle. The overlay handles
- // it's own settling, and every gesture to the overlay should be self-contained and start
- // from 0, so we zero it out here.
- if (isScrollingOverlay()) {
- // We reset mWasInOverscroll so that PagedView doesn't zero out the overscroll
- // interaction when we call snapToPageImmediately.
- mWasInOverscroll = false;
+ if (mOverlayEdgeEffect != null && !mOverlayEdgeEffect.isFinished()) {
snapToPageImmediately(0);
} else {
super.snapToDestination();
@@ -1018,38 +994,6 @@
}
@Override
- protected void overScroll(int amount) {
- boolean shouldScrollOverlay = mLauncherOverlay != null && !mScroller.isSpringing() &&
- ((amount <= 0 && !mIsRtl) || (amount >= 0 && mIsRtl));
-
- boolean shouldZeroOverlay = mLauncherOverlay != null && mLastOverlayScroll != 0 &&
- ((amount >= 0 && !mIsRtl) || (amount <= 0 && mIsRtl));
-
- if (shouldScrollOverlay) {
- if (!mStartedSendingScrollEvents && mScrollInteractionBegan) {
- mStartedSendingScrollEvents = true;
- mLauncherOverlay.onScrollInteractionBegin();
- }
-
- mLastOverlayScroll = Math.abs(((float) amount) / getMeasuredWidth());
- mLauncherOverlay.onScrollChange(mLastOverlayScroll, mIsRtl);
- } else {
- dampedOverScroll(amount);
- }
-
- if (shouldZeroOverlay) {
- mLauncherOverlay.onScrollChange(0, mIsRtl);
- }
- }
-
- @Override
- protected boolean onOverscroll(int amount) {
- // Enforce overscroll on -1 direction
- if ((amount > 0 && !mIsRtl) || (amount < 0 && mIsRtl)) return false;
- return super.onOverscroll(amount);
- }
-
- @Override
protected boolean shouldFlingForVelocity(int velocityX) {
// When the overlay is moving, the fling or settle transition is controlled by the overlay.
return Float.compare(Math.abs(mOverlayTranslation), 0) == 0 &&
@@ -1377,10 +1321,6 @@
mOutlineProvider = outlineProvider;
}
- public void snapToPageFromOverView(int whichPage) {
- snapToPage(whichPage, OVERVIEW.getTransitionDuration(mLauncher), Interpolators.ZOOM_IN);
- }
-
private void onStartStateTransition(LauncherState state) {
mIsSwitchingState = true;
mTransitionProgress = 0;
@@ -2999,20 +2939,30 @@
* Similar to {@link #getFirstMatch} but optimized to finding a suitable view for the app close
* animation.
*
+ * @param preferredItemId The id of the preferred item to match to if it exists.
* @param packageName The package name of the app to match.
* @param user The user of the app to match.
*/
- public View getFirstMatchForAppClose(String packageName, UserHandle user) {
- List<CellLayout> cellLayouts = new ArrayList<>(getPanelCount() + 1);
- cellLayouts.add(getHotseat());
- getVisiblePages().forEach(page -> cellLayouts.add((CellLayout) page));
-
- final Workspace.ItemOperator packageAndUser = (ItemInfo info, View view) -> info != null
- && info.getTargetComponent() != null
- && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName)
- && info.user.equals(user);
+ public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user) {
+ final Workspace.ItemOperator preferredItem = (ItemInfo info, View view) ->
+ info != null && info.id == preferredItemId;
+ final Workspace.ItemOperator preferredItemInFolder = (info, view) -> {
+ if (info instanceof FolderInfo) {
+ FolderInfo folderInfo = (FolderInfo) info;
+ for (WorkspaceItemInfo shortcutInfo : folderInfo.contents) {
+ if (preferredItem.evaluate(shortcutInfo, view)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ };
final Workspace.ItemOperator packageAndUserAndApp = (ItemInfo info, View view) ->
- packageAndUser.evaluate(info, view) && info.itemType == ITEM_TYPE_APPLICATION;
+ info != null
+ && info.getTargetComponent() != null
+ && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName)
+ && info.user.equals(user)
+ && info.itemType == ITEM_TYPE_APPLICATION;
final Workspace.ItemOperator packageAndUserAndAppInFolder = (info, view) -> {
if (info instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) info;
@@ -3025,13 +2975,18 @@
return false;
};
+ List<CellLayout> cellLayouts = new ArrayList<>(getPanelCount() + 1);
+ cellLayouts.add(getHotseat());
+ getVisiblePages().forEach(page -> cellLayouts.add((CellLayout) page));
+
// Order: App icons, app in folder. Items in hotseat get returned first.
if (ADAPTIVE_ICON_WINDOW_ANIM.get()) {
- return getFirstMatch(cellLayouts, packageAndUserAndApp, packageAndUserAndAppInFolder);
+ return getFirstMatch(cellLayouts, preferredItem, preferredItemInFolder,
+ packageAndUserAndApp, packageAndUserAndAppInFolder);
} else {
// Do not use Folder as a criteria, since it'll cause a crash when trying to draw
// FolderAdaptiveIcon as the background.
- return getFirstMatch(cellLayouts, packageAndUserAndApp);
+ return getFirstMatch(cellLayouts, preferredItem, packageAndUserAndApp);
}
}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 272dfc2..7d5ed60 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -199,10 +199,6 @@
"EXPANDED_SMARTSPACE", false, "Expands smartspace height to two rows. "
+ "Any apps occupying the first row will be removed from workspace.");
- public static final DeviceFlag ENABLE_FOUR_COLUMNS = new DeviceFlag(
- "ENABLE_FOUR_COLUMNS", false, "Uses 4 columns in launcher grid."
- + "Warning: This will permanently alter your home screen items and is not reversible.");
-
// TODO: b/172467144 Remove ENABLE_LAUNCHER_ACTIVITY_THEME_CROSSFADE feature flag.
public static final BooleanFlag ENABLE_LAUNCHER_ACTIVITY_THEME_CROSSFADE = new DeviceFlag(
"ENABLE_LAUNCHER_ACTIVITY_THEME_CROSSFADE", false, "Enables a "
@@ -245,12 +241,6 @@
}
}
- public static void removeFlag(DebugFlag flag) {
- synchronized (sDebugFlags) {
- sDebugFlags.remove(flag);
- }
- }
-
static List<DebugFlag> getDebugFlags() {
synchronized (sDebugFlags) {
return new ArrayList<>(sDebugFlags);
@@ -328,15 +318,6 @@
.getBoolean(key, defaultValue);
}
- /**
- * Resets value to default value.
- */
- public void reset(Context context) {
- mCurrentValue = defaultValue;
- context.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE)
- .edit().putBoolean(key, defaultValue).apply();
- }
-
@Override
protected StringBuilder appendProps(StringBuilder src) {
return super.appendProps(src).append(", mCurrentValue=").append(mCurrentValue);
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index c1f4643..a4e8be6 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -42,7 +42,6 @@
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace.ItemOperator;
-import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -433,8 +432,7 @@
int scroll = getScrollForPage(getNextPage()) + hint;
int delta = scroll - getScrollX();
if (delta != 0) {
- mScroller.setInterpolator(Interpolators.DEACCEL);
- mScroller.startScroll(getScrollX(), delta, Folder.SCROLL_HINT_DURATION);
+ mScroller.startScroll(getScrollX(), 0, delta, 0, Folder.SCROLL_HINT_DURATION);
invalidate();
}
}
diff --git a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
index fd51ba8..29287d9 100644
--- a/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
+++ b/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
@@ -32,11 +32,13 @@
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.LauncherAppWidgetInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pm.InstallSessionHelper;
import com.android.launcher3.pm.PackageInstallInfo;
import com.android.launcher3.util.GridOccupancy;
+import com.android.launcher3.util.IOUtils;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.PackageManagerHelper;
@@ -126,6 +128,12 @@
}
SessionInfo sessionInfo = packageInstaller.getActiveSessionInfo(item.user,
packageName);
+
+ if (!packageInstaller.verifySessionInfo(sessionInfo)) {
+ Log.d(LOG, "Item info failed session info verification: "
+ + workspaceInfo);
+ }
+
List<LauncherActivityInfo> activities = launcherApps
.getActivityList(packageName, item.user);
boolean hasActivity = activities != null && !activities.isEmpty();
@@ -171,7 +179,15 @@
// Save the WorkspaceItemInfo for binding in the workspace
addedItemsFinal.add(itemInfo);
- Log.i(LOG, "Adding item info to workspace: " + itemInfo);
+ // log bitmap and label
+ Log.d(LOG, "Adding item info to workspace: " + itemInfo);
+ if (itemInfo instanceof ItemInfoWithIcon) {
+ ItemInfoWithIcon infoWithIcon = (ItemInfoWithIcon) itemInfo;
+
+ Log.d(LOG, "Item info icon base 64 string: "
+ + infoWithIcon.bitmap.icon == null
+ ? "null" : IOUtils.toBase64String(infoWithIcon.bitmap.icon));
+ }
}
}
diff --git a/src/com/android/launcher3/model/ItemInstallQueue.java b/src/com/android/launcher3/model/ItemInstallQueue.java
index 836d804..22cb46b 100644
--- a/src/com/android/launcher3/model/ItemInstallQueue.java
+++ b/src/com/android/launcher3/model/ItemInstallQueue.java
@@ -130,6 +130,7 @@
// Add the items and clear queue
if (!installQueue.isEmpty()) {
+ // add log
launcher.getModel().addAndBindAddedWorkspaceItems(installQueue);
}
mItems.clear();
@@ -184,14 +185,20 @@
}
private void queuePendingShortcutInfo(PendingInstallShortcutInfo info) {
+ final Exception stackTrace = new Exception();
+
// Queue the item up for adding if launcher has not loaded properly yet
MODEL_EXECUTOR.post(() -> {
Pair<ItemInfo, Object> itemInfo = info.getItemInfo(mContext);
if (itemInfo == null) {
- Log.i(LOG, "Adding PendingInstallShortcutInfo with no attached info to queue.");
+ Log.d(LOG,
+ "Adding PendingInstallShortcutInfo with no attached info to queue.",
+ stackTrace);
} else {
- Log.i(LOG, "Adding PendingInstallShortcutInfo to queue. Attached info: "
- + itemInfo.first);
+ Log.d(LOG,
+ "Adding PendingInstallShortcutInfo to queue. Attached info: "
+ + itemInfo.first,
+ stackTrace);
}
addToQueue(info);
diff --git a/src/com/android/launcher3/pm/InstallSessionHelper.java b/src/com/android/launcher3/pm/InstallSessionHelper.java
index 72f1c58..88db430 100644
--- a/src/com/android/launcher3/pm/InstallSessionHelper.java
+++ b/src/com/android/launcher3/pm/InstallSessionHelper.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionInfo;
import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
@@ -40,6 +41,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.ItemInstallQueue;
+import com.android.launcher3.util.IOUtils;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.MainThreadInitializedObject;
@@ -215,14 +217,8 @@
void tryQueuePromiseAppIcon(PackageInstaller.SessionInfo sessionInfo) {
if (FeatureFlags.PROMISE_APPS_NEW_INSTALLS.get()
&& SessionCommitReceiver.isEnabled(mAppContext)
- && verify(sessionInfo) != null
- && sessionInfo.getInstallReason() == PackageManager.INSTALL_REASON_USER
- && sessionInfo.getAppIcon() != null
- && !TextUtils.isEmpty(sessionInfo.getAppLabel())
- && !promiseIconAddedForId(sessionInfo.getSessionId())
- && !new PackageManagerHelper(mAppContext).isAppInstalled(
- sessionInfo.getAppPackageName(), getUserHandle(sessionInfo))) {
- Log.i(LOG, "Adding package name to install queue: "
+ && verifySessionInfo(sessionInfo)) {
+ Log.d(LOG, "Adding package name to install queue: "
+ sessionInfo.getAppPackageName());
ItemInstallQueue.INSTANCE.get(mAppContext)
@@ -233,6 +229,37 @@
}
}
+ public boolean verifySessionInfo(PackageInstaller.SessionInfo sessionInfo) {
+ boolean validSessionInfo = verify(sessionInfo) != null
+ && sessionInfo.getInstallReason() == PackageManager.INSTALL_REASON_USER
+ && sessionInfo.getAppIcon() != null
+ && !TextUtils.isEmpty(sessionInfo.getAppLabel())
+ && !promiseIconAddedForId(sessionInfo.getSessionId())
+ && !new PackageManagerHelper(mAppContext).isAppInstalled(
+ sessionInfo.getAppPackageName(), getUserHandle(sessionInfo));
+
+ if (sessionInfo != null) {
+ Bitmap appIcon = sessionInfo.getAppIcon();
+
+ Log.d(LOG, String.format(
+ "Verifying session info. Valid: %b, Session verified: %b, Install reason valid:"
+ + " %b, App icon: %s, App label: %s, Promise icon added: %b, "
+ + "App installed: %b.",
+ validSessionInfo,
+ verify(sessionInfo) != null,
+ sessionInfo.getInstallReason() == PackageManager.INSTALL_REASON_USER,
+ appIcon == null ? "null" : IOUtils.toBase64String(appIcon),
+ sessionInfo.getAppLabel(),
+ promiseIconAddedForId(sessionInfo.getSessionId()),
+ new PackageManagerHelper(mAppContext).isAppInstalled(
+ sessionInfo.getAppPackageName(), getUserHandle(sessionInfo))));
+ } else {
+ Log.d(LOG, "Verifying session info failed: session info null.");
+ }
+
+ return validSessionInfo;
+ }
+
public InstallSessionTracker registerInstallTracker(InstallSessionTracker.Callback callback) {
InstallSessionTracker tracker = new InstallSessionTracker(this, callback);
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index 2e54904..ce7dc07 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -180,7 +180,7 @@
LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class);
try {
launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null,
- launcher.getActivityLaunchOptions(v).toBundle());
+ launcher.getActivityLaunchOptions(v, item).toBundle());
return;
} catch (Exception e) {
Log.e(TAG, "Unable to launch market intent for package=" + packageName, e);
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 18e27a4..2254ab3 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -38,10 +38,8 @@
import android.widget.LinearLayout;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.util.OverScroller;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import java.util.Collections;
@@ -60,18 +58,23 @@
}
@Override
- public void delegateScrollTo(PagedView pagedView, int secondaryScroll, int minMaxScroll) {
- pagedView.superScrollTo(secondaryScroll, minMaxScroll);
+ public int getPrimaryValue(int x, int y) {
+ return y;
}
@Override
- public void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y) {
- pagedView.scrollTo(pagedView.getScrollX() + x, unboundedScroll + y);
+ public int getSecondaryValue(int x, int y) {
+ return x;
}
@Override
- public void scrollerStartScroll(OverScroller scroller, int newPosition) {
- scroller.startScroll(scroller.getCurrPos(), newPosition - scroller.getCurrPos());
+ public float getPrimaryValue(float x, float y) {
+ return y;
+ }
+
+ @Override
+ public float getSecondaryValue(float x, float y) {
+ return x;
}
@Override
@@ -87,11 +90,6 @@
}
@Override
- public void delegateScrollTo(PagedView pagedView, int primaryScroll) {
- pagedView.superScrollTo(pagedView.getScrollX(), primaryScroll);
- }
-
- @Override
public <T> void set(T target, Int2DAction<T> action, int param) {
action.call(target, 0, param);
}
@@ -241,13 +239,13 @@
}
@Override
- public float getTaskMenuX(float x, View thumbnailView) {
+ public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
return thumbnailView.getMeasuredWidth() + x;
}
@Override
- public float getTaskMenuY(float y, View thumbnailView) {
- return y;
+ public float getTaskMenuY(float y, View thumbnailView, int overScroll) {
+ return y + overScroll;
}
@Override
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index 560df86..c9149ff 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -30,8 +30,6 @@
import android.widget.LinearLayout;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.PagedView;
-import com.android.launcher3.util.OverScroller;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
@@ -89,16 +87,19 @@
boolean getRecentsRtlSetting(Resources resources);
float getDegreesRotated();
int getRotation();
+
<T> T getPrimaryValue(T x, T y);
<T> T getSecondaryValue(T x, T y);
- void delegateScrollTo(PagedView pagedView, int secondaryScroll, int primaryScroll);
- /** Uses {@params pagedView}.getScroll[X|Y]() method for the secondary amount*/
- void delegateScrollTo(PagedView pagedView, int primaryScroll);
- void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y);
- void scrollerStartScroll(OverScroller scroller, int newPosition);
+
+ int getPrimaryValue(int x, int y);
+ int getSecondaryValue(int x, int y);
+
+ float getPrimaryValue(float x, float y);
+ float getSecondaryValue(float x, float y);
+
boolean isLayoutNaturalToLauncher();
- float getTaskMenuX(float x, View thumbnailView);
- float getTaskMenuY(float y, View thumbnailView);
+ float getTaskMenuX(float x, View thumbnailView, int overScroll);
+ float getTaskMenuY(float y, View thumbnailView, int overScroll);
int getTaskMenuWidth(View view);
int getTaskMenuLayoutOrientation(boolean canRecentsActivityRotate, LinearLayout taskMenuLayout);
void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp);
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index 86508c4..31586e7 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -36,10 +36,8 @@
import android.widget.LinearLayout;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.PagedView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.util.OverScroller;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import java.util.ArrayList;
@@ -58,18 +56,23 @@
}
@Override
- public void delegateScrollTo(PagedView pagedView, int secondaryScroll, int primaryScroll) {
- pagedView.superScrollTo(primaryScroll, secondaryScroll);
+ public int getPrimaryValue(int x, int y) {
+ return x;
}
@Override
- public void delegateScrollBy(PagedView pagedView, int unboundedScroll, int x, int y) {
- pagedView.scrollTo(unboundedScroll + x, pagedView.getScrollY() + y);
+ public int getSecondaryValue(int x, int y) {
+ return y;
}
@Override
- public void scrollerStartScroll(OverScroller scroller, int newPosition) {
- scroller.startScroll(newPosition - scroller.getCurrPos(), scroller.getCurrPos());
+ public float getPrimaryValue(float x, float y) {
+ return x;
+ }
+
+ @Override
+ public float getSecondaryValue(float x, float y) {
+ return y;
}
@Override
@@ -83,11 +86,6 @@
}
@Override
- public void delegateScrollTo(PagedView pagedView, int primaryScroll) {
- pagedView.superScrollTo(primaryScroll, pagedView.getScrollY());
- }
-
- @Override
public <T> void set(T target, Int2DAction<T> action, int param) {
action.call(target, param, 0);
}
@@ -240,12 +238,12 @@
}
@Override
- public float getTaskMenuX(float x, View thumbnailView) {
- return x;
+ public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
+ return x + overScroll;
}
@Override
- public float getTaskMenuY(float y, View thumbnailView) {
+ public float getTaskMenuY(float y, View thumbnailView, int overScroll) {
return y;
}
@@ -313,21 +311,31 @@
@Override
public List<SplitPositionOption> getSplitPositionOptions(DeviceProfile dp) {
List<SplitPositionOption> options = new ArrayList<>(1);
+ // Add both left and right options if we're in tablet mode
// TODO: Add in correct icons
- if (dp.isSeascape()) { // or seascape
- // Add left/right options
+ if (dp.isTablet && dp.isLandscape) {
options.add(new SplitPositionOption(
R.drawable.ic_split_screen, R.string.split_screen_position_right,
- STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
- } else if (dp.isLandscape) {
+ STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN));
options.add(new SplitPositionOption(
R.drawable.ic_split_screen, R.string.split_screen_position_left,
STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
} else {
- // Only add top option
- options.add(new SplitPositionOption(
- R.drawable.ic_split_screen, R.string.split_screen_position_top,
- STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
+ if (dp.isSeascape()) {
+ // Add left/right options
+ options.add(new SplitPositionOption(
+ R.drawable.ic_split_screen, R.string.split_screen_position_right,
+ STAGE_POSITION_BOTTOM_OR_RIGHT, STAGE_TYPE_MAIN));
+ } else if (dp.isLandscape) {
+ options.add(new SplitPositionOption(
+ R.drawable.ic_split_screen, R.string.split_screen_position_left,
+ STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
+ } else {
+ // Only add top option
+ options.add(new SplitPositionOption(
+ R.drawable.ic_split_screen, R.string.split_screen_position_top,
+ STAGE_POSITION_TOP_OR_LEFT, STAGE_TYPE_MAIN));
+ }
}
return options;
}
diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
index bd6e31b..893a274 100644
--- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
@@ -79,13 +79,13 @@
}
@Override
- public float getTaskMenuX(float x, View thumbnailView) {
+ public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
return x;
}
@Override
- public float getTaskMenuY(float y, View thumbnailView) {
- return y + thumbnailView.getMeasuredHeight();
+ public float getTaskMenuY(float y, View thumbnailView, int overScroll) {
+ return y + thumbnailView.getMeasuredHeight() + overScroll;
}
@Override
diff --git a/src/com/android/launcher3/util/ActivityTracker.java b/src/com/android/launcher3/util/ActivityTracker.java
index 59266b4..b5b9c2f 100644
--- a/src/com/android/launcher3/util/ActivityTracker.java
+++ b/src/com/android/launcher3/util/ActivityTracker.java
@@ -75,9 +75,8 @@
private boolean handleIntent(T activity, Intent intent, boolean alreadyOnHome) {
if (intent != null && intent.getExtras() != null) {
IBinder stateBinder = intent.getExtras().getBinder(EXTRA_SCHEDULER_CALLBACK);
- if (stateBinder instanceof ObjectWrapper) {
- SchedulerCallback<T> handler =
- ((ObjectWrapper<SchedulerCallback>) stateBinder).get();
+ SchedulerCallback<T> handler = ObjectWrapper.unwrap(stateBinder);
+ if (handler != null) {
if (!handler.init(activity, alreadyOnHome)) {
intent.getExtras().remove(EXTRA_SCHEDULER_CALLBACK);
}
diff --git a/src/com/android/launcher3/util/EdgeEffectCompat.java b/src/com/android/launcher3/util/EdgeEffectCompat.java
new file mode 100644
index 0000000..491582b
--- /dev/null
+++ b/src/com/android/launcher3/util/EdgeEffectCompat.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 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.launcher3.util;
+
+import android.content.Context;
+import android.widget.EdgeEffect;
+
+import com.android.launcher3.Utilities;
+
+/**
+ * Extension of {@link EdgeEffect} to allow backwards compatibility
+ */
+public class EdgeEffectCompat extends EdgeEffect {
+
+ public EdgeEffectCompat(Context context) {
+ super(context);
+ }
+
+ @Override
+ public float getDistance() {
+ return Utilities.ATLEAST_S ? super.getDistance() : 0;
+ }
+
+ @Override
+ public float onPullDistance(float deltaDistance, float displacement) {
+ if (Utilities.ATLEAST_S) {
+ return super.onPullDistance(deltaDistance, displacement);
+ } else {
+ onPull(deltaDistance, displacement);
+ return deltaDistance;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/util/IOUtils.java b/src/com/android/launcher3/util/IOUtils.java
index 1cec0ec..d7fa905 100644
--- a/src/com/android/launcher3/util/IOUtils.java
+++ b/src/com/android/launcher3/util/IOUtils.java
@@ -16,7 +16,9 @@
package com.android.launcher3.util;
+import android.graphics.Bitmap;
import android.os.FileUtils;
+import android.util.Base64;
import android.util.Log;
import com.android.launcher3.Utilities;
@@ -50,6 +52,12 @@
return out.toByteArray();
}
+ public static String toBase64String(Bitmap bitmap) {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
+ return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT);
+ }
+
public static long copy(InputStream from, OutputStream to) throws IOException {
if (Utilities.ATLEAST_Q) {
return FileUtils.copy(from, to);
diff --git a/src/com/android/launcher3/util/ObjectWrapper.java b/src/com/android/launcher3/util/ObjectWrapper.java
index e5b4707..a715821 100644
--- a/src/com/android/launcher3/util/ObjectWrapper.java
+++ b/src/com/android/launcher3/util/ObjectWrapper.java
@@ -42,4 +42,11 @@
public static IBinder wrap(Object obj) {
return new ObjectWrapper<>(obj);
}
+
+ public static <T> T unwrap(IBinder binder) {
+ if (binder instanceof ObjectWrapper) {
+ return ((ObjectWrapper<T>) binder).get();
+ }
+ return null;
+ }
}
diff --git a/src/com/android/launcher3/util/OverScroller.java b/src/com/android/launcher3/util/OverScroller.java
deleted file mode 100644
index 87e6986..0000000
--- a/src/com/android/launcher3/util/OverScroller.java
+++ /dev/null
@@ -1,867 +0,0 @@
-/*
- * Copyright (C) 2010 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.launcher3.util;
-
-import static com.android.launcher3.anim.Interpolators.SCROLL;
-
-import android.animation.TimeInterpolator;
-import android.content.Context;
-import android.hardware.SensorManager;
-import android.util.Log;
-import android.view.ViewConfiguration;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
-
-import androidx.dynamicanimation.animation.FloatPropertyCompat;
-import androidx.dynamicanimation.animation.SpringAnimation;
-import androidx.dynamicanimation.animation.SpringForce;
-
-import com.android.launcher3.R;
-import com.android.systemui.plugins.ResourceProvider;
-
-/**
- * Based on {@link android.widget.OverScroller} supporting only 1-d scrolling and with more
- * customization options.
- */
-public class OverScroller {
- private int mMode;
-
- private final SplineOverScroller mScroller;
-
- private TimeInterpolator mInterpolator;
-
- private final boolean mFlywheel;
-
- private static final int DEFAULT_DURATION = 250;
- private static final int SCROLL_MODE = 0;
- private static final int FLING_MODE = 1;
-
- /**
- * Creates an OverScroller with a viscous fluid scroll interpolator and flywheel.
- * @param context
- */
- public OverScroller(Context context) {
- this(context, null);
- }
-
- /**
- * Creates an OverScroller with flywheel enabled.
- * @param context The context of this application.
- * @param interpolator The scroll interpolator. If null, a default (viscous) interpolator will
- * be used.
- */
- public OverScroller(Context context, Interpolator interpolator) {
- this(context, interpolator, true);
- }
-
- /**
- * Creates an OverScroller.
- * @param context The context of this application.
- * @param interpolator The scroll interpolator. If null, a default (viscous) interpolator will
- * be used.
- * @param flywheel If true, successive fling motions will keep on increasing scroll speed.
- */
- public OverScroller(Context context, Interpolator interpolator, boolean flywheel) {
- if (interpolator == null) {
- mInterpolator = SCROLL;
- } else {
- mInterpolator = interpolator;
- }
- mFlywheel = flywheel;
- mScroller = new SplineOverScroller(context);
- }
-
- public void setInterpolator(TimeInterpolator interpolator) {
- if (interpolator == null) {
- mInterpolator = SCROLL;
- } else {
- mInterpolator = interpolator;
- }
- }
-
- /**
- * The amount of friction applied to flings. The default value
- * is {@link ViewConfiguration#getScrollFriction}.
- *
- * @param friction A scalar dimension-less value representing the coefficient of
- * friction.
- */
- public final void setFriction(float friction) {
- mScroller.setFriction(friction);
- }
-
- /**
- *
- * Returns whether the scroller has finished scrolling.
- *
- * @return True if the scroller has finished scrolling, false otherwise.
- */
- public final boolean isFinished() {
- return mScroller.mFinished;
- }
-
- /**
- * Force the finished field to a particular value. Contrary to
- * {@link #abortAnimation()}, forcing the animation to finished
- * does NOT cause the scroller to move to the final x and y
- * position.
- *
- * @param finished The new finished value.
- */
- public final void forceFinished(boolean finished) {
- mScroller.mFinished = finished;
- }
-
- /**
- * Returns the current offset in the scroll.
- *
- * @return The new offset as an absolute distance from the origin.
- */
- public final int getCurrPos() {
- return mScroller.mCurrentPosition;
- }
-
- /**
- * Returns the absolute value of the current velocity.
- *
- * @return The original velocity less the deceleration, norm of the X and Y velocity vector.
- */
- public float getCurrVelocity() {
- return mScroller.mCurrVelocity;
- }
-
- /**
- * Returns the start offset in the scroll.
- *
- * @return The start offset as an absolute distance from the origin.
- */
- public final int getStartPos() {
- return mScroller.mStart;
- }
-
- /**
- * Returns where the scroll will end. Valid only for "fling" scrolls.
- *
- * @return The final offset as an absolute distance from the origin.
- */
- public final int getFinalPos() {
- return mScroller.mFinal;
- }
-
- /**
- * Returns how long the scroll event will take, in milliseconds.
- *
- * Note that if mScroller.mState == SPRING, this duration is ignored, so can only
- * serve as an estimate for how long the spring-controlled scroll will take.
- *
- * @return The duration of the scroll in milliseconds.
- */
- public final int getDuration() {
- return mScroller.mDuration;
- }
-
- /**
- * Extend the scroll animation. This allows a running animation to scroll
- * further and longer, when used with {@link #setFinalPos(int)}.
- *
- * @param extend Additional time to scroll in milliseconds.
- * @see #setFinalPos(int)
- */
- public void extendDuration(int extend) {
- mScroller.extendDuration(extend);
- }
-
- /**
- * Sets the final position for this scroller.
- *
- * @param newPos The new offset as an absolute distance from the origin.
- * @see #extendDuration(int)
- */
- public void setFinalPos(int newPos) {
- mScroller.setFinalPosition(newPos);
- }
-
- /**
- * Call this when you want to know the new location. If it returns true, the
- * animation is not yet finished.
- */
- public boolean computeScrollOffset() {
- if (isFinished()) {
- return false;
- }
-
- switch (mMode) {
- case SCROLL_MODE:
- if (isSpringing()) {
- return true;
- }
- long time = AnimationUtils.currentAnimationTimeMillis();
- // Any scroller can be used for time, since they were started
- // together in scroll mode. We use X here.
- final long elapsedTime = time - mScroller.mStartTime;
-
- final int duration = mScroller.mDuration;
- if (elapsedTime < duration) {
- final float q = mInterpolator.getInterpolation(elapsedTime / (float) duration);
- mScroller.updateScroll(q);
- } else {
- abortAnimation();
- }
- break;
-
- case FLING_MODE:
- if (!mScroller.mFinished) {
- if (!mScroller.update()) {
- if (!mScroller.continueWhenFinished()) {
- mScroller.finish();
- }
- }
- }
-
- break;
- }
-
- return true;
- }
-
- /**
- * Start scrolling by providing a starting point and the distance to travel.
- * The scroll will use the default value of 250 milliseconds for the
- * duration.
- *
- * @param start Starting horizontal scroll offset in pixels. Positive
- * numbers will scroll the content to the left.
- * @param delta Distance to travel. Positive numbers will scroll the
- * content to the left.
- */
- public void startScroll(int start, int delta) {
- startScroll(start, delta, DEFAULT_DURATION);
- }
-
- /**
- * Start scrolling by providing a starting point and the distance to travel.
- *
- * @param start Starting scroll offset in pixels. Positive
- * numbers will scroll the content to the left.
- * @param delta Distance to travel. Positive numbers will scroll the
- * content to the left.
- * @param duration Duration of the scroll in milliseconds.
- */
- public void startScroll(int start, int delta, int duration) {
- mMode = SCROLL_MODE;
- mScroller.startScroll(start, delta, duration);
- }
-
- /**
- * Start scrolling using a spring by providing a starting point and the distance to travel.
- *
- * @param start Starting scroll offset in pixels. Positive
- * numbers will scroll the content to the left.
- * @param delta Distance to travel. Positive numbers will scroll the
- * content to the left.
- * @param duration Duration of the scroll in milliseconds.
- * @param velocity The starting velocity for the spring in px per ms.
- */
- public void startScrollSpring(int start, int delta, int duration, float velocity) {
- mMode = SCROLL_MODE;
- mScroller.mState = mScroller.SPRING;
- mScroller.startScroll(start, delta, duration, velocity);
- }
-
- /**
- * Call this when you want to 'spring back' into a valid coordinate range.
- *
- * @param start Starting X coordinate
- * @param min Minimum valid X value
- * @param max Maximum valid X value
- * @return true if a springback was initiated, false if startX and startY were
- * already within the valid range.
- */
- public boolean springBack(int start, int min, int max) {
- mMode = FLING_MODE;
- return mScroller.springback(start, min, max);
- }
-
- public void fling(int start, int velocity, int min, int max) {
- fling(start, velocity, min, max, 0);
- }
-
- /**
- * Start scrolling based on a fling gesture. The distance traveled will
- * depend on the initial velocity of the fling.
- * @param start Starting point of the scroll (X)
- * @param velocity Initial velocity of the fling (X) measured in pixels per
- * second.
- * @param min Minimum X value. The scroller will not scroll past this point
- * unless overX > 0. If overfling is allowed, it will use minX as
- * a springback boundary.
- * @param max Maximum X value. The scroller will not scroll past this point
-* unless overX > 0. If overfling is allowed, it will use maxX as
-* a springback boundary.
- * @param over Overfling range. If > 0, horizontal overfling in either
-* direction will be possible.
- */
- public void fling(int start, int velocity, int min, int max, int over) {
- // Continue a scroll or fling in progress
- if (mFlywheel && !isFinished()) {
- float oldVelocityX = mScroller.mCurrVelocity;
- if (Math.signum(velocity) == Math.signum(oldVelocityX)) {
- velocity += oldVelocityX;
- }
- }
-
- mMode = FLING_MODE;
- mScroller.fling(start, velocity, min, max, over);
- }
-
- /**
- * Notify the scroller that we've reached a horizontal boundary.
- * Normally the information to handle this will already be known
- * when the animation is started, such as in a call to one of the
- * fling functions. However there are cases where this cannot be known
- * in advance. This function will transition the current motion and
- * animate from startX to finalX as appropriate.
- * @param start Starting/current X position
- * @param finalPos Desired final X position
- * @param over Magnitude of overscroll allowed. This should be the maximum
- */
- public void notifyEdgeReached(int start, int finalPos, int over) {
- mScroller.notifyEdgeReached(start, finalPos, over);
- }
-
- /**
- * Returns whether the current Scroller is currently returning to a valid position.
- * Valid bounds were provided by the
- * {@link #fling(int, int, int, int, int)} method.
- *
- * One should check this value before calling
- * {@link #startScroll(int, int)} as the interpolation currently in progress
- * to restore a valid position will then be stopped. The caller has to take into account
- * the fact that the started scroll will start from an overscrolled position.
- *
- * @return true when the current position is overscrolled and in the process of
- * interpolating back to a valid value.
- */
- public boolean isOverScrolled() {
- return (!mScroller.mFinished && mScroller.mState != SplineOverScroller.SPLINE);
- }
-
- /**
- * Stops the animation. Contrary to {@link #forceFinished(boolean)},
- * aborting the animating causes the scroller to move to the final x and y
- * positions.
- *
- * @see #forceFinished(boolean)
- */
- public void abortAnimation() {
- mScroller.finish();
- }
-
- /**
- * Returns the time elapsed since the beginning of the scrolling.
- *
- * @return The elapsed time in milliseconds.
- *
- * @hide
- */
- public int timePassed() {
- final long time = AnimationUtils.currentAnimationTimeMillis();
- return (int) (time - mScroller.mStartTime);
- }
-
- public boolean isSpringing() {
- return mScroller.mState == SplineOverScroller.SPRING && !isFinished();
- }
-
- static class SplineOverScroller {
- // Initial position
- private int mStart;
-
- // Current position
- private int mCurrentPosition;
-
- // Final position
- private int mFinal;
-
- // Initial velocity
- private int mVelocity;
-
- // Current velocity
- private float mCurrVelocity;
-
- // Constant current deceleration
- private float mDeceleration;
-
- // Animation starting time, in system milliseconds
- private long mStartTime;
-
- // Animation duration, in milliseconds
- private int mDuration;
-
- // Duration to complete spline component of animation
- private int mSplineDuration;
-
- // Distance to travel along spline animation
- private int mSplineDistance;
-
- // Whether the animation is currently in progress
- private boolean mFinished;
-
- // The allowed overshot distance before boundary is reached.
- private int mOver;
-
- // Fling friction
- private float mFlingFriction = ViewConfiguration.getScrollFriction();
-
- // Current state of the animation.
- private int mState = SPLINE;
-
- private Context mContext;
- private SpringAnimation mSpring;
-
- // Constant gravity value, used in the deceleration phase.
- private static final float GRAVITY = 2000.0f;
-
- // A context-specific coefficient adjusted to physical values.
- private float mPhysicalCoeff;
-
- private static float DECELERATION_RATE = (float) (Math.log(0.78) / Math.log(0.9));
- private static final float INFLEXION = 0.35f; // Tension lines cross at (INFLEXION, 1)
- private static final float START_TENSION = 0.5f;
- private static final float END_TENSION = 1.0f;
- private static final float P1 = START_TENSION * INFLEXION;
- private static final float P2 = 1.0f - END_TENSION * (1.0f - INFLEXION);
-
- private static final int NB_SAMPLES = 100;
- private static final float[] SPLINE_POSITION = new float[NB_SAMPLES + 1];
- private static final float[] SPLINE_TIME = new float[NB_SAMPLES + 1];
-
- private static final int SPLINE = 0;
- private static final int CUBIC = 1;
- private static final int BALLISTIC = 2;
- private static final int SPRING = 3;
-
- private static final FloatPropertyCompat<SplineOverScroller> SPRING_PROPERTY =
- new FloatPropertyCompat<SplineOverScroller>("splineOverScrollerSpring") {
- @Override
- public float getValue(SplineOverScroller scroller) {
- return scroller.mCurrentPosition;
- }
-
- @Override
- public void setValue(SplineOverScroller scroller, float value) {
- scroller.mCurrentPosition = (int) value;
- }
- };
-
- static {
- float x_min = 0.0f;
- float y_min = 0.0f;
- for (int i = 0; i < NB_SAMPLES; i++) {
- final float alpha = (float) i / NB_SAMPLES;
-
- float x_max = 1.0f;
- float x, tx, coef;
- while (true) {
- x = x_min + (x_max - x_min) / 2.0f;
- coef = 3.0f * x * (1.0f - x);
- tx = coef * ((1.0f - x) * P1 + x * P2) + x * x * x;
- if (Math.abs(tx - alpha) < 1E-5) break;
- if (tx > alpha) x_max = x;
- else x_min = x;
- }
- SPLINE_POSITION[i] = coef * ((1.0f - x) * START_TENSION + x) + x * x * x;
-
- float y_max = 1.0f;
- float y, dy;
- while (true) {
- y = y_min + (y_max - y_min) / 2.0f;
- coef = 3.0f * y * (1.0f - y);
- dy = coef * ((1.0f - y) * START_TENSION + y) + y * y * y;
- if (Math.abs(dy - alpha) < 1E-5) break;
- if (dy > alpha) y_max = y;
- else y_min = y;
- }
- SPLINE_TIME[i] = coef * ((1.0f - y) * P1 + y * P2) + y * y * y;
- }
- SPLINE_POSITION[NB_SAMPLES] = SPLINE_TIME[NB_SAMPLES] = 1.0f;
- }
-
- void setFriction(float friction) {
- mFlingFriction = friction;
- }
-
- SplineOverScroller(Context context) {
- mContext = context;
- mFinished = true;
- final float ppi = context.getResources().getDisplayMetrics().density * 160.0f;
- mPhysicalCoeff = SensorManager.GRAVITY_EARTH // g (m/s^2)
- * 39.37f // inch/meter
- * ppi
- * 0.84f; // look and feel tuning
- }
-
- void updateScroll(float q) {
- if (mState == SPRING) {
- return;
- }
- mCurrentPosition = mStart + Math.round(q * (mFinal - mStart));
- }
-
- /*
- * Get a signed deceleration that will reduce the velocity.
- */
- static private float getDeceleration(int velocity) {
- return velocity > 0 ? -GRAVITY : GRAVITY;
- }
-
- /*
- * Modifies mDuration to the duration it takes to get from start to newFinal using the
- * spline interpolation. The previous duration was needed to get to oldFinal.
- */
- private void adjustDuration(int start, int oldFinal, int newFinal) {
- final int oldDistance = oldFinal - start;
- final int newDistance = newFinal - start;
- final float x = Math.abs((float) newDistance / oldDistance);
- final int index = (int) (NB_SAMPLES * x);
- if (index < NB_SAMPLES) {
- final float x_inf = (float) index / NB_SAMPLES;
- final float x_sup = (float) (index + 1) / NB_SAMPLES;
- final float t_inf = SPLINE_TIME[index];
- final float t_sup = SPLINE_TIME[index + 1];
- final float timeCoef = t_inf + (x - x_inf) / (x_sup - x_inf) * (t_sup - t_inf);
- mDuration *= timeCoef;
- }
- }
-
- void startScroll(int start, int distance, int duration) {
- startScroll(start, distance, duration, 0);
- }
-
- void startScroll(int start, int distance, int duration, float velocity) {
- mFinished = false;
-
- mCurrentPosition = mStart = start;
- mFinal = start + distance;
-
- mStartTime = AnimationUtils.currentAnimationTimeMillis();
- mDuration = duration;
-
- if (mSpring != null) {
- mSpring.cancel();
- }
-
- if (mState == SPRING) {
- mSpring = new SpringAnimation(this, SPRING_PROPERTY);
-
- ResourceProvider rp = DynamicResource.provider(mContext);
- float stiffness = rp.getFloat(R.dimen.horizontal_spring_stiffness);
- float damping = rp.getFloat(R.dimen.horizontal_spring_damping_ratio);
- mSpring.setSpring(new SpringForce(mFinal)
- .setStiffness(stiffness)
- .setDampingRatio(damping));
- mSpring.setStartVelocity(velocity);
- mSpring.animateToFinalPosition(mFinal);
- mSpring.addEndListener((animation, canceled, value, velocity1) -> {
- mSpring = null;
- finish();
- mState = SPLINE;
- });
- }
- // Unused
- mDeceleration = 0.0f;
- mVelocity = 0;
- }
-
- void finish() {
- if (mSpring != null && mSpring.isRunning()) mSpring.cancel();
-
- mCurrentPosition = mFinal;
- // Not reset since WebView relies on this value for fast fling.
- // TODO: restore when WebView uses the fast fling implemented in this class.
- // mCurrVelocity = 0.0f;
- mFinished = true;
- }
-
- void setFinalPosition(int position) {
- mFinal = position;
- if (mState == SPRING && mSpring != null) {
- mSpring.animateToFinalPosition(mFinal);
- }
- mSplineDistance = mFinal - mStart;
- mFinished = false;
- }
-
- void extendDuration(int extend) {
- final long time = AnimationUtils.currentAnimationTimeMillis();
- final int elapsedTime = (int) (time - mStartTime);
- mDuration = mSplineDuration = elapsedTime + extend;
- mFinished = false;
- }
-
- boolean springback(int start, int min, int max) {
- mFinished = true;
-
- mCurrentPosition = mStart = mFinal = start;
- mVelocity = 0;
-
- mStartTime = AnimationUtils.currentAnimationTimeMillis();
- mDuration = 0;
-
- if (start < min) {
- startSpringback(start, min, 0);
- } else if (start > max) {
- startSpringback(start, max, 0);
- }
-
- return !mFinished;
- }
-
- private void startSpringback(int start, int end, int velocity) {
- // mStartTime has been set
- mFinished = false;
- mState = CUBIC;
- mCurrentPosition = mStart = start;
- mFinal = end;
- final int delta = start - end;
- mDeceleration = getDeceleration(delta);
- // TODO take velocity into account
- mVelocity = -delta; // only sign is used
- mOver = Math.abs(delta);
- mDuration = (int) (1000.0 * Math.sqrt(-2.0 * delta / mDeceleration));
- }
-
- void fling(int start, int velocity, int min, int max, int over) {
- mOver = over;
- mFinished = false;
- mCurrVelocity = mVelocity = velocity;
- mDuration = mSplineDuration = 0;
- mStartTime = AnimationUtils.currentAnimationTimeMillis();
- mCurrentPosition = mStart = start;
-
- if (start > max || start < min) {
- startAfterEdge(start, min, max, velocity);
- return;
- }
-
- mState = SPLINE;
- double totalDistance = 0.0;
-
- if (velocity != 0) {
- mDuration = mSplineDuration = getSplineFlingDuration(velocity);
- totalDistance = getSplineFlingDistance(velocity);
- }
-
- mSplineDistance = (int) (totalDistance * Math.signum(velocity));
- mFinal = start + mSplineDistance;
-
- // Clamp to a valid final position
- if (mFinal < min) {
- adjustDuration(mStart, mFinal, min);
- mFinal = min;
- }
-
- if (mFinal > max) {
- adjustDuration(mStart, mFinal, max);
- mFinal = max;
- }
- }
-
- private double getSplineDeceleration(int velocity) {
- return Math.log(INFLEXION * Math.abs(velocity) / (mFlingFriction * mPhysicalCoeff));
- }
-
- private double getSplineFlingDistance(int velocity) {
- final double l = getSplineDeceleration(velocity);
- final double decelMinusOne = DECELERATION_RATE - 1.0;
- return mFlingFriction * mPhysicalCoeff * Math.exp(DECELERATION_RATE / decelMinusOne * l);
- }
-
- /* Returns the duration, expressed in milliseconds */
- private int getSplineFlingDuration(int velocity) {
- final double l = getSplineDeceleration(velocity);
- final double decelMinusOne = DECELERATION_RATE - 1.0;
- return (int) (1000.0 * Math.exp(l / decelMinusOne));
- }
-
- private void fitOnBounceCurve(int start, int end, int velocity) {
- // Simulate a bounce that started from edge
- final float durationToApex = - velocity / mDeceleration;
- // The float cast below is necessary to avoid integer overflow.
- final float velocitySquared = (float) velocity * velocity;
- final float distanceToApex = velocitySquared / 2.0f / Math.abs(mDeceleration);
- final float distanceToEdge = Math.abs(end - start);
- final float totalDuration = (float) Math.sqrt(
- 2.0 * (distanceToApex + distanceToEdge) / Math.abs(mDeceleration));
- mStartTime -= (int) (1000.0f * (totalDuration - durationToApex));
- mCurrentPosition = mStart = end;
- mVelocity = (int) (- mDeceleration * totalDuration);
- }
-
- private void startBounceAfterEdge(int start, int end, int velocity) {
- mDeceleration = getDeceleration(velocity == 0 ? start - end : velocity);
- fitOnBounceCurve(start, end, velocity);
- onEdgeReached();
- }
-
- private void startAfterEdge(int start, int min, int max, int velocity) {
- if (start > min && start < max) {
- Log.e("OverScroller", "startAfterEdge called from a valid position");
- mFinished = true;
- return;
- }
- final boolean positive = start > max;
- final int edge = positive ? max : min;
- final int overDistance = start - edge;
- boolean keepIncreasing = overDistance * velocity >= 0;
- if (keepIncreasing) {
- // Will result in a bounce or a to_boundary depending on velocity.
- startBounceAfterEdge(start, edge, velocity);
- } else {
- final double totalDistance = getSplineFlingDistance(velocity);
- if (totalDistance > Math.abs(overDistance)) {
- fling(start, velocity, positive ? min : start, positive ? start : max, mOver);
- } else {
- startSpringback(start, edge, velocity);
- }
- }
- }
-
- void notifyEdgeReached(int start, int end, int over) {
- // mState is used to detect successive notifications
- if (mState == SPLINE) {
- mOver = over;
- mStartTime = AnimationUtils.currentAnimationTimeMillis();
- // We were in fling/scroll mode before: current velocity is such that distance to
- // edge is increasing. This ensures that startAfterEdge will not start a new fling.
- startAfterEdge(start, end, end, (int) mCurrVelocity);
- }
- }
-
- private void onEdgeReached() {
- // mStart, mVelocity and mStartTime were adjusted to their values when edge was reached.
- // The float cast below is necessary to avoid integer overflow.
- final float velocitySquared = (float) mVelocity * mVelocity;
- float distance = velocitySquared / (2.0f * Math.abs(mDeceleration));
- final float sign = Math.signum(mVelocity);
-
- if (distance > mOver) {
- // Default deceleration is not sufficient to slow us down before boundary
- mDeceleration = - sign * velocitySquared / (2.0f * mOver);
- distance = mOver;
- }
-
- mOver = (int) distance;
- mState = BALLISTIC;
- mFinal = mStart + (int) (mVelocity > 0 ? distance : -distance);
- mDuration = - (int) (1000.0f * mVelocity / mDeceleration);
- }
-
- boolean continueWhenFinished() {
- switch (mState) {
- case SPLINE:
- // Duration from start to null velocity
- if (mDuration < mSplineDuration) {
- // If the animation was clamped, we reached the edge
- mCurrentPosition = mStart = mFinal;
- // TODO Better compute speed when edge was reached
- mVelocity = (int) mCurrVelocity;
- mDeceleration = getDeceleration(mVelocity);
- mStartTime += mDuration;
- onEdgeReached();
- } else {
- // Normal stop, no need to continue
- return false;
- }
- break;
- case BALLISTIC:
- mStartTime += mDuration;
- startSpringback(mFinal, mStart, 0);
- break;
- case CUBIC:
- return false;
- }
-
- update();
- return true;
- }
-
- /*
- * Update the current position and velocity for current time. Returns
- * true if update has been done and false if animation duration has been
- * reached.
- */
- boolean update() {
- if (mState == SPRING) {
- return mFinished;
- }
-
- final long time = AnimationUtils.currentAnimationTimeMillis();
- final long currentTime = time - mStartTime;
-
- if (currentTime == 0) {
- // Skip work but report that we're still going if we have a nonzero duration.
- return mDuration > 0;
- }
- if (currentTime > mDuration) {
- return false;
- }
-
- double distance = 0.0;
- switch (mState) {
- case SPLINE: {
- final float t = (float) currentTime / mSplineDuration;
- final int index = (int) (NB_SAMPLES * t);
- float distanceCoef = 1.f;
- float velocityCoef = 0.f;
- if (index < NB_SAMPLES) {
- final float t_inf = (float) index / NB_SAMPLES;
- final float t_sup = (float) (index + 1) / NB_SAMPLES;
- final float d_inf = SPLINE_POSITION[index];
- final float d_sup = SPLINE_POSITION[index + 1];
- velocityCoef = (d_sup - d_inf) / (t_sup - t_inf);
- distanceCoef = d_inf + (t - t_inf) * velocityCoef;
- }
-
- distance = distanceCoef * mSplineDistance;
- mCurrVelocity = velocityCoef * mSplineDistance / mSplineDuration * 1000.0f;
- break;
- }
-
- case BALLISTIC: {
- final float t = currentTime / 1000.0f;
- mCurrVelocity = mVelocity + mDeceleration * t;
- distance = mVelocity * t + mDeceleration * t * t / 2.0f;
- break;
- }
-
- case CUBIC: {
- final float t = (float) (currentTime) / mDuration;
- final float t2 = t * t;
- final float sign = Math.signum(mVelocity);
- distance = sign * mOver * (3.0f * t2 - 2.0f * t * t2);
- mCurrVelocity = sign * mOver * 6.0f * (- t + t2);
- break;
- }
- }
-
- mCurrentPosition = mStart + (int) Math.round(distance);
-
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/android/launcher3/util/OverlayEdgeEffect.java b/src/com/android/launcher3/util/OverlayEdgeEffect.java
new file mode 100644
index 0000000..8d455c6
--- /dev/null
+++ b/src/com/android/launcher3/util/OverlayEdgeEffect.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2021 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.launcher3.util;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.widget.EdgeEffect;
+
+import com.android.launcher3.Utilities;
+import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay;
+
+/**
+ * Extension of {@link EdgeEffect} which shows the Launcher overlay
+ */
+public class OverlayEdgeEffect extends EdgeEffectCompat {
+
+ private final LauncherOverlay mOverlay;
+ private final boolean mIsRtl;
+
+ private float mDistance;
+ private boolean mIsScrolling;
+
+ public OverlayEdgeEffect(Context context, LauncherOverlay overlay) {
+ super(context);
+ mOverlay = overlay;
+ mIsRtl = Utilities.isRtl(context.getResources());
+
+ }
+
+ @Override
+ public float getDistance() {
+ return mDistance;
+ }
+
+ public float onPullDistance(float deltaDistance, float displacement) {
+ mDistance = Math.max(0f, deltaDistance + mDistance);
+ if (!mIsScrolling) {
+ mOverlay.onScrollInteractionBegin();
+ mIsScrolling = true;
+ }
+ mOverlay.onScrollChange(mDistance, mIsRtl);
+ return mDistance > 0 ? deltaDistance : 0;
+ }
+
+ @Override
+ public void onAbsorb(int velocity) { }
+
+ @Override
+ public boolean isFinished() {
+ return mDistance <= 0;
+ }
+
+ @Override
+ public void onRelease() {
+ if (mIsScrolling) {
+ mDistance = 0;
+ mOverlay.onScrollInteractionEnd();
+ mIsScrolling = false;
+ }
+ }
+
+ @Override
+ public boolean draw(Canvas canvas) {
+ return false;
+ }
+
+ public void finish() {
+ mDistance = 0;
+ }
+}
diff --git a/src/com/android/launcher3/util/TranslateEdgeEffect.java b/src/com/android/launcher3/util/TranslateEdgeEffect.java
new file mode 100644
index 0000000..8fdc8df
--- /dev/null
+++ b/src/com/android/launcher3/util/TranslateEdgeEffect.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 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.launcher3.util;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.RenderNode;
+import android.widget.EdgeEffect;
+
+/**
+ * Extension of {@link EdgeEffect} which translates the content instead of the default
+ * platform implementation
+ */
+@SuppressWarnings("NewApi")
+public class TranslateEdgeEffect extends EdgeEffectCompat {
+
+ private final RenderNode mNode;
+
+ public TranslateEdgeEffect(Context context) {
+ super(context);
+ mNode = new RenderNode("TranslateEdgeEffect");
+ }
+
+ @Override
+ public boolean draw(Canvas canvas) {
+ return false;
+ }
+
+ public boolean getTranslationShift(float[] out) {
+ Canvas c = mNode.beginRecording(1, 1);
+ boolean result = super.draw(c);
+ mNode.endRecording();
+
+ out[0] = getDistance();
+ return result;
+ }
+}
diff --git a/src/com/android/launcher3/views/FloatingSurfaceView.java b/src/com/android/launcher3/views/FloatingSurfaceView.java
index f13484f..e2e3be7 100644
--- a/src/com/android/launcher3/views/FloatingSurfaceView.java
+++ b/src/com/android/launcher3/views/FloatingSurfaceView.java
@@ -158,7 +158,7 @@
if (mContract == null) {
return;
}
- View icon = mLauncher.getWorkspace().getFirstMatchForAppClose(
+ View icon = mLauncher.getWorkspace().getFirstMatchForAppClose(-1,
mContract.componentName.getPackageName(), mContract.user);
boolean iconChanged = mIcon != icon;
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
index 1aefe41..18f1be3 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
@@ -43,6 +43,7 @@
private static final float DOWN_SCALE_RATIO = 0.9f;
private static final float MAX_DOWN_SCALE_RATIO = 0.5f;
private final float mWidgetCellTextViewsHeight;
+ private final float mWidgetPreviewPadding;
private float mRecommendationTableMaxHeight = Float.MAX_VALUE;
@Nullable private OnLongClickListener mWidgetCellOnLongClickListener;
@@ -57,6 +58,8 @@
super(context, attrs);
// There are 1 row for title, 1 row for dimension and 2 rows for description.
mWidgetCellTextViewsHeight = 4 * getResources().getDimension(R.dimen.widget_cell_font_size);
+ mWidgetPreviewPadding = 2 * getResources()
+ .getDimensionPixelSize(R.dimen.widget_preview_shortcut_padding);
}
/** Sets a {@link android.view.View.OnLongClickListener} for all widget cells in this table. */
@@ -147,7 +150,7 @@
float rowHeight = 0;
for (int j = 0; j < widgetItems.size(); j++) {
float previewHeight = widgetItems.get(j).spanY * deviceProfile.cellHeightPx
- * previewScale;
+ * previewScale + mWidgetPreviewPadding;
rowHeight = Math.max(rowHeight, previewHeight + mWidgetCellTextViewsHeight);
}
totalHeight += rowHeight;