Loading src/com/android/settings/homepage/SettingsHomepageActivity.java +9 −4 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements private SplitControllerCallbackAdapter mSplitControllerAdapter; private SplitInfoCallback mCallback; private boolean mAllowUpdateSuggestion = true; /** A listener receiving homepage loaded events. */ public interface HomepageLoadedListener { Loading Loading @@ -155,15 +156,18 @@ public class SettingsHomepageActivity extends FragmentActivity implements * to avoid the flicker caused by the suggestion suddenly appearing/disappearing. */ public void showHomepageWithSuggestion(boolean showSuggestion) { if (mAllowUpdateSuggestion) { Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion); mAllowUpdateSuggestion = false; mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); } if (mHomepageView == null) { return; } Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion); final View homepageView = mHomepageView; mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); mHomepageView = null; mLoadedListeners.forEach(listener -> listener.onHomepageLoaded()); mLoadedListeners.clear(); homepageView.setVisibility(View.VISIBLE); Loading Loading @@ -284,6 +288,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements @Override protected void onStop() { super.onStop(); mAllowUpdateSuggestion = true; if (mSplitControllerAdapter != null && mCallback != null) { mSplitControllerAdapter.removeSplitListener(mCallback); mCallback = null; Loading tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,19 @@ public class SettingsHomepageActivityTest { assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE); } @Test public void showHomepageWithSuggestion_callAfterOnStop_shouldUpdateVisibility() { final SettingsHomepageActivity activity = Robolectric.buildActivity( SettingsHomepageActivity.class).create().get(); final View suggestionTile = activity.findViewById(R.id.suggestion_content); activity.showHomepageWithSuggestion(true); activity.onStop(); activity.showHomepageWithSuggestion(false); assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE); } @Test public void onStart_isNotDebuggable_shouldHideSystemOverlay() { ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false); Loading Loading
src/com/android/settings/homepage/SettingsHomepageActivity.java +9 −4 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements private SplitControllerCallbackAdapter mSplitControllerAdapter; private SplitInfoCallback mCallback; private boolean mAllowUpdateSuggestion = true; /** A listener receiving homepage loaded events. */ public interface HomepageLoadedListener { Loading Loading @@ -155,15 +156,18 @@ public class SettingsHomepageActivity extends FragmentActivity implements * to avoid the flicker caused by the suggestion suddenly appearing/disappearing. */ public void showHomepageWithSuggestion(boolean showSuggestion) { if (mAllowUpdateSuggestion) { Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion); mAllowUpdateSuggestion = false; mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); } if (mHomepageView == null) { return; } Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion); final View homepageView = mHomepageView; mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); mTwoPaneSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE); mHomepageView = null; mLoadedListeners.forEach(listener -> listener.onHomepageLoaded()); mLoadedListeners.clear(); homepageView.setVisibility(View.VISIBLE); Loading Loading @@ -284,6 +288,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements @Override protected void onStop() { super.onStop(); mAllowUpdateSuggestion = true; if (mSplitControllerAdapter != null && mCallback != null) { mSplitControllerAdapter.removeSplitListener(mCallback); mCallback = null; Loading
tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,19 @@ public class SettingsHomepageActivityTest { assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE); } @Test public void showHomepageWithSuggestion_callAfterOnStop_shouldUpdateVisibility() { final SettingsHomepageActivity activity = Robolectric.buildActivity( SettingsHomepageActivity.class).create().get(); final View suggestionTile = activity.findViewById(R.id.suggestion_content); activity.showHomepageWithSuggestion(true); activity.onStop(); activity.showHomepageWithSuggestion(false); assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE); } @Test public void onStart_isNotDebuggable_shouldHideSystemOverlay() { ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", false); Loading