Search in sources :

Example 1 with Condition

use of com.android.settings.dashboard.conditional.Condition in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardSummary method onStop.

@Override
public void onStop() {
    super.onStop();
    ((SettingsDrawerActivity) getActivity()).remCategoryListener(this);
    mSummaryLoader.setListening(false);
    for (Condition c : mConditionManager.getConditions()) {
        if (c.shouldShow()) {
            MetricsLogger.hidden(getContext(), c.getMetricsConstant());
        }
    }
    if (mAdapter.getSuggestions() == null) {
        return;
    }
    if (!getActivity().isChangingConfigurations()) {
        for (Tile suggestion : mAdapter.getSuggestions()) {
            String id = DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion);
            if (!mSuggestionsHiddenLogged.contains(id)) {
                mSuggestionsHiddenLogged.add(id);
                MetricsLogger.action(getContext(), MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION, id);
            }
        }
    }
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) Tile(com.android.settingslib.drawer.Tile) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity)

Example 2 with Condition

use of com.android.settings.dashboard.conditional.Condition in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DashboardSummary method onStart.

@Override
public void onStart() {
    long startTime = System.currentTimeMillis();
    super.onStart();
    ((SettingsDrawerActivity) getActivity()).addCategoryListener(this);
    mSummaryLoader.setListening(true);
    for (Condition c : mConditionManager.getConditions()) {
        if (c.shouldShow()) {
            MetricsLogger.visible(getContext(), c.getMetricsConstant());
        }
    }
    if (mAdapter.getSuggestions() != null) {
        for (Tile suggestion : mAdapter.getSuggestions()) {
            MetricsLogger.action(getContext(), MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, DashboardAdapter.getSuggestionIdentifier(getContext(), suggestion));
        }
    }
    if (DEBUG_TIMING)
        Log.d(TAG, "onStart took " + (System.currentTimeMillis() - startTime) + " ms");
    updateSettings();
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) Tile(com.android.settingslib.drawer.Tile) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity)

Example 3 with Condition

use of com.android.settings.dashboard.conditional.Condition in project android_packages_apps_Settings by LineageOS.

the class DashboardSummary method onPause.

@Override
public void onPause() {
    super.onPause();
    ((SettingsDrawerActivity) getActivity()).remCategoryListener(this);
    mSummaryLoader.setListening(false);
    for (Condition c : mConditionManager.getConditions()) {
        if (c.shouldShow()) {
            mMetricsFeatureProvider.hidden(getContext(), c.getMetricsConstant());
        }
    }
    if (!getActivity().isChangingConfigurations()) {
        mAdapter.onPause();
    }
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity)

Example 4 with Condition

use of com.android.settings.dashboard.conditional.Condition in project android_packages_apps_Settings by LineageOS.

the class DashboardDataTest method testGetPositionByEntity_notExisted_returnNotFound.

@Test
public void testGetPositionByEntity_notExisted_returnNotFound() {
    final Condition condition = mock(AirplaneModeCondition.class);
    final int position = mDashboardDataWithOneConditions.getPositionByEntity(condition);
    assertThat(position).isEqualTo(DashboardData.POSITION_NOT_FOUND);
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) AirplaneModeCondition(com.android.settings.dashboard.conditional.AirplaneModeCondition) Test(org.junit.Test)

Example 5 with Condition

use of com.android.settings.dashboard.conditional.Condition in project android_packages_apps_Settings by omnirom.

the class DashboardDataTest method testGetPositionByEntity_notExisted_returnNotFound.

@Test
public void testGetPositionByEntity_notExisted_returnNotFound() {
    final Condition condition = mock(AirplaneModeCondition.class);
    final int position = mDashboardDataWithOneConditions.getPositionByEntity(condition);
    assertThat(position).isEqualTo(DashboardData.POSITION_NOT_FOUND);
}
Also used : Condition(com.android.settings.dashboard.conditional.Condition) AirplaneModeCondition(com.android.settings.dashboard.conditional.AirplaneModeCondition) Test(org.junit.Test)

Aggregations

Condition (com.android.settings.dashboard.conditional.Condition)38 SettingsDrawerActivity (com.android.settingslib.drawer.SettingsDrawerActivity)14 Tile (com.android.settingslib.drawer.Tile)14 ArrayList (java.util.ArrayList)12 VisibleForTesting (android.support.annotation.VisibleForTesting)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 AirplaneModeCondition (com.android.settings.dashboard.conditional.AirplaneModeCondition)6 ConditionAdapter (com.android.settings.dashboard.conditional.ConditionAdapter)6 SuggestionAdapter (com.android.settings.dashboard.suggestions.SuggestionAdapter)6 SuggestionDismissController (com.android.settings.dashboard.suggestions.SuggestionDismissController)6 List (java.util.List)6 Test (org.junit.Test)6