Merge "Improve the cold start performance" into sc-v2-dev am: b5687c464a

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16386047

Change-Id: I4f34ac927281356ea602550d764bf4e86569d70b
This commit is contained in:
TreeHugger Robot
2021-12-06 09:20:41 +00:00
committed by Automerger Merge Worker

View File

@@ -167,10 +167,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements
mCategoryMixin = new CategoryMixin(this); mCategoryMixin = new CategoryMixin(this);
getLifecycle().addObserver(mCategoryMixin); getLifecycle().addObserver(mCategoryMixin);
final String highlightMenuKey = getHighlightMenuKey();
// Only allow features on high ram devices. // Only allow features on high ram devices.
if (!getSystemService(ActivityManager.class).isLowRamDevice()) { if (!getSystemService(ActivityManager.class).isLowRamDevice()) {
initAvatarView(); initAvatarView();
showSuggestionFragment(); final boolean scrollNeeded = mIsEmbeddingActivityEnabled
&& !TextUtils.equals(getString(DEFAULT_HIGHLIGHT_MENU_KEY), highlightMenuKey);
showSuggestionFragment(scrollNeeded);
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) { if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
showFragment(() -> new ContextualCardsFragment(), R.id.contextual_cards_content); showFragment(() -> new ContextualCardsFragment(), R.id.contextual_cards_content);
} }
@@ -178,7 +181,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
mMainFragment = showFragment(() -> { mMainFragment = showFragment(() -> {
final TopLevelSettings fragment = new TopLevelSettings(); final TopLevelSettings fragment = new TopLevelSettings();
fragment.getArguments().putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, fragment.getArguments().putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY,
getHighlightMenuKey()); highlightMenuKey);
return fragment; return fragment;
}, R.id.main_content); }, R.id.main_content);
@@ -265,7 +268,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
findViewById(R.id.settings_homepage_container).setBackgroundColor(color); findViewById(R.id.settings_homepage_container).setBackgroundColor(color);
} }
private void showSuggestionFragment() { private void showSuggestionFragment(boolean scrollNeeded) {
final Class<? extends Fragment> fragmentClass = FeatureFactory.getFactory(this) final Class<? extends Fragment> fragmentClass = FeatureFactory.getFactory(this)
.getSuggestionFeatureProvider(this).getContextualSuggestionFragment(); .getSuggestionFeatureProvider(this).getContextualSuggestionFragment();
if (fragmentClass == null) { if (fragmentClass == null) {
@@ -275,8 +278,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements
mSuggestionView = findViewById(R.id.suggestion_content); mSuggestionView = findViewById(R.id.suggestion_content);
mTwoPaneSuggestionView = findViewById(R.id.two_pane_suggestion_content); mTwoPaneSuggestionView = findViewById(R.id.two_pane_suggestion_content);
mHomepageView = findViewById(R.id.settings_homepage_container); mHomepageView = findViewById(R.id.settings_homepage_container);
// Hide the homepage for preparing the suggestion. // Hide the homepage for preparing the suggestion. If scrolling is needed, the list views
mHomepageView.setVisibility(View.INVISIBLE); // should be initialized in the invisible homepage view to prevent a scroll flicker.
mHomepageView.setVisibility(scrollNeeded ? View.INVISIBLE : View.GONE);
// Schedule a timer to show the homepage and hide the suggestion on timeout. // Schedule a timer to show the homepage and hide the suggestion on timeout.
mHomepageView.postDelayed(() -> showHomepageWithSuggestion(false), mHomepageView.postDelayed(() -> showHomepageWithSuggestion(false),
HOMEPAGE_LOADING_TIMEOUT_MS); HOMEPAGE_LOADING_TIMEOUT_MS);