From 9b303758becd1766bc4ed1d438fef02ad0a76577 Mon Sep 17 00:00:00 2001 From: Yash-Garg Date: Tue, 8 Nov 2022 11:36:21 +0530 Subject: [PATCH 1/5] add a value animtor for changing the bg color of navbar Signed-off-by: Yash-Garg --- .../features/launcher/LauncherActivity.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 14b7a12517..0884c393c8 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -9,8 +9,10 @@ import android.Manifest; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; +import android.animation.ArgbEvaluator; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; @@ -70,6 +72,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; +import androidx.core.graphics.ColorUtils; import androidx.core.view.GestureDetectorCompat; import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsControllerCompat; @@ -1197,6 +1200,8 @@ public class LauncherActivity extends AppCompatActivity * currentPageNumber updated */ private void createPageChangeListener() { + ValueAnimator navbarAnimtor = navbarColorAnimator(); + mHorizontalPager.addOnScrollListener(new HorizontalPager.OnScrollListener() { boolean isViewScrolling = true; @@ -1231,10 +1236,13 @@ public class LauncherActivity extends AppCompatActivity if (currentPageNumber != page) { currentPageNumber = page; - if (currentPageNumber == 0) { + navbarAnimtor.cancel(); + if (currentPageNumber == WIDGET_PAGE) { + navbarAnimtor.start(); refreshSuggestedApps(widgetsPage, forceRefreshSuggestedApps); mInsetsController.hide(WindowInsetsCompat.Type.statusBars()); } else { + navbarAnimtor.reverse(); mInsetsController.show(WindowInsetsCompat.Type.statusBars()); } @@ -1245,6 +1253,22 @@ public class LauncherActivity extends AppCompatActivity }); } + private ValueAnimator navbarColorAnimator() { + int navColor = getWindow().getNavigationBarColor(); + ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), navColor, + ColorUtils.setAlphaComponent(navColor, 80)); + colorAnimation.setDuration(400); + colorAnimation.setInterpolator(new LinearInterpolator()); + colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animator) { + getWindow().setNavigationBarColor((int) animator.getAnimatedValue()); + } + }); + + return colorAnimation; + } + public void refreshSuggestedApps(ViewGroup viewGroup, boolean forceRefresh) { TextView openUsageAccessSettingsTv = viewGroup.findViewById(R.id.openUsageAccessSettings); GridLayout suggestedAppsGridLayout = viewGroup.findViewById(R.id.suggestedAppGrid); -- GitLab From 881fe89e1fdfbfbfe2b3f30d71ab241709c9c6ed Mon Sep 17 00:00:00 2001 From: Yash-Garg Date: Wed, 9 Nov 2022 10:58:35 +0530 Subject: [PATCH 2/5] make animation duration faster and increase alpha --- .../e/blisslauncher/features/launcher/LauncherActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 0884c393c8..98f442cbc6 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -1256,8 +1256,8 @@ public class LauncherActivity extends AppCompatActivity private ValueAnimator navbarColorAnimator() { int navColor = getWindow().getNavigationBarColor(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), navColor, - ColorUtils.setAlphaComponent(navColor, 80)); - colorAnimation.setDuration(400); + ColorUtils.setAlphaComponent(navColor, 160)); + colorAnimation.setDuration(100); colorAnimation.setInterpolator(new LinearInterpolator()); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override -- GitLab From 515c9957d870ed8c9436dda43188d2a037d81b12 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Mon, 14 Nov 2022 05:42:09 +0000 Subject: [PATCH 3/5] change animation duration back to 400ms --- .../e/blisslauncher/features/launcher/LauncherActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 98f442cbc6..ed5a4f0fa2 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -1257,7 +1257,7 @@ public class LauncherActivity extends AppCompatActivity int navColor = getWindow().getNavigationBarColor(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), navColor, ColorUtils.setAlphaComponent(navColor, 160)); - colorAnimation.setDuration(100); + colorAnimation.setDuration(400); colorAnimation.setInterpolator(new LinearInterpolator()); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override @@ -3425,4 +3425,4 @@ public class LauncherActivity extends AppCompatActivity } } -} \ No newline at end of file +} -- GitLab From d43188b70753fcebd70db8199338eceb0228af14 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Mon, 14 Nov 2022 05:47:27 +0000 Subject: [PATCH 4/5] fix typo in variable name --- .../blisslauncher/features/launcher/LauncherActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index ed5a4f0fa2..aeb388964e 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -1200,7 +1200,7 @@ public class LauncherActivity extends AppCompatActivity * currentPageNumber updated */ private void createPageChangeListener() { - ValueAnimator navbarAnimtor = navbarColorAnimator(); + ValueAnimator navbarAnimator = navbarColorAnimator(); mHorizontalPager.addOnScrollListener(new HorizontalPager.OnScrollListener() { boolean isViewScrolling = true; @@ -1236,13 +1236,13 @@ public class LauncherActivity extends AppCompatActivity if (currentPageNumber != page) { currentPageNumber = page; - navbarAnimtor.cancel(); + navbarAnimator.cancel(); if (currentPageNumber == WIDGET_PAGE) { - navbarAnimtor.start(); + navbarAnimator.start(); refreshSuggestedApps(widgetsPage, forceRefreshSuggestedApps); mInsetsController.hide(WindowInsetsCompat.Type.statusBars()); } else { - navbarAnimtor.reverse(); + navbarAnimator.reverse(); mInsetsController.show(WindowInsetsCompat.Type.statusBars()); } -- GitLab From 7582f3f5dbf708815829211d6d9a88f319f0b555 Mon Sep 17 00:00:00 2001 From: Yash Garg Date: Mon, 14 Nov 2022 21:50:57 +0530 Subject: [PATCH 5/5] fix: apply suggestions and format files --- .../e/blisslauncher/features/launcher/LauncherActivity.java | 5 +++-- app/src/main/res/values-nl/strings.xml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java index 411ed0b457..8e811cce0b 100755 --- a/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/launcher/LauncherActivity.java @@ -1201,7 +1201,7 @@ public class LauncherActivity extends AppCompatActivity * currentPageNumber updated */ private void createPageChangeListener() { - ValueAnimator navbarAnimator = navbarColorAnimator(); + ValueAnimator navbarAnimator = createNavbarColorAnimator(); mHorizontalPager.addOnScrollListener(new HorizontalPager.OnScrollListener() { boolean isViewScrolling = true; @@ -1254,10 +1254,11 @@ public class LauncherActivity extends AppCompatActivity }); } - private ValueAnimator navbarColorAnimator() { + private ValueAnimator createNavbarColorAnimator() { int navColor = getWindow().getNavigationBarColor(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), navColor, ColorUtils.setAlphaComponent(navColor, 160)); + colorAnimation.setDuration(400); colorAnimation.setInterpolator(new LinearInterpolator()); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 23cc85ff18..57359aea95 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -148,4 +148,4 @@ Toestaan Om notificatie bolletjes op app iconen te zien moet je launcher notificatie toegang geven. Toestemming vereist - \ No newline at end of file + -- GitLab