Merge "Using WindowContext for listening to configuration changes" into sc-dev
diff --git a/OWNERS b/OWNERS
index daad057..05fa502 100644
--- a/OWNERS
+++ b/OWNERS
@@ -4,6 +4,9 @@
# People who can approve changes for submission
#
+alexchau@google.com
+andraskloczl@google.com
+patmanning@google.com
petrcermak@google.com
pbdr@google.com
kideckel@google.com
diff --git a/quickstep/res/values-or/strings.xml b/quickstep/res/values-or/strings.xml
index 08c22fc..8c36972 100644
--- a/quickstep/res/values-or/strings.xml
+++ b/quickstep/res/values-or/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-pt-rPT/strings.xml b/quickstep/res/values-pt-rPT/strings.xml
index bbc4ce8..0feead7 100644
--- a/quickstep/res/values-pt-rPT/strings.xml
+++ b/quickstep/res/values-pt-rPT/strings.xml
@@ -30,7 +30,7 @@
<string name="time_left_for_app" msgid="3111996412933644358">"Resta(m) <xliff:g id="TIME">%1$s</xliff:g> hoje."</string>
<string name="title_app_suggestions" msgid="4185902664111965088">"Sugestões de apps"</string>
<string name="all_apps_label" msgid="8542784161730910663">"Todas as apps"</string>
- <string name="all_apps_prediction_tip" msgid="2672336544844936186">"As suas aplicações previstas"</string>
+ <string name="all_apps_prediction_tip" msgid="2672336544844936186">"As suas apps previstas"</string>
<string name="hotseat_edu_title_migrate" msgid="306578144424489980">"Obtenha sugestões de apps na última fila do ecrã principal"</string>
<string name="hotseat_edu_title_migrate_landscape" msgid="3633942953997845243">"Obtenha sugestões de apps na fila dos favoritos do ecrã principal"</string>
<string name="hotseat_edu_message_migrate" msgid="8927179260533775320">"Aceda facilmente às suas apps mais utilizadas, diretamente no ecrã principal. As sugestões mudam em função das suas rotinas. As apps na última fila passam para o ecrã principal."</string>
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index e9d2eb4..18c0b7a 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -149,6 +149,8 @@
@BinderThread
public void onInitialize(Bundle bundle) {
+ Log.d(TAG + " b/182478748", "TouchInteractionService.onInitialize: user="
+ + getUserId());
ISystemUiProxy proxy = ISystemUiProxy.Stub.asInterface(
bundle.getBinder(KEY_EXTRA_SYSUI_PROXY));
IPip pip = IPip.Stub.asInterface(bundle.getBinder(KEY_EXTRA_SHELL_PIP));
@@ -310,6 +312,8 @@
}
private void disposeEventHandlers() {
+ Log.d(TAG + " b/182478748", "TouchInteractionService.disposeEventHandlers: user="
+ + getUserId());
if (mInputEventReceiver != null) {
mInputEventReceiver.dispose();
mInputEventReceiver = null;
@@ -321,6 +325,8 @@
}
private void initInputMonitor() {
+ Log.d(TAG + " b/182478748", "TouchInteractionService.initInputMonitor: user="
+ + getUserId());
disposeEventHandlers();
if (TestProtocol.sDebugTracing) {
@@ -329,9 +335,11 @@
}
if (mDeviceState.isButtonNavMode()) {
+ Log.d(TAG + " b/182478748", "isButtonNav: user=" + getUserId());
return;
}
+ Log.d(TAG + " b/182478748", "create swipe-up input monitor: user=" + getUserId());
mInputMonitorCompat = new InputMonitorCompat("swipe-up", mDeviceState.getDisplayId());
mInputEventReceiver = mInputMonitorCompat.getInputReceiver(Looper.getMainLooper(),
mMainChoreographer, this::onInputEvent);
@@ -448,6 +456,7 @@
@Override
public void onDestroy() {
+ Log.d(TAG, "Touch service destroyed: user=" + getUserId());
sIsInitialized = false;
if (mDeviceState.isUserUnlocked()) {
mInputConsumer.unregisterInputConsumer();
@@ -469,7 +478,7 @@
@Override
public IBinder onBind(Intent intent) {
- Log.d(TAG, "Touch service connected");
+ Log.d(TAG, "Touch service connected: user=" + getUserId());
return mMyBinder;
}
@@ -506,7 +515,8 @@
}
mRotationTouchHelper.setOrientationTransformIfNeeded(event);
- if (mRotationTouchHelper.isInSwipeUpTouchRegion(event)) {
+ if (!mDeviceState.isOneHandedModeActive()
+ && mRotationTouchHelper.isInSwipeUpTouchRegion(event)) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.NO_SWIPE_TO_HOME,
"TouchInteractionService.onInputEvent:isInSwipeUpTouchRegion");
@@ -535,8 +545,7 @@
InputConsumer.NO_OP, mInputMonitorCompat,
mDeviceState,
event);
- } else if (mDeviceState.canTriggerOneHandedAction(event)
- && !mDeviceState.isOneHandedModeActive()) {
+ } else if (mDeviceState.canTriggerOneHandedAction(event)) {
// Consume gesture event for triggering one handed feature.
mUncheckedConsumer = new OneHandedModeInputConsumer(this, mDeviceState,
InputConsumer.NO_OP, mInputMonitorCompat);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 150ae02..6ed490d 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1420,7 +1420,9 @@
mTaskListChangeId = -1;
mFocusedTaskId = -1;
- mRecentsAnimationController = null;
+ if (mRecentsAnimationController != null) {
+ finishRecentsAnimation(true /* toRecents */, null);
+ }
mLiveTileParams.setTargetSet(null);
mLiveTileTaskViewSimulator.setDrawsBelowRecents(true);
@@ -2340,6 +2342,15 @@
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ if (LIVE_TILE.get() && mRunningTaskId != -1) {
+ switchToScreenshot(
+ () -> finishRecentsAnimation(true, this::onConfigurationChangedInternal));
+ } else {
+ onConfigurationChangedInternal();
+ }
+ }
+
+ private void onConfigurationChangedInternal() {
final int rotation = mActivity.getDisplay().getRotation();
if (mOrientationState.setRecentsRotation(rotation)) {
updateOrientationHandler();
@@ -2517,6 +2528,10 @@
? ((TaskView) child).getPrimaryTaskOffsetTranslationProperty()
: mOrientationHandler.getPrimaryViewTranslate();
translationProperty.set(child, totalTranslation);
+ if (LIVE_TILE.get() && mEnableDrawingLiveTile && i == getRunningTaskIndex()) {
+ mLiveTileTaskViewSimulator.taskPrimaryTranslation.value = totalTranslation;
+ redrawLiveTile();
+ }
}
updateCurveProperties();
}
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index ac7c84b..c49dce5 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -109,7 +109,7 @@
<string name="msg_missing_notification_access" msgid="281113995110910548">"Per veure els punts de notificació, activa les notificacions de l\'aplicació <xliff:g id="NAME">%1$s</xliff:g>"</string>
<string name="title_change_settings" msgid="1376365968844349552">"Canvia la configuració"</string>
<string name="notification_dots_service_title" msgid="4284221181793592871">"Mostra els punts de notificació"</string>
- <string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Afegeix icones a la pantalla d\'inici"</string>
+ <string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Afegeix icones d\'aplicacions a la pantalla d\'inici"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Per a les aplicacions noves"</string>
<string name="package_state_unknown" msgid="7592128424511031410">"Desconegut"</string>
<string name="abandoned_clean_this" msgid="7610119707847920412">"Suprimeix"</string>
diff --git a/res/values-km/strings.xml b/res/values-km/strings.xml
index bc70a3d..f460512 100644
--- a/res/values-km/strings.xml
+++ b/res/values-km/strings.xml
@@ -124,7 +124,7 @@
<string name="action_add_to_workspace" msgid="8902165848117513641">"បញ្ចូលទៅអេក្រង់ដើម"</string>
<string name="action_move_here" msgid="2170188780612570250">"ផ្លាស់ធាតុមកទីនេះ"</string>
<string name="item_added_to_workspace" msgid="4211073925752213539">"ធាតុដែលត្រូវបានបន្ថែមទៅអេក្រង់ដើម"</string>
- <string name="item_removed" msgid="851119963877842327">"ធាតុដែលបានដកចេញ"</string>
+ <string name="item_removed" msgid="851119963877842327">"បានដកធាតុចេញ"</string>
<string name="undo" msgid="4151576204245173321">"ត្រឡប់វិញ"</string>
<string name="action_move" msgid="4339390619886385032">"ផ្លាស់ទីធាតុ"</string>
<string name="move_to_empty_cell" msgid="2833711483015685619">"ផ្លាស់ទីទៅជួរដេកទី <xliff:g id="NUMBER_0">%1$s</xliff:g> ជួរឈរទី <xliff:g id="NUMBER_1">%2$s</xliff:g>"</string>
diff --git a/res/values-ne/strings.xml b/res/values-ne/strings.xml
index 6f2afc2..9c348e3 100644
--- a/res/values-ne/strings.xml
+++ b/res/values-ne/strings.xml
@@ -108,7 +108,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/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index 243f665..fa2a50e 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -97,7 +97,7 @@
<string name="folder_name_format_exact" msgid="8626242716117004803">"Pasta: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> itens"</string>
<string name="folder_name_format_overflow" msgid="4270108890534995199">"Pasta: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> ou mais itens"</string>
<string name="wallpaper_button_text" msgid="8404103075899945851">"Imagens de fundo"</string>
- <string name="styles_wallpaper_button_text" msgid="4342122323125579619">"Estilos e imagens de fundo"</string>
+ <string name="styles_wallpaper_button_text" msgid="4342122323125579619">"Estilos e fundo"</string>
<string name="settings_button_text" msgid="8873672322605444408">"Definições de início"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Desativada pelo gestor"</string>
<string name="allow_rotation_title" msgid="7728578836261442095">"Permitir rotação do ecrã principal"</string>
@@ -110,7 +110,7 @@
<string name="title_change_settings" msgid="1376365968844349552">"Alterar definições"</string>
<string name="notification_dots_service_title" msgid="4284221181793592871">"Mostrar pontos de notificação"</string>
<string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Adic. ícones de apps ao ecrã principal"</string>
- <string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Para novas aplicações"</string>
+ <string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Para novas apps"</string>
<string name="package_state_unknown" msgid="7592128424511031410">"Desconhecido"</string>
<string name="abandoned_clean_this" msgid="7610119707847920412">"Remover"</string>
<string name="abandoned_search" msgid="891119232568284442">"Pesquisar"</string>
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index 22a041d..165a013 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -98,7 +98,7 @@
<string name="folder_name_format_overflow" msgid="4270108890534995199">"Pasta: <xliff:g id="NAME">%1$s</xliff:g>, <xliff:g id="SIZE">%2$d</xliff:g> ou mais itens"</string>
<string name="wallpaper_button_text" msgid="8404103075899945851">"Planos de fundo"</string>
<string name="styles_wallpaper_button_text" msgid="4342122323125579619">"Estilos e planos de fundo"</string>
- <string name="settings_button_text" msgid="8873672322605444408">"Config. tela inicial"</string>
+ <string name="settings_button_text" msgid="8873672322605444408">"Configurações da tela inicial"</string>
<string name="msg_disabled_by_admin" msgid="6898038085516271325">"Desativado pelo administrador"</string>
<string name="allow_rotation_title" msgid="7728578836261442095">"Permitir rotação da tela inicial"</string>
<string name="allow_rotation_desc" msgid="8662546029078692509">"Quando o smartphone for girado"</string>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index f7bef37..318d453 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -108,7 +108,7 @@
<string name="title_missing_notification_access" msgid="7503287056163941064">"Cần quyền truy cập thông báo"</string>
<string name="msg_missing_notification_access" msgid="281113995110910548">"Để hiển thị Dấu chấm thông báo, hãy bật thông báo ứng dụng cho <xliff:g id="NAME">%1$s</xliff:g>"</string>
<string name="title_change_settings" msgid="1376365968844349552">"Thay đổi cài đặt"</string>
- <string name="notification_dots_service_title" msgid="4284221181793592871">"Hiển thị dấu chấm thông báo"</string>
+ <string name="notification_dots_service_title" msgid="4284221181793592871">"Hiện dấu chấm thông báo"</string>
<string name="auto_add_shortcuts_label" msgid="3698776050751790653">"Thêm biểu tượng ứng dụng vào Màn hình chính"</string>
<string name="auto_add_shortcuts_description" msgid="7117251166066978730">"Cho ứng dụng mới"</string>
<string name="package_state_unknown" msgid="7592128424511031410">"Không xác định"</string>
@@ -125,7 +125,7 @@
<string name="action_move_here" msgid="2170188780612570250">"Di chuyển mục vào đây"</string>
<string name="item_added_to_workspace" msgid="4211073925752213539">"Đã thêm mục vào màn hình chính"</string>
<string name="item_removed" msgid="851119963877842327">"Đã xóa mục"</string>
- <string name="undo" msgid="4151576204245173321">"Hoàn tác"</string>
+ <string name="undo" msgid="4151576204245173321">"Hủy"</string>
<string name="action_move" msgid="4339390619886385032">"Di chuyển mục"</string>
<string name="move_to_empty_cell" msgid="2833711483015685619">"Di chuyển đến hàng <xliff:g id="NUMBER_0">%1$s</xliff:g> cột <xliff:g id="NUMBER_1">%2$s</xliff:g>"</string>
<string name="move_to_position" msgid="6750008980455459790">"Di chuyển tới vị trí <xliff:g id="NUMBER">%1$s</xliff:g>"</string>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index fd0ff0e..c6f933c 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/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/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 41865ce..40f7ab1 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -75,8 +75,9 @@
public class AllAppsContainerView extends SpringRelativeLayout implements DragSource,
Insettable, OnDeviceProfileChangeListener, OnActivePageChangedListener {
- private static final float FLING_VELOCITY_MULTIPLIER = 1000 * .2f;
- // Starts the springs after at least 55% of the animation has passed.
+ private static final float FLING_VELOCITY_MULTIPLIER = 1800f;
+
+ // Starts the springs after at least 25% of the animation has passed.
private static final float FLING_ANIMATION_THRESHOLD = 0.25f;
protected final BaseDraggingActivity mLauncher;
@@ -610,7 +611,7 @@
public void onAnimationUpdate(ValueAnimator valueAnimator) {
if (shouldSpring
&& valueAnimator.getAnimatedFraction() >= FLING_ANIMATION_THRESHOLD) {
- absorbSwipeUpVelocity(Math.abs(
+ absorbSwipeUpVelocity(-Math.abs(
Math.round(velocity * FLING_VELOCITY_MULTIPLIER)));
shouldSpring = false;
}
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java
index fc635a9..d5a04a6 100644
--- a/src/com/android/launcher3/dragndrop/AddItemActivity.java
+++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java
@@ -59,6 +59,7 @@
import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.widget.LauncherAppWidgetHost;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
+import com.android.launcher3.widget.NavigableAppWidgetHostView;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.WidgetCell;
@@ -147,20 +148,31 @@
public boolean onLongClick(View view) {
// Find the position of the preview relative to the touch location.
WidgetImageView img = mWidgetCell.getWidgetView();
+ NavigableAppWidgetHostView appWidgetHostView = mWidgetCell.getAppWidgetHostViewPreview();
// If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and
// we abort the drag.
- if (img.getDrawable() == null) {
+ if (img.getDrawable() == null && appWidgetHostView == null) {
return false;
}
- Rect bounds = img.getBitmapBounds();
- bounds.offset(img.getLeft() - (int) mLastTouchPos.x, img.getTop() - (int) mLastTouchPos.y);
-
+ final Rect bounds;
// Start home and pass the draw request params
- PinItemDragListener listener = new PinItemDragListener(mRequest, bounds,
- img.getDrawable().getIntrinsicWidth(), img.getWidth());
-
+ final PinItemDragListener listener;
+ if (appWidgetHostView != null) {
+ bounds = new Rect();
+ appWidgetHostView.getSourceVisualDragBounds(bounds);
+ bounds.offset(appWidgetHostView.getLeft() - (int) mLastTouchPos.x,
+ appWidgetHostView.getTop() - (int) mLastTouchPos.y);
+ listener = new PinItemDragListener(mRequest, bounds,
+ appWidgetHostView.getMeasuredWidth(), appWidgetHostView.getMeasuredWidth());
+ } else {
+ bounds = img.getBitmapBounds();
+ bounds.offset(img.getLeft() - (int) mLastTouchPos.x,
+ img.getTop() - (int) mLastTouchPos.y);
+ listener = new PinItemDragListener(mRequest, bounds,
+ img.getDrawable().getIntrinsicWidth(), img.getWidth());
+ }
// Start a system drag and drop. We use a transparent bitmap as preview for system drag
// as the preview is handled internally by launcher.
@@ -214,7 +226,7 @@
// Cannot add widget
return false;
}
- mWidgetCell.setPreview(PinItemDragListener.getPreview(mRequest));
+ mWidgetCell.setRemoteViewsPreview(PinItemDragListener.getPreview(mRequest));
mAppWidgetManager = new WidgetManagerHelper(this);
mAppWidgetHost = new LauncherAppWidgetHost(this);
@@ -238,6 +250,7 @@
@Override
protected void onPostExecute(WidgetItem item) {
+ mWidgetCell.setPreviewSize(item.spanX, item.spanY);
mWidgetCell.applyFromCellItem(item, mApp.getWidgetCache());
mWidgetCell.ensurePreview();
}
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index 95b887c..415f48d 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -114,7 +114,7 @@
}
PendingItemDragHelper dragHelper = new PendingItemDragHelper(v);
- dragHelper.setRemoteViewsPreview(v.getPreview());
+ dragHelper.setRemoteViewsPreview(v.getRemoteViewsPreview());
dragHelper.setAppWidgetHostViewPreview(v.getAppWidgetHostViewPreview());
if (image.getDrawable() != null) {
diff --git a/src/com/android/launcher3/widget/PendingItemDragHelper.java b/src/com/android/launcher3/widget/PendingItemDragHelper.java
index df368cd..cea4de7 100644
--- a/src/com/android/launcher3/widget/PendingItemDragHelper.java
+++ b/src/com/android/launcher3/widget/PendingItemDragHelper.java
@@ -23,6 +23,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
+import android.view.View.MeasureSpec;
import android.widget.RemoteViews;
import androidx.annotation.Nullable;
@@ -53,7 +54,7 @@
private int[] mEstimatedCellSize;
@Nullable private RemoteViews mRemoteViewsPreview;
- @Nullable private LauncherAppWidgetHostView mAppWidgetHostViewPreview;
+ @Nullable private NavigableAppWidgetHostView mAppWidgetHostViewPreview;
private final float mEnforcedRoundedCornersForWidget;
public PendingItemDragHelper(View view) {
@@ -71,9 +72,9 @@
mRemoteViewsPreview = remoteViewsPreview;
}
- /** Sets a {@link LauncherAppWidgetHostView} which shows a preview layout of an app widget. */
+ /** Sets a {@link NavigableAppWidgetHostView} which shows a preview layout of an app widget. */
public void setAppWidgetHostViewPreview(
- @Nullable LauncherAppWidgetHostView appWidgetHostViewPreview) {
+ @Nullable NavigableAppWidgetHostView appWidgetHostViewPreview) {
mAppWidgetHostViewPreview = appWidgetHostViewPreview;
}
@@ -110,9 +111,22 @@
int[] previewSizeBeforeScale = new int[1];
if (mRemoteViewsPreview != null) {
- preview = new FastBitmapDrawable(
- WidgetCell.generateFromRemoteViews(launcher, mRemoteViewsPreview,
- createWidgetInfo.info, maxWidth, previewSizeBeforeScale));
+ mAppWidgetHostViewPreview = new LauncherAppWidgetHostView(launcher);
+ mAppWidgetHostViewPreview.setAppWidget(/* appWidgetId= */ -1,
+ ((PendingAddWidgetInfo) mAddInfo).info);
+ DeviceProfile deviceProfile = launcher.getDeviceProfile();
+ Rect padding = new Rect();
+ mAppWidgetHostViewPreview.getWidgetInset(deviceProfile, padding);
+ mAppWidgetHostViewPreview.setPadding(padding.left, padding.top, padding.right,
+ padding.bottom);
+ mAppWidgetHostViewPreview.updateAppWidget(/* remoteViews= */ mRemoteViewsPreview);
+ int width =
+ deviceProfile.cellWidthPx * mAddInfo.spanX + padding.left + padding.right;
+ int height =
+ deviceProfile.cellHeightPx * mAddInfo.spanY + padding.top + padding.bottom;
+ mAppWidgetHostViewPreview.measure(
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
}
if (mAppWidgetHostViewPreview != null) {
previewSizeBeforeScale[0] = mAppWidgetHostViewPreview.getMeasuredWidth();
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index c08160b..3fcd3f7 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -46,7 +46,6 @@
import com.android.launcher3.R;
import com.android.launcher3.WidgetPreviewLoader;
import com.android.launcher3.icons.BaseIconFactory;
-import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.icons.FastBitmapDrawable;
import com.android.launcher3.icons.RoundDrawableWrapper;
import com.android.launcher3.model.WidgetItem;
@@ -100,8 +99,8 @@
private final CheckLongPressHelper mLongPressHelper;
private final float mEnforcedCornerRadius;
- private RemoteViews mPreview;
- private LauncherAppWidgetHostView mAppWidgetHostViewPreview;
+ private RemoteViews mRemoteViewsPreview;
+ private NavigableAppWidgetHostView mAppWidgetHostViewPreview;
public WidgetCell(Context context) {
this(context, null);
@@ -143,12 +142,13 @@
mWidgetDescription = findViewById(R.id.widget_description);
}
- public void setPreview(RemoteViews view) {
- mPreview = view;
+ public void setRemoteViewsPreview(RemoteViews view) {
+ mRemoteViewsPreview = view;
}
- public RemoteViews getPreview() {
- return mPreview;
+ @Nullable
+ public RemoteViews getRemoteViewsPreview() {
+ return mRemoteViewsPreview;
}
/**
@@ -172,7 +172,7 @@
mActiveRequest.cancel();
mActiveRequest = null;
}
- mPreview = null;
+ mRemoteViewsPreview = null;
if (mAppWidgetHostViewPreview != null) {
mWidgetImageContainer.removeView(mAppWidgetHostViewPreview);
}
@@ -180,7 +180,7 @@
}
public void applyFromCellItem(WidgetItem item, WidgetPreviewLoader loader) {
- applyPreviewLayout(item);
+ applyPreviewOnAppWidgetHostView(item);
mItem = item;
mWidgetName.setText(mItem.label);
@@ -206,9 +206,26 @@
}
}
- private void applyPreviewLayout(WidgetItem item) {
+
+ private void applyPreviewOnAppWidgetHostView(WidgetItem item) {
+ if (mRemoteViewsPreview != null) {
+ mAppWidgetHostViewPreview = new NavigableAppWidgetHostView(getContext()) {
+ @Override
+ protected boolean shouldAllowDirectClick() {
+ return false;
+ }
+ };
+ mAppWidgetHostViewPreview.setAppWidget(/* appWidgetId= */ -1, item.widgetInfo);
+ Rect padding = new Rect();
+ mAppWidgetHostViewPreview.getWidgetInset(mActivity.getDeviceProfile(), padding);
+ mAppWidgetHostViewPreview.setPadding(padding.left, padding.top, padding.right,
+ padding.bottom);
+ mAppWidgetHostViewPreview.updateAppWidget(/* remoteViews= */ mRemoteViewsPreview);
+ return;
+ }
+
if (ATLEAST_S
- && mPreview == null
+ && mRemoteViewsPreview == null
&& item.widgetInfo != null
&& item.widgetInfo.previewLayout != Resources.ID_NULL) {
mAppWidgetHostViewPreview = new LauncherAppWidgetHostView(getContext());
@@ -234,7 +251,7 @@
}
@Nullable
- public LauncherAppWidgetHostView getAppWidgetHostViewPreview() {
+ public NavigableAppWidgetHostView getAppWidgetHostViewPreview() {
return mAppWidgetHostViewPreview;
}
@@ -303,15 +320,6 @@
}
public void ensurePreview() {
- if (mPreview != null && mActiveRequest == null) {
- Bitmap preview = generateFromRemoteViews(
- mActivity, mPreview, mItem.widgetInfo, mPresetPreviewSize, new int[1]);
- if (preview != null) {
- applyPreview(new FastBitmapDrawable(preview));
- return;
- }
- }
-
if (mAppWidgetHostViewPreview != null) {
setContainerSize(mPreviewWidth, mPreviewHeight);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
@@ -385,53 +393,4 @@
super.onInitializeAccessibilityNodeInfo(info);
info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK);
}
-
- /**
- * Generates a bitmap by inflating {@param views}.
- * @see com.android.launcher3.WidgetPreviewLoader#generateWidgetPreview
- *
- * TODO: Consider moving this to the background thread.
- */
- public static Bitmap generateFromRemoteViews(BaseActivity activity, RemoteViews views,
- LauncherAppWidgetProviderInfo info, int previewSize, int[] preScaledWidthOut) {
- try {
- return generateFromView(activity, views.apply(activity, new FrameLayout(activity)),
- info, previewSize, preScaledWidthOut);
- } catch (Exception e) {
- return null;
- }
- }
-
- private static Bitmap generateFromView(BaseActivity activity, View v,
- LauncherAppWidgetProviderInfo info, int previewSize, int[] preScaledWidthOut) {
-
- DeviceProfile dp = activity.getDeviceProfile();
- int viewWidth = dp.cellWidthPx * info.spanX;
- int viewHeight = dp.cellHeightPx * info.spanY;
-
- v.measure(MeasureSpec.makeMeasureSpec(viewWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(viewHeight, MeasureSpec.EXACTLY));
-
- viewWidth = v.getMeasuredWidth();
- viewHeight = v.getMeasuredHeight();
- v.layout(0, 0, viewWidth, viewHeight);
-
- preScaledWidthOut[0] = viewWidth;
- final int bitmapWidth, bitmapHeight;
- final float scale;
- if (viewWidth > previewSize) {
- scale = ((float) previewSize) / viewWidth;
- bitmapWidth = previewSize;
- bitmapHeight = (int) (viewHeight * scale);
- } else {
- scale = 1;
- bitmapWidth = viewWidth;
- bitmapHeight = viewHeight;
- }
-
- return BitmapRenderer.createSoftwareBitmap(bitmapWidth, bitmapHeight, c -> {
- c.scale(scale, scale);
- v.draw(c);
- });
- }
}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 5be9a95..240958b 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -279,6 +279,7 @@
super.onAttachedToWindow();
mLauncher.getAppWidgetHost().addProviderChangeListener(this);
notifyWidgetProvidersChanged();
+ onRecommendedWidgetsBound();
}
@Override
@@ -416,6 +417,7 @@
@Override
public void exitSearchMode() {
+ if (!mIsInSearchMode) return;
onSearchResults(new ArrayList<>());
setViewVisibilityBasedOnSearch(/*isInSearchMode=*/ false);
if (mHasWorkProfile) {
@@ -464,7 +466,7 @@
mLauncher.getPopupDataProvider().getRecommendedWidgets();
WidgetsRecommendationTableLayout table =
mSearchAndRecommendationViewHolder.mRecommendedWidgetsTable;
- if (recommendedWidgets.size() > 0) {
+ if (!mIsInSearchMode && recommendedWidgets.size() > 0) {
// TODO(b/185508758): Revert the following log after debugging.
if (getHeaderViewHeight() == 0) {
Log.d(TAG, "Header view height is 0 when inflating recommended widgets");
diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
index 824b580..1aefe41 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsRecommendationTableLayout.java
@@ -146,7 +146,7 @@
List<WidgetItem> widgetItems = recommendedWidgetsInTable.get(i);
float rowHeight = 0;
for (int j = 0; j < widgetItems.size(); j++) {
- float previewHeight = widgetItems.get(j).spanY * deviceProfile.allAppsCellHeightPx
+ float previewHeight = widgetItems.get(j).spanY * deviceProfile.cellHeightPx
* previewScale;
rowHeight = Math.max(rowHeight, previewHeight + mWidgetCellTextViewsHeight);
}
diff --git a/tests/dummy_app/Android.mk b/tests/dummy_app/Android.mk
index f4ab582..3472079 100644
--- a/tests/dummy_app/Android.mk
+++ b/tests/dummy_app/Android.mk
@@ -7,6 +7,9 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := Aardwolf
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../NOTICE
LOCAL_SDK_VERSION := current