Loading src/com/android/customization/picker/theme/ThemeFragment.java +26 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.Toast; import androidx.annotation.NonNull; Loading @@ -55,6 +56,7 @@ import com.android.wallpaper.module.CurrentWallpaperInfoFactory; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.picker.AppbarFragment; import com.android.wallpaper.widget.BottomActionBar; import com.android.wallpaper.widget.WallpaperColorsLoader; import java.util.List; Loading Loading @@ -91,6 +93,7 @@ public class ThemeFragment extends AppbarFragment { private CurrentWallpaperInfoFactory mCurrentWallpaperFactory; private BottomActionBar mBottomActionBar; private WallpaperPreviewer mWallpaperPreviewer; private ImageView mWallpaperImage; private ThemeOptionPreviewer mThemeOptionPreviewer; private ThemeInfoView mThemeInfoView; Loading Loading @@ -118,31 +121,35 @@ public class ThemeFragment extends AppbarFragment { mOptionsContainer = view.findViewById(R.id.options_container); // Set Wallpaper background. mWallpaperImage = view.findViewById(R.id.wallpaper_preview_image); mWallpaperPreviewer = new WallpaperPreviewer( getLifecycle(), getActivity(), view.findViewById(R.id.wallpaper_preview_image), mWallpaperImage, view.findViewById(R.id.wallpaper_preview_surface)); mCurrentWallpaperFactory.createCurrentWallpaperInfos( (homeWallpaper, lockWallpaper, presentationMode) -> { mCurrentHomeWallpaper = homeWallpaper; mWallpaperPreviewer.setWallpaper(mCurrentHomeWallpaper); updateThemePreviewColorPerWallpaper(); }, false); ViewGroup previewContainer = view.findViewById(R.id.theme_preview_container); previewContainer.setOnClickListener(v -> showFullPreview()); mThemeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), previewContainer); view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mWallpaperPreviewer.updatePreviewCardRadius(); updateThemePreviewColorPerWallpaper(); view.removeOnLayoutChangeListener(this); } }); ViewGroup previewContainer = view.findViewById(R.id.theme_preview_container); previewContainer.setOnClickListener(v -> showFullPreview()); mThemeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), previewContainer); return view; } Loading @@ -168,6 +175,17 @@ public class ThemeFragment extends AppbarFragment { setUpOptions(savedInstanceState); } private void updateThemePreviewColorPerWallpaper() { if (mCurrentHomeWallpaper != null && mWallpaperImage.getMeasuredWidth() > 0 && mWallpaperImage.getMeasuredHeight() > 0) { WallpaperColorsLoader.getWallpaperColors( mCurrentHomeWallpaper.getThumbAsset(getContext()), mWallpaperImage.getMeasuredWidth(), mWallpaperImage.getMeasuredHeight(), mThemeOptionPreviewer::updateColorForLauncherWidgets); } } private void applyTheme() { mThemeManager.apply(mSelectedTheme, new Callback() { @Override Loading src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading @@ -42,6 +43,7 @@ import com.android.wallpaper.model.WallpaperInfo; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.picker.AppbarFragment; import com.android.wallpaper.widget.BottomActionBar; import com.android.wallpaper.widget.WallpaperColorsLoader; import com.bumptech.glide.Glide; Loading Loading @@ -101,27 +103,33 @@ public class ThemeFullPreviewFragment extends AppbarFragment { Glide.get(getContext()).clearMemory(); // Set wallpaper background. ImageView wallpaperImageView = view.findViewById(R.id.wallpaper_preview_image); final WallpaperPreviewer wallpaperPreviewer = new WallpaperPreviewer( getLifecycle(), getActivity(), view.findViewById(R.id.wallpaper_preview_image), wallpaperImageView, view.findViewById(R.id.wallpaper_preview_surface)); wallpaperPreviewer.setWallpaper(mWallpaper); // Set theme option. final ThemeOptionPreviewer themeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), view.findViewById(R.id.theme_preview_container)); themeOptionPreviewer.setThemeBundle(mThemeBundle); view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { wallpaperPreviewer.updatePreviewCardRadius(); WallpaperColorsLoader.getWallpaperColors( mWallpaper.getThumbAsset(getContext()), wallpaperImageView.getMeasuredWidth(), wallpaperImageView.getMeasuredHeight(), themeOptionPreviewer::updateColorForLauncherWidgets); view.removeOnLayoutChangeListener(this); } }); // Set theme option. final ThemeOptionPreviewer themeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), view.findViewById(R.id.theme_preview_container)); themeOptionPreviewer.setThemeBundle(mThemeBundle); return view; } Loading src/com/android/customization/picker/theme/ThemeOptionPreviewer.java +26 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.customization.picker.theme; import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.makeMeasureSpec; import android.app.WallpaperColors; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; Loading Loading @@ -157,6 +158,31 @@ class ThemeOptionPreviewer implements LifecycleObserver { setQsbRadius(previewInfo.bottomSheeetCornerRadius); } /** * Updates the color of widgets in launcher (like top status bar, smart space, and app name * text) which will change its content color according to different wallpapers. */ public void updateColorForLauncherWidgets(WallpaperColors colors) { int color = mContext.getColor( (colors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_TEXT) == 0 ? R.color.text_color_light : R.color.text_color_dark); // Update the top status bar clock text color. mClock.setTextColor(color); // Update the top status bar icon color. ViewGroup iconsContainer = mContentView.findViewById(R.id.theme_preview_top_bar_icons); for (int i = 0; i < iconsContainer.getChildCount(); i++) { ((ImageView) iconsContainer.getChildAt(i)) .setImageTintList(ColorStateList.valueOf(color)); } // Update smart space date color. ((TextView) mContentView.findViewById(R.id.smart_space_date)).setTextColor(color); // Update shape app icon name text color. for (int id : mShapeIconAppNameIds) { ((TextView) mContentView.findViewById(id)).setTextColor(color); } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @MainThread public void onResume() { Loading Loading
src/com/android/customization/picker/theme/ThemeFragment.java +26 −8 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.Toast; import androidx.annotation.NonNull; Loading @@ -55,6 +56,7 @@ import com.android.wallpaper.module.CurrentWallpaperInfoFactory; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.picker.AppbarFragment; import com.android.wallpaper.widget.BottomActionBar; import com.android.wallpaper.widget.WallpaperColorsLoader; import java.util.List; Loading Loading @@ -91,6 +93,7 @@ public class ThemeFragment extends AppbarFragment { private CurrentWallpaperInfoFactory mCurrentWallpaperFactory; private BottomActionBar mBottomActionBar; private WallpaperPreviewer mWallpaperPreviewer; private ImageView mWallpaperImage; private ThemeOptionPreviewer mThemeOptionPreviewer; private ThemeInfoView mThemeInfoView; Loading Loading @@ -118,31 +121,35 @@ public class ThemeFragment extends AppbarFragment { mOptionsContainer = view.findViewById(R.id.options_container); // Set Wallpaper background. mWallpaperImage = view.findViewById(R.id.wallpaper_preview_image); mWallpaperPreviewer = new WallpaperPreviewer( getLifecycle(), getActivity(), view.findViewById(R.id.wallpaper_preview_image), mWallpaperImage, view.findViewById(R.id.wallpaper_preview_surface)); mCurrentWallpaperFactory.createCurrentWallpaperInfos( (homeWallpaper, lockWallpaper, presentationMode) -> { mCurrentHomeWallpaper = homeWallpaper; mWallpaperPreviewer.setWallpaper(mCurrentHomeWallpaper); updateThemePreviewColorPerWallpaper(); }, false); ViewGroup previewContainer = view.findViewById(R.id.theme_preview_container); previewContainer.setOnClickListener(v -> showFullPreview()); mThemeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), previewContainer); view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mWallpaperPreviewer.updatePreviewCardRadius(); updateThemePreviewColorPerWallpaper(); view.removeOnLayoutChangeListener(this); } }); ViewGroup previewContainer = view.findViewById(R.id.theme_preview_container); previewContainer.setOnClickListener(v -> showFullPreview()); mThemeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), previewContainer); return view; } Loading @@ -168,6 +175,17 @@ public class ThemeFragment extends AppbarFragment { setUpOptions(savedInstanceState); } private void updateThemePreviewColorPerWallpaper() { if (mCurrentHomeWallpaper != null && mWallpaperImage.getMeasuredWidth() > 0 && mWallpaperImage.getMeasuredHeight() > 0) { WallpaperColorsLoader.getWallpaperColors( mCurrentHomeWallpaper.getThumbAsset(getContext()), mWallpaperImage.getMeasuredWidth(), mWallpaperImage.getMeasuredHeight(), mThemeOptionPreviewer::updateColorForLauncherWidgets); } } private void applyTheme() { mThemeManager.apply(mSelectedTheme, new Callback() { @Override Loading
src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading @@ -42,6 +43,7 @@ import com.android.wallpaper.model.WallpaperInfo; import com.android.wallpaper.module.InjectorProvider; import com.android.wallpaper.picker.AppbarFragment; import com.android.wallpaper.widget.BottomActionBar; import com.android.wallpaper.widget.WallpaperColorsLoader; import com.bumptech.glide.Glide; Loading Loading @@ -101,27 +103,33 @@ public class ThemeFullPreviewFragment extends AppbarFragment { Glide.get(getContext()).clearMemory(); // Set wallpaper background. ImageView wallpaperImageView = view.findViewById(R.id.wallpaper_preview_image); final WallpaperPreviewer wallpaperPreviewer = new WallpaperPreviewer( getLifecycle(), getActivity(), view.findViewById(R.id.wallpaper_preview_image), wallpaperImageView, view.findViewById(R.id.wallpaper_preview_surface)); wallpaperPreviewer.setWallpaper(mWallpaper); // Set theme option. final ThemeOptionPreviewer themeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), view.findViewById(R.id.theme_preview_container)); themeOptionPreviewer.setThemeBundle(mThemeBundle); view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { wallpaperPreviewer.updatePreviewCardRadius(); WallpaperColorsLoader.getWallpaperColors( mWallpaper.getThumbAsset(getContext()), wallpaperImageView.getMeasuredWidth(), wallpaperImageView.getMeasuredHeight(), themeOptionPreviewer::updateColorForLauncherWidgets); view.removeOnLayoutChangeListener(this); } }); // Set theme option. final ThemeOptionPreviewer themeOptionPreviewer = new ThemeOptionPreviewer( getLifecycle(), getContext(), view.findViewById(R.id.theme_preview_container)); themeOptionPreviewer.setThemeBundle(mThemeBundle); return view; } Loading
src/com/android/customization/picker/theme/ThemeOptionPreviewer.java +26 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.customization.picker.theme; import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.makeMeasureSpec; import android.app.WallpaperColors; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; Loading Loading @@ -157,6 +158,31 @@ class ThemeOptionPreviewer implements LifecycleObserver { setQsbRadius(previewInfo.bottomSheeetCornerRadius); } /** * Updates the color of widgets in launcher (like top status bar, smart space, and app name * text) which will change its content color according to different wallpapers. */ public void updateColorForLauncherWidgets(WallpaperColors colors) { int color = mContext.getColor( (colors.getColorHints() & WallpaperColors.HINT_SUPPORTS_DARK_TEXT) == 0 ? R.color.text_color_light : R.color.text_color_dark); // Update the top status bar clock text color. mClock.setTextColor(color); // Update the top status bar icon color. ViewGroup iconsContainer = mContentView.findViewById(R.id.theme_preview_top_bar_icons); for (int i = 0; i < iconsContainer.getChildCount(); i++) { ((ImageView) iconsContainer.getChildAt(i)) .setImageTintList(ColorStateList.valueOf(color)); } // Update smart space date color. ((TextView) mContentView.findViewById(R.id.smart_space_date)).setTextColor(color); // Update shape app icon name text color. for (int id : mShapeIconAppNameIds) { ((TextView) mContentView.findViewById(id)).setTextColor(color); } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @MainThread public void onResume() { Loading