summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Casey <mrcasey@google.com>2020-04-07 00:43:45 +0000
committerMatt Casey <mrcasey@google.com>2020-04-07 00:43:45 +0000
commit04750a8212ef5f3a96686fcc6b963e641dd61444 (patch)
treee74b294c1ec8e592925f407032ad1f3a2f0f3c6a
parentd169422c464a118094f0df6428e5f8408ec389ca (diff)
parent6b1dfed0d4b00bcf4cfee968fb6ed919dd8c0cf8 (diff)
downloadWallpaperPicker2-android11-mainline-cellbroadcast-release.tar.gz
Merging from ub-launcher3-master @ build 6369897android-mainline-12.0.0_r112android-mainline-11.0.0_r44android-mainline-11.0.0_r43android-mainline-11.0.0_r42android-mainline-11.0.0_r41android-mainline-11.0.0_r40android-mainline-11.0.0_r39android-mainline-11.0.0_r38android-mainline-11.0.0_r37android-mainline-11.0.0_r36android-mainline-11.0.0_r35android-mainline-11.0.0_r34android-mainline-11.0.0_r32android-mainline-11.0.0_r31android-mainline-11.0.0_r30android-mainline-11.0.0_r28android-mainline-11.0.0_r27android-mainline-11.0.0_r26android-mainline-11.0.0_r25android-mainline-11.0.0_r24android-mainline-11.0.0_r23android-mainline-11.0.0_r22android-mainline-11.0.0_r21android-mainline-11.0.0_r20android-mainline-11.0.0_r18android-mainline-11.0.0_r17android-mainline-11.0.0_r16android-mainline-11.0.0_r15android-mainline-11.0.0_r14android-mainline-11.0.0_r13android-mainline-11.0.0_r12aml_tz2_305400500aml_tz2_305400300aml_tz2_305400100aml_tz2_304500300aml_tz2_303900110aml_tz2_303900102aml_tz2_303800002aml_tz2_303800001aml_tz2_303200001android12-mainline-tzdata2-releaseandroid11-mainline-tethering-releaseandroid11-mainline-permission-releaseandroid11-mainline-os-statsd-releaseandroid11-mainline-networkstack-releaseandroid11-mainline-media-swcodec-releaseandroid11-mainline-media-releaseandroid11-mainline-extservices-releaseandroid11-mainline-documentsui-releaseandroid11-mainline-conscrypt-releaseandroid11-mainline-cellbroadcast-releaseandroid11-mainline-captiveportallogin-releaseandroid11-devaml_tz2_305400100
Bug:150504032 Test: manual, presubmit on the source branch x20/teams/android-launcher/merge/ub-launcher3-master_rvc-dev_6369897.html Change-Id: I5e62a4b492bc01dfa0c03b004f044de8593970b2
-rw-r--r--res/layout/wallpaper_preview_card.xml5
-rwxr-xr-xsrc/com/android/wallpaper/picker/CategoryFragment.java88
2 files changed, 77 insertions, 16 deletions
diff --git a/res/layout/wallpaper_preview_card.xml b/res/layout/wallpaper_preview_card.xml
index 44328800..f9e36dab 100644
--- a/res/layout/wallpaper_preview_card.xml
+++ b/res/layout/wallpaper_preview_card.xml
@@ -28,4 +28,9 @@
android:id="@+id/workspace_surface"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
+ <SurfaceView
+ android:id="@+id/wallpaper_surface"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
</androidx.cardview.widget.CardView> \ No newline at end of file
diff --git a/src/com/android/wallpaper/picker/CategoryFragment.java b/src/com/android/wallpaper/picker/CategoryFragment.java
index 5187d279..13ebef0c 100755
--- a/src/com/android/wallpaper/picker/CategoryFragment.java
+++ b/src/com/android/wallpaper/picker/CategoryFragment.java
@@ -15,6 +15,9 @@
*/
package com.android.wallpaper.picker;
+import static android.view.View.MeasureSpec.EXACTLY;
+import static android.view.View.MeasureSpec.makeMeasureSpec;
+
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
@@ -36,6 +39,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
+import android.view.SurfaceControlViewHost;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
@@ -52,6 +56,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.cardview.widget.CardView;
+import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
@@ -133,6 +138,7 @@ public class CategoryFragment extends ToolbarFragment
private boolean mTestingMode;
private ImageView mHomePreview;
private SurfaceView mWorkspaceSurface;
+ private SurfaceView mWallpaperSurface;
private ImageView mLockscreenPreview;
private PreviewPager mPreviewPager;
private List<View> mWallPaperPreviews;
@@ -142,6 +148,10 @@ public class CategoryFragment extends ToolbarFragment
private BottomSheetBehavior mBottomSheetBehavior;
private PreviewUtils mPreviewUtils;
+ // Home workspace surface is behind the app window, and so must the home image wallpaper like
+ // the live wallpaper. This view is rendered on mWallpaperSurface for home image wallpaper.
+ private ImageView mHomeImageWallpaper;
+
public CategoryFragment() {
mCategorySelectorFragment = new CategorySelectorFragment();
}
@@ -159,6 +169,7 @@ public class CategoryFragment extends ToolbarFragment
R.layout.wallpaper_preview_card, null);
mHomePreview = homePreviewCard.findViewById(R.id.wallpaper_preview_image);
mWorkspaceSurface = homePreviewCard.findViewById(R.id.workspace_surface);
+ mWallpaperSurface = homePreviewCard.findViewById(R.id.wallpaper_surface);
mWallPaperPreviews.add(homePreviewCard);
if (LockWallpaperStatusChecker.isLockWallpaperSet(getContext())) {
@@ -166,6 +177,7 @@ public class CategoryFragment extends ToolbarFragment
R.layout.wallpaper_preview_card, null);
mLockscreenPreview = lockscreenPreviewCard.findViewById(R.id.wallpaper_preview_image);
lockscreenPreviewCard.findViewById(R.id.workspace_surface).setVisibility(View.GONE);
+ lockscreenPreviewCard.findViewById(R.id.wallpaper_surface).setVisibility(View.GONE);
mWallPaperPreviews.add(lockscreenPreviewCard);
}
@@ -221,6 +233,12 @@ public class CategoryFragment extends ToolbarFragment
}
@Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ updateWallpaperSurface();
+ updateWorkspaceSurface();
+ }
+
+ @Override
public CharSequence getDefaultTitle() {
return getContext().getString(R.string.app_name);
}
@@ -244,7 +262,6 @@ public class CategoryFragment extends ToolbarFragment
if (mWallpaperConnection != null) {
mWallpaperConnection.setVisibility(true);
}
- updateWorkspaceSurface();
}
@Override
@@ -647,8 +664,12 @@ public class CategoryFragment extends ToolbarFragment
}
UserEventLogger eventLogger = InjectorProvider.getInjector().getUserEventLogger(activity);
+
+ boolean renderInImageWallpaperSurface =
+ !(wallpaperInfo instanceof LiveWallpaperInfo) && isHomeWallpaper;
wallpaperInfo.getThumbAsset(activity.getApplicationContext())
- .loadDrawable(activity, thumbnailView,
+ .loadDrawable(activity,
+ renderInImageWallpaperSurface ? mHomeImageWallpaper : thumbnailView,
getResources().getColor(R.color.secondary_color));
if (isHomeWallpaper) {
LiveTileOverlay.INSTANCE.detach(thumbnailView.getOverlay());
@@ -669,24 +690,59 @@ public class CategoryFragment extends ToolbarFragment
});
}
+ private void updateWallpaperSurface() {
+ mWallpaperSurface.getHolder().addCallback(mWallpaperSurfaceCallback);
+ }
+
private void updateWorkspaceSurface() {
- mWorkspaceSurface.setZOrderOnTop(true);
- mWorkspaceSurface.getHolder().addCallback(new SurfaceHolder.Callback() {
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- Bundle bundle = SurfaceViewRequestUtils.createSurfaceBundle(mWorkspaceSurface);
- if (mPreviewUtils.supportsPreview()) {
- mPreviewUtils.renderPreview(bundle);
- }
+ mWorkspaceSurface.setZOrderMediaOverlay(true);
+ mWorkspaceSurface.getHolder().addCallback(mWorkspaceSurfaceCallback);
+ }
+
+ private final SurfaceHolder.Callback mWallpaperSurfaceCallback = new SurfaceHolder.Callback() {
+
+ @Override
+ public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) {
+ if (mHomeImageWallpaper == null) {
+ mHomeImageWallpaper = new ImageView(getContext());
+ mHomeImageWallpaper.setBackgroundColor(
+ ContextCompat.getColor(getContext(), R.color.primary_color));
+ mHomeImageWallpaper.measure(makeMeasureSpec(mHomePreview.getWidth(), EXACTLY),
+ makeMeasureSpec(mHomePreview.getHeight(), EXACTLY));
+ mHomeImageWallpaper.layout(0, 0, mHomePreview.getWidth(), mHomePreview.getHeight());
+
+ SurfaceControlViewHost host = new SurfaceControlViewHost(getContext(),
+ getContext().getDisplay(), mWallpaperSurface.getHostToken());
+ host.setView(mHomeImageWallpaper, mHomeImageWallpaper.getWidth(),
+ mHomeImageWallpaper.getHeight());
+ mWallpaperSurface.setChildSurfacePackage(host.getSurfacePackage());
}
+ }
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { }
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ }
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) { }
- });
- }
+ @Override
+ public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) {
+ }
+ };
+
+ private final SurfaceHolder.Callback mWorkspaceSurfaceCallback = new SurfaceHolder.Callback() {
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ Bundle bundle = SurfaceViewRequestUtils.createSurfaceBundle(mWorkspaceSurface);
+ if (mPreviewUtils.supportsPreview()) {
+ mPreviewUtils.renderPreview(bundle);
+ }
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) { }
+ };
private interface MetadataHolder {
/**