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

Commit 78490cec authored by Yash Garg's avatar Yash Garg 💬 Committed by Mohammed Althaf T
Browse files

feat(navbar): add opacity animation for widgets page

parent 64903f53
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -17,10 +17,14 @@
 */
package foundation.e.bliss.utils

import android.animation.ArgbEvaluator
import android.animation.ValueAnimator
import android.content.Context
import android.view.View
import android.view.Window
import android.view.animation.LinearInterpolator
import android.view.inputmethod.InputMethodManager
import kotlin.Exception
import androidx.core.graphics.ColorUtils

fun Context.toggleKeyboard(view: View, hasFocus: Boolean) {
    val inputMethodManager = getSystemService(InputMethodManager::class.java)
@@ -44,3 +48,21 @@ fun <T> resourcesToMap(array: List<T>): Map<T, T> {

    return map
}

fun createNavbarColorAnimator(window: Window): ValueAnimator {
    val navColor: Int = window.navigationBarColor
    val colorAnimation =
        ValueAnimator.ofObject(
            ArgbEvaluator(),
            navColor,
            ColorUtils.setAlphaComponent(navColor, 160)
        )

    colorAnimation.apply {
        duration = 400
        interpolator = LinearInterpolator()
        addUpdateListener { window.navigationBarColor = it.animatedValue as Int }
    }

    return colorAnimation
}
+13 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPELEFT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPERIGHT;

import static foundation.e.bliss.utils.BlissUtilsKt.createNavbarColorAnimator;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.LayoutTransition;
@@ -298,6 +300,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>

    private final StatsLogManager mStatsLogManager;

    private final ValueAnimator navbarAnimator;

    /**
     * Used to inflate the Workspace from XML.
     *
@@ -321,6 +325,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
        mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
        mWallpaperManager = WallpaperManager.getInstance(context);
        mAllAppsIconSize = mLauncher.getDeviceProfile().allAppsIconSizePx;

        navbarAnimator = createNavbarColorAnimator(mLauncher.getWindow());

        mWallpaperOffset = new WallpaperOffsetInterpolator(this);

        setHapticFeedbackEnabled(false);
@@ -1387,6 +1394,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
                                    LauncherAtom.WorkspaceContainer.newBuilder()
                                            .setPageIndex(prevPage)).build())
                    .log(event);

            if (mCurrentPage == 0 && prevPage == 1) {
                navbarAnimator.start();
            } else if (prevPage == 0 && mCurrentPage == 1) {
                navbarAnimator.reverse();
            }
        }
    }