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

Commit 9f5b6708 authored by Amit Kumar's avatar Amit Kumar 💻
Browse files

Add front blur layer for smooth blur effect and Clear blur layer if folder is minimised

parent 2c994e85
Loading
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -68,10 +68,6 @@ public class BlurWallpaperProvider {
        updateWallpaper();
    }

    private void updateAsync() {
        mDispatcher.submit(updateRunnable);
    }

    private void updateWallpaper() {
        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            return;
@@ -92,8 +88,7 @@ public class BlurWallpaperProvider {
            @Override
            void onBlurSuccess(Bitmap bitmap) {
                if (bitmap != null && listener != null) {
                    listener.onBlurSuccess(bitmap);
                    //bitmap.recycle();
                    listener.blurBackgroundLayer(bitmap);
                }
            }

@@ -134,8 +129,8 @@ public class BlurWallpaperProvider {
            @Override
            void onBlurSuccess(Bitmap bitmap) {
                if (bitmap != null && listener != null) {
                    listener.onBlurSuccess(bitmap);
                    //bitmap.recycle();
                    Log.d(TAG, "blurBackgroundLayer() called with: bitmap = [" + bitmap + "]");
                    listener.blurFrontLayer(bitmap);
                }
            }

@@ -148,6 +143,7 @@ public class BlurWallpaperProvider {

    public void cancelPreTask(boolean interrupt) {
        if (mFuture != null && !mFuture.isCancelled() && !mFuture.isDone()) {
            Log.d(TAG, "cancelPreTask() called with: interrupt = [" + interrupt + "]");
            mFuture.cancel(interrupt);
            mFuture = null;
        }
@@ -191,12 +187,15 @@ public class BlurWallpaperProvider {
    }

    public interface Listener {
        void onBlurSuccess(Bitmap bitmap);
        void blurBackgroundLayer(Bitmap bitmap);

        void blurFrontLayer(Bitmap bitmap);

        void fallbackToDimBackground(float dimAlpha);
    }

    public void clear() {
        Log.d(TAG, "clear() called");
        listener = null;
        cancelPreTask(true);
        sInstance = null;
+48 −11
Original line number Diff line number Diff line
@@ -204,7 +204,8 @@ public class LauncherActivity extends AppCompatActivity implements
    private List<UsageStats> mUsageStats;
    private FrameLayout swipeSearchContainer;
    private RelativeLayout workspace;
    private View backgroundLayer;
    private View backgroundLayer; // Blur layer for horizontal pager.
    private View frontLayer; // Blur layer for folders and search container.

    private BroadcastReceiver mWeatherReceiver = new BroadcastReceiver() {
        @Override
@@ -306,6 +307,7 @@ public class LauncherActivity extends AppCompatActivity implements
        workspace = mLauncherView.findViewById(R.id.workspace);
        mHorizontalPager = mLauncherView.findViewById(R.id.pages_container);
        backgroundLayer = mLauncherView.findViewById(R.id.background_layer);
        frontLayer = mLauncherView.findViewById(R.id.blur_layer);
        statusBarHeight = 0;
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
@@ -1104,11 +1106,15 @@ public class LauncherActivity extends AppCompatActivity implements

            @Override
            public void onViewScrollFinished(int page) {
                Log.d(TAG, "onViewScrollFinished() called with: page = [" + page + "]");
                isViewScrolling = false;
                if (page != 0 && mFolderWindowContainer.getVisibility() != VISIBLE) {
                    BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                if (page != 0) {
                    backgroundLayer.setBackground(null);
                }

                if (mFolderWindowContainer.getVisibility() != VISIBLE) {
                    frontLayer.setBackground(null);
                }
                if (currentPageNumber != page) {
                    currentPageNumber = page;
                    // Remove mIndicator and mDock from widgets page, and make them
@@ -1142,12 +1148,19 @@ public class LauncherActivity extends AppCompatActivity implements
    }

    @Override
    public void onBlurSuccess(Bitmap bitmap) {
        Log.d(TAG, "onBlurSuccess() called with: bitmap = [" + bitmap + "]");
    public void blurBackgroundLayer(Bitmap bitmap) {
        Log.d(TAG, "blurBackgroundLayer() called with: bitmap = [" + bitmap + "]");
        BitmapDrawable drawable = new BitmapDrawable(bitmap);
        runOnUiThread(() -> backgroundLayer.setBackground(drawable));
    }

    @Override
    public void blurFrontLayer(Bitmap bitmap) {
        Log.d(TAG, "blurFrontLayer() called with: bitmap = [" + bitmap + "]");
        BitmapDrawable drawable = new BitmapDrawable(bitmap);
        runOnUiThread(() -> frontLayer.setBackground(drawable));
    }

    @Override
    public void fallbackToDimBackground(float dimAlpha) {
        Log.d(TAG, "fallbackToDimBackground() called with: dimAlpha = [" + dimAlpha + "]");
@@ -1159,6 +1172,14 @@ public class LauncherActivity extends AppCompatActivity implements
        runOnUiThread(() -> backgroundLayer.setBackgroundColor(Color.argb(alpha, red, green, blue)));
    }

    private void removeBlur(View view) {
        new Handler(Looper.getMainLooper())
                .post(() -> {
                    Log.d(TAG, "removeBlur() called");
                    view.setBackground(null);
                });
    }

    public void refreshSuggestedApps(ViewGroup viewGroup, boolean forceRefresh) {
        TextView openUsageAccessSettingsTv = viewGroup.findViewById(R.id.openUsageAccessSettings);
        GridLayout suggestedAppsGridLayout = viewGroup.findViewById(R.id.suggestedAppGrid);
@@ -2761,6 +2782,8 @@ public class LauncherActivity extends AppCompatActivity implements
            startBounds.bottom += deltaHeight;
        }

        Log.d("ShowFolder", "displayFolder() called with: app = [" + app + "], v = [" + v + "]");

        // Construct and run the parallel animation of the four translation and
        // scale properties (X, Y, SCALE_X, and SCALE_Y).
        AnimatorSet set = new AnimatorSet();
@@ -2786,6 +2809,7 @@ public class LauncherActivity extends AppCompatActivity implements
            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                Log.d("ShowFolder", "onAnimationStart() called with: animation = [" + animation + "]");
                mFolderWindowContainer.setVisibility(View.VISIBLE);

                // Set the pivot point for SCALE_X and SCALE_Y transformations
@@ -2798,12 +2822,21 @@ public class LauncherActivity extends AppCompatActivity implements

            @Override
            public void onAnimationEnd(Animator animation) {
                Log.d("ShowFolder", "onAnimationEnd() called with: animation = [" + animation + "]");
                currentAnimator = null;
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                Log.d("ShowFolder", "onAnimationCancel() called with: animation = [" + animation + "]");
                currentAnimator = null;
                mergedView = null;
                BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                removeBlur(frontLayer);
                mFolderWindowContainer.setVisibility(GONE);
                mHorizontalPager.setAlpha(1f);
                mIndicator.setAlpha(1f);
                mDock.setAlpha(1f);
            }
        });
        set.start();
@@ -2844,6 +2877,8 @@ public class LauncherActivity extends AppCompatActivity implements
            currentAnimator.cancel();
        }

        Log.d("HideFolder", "hideFolderWindowContainer() called");

        // Animate the four positioning/sizing properties in parallel,
        // back to their original values.
        AnimatorSet set = new AnimatorSet();
@@ -2870,20 +2905,22 @@ public class LauncherActivity extends AppCompatActivity implements
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                Log.d("HideFolder", "onAnimationEnd() called with: animation = [" + animation + "]");
                mFolderWindowContainer.setVisibility(View.GONE);
                currentAnimator = null;
                mergedView = null;
                BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                backgroundLayer.setBackground(null);
                removeBlur(frontLayer);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                Log.d("HideFolder", "onAnimationCancel() called with: animation = [" + animation + "]");
                mFolderWindowContainer.setVisibility(View.GONE);
                currentAnimator = null;
                mergedView = null;
                BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                backgroundLayer.setBackground(null);
                removeBlur(frontLayer);
                mHorizontalPager.setAlpha(1f);
                mIndicator.setAlpha(1f);
                mDock.setAlpha(1f);
@@ -2955,12 +2992,12 @@ public class LauncherActivity extends AppCompatActivity implements
                                super.onAnimationCancel(animation);
                                Log.d(TAG, "onAnimationCancel() called with: animation = [" + animation + "]");
                                currentAnimator = null;
                                BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                                removeBlur(frontLayer);
                                swipeSearchContainer.setVisibility(GONE);
                                mHorizontalPager.setVisibility(VISIBLE);
                                mIndicator.setVisibility(VISIBLE);
                                mDock.setVisibility(VISIBLE);
                                BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                                backgroundLayer.setBackground(null);
                            }

                            @Override
@@ -3093,9 +3130,9 @@ public class LauncherActivity extends AppCompatActivity implements
                                super.onAnimationEnd(animation);
                                currentAnimator = null;
                                mergedView = null;
                                swipeSearchContainer.setVisibility(GONE);
                                BlurWallpaperProvider.getInstance(LauncherActivity.this).clear();
                                backgroundLayer.setBackground(null);
                                removeBlur(frontLayer);
                                swipeSearchContainer.setVisibility(GONE);
                                if (searchDisposableObserver != null
                                        && !searchDisposableObserver.isDisposed()) {
                                    searchDisposableObserver.dispose();
+6 −3
Original line number Diff line number Diff line
@@ -10,9 +10,7 @@
    <View
        android:id="@+id/background_layer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="1"
        android:background="@color/dark_grey_44" />
        android:layout_height="match_parent" />

    <foundation.e.blisslauncher.core.customviews.HorizontalPager
        android:id="@+id/pages_container"
@@ -42,6 +40,11 @@
        android:columnCount="@integer/col_count"
        android:rowCount="1" />

    <View
        android:id="@+id/blur_layer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <RelativeLayout
        android:id="@+id/folder_window_container"
        android:layout_width="match_parent"