Merge "Import translations. DO NOT MERGE ANYWHERE" into sc-dev
diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java
index 65dba33..1548268 100644
--- a/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java
+++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java
@@ -72,14 +72,20 @@
mForegroundProperties.init(
mOriginalForeground.getConstantState().newDrawable().mutate());
setForeground(mForegroundProperties.mDrawable);
- mSourceView.setForeground(null);
+ Drawable clipPlaceholder =
+ mOriginalForeground.getConstantState().newDrawable().mutate();
+ clipPlaceholder.setAlpha(0);
+ mSourceView.setForeground(clipPlaceholder);
}
if (isSupportedDrawable(backgroundView.getBackground())) {
mOriginalBackground = backgroundView.getBackground();
mBackgroundProperties.init(
mOriginalBackground.getConstantState().newDrawable().mutate());
setBackground(mBackgroundProperties.mDrawable);
- mSourceView.setBackground(null);
+ Drawable clipPlaceholder =
+ mOriginalBackground.getConstantState().newDrawable().mutate();
+ clipPlaceholder.setAlpha(0);
+ mSourceView.setBackground(clipPlaceholder);
} else if (mOriginalForeground == null) {
mFallbackDrawable.setColor(fallbackBackgroundColor);
setBackground(mFallbackDrawable);
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 5759f75..5769ba0 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -43,6 +43,7 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.CheckLongPressHelper;
import com.android.launcher3.DeviceProfile;
+import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.icons.FastBitmapDrawable;
import com.android.launcher3.icons.RoundDrawableWrapper;
@@ -217,12 +218,7 @@
private void applyPreviewOnAppWidgetHostView(WidgetItem item) {
if (mRemoteViewsPreview != null) {
- mAppWidgetHostViewPreview = new NavigableAppWidgetHostView(getContext()) {
- @Override
- protected boolean shouldAllowDirectClick() {
- return false;
- }
- };
+ mAppWidgetHostViewPreview = createAppWidgetHostView(getContext());
setAppWidgetHostViewPreview(mAppWidgetHostViewPreview, item.widgetInfo,
mRemoteViewsPreview);
return;
@@ -230,10 +226,15 @@
if (!item.hasPreviewLayout()) return;
- mAppWidgetHostViewPreview = new LauncherAppWidgetHostView(getContext());
+ Context context = getContext();
+ // If the context is a Launcher activity, DragView will show mAppWidgetHostViewPreview as
+ // a preview during drag & drop. And thus, we should use LauncherAppWidgetHostView, which
+ // supports applying local color extraction during drag & drop.
+ mAppWidgetHostViewPreview = isLauncherContext(context)
+ ? new LauncherAppWidgetHostView(context)
+ : createAppWidgetHostView(context);
LauncherAppWidgetProviderInfo launcherAppWidgetProviderInfo =
- LauncherAppWidgetProviderInfo.fromProviderInfo(getContext(),
- item.widgetInfo.clone());
+ LauncherAppWidgetProviderInfo.fromProviderInfo(context, item.widgetInfo.clone());
// A hack to force the initial layout to be the preview layout since there is no API for
// rendering a preview layout for work profile apps yet. For non-work profile layout, a
// proper solution is to use RemoteViews(PackageName, LayoutId).
@@ -400,6 +401,24 @@
return "";
}
+ private static NavigableAppWidgetHostView createAppWidgetHostView(Context context) {
+ return new NavigableAppWidgetHostView(context) {
+ @Override
+ protected boolean shouldAllowDirectClick() {
+ return false;
+ }
+ };
+ }
+
+ private static boolean isLauncherContext(Context context) {
+ try {
+ Launcher.getLauncher(context);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
@Override
public CharSequence getAccessibilityClassName() {
return WidgetCell.class.getName();