Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bca448ff authored by chihhangchuang's avatar chihhangchuang
Browse files

Show theme preview when all view is ready

Issue description is in b/157633257
Vedio: https://drive.google.com/file/d/1XxPgFGqueM_kV7XwKMtRvVd3ACEfqDL6/view?usp=sharing

Test: Manually
Fixes: 157633257
Change-Id: I23b7299c6f7128511106fc28589891a89fd76b1f
parent 6cbdde99
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -125,11 +125,12 @@ public class ThemeFullPreviewFragment extends AppbarFragment {
            public void onLayoutChange(View v, int left, int top, int right, int bottom,
                                       int oldLeft, int oldTop, int oldRight, int oldBottom) {
                wallpaperPreviewer.updatePreviewCardRadius();
                // Let's use half size of full preview card to reduce memory and loading time.
                WallpaperColorsLoader.getWallpaperColors(
                        getContext(),
                        mWallpaper.getThumbAsset(getContext()),
                        wallpaperImageView.getMeasuredWidth(),
                        wallpaperImageView.getMeasuredHeight(),
                        wallpaperImageView.getMeasuredWidth() / 2,
                        wallpaperImageView.getMeasuredHeight() / 2,
                        themeOptionPreviewer::updateColorForLauncherWidgets);
                view.removeOnLayoutChangeListener(this);
            }
+24 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
@@ -102,12 +103,16 @@ class ThemeOptionPreviewer implements LifecycleObserver {
    private TextView mSmartSpaceDate;
    private TimeTicker mTicker;

    private boolean mHasPreviewInfoSet;
    private boolean mHasWallpaperColorSet;

    ThemeOptionPreviewer(Lifecycle lifecycle, Context context, ViewGroup previewContainer) {
        lifecycle.addObserver(this);

        mContext = context;
        mContentView = LayoutInflater.from(context).inflate(
                R.layout.theme_preview_content, /* root= */ null);
        mContentView.setVisibility(View.INVISIBLE);
        mStatusBarClock = mContentView.findViewById(R.id.theme_preview_clock);
        mSmartSpaceDate = mContentView.findViewById(R.id.smart_space_date);
        updateTime();
@@ -160,6 +165,8 @@ class ThemeOptionPreviewer implements LifecycleObserver {
                previewInfo.resolveAccentColor(mContext.getResources()));
        setColorAndIconsBoxRadius(previewInfo.bottomSheeetCornerRadius);
        setQsbRadius(previewInfo.bottomSheeetCornerRadius);
        mHasPreviewInfoSet = true;
        showPreviewIfHasAllConfigSet();
    }

    /**
@@ -185,6 +192,9 @@ class ThemeOptionPreviewer implements LifecycleObserver {
        for (int id : mShapeIconAppNameIds) {
            ((TextView) mContentView.findViewById(id)).setTextColor(color);
        }

        mHasWallpaperColorSet = true;
        showPreviewIfHasAllConfigSet();
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@@ -202,6 +212,20 @@ class ThemeOptionPreviewer implements LifecycleObserver {
        }
    }

    private void showPreviewIfHasAllConfigSet() {
        if (mHasPreviewInfoSet && mHasWallpaperColorSet
                && mContentView.getVisibility() != View.VISIBLE) {
            mContentView.setAlpha(0f);
            mContentView.setVisibility(View.VISIBLE);
            mContentView.animate().alpha(1f)
                    .setStartDelay(50)
                    .setDuration(200)
                    .setInterpolator(AnimationUtils.loadInterpolator(mContext,
                            android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    private void setHeadlineFont(Typeface headlineFont) {
        mStatusBarClock.setTypeface(headlineFont);
        mSmartSpaceDate.setTypeface(headlineFont);