Search in sources :

Example 1 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 2 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsHomepageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_homepage_container);
    final View root = findViewById(R.id.settings_homepage_container);
    root.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    setHomepageContainerPaddingTop();
    context = getApplicationContext();
    mUserManager = context.getSystemService(UserManager.class);
    final Toolbar toolbar = findViewById(R.id.search_action_bar);
    FeatureFactory.getFactory(this).getSearchFeatureProvider().initSearchToolbar(this, /* activity */
    toolbar, SettingsEnums.SETTINGS_HOMEPAGE);
    avatarView = root.findViewById(R.id.account_avatar);
    // final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(this, avatarView);
    avatarView.setImageDrawable(getCircularUserIcon(context));
    avatarView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_MAIN);
            intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$UserSettingsActivity"));
            startActivity(intent);
        }
    });
    if (!getSystemService(ActivityManager.class).isLowRamDevice()) {
        // Only allow contextual feature on high ram devices.
        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);
    SettingsObserver observer = new SettingsObserver(new Handler(Looper.getMainLooper()));
    observer.observe();
    recreateSpacer();
}
Also used : UserManager(android.os.UserManager) ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) Handler(android.os.Handler) Intent(android.content.Intent) ComponentName(android.content.ComponentName) LottieAnimationView(com.airbnb.lottie.LottieAnimationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Toolbar(android.widget.Toolbar)

Example 3 with ContextualCardsFragment

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

the class SliceContextualCardRendererTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final ActivityController<Activity> activityController = Robolectric.buildActivity(Activity.class);
    mActivity = activityController.get();
    mActivity.setTheme(R.style.Theme_Settings_Home);
    activityController.create();
    mLifecycleOwner = new ContextualCardsFragment();
    mRenderer = new SliceContextualCardRenderer(mActivity, mLifecycleOwner, mControllerRendererPool);
    SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
}
Also used : ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) Activity(android.app.Activity) Before(org.junit.Before)

Example 4 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceContextualCardRendererTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final ActivityController<Activity> activityController = Robolectric.buildActivity(Activity.class);
    mActivity = activityController.get();
    mActivity.setTheme(R.style.Theme_Settings_Home);
    activityController.create();
    mLifecycleOwner = new ContextualCardsFragment();
    mRenderer = new SliceContextualCardRenderer(mActivity, mLifecycleOwner, mControllerRendererPool);
}
Also used : ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) Activity(android.app.Activity) Before(org.junit.Before)

Example 5 with ContextualCardsFragment

use of com.android.settings.homepage.contextualcards.ContextualCardsFragment in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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