From 24a3664048b63a074a6ce21ca029f45891e7815b Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 10 May 2022 19:44:55 -0700 Subject: [PATCH] resolve #67 --- app/build.gradle | 4 +-- .../launcher/activities/HomeActivity.java | 24 ++++++------------ .../fragments/HomeScreenFragment.java | 25 +++++++++---------- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f0108b9..c9c8410 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "com.factor.launcher" minSdkVersion 22 targetSdkVersion 31 - versionCode 36 - versionName "0.65.8" + versionCode 37 + versionName "0.65.9" renderscriptTargetApi 31 renderscriptSupportModeEnabled true diff --git a/app/src/main/java/com/factor/launcher/activities/HomeActivity.java b/app/src/main/java/com/factor/launcher/activities/HomeActivity.java index 446693e..a1ee183 100644 --- a/app/src/main/java/com/factor/launcher/activities/HomeActivity.java +++ b/app/src/main/java/com/factor/launcher/activities/HomeActivity.java @@ -16,6 +16,7 @@ import androidx.core.content.PermissionChecker; import androidx.core.view.WindowCompat; import androidx.fragment.app.Fragment; +import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleOwner; import com.factor.launcher.R; import com.factor.launcher.databinding.ActivityHomeBinding; @@ -37,8 +38,6 @@ public class HomeActivity extends AppCompatActivity implements LifecycleOwner private boolean areSettingsChanged = false; - private boolean isVisible = true; - @SuppressLint("MissingPermission") @Override protected void onCreate(Bundle savedInstanceState) @@ -102,8 +101,6 @@ protected void onResume() return; } - isVisible = true; - detectWallpaperChanges(); if(isWallpaperChanged || areSettingsChanged) @@ -114,21 +111,16 @@ protected void onResume() } } - //set isVisible to false when activity is no longer visible - @Override - protected void onPause() - { - super.onPause(); - isVisible = false; - } - @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); - Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.home_fragment_container); - if (!(fragment instanceof OnSystemActionsCallBack) || !((OnSystemActionsCallBack) fragment).onNewIntent()) - finishAfterTransition(); + if (hasWindowFocus()) + { + Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.home_fragment_container); + if (!(fragment instanceof OnSystemActionsCallBack) || !((OnSystemActionsCallBack) fragment).onNewIntent()) + finishAfterTransition(); + } } @@ -165,7 +157,7 @@ public void reload() { AppSettingsManager.getInstance(getApplication()).respondToSettingsChange(); - if (isVisible) + if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) { areSettingsChanged = false; Log.d("settings_changed", "reload"); diff --git a/app/src/main/java/com/factor/launcher/fragments/HomeScreenFragment.java b/app/src/main/java/com/factor/launcher/fragments/HomeScreenFragment.java index 55cd907..fd96515 100644 --- a/app/src/main/java/com/factor/launcher/fragments/HomeScreenFragment.java +++ b/app/src/main/java/com/factor/launcher/fragments/HomeScreenFragment.java @@ -170,24 +170,23 @@ public boolean onNewIntent() { if (isWidgetExpanded && !animatorCollapse.isStarted()) animatorCollapse.start(); - } - - if (binding.homePager.getCurrentItem() == 1) - { - if (appListManager.isDisplayingHidden()) - binding.appsList.setAdapter(appListManager.setDisplayHidden(false)); - if (binding.appsList.getLayoutManager() != null) - (binding.appsList.getLayoutManager()).smoothScrollToPosition(binding.appsList, new RecyclerView.State(), 0); + if (binding.homePager.getCurrentItem() == 1) + { + if (appListManager.isDisplayingHidden()) + binding.appsList.setAdapter(appListManager.setDisplayHidden(false)); + if (binding.appsList.getLayoutManager() != null) + (binding.appsList.getLayoutManager()).smoothScrollToPosition(binding.appsList, new RecyclerView.State(), 0); - binding.homePager.setCurrentItem(0, true); - } - if (binding.tilesList.getLayoutManager() != null) - binding.tilesList.getLayoutManager().smoothScrollToPosition(binding.tilesList, new RecyclerView.State(), 0); + binding.homePager.setCurrentItem(0, true); + } + if (binding.tilesList.getLayoutManager() != null) + binding.tilesList.getLayoutManager().smoothScrollToPosition(binding.tilesList, new RecyclerView.State(), 0); + } return true; } @@ -272,7 +271,7 @@ public void onStart() private void forceNotificationListener() { - //appListManager.clearAllNotifications(); + appListManager.clearAllNotifications(); if (notificationListenerIntent != null && getContext() != null) { try