Search in sources :

Example 31 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkScorerPickerPreferenceControllerTest method updateState_scorersAvailable_preferenceEnabled.

@Test
public void updateState_scorersAvailable_preferenceEnabled() {
    ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE, TEST_SCORER_CLASS);
    NetworkScorerAppData scorerAppData = new NetworkScorerAppData(0, scorer, TEST_SCORER_LABEL, null, /* enableUseOpenWifiActivity */
    null);
    when(mNetworkScorer.getAllValidScorers()).thenReturn(Collections.singletonList(scorerAppData));
    Preference preference = mock(Preference.class);
    mController.updateState(preference);
    verify(preference).setEnabled(true);
}
Also used : Preference(androidx.preference.Preference) ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) Test(org.junit.Test)

Example 32 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UseOpenWifiPreferenceControllerTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    sEnableActivityComponent = new ComponentName("package", "activityClass");
    sAppData = new NetworkScorerAppData(0, null, null, sEnableActivityComponent, null);
    sAppDataNoActivity = new NetworkScorerAppData(0, null, null, null, null);
}
Also used : ComponentName(android.content.ComponentName) NetworkScorerAppData(android.net.NetworkScorerAppData) BeforeClass(org.junit.BeforeClass)

Example 33 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UseOpenWifiPreferenceController method updateEnableUseWifiComponentName.

private void updateEnableUseWifiComponentName() {
    NetworkScorerAppData appData = mNetworkScoreManager.getActiveScorer();
    mEnableUseWifiComponentName = appData == null ? null : appData.getEnableUseOpenWifiActivity();
}
Also used : NetworkScorerAppData(android.net.NetworkScorerAppData)

Example 34 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkScorerPicker method updateCandidates.

@VisibleForTesting
public void updateCandidates() {
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    final List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
    final String defaultAppKey = getActiveScorerPackage();
    final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
    nonePref.setTitle(R.string.network_scorer_picker_none_preference);
    if (scorers.isEmpty()) {
        nonePref.setChecked(true);
    } else {
        nonePref.setKey(null);
        nonePref.setChecked(TextUtils.isEmpty(defaultAppKey));
        nonePref.setOnClickListener(this);
    }
    screen.addPreference(nonePref);
    final int numScorers = scorers.size();
    for (int i = 0; i < numScorers; i++) {
        final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
        final NetworkScorerAppData appData = scorers.get(i);
        final String appKey = appData.getRecommendationServicePackageName();
        pref.setTitle(appData.getRecommendationServiceLabel());
        pref.setKey(appKey);
        pref.setChecked(TextUtils.equals(defaultAppKey, appKey));
        pref.setOnClickListener(this);
        screen.addPreference(pref);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) NetworkScorerAppData(android.net.NetworkScorerAppData) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 35 with NetworkScorerAppData

use of android.net.NetworkScorerAppData in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NetworkScorerPickerPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    final List<NetworkScorerAppData> allValidScorers = mNetworkScoreManager.getAllValidScorers();
    boolean enabled = !allValidScorers.isEmpty();
    preference.setEnabled(enabled);
    if (!enabled) {
        preference.setSummary(null);
        return;
    }
    NetworkScorerAppData scorer = mNetworkScoreManager.getActiveScorer();
    if (scorer == null) {
        preference.setSummary(mContext.getString(R.string.network_scorer_picker_none_preference));
    } else {
        preference.setSummary(scorer.getRecommendationServiceLabel());
    }
}
Also used : NetworkScorerAppData(android.net.NetworkScorerAppData)

Aggregations

NetworkScorerAppData (android.net.NetworkScorerAppData)64 ComponentName (android.content.ComponentName)36 Test (org.junit.Test)35 RadioButtonPreference (com.android.settings.widget.RadioButtonPreference)21 Preference (android.support.v7.preference.Preference)18 VisibleForTesting (android.support.annotation.VisibleForTesting)6 PreferenceScreen (android.support.v7.preference.PreferenceScreen)6 Preference (androidx.preference.Preference)3 VisibleForTesting (androidx.annotation.VisibleForTesting)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 BeforeClass (org.junit.BeforeClass)1