Search in sources :

Example 6 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project android_packages_apps_Settings by omnirom.

the class SettingsHomepageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_homepage_container);
    final View appBar = findViewById(R.id.app_bar_container);
    appBar.setMinimumHeight(getSearchBoxHeight());
    initHomepageContainer();
    final Toolbar toolbar = findViewById(R.id.search_action_bar);
    FeatureFactory.getFactory(this).getSearchFeatureProvider().initSearchToolbar(this, /* activity */
    toolbar, SettingsEnums.SETTINGS_HOMEPAGE);
    getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
    mCategoryMixin = new CategoryMixin(this);
    getLifecycle().addObserver(mCategoryMixin);
    if (!getSystemService(ActivityManager.class).isLowRamDevice()) {
        // Only allow features on high ram devices.
        final ImageView avatarView = findViewById(R.id.account_avatar);
        if (AvatarViewMixin.isAvatarSupported(this)) {
            avatarView.setVisibility(View.VISIBLE);
            getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
        }
        showSuggestionFragment();
        if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
            showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
        }
    }
    showFragment(new TopLevelSettings(), R.id.main_content);
    ((FrameLayout) findViewById(R.id.main_content)).getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
}
Also used : HideNonSystemOverlayMixin(com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin) ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) ImageView(android.widget.ImageView) CategoryMixin(com.android.settings.core.CategoryMixin) ImageView(android.widget.ImageView) View(android.view.View) AvatarViewMixin(com.android.settings.accounts.AvatarViewMixin) Toolbar(android.widget.Toolbar)

Example 7 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project android_packages_apps_Settings by omnirom.

the class SliceContextualCardControllerTest method onDismissed_feedbackDisabled_shouldNotShowFeedbackDialog.

@Test
public void onDismissed_feedbackDisabled_shouldNotShowFeedbackDialog() {
    mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
    final ContextualCardsFragment fragment = FragmentController.of(new ContextualCardsFragment()).create().get();
    final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
    doReturn(false).when(mController).isFeedbackEnabled(anyString());
    mController.onDismissed(getTestSliceCard());
    assertThat(shadowActivity.getNextStartedActivity()).isNull();
}
Also used : ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) ShadowActivity(org.robolectric.shadows.ShadowActivity) Test(org.junit.Test)

Example 8 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project android_packages_apps_Settings by omnirom.

the class SliceContextualCardControllerTest method onDismissed_feedbackEnabled_shouldShowFeedbackDialog.

@Test
public void onDismissed_feedbackEnabled_shouldShowFeedbackDialog() {
    mResolver.insert(CardContentProvider.REFRESH_CARD_URI, generateOneRow());
    final ContextualCardsFragment fragment = FragmentController.of(new ContextualCardsFragment()).create().get();
    final ShadowActivity shadowActivity = Shadows.shadowOf(fragment.getActivity());
    doReturn(true).when(mController).isFeedbackEnabled(anyString());
    mController.onDismissed(getTestSliceCard());
    assertThat(shadowActivity.getNextStartedActivity().getComponent().getClassName()).isEqualTo(ContextualCardFeedbackDialog.class.getName());
}
Also used : ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) ShadowActivity(org.robolectric.shadows.ShadowActivity) ContextualCardFeedbackDialog(com.android.settings.homepage.contextualcards.ContextualCardFeedbackDialog) Test(org.junit.Test)

Aggregations

ContextualCardsFragment (com.android.settings.homepage.contextualcards.ContextualCardsFragment)8 Test (org.junit.Test)4 ShadowActivity (org.robolectric.shadows.ShadowActivity)4 Activity (android.app.Activity)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 Toolbar (android.widget.Toolbar)2 ContextualCardFeedbackDialog (com.android.settings.homepage.contextualcards.ContextualCardFeedbackDialog)2 Before (org.junit.Before)2 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 UserManager (android.os.UserManager)1 TextView (android.widget.TextView)1 LottieAnimationView (com.airbnb.lottie.LottieAnimationView)1 AvatarViewMixin (com.android.settings.accounts.AvatarViewMixin)1 CategoryMixin (com.android.settings.core.CategoryMixin)1 HideNonSystemOverlayMixin (com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin)1