Merge "Allow "None" to be selected as a Network rating provider." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b8eb78b321
@@ -74,14 +74,19 @@ public class NetworkScorerPicker extends InstrumentedPreferenceFragment implemen
|
||||
screen.removeAll();
|
||||
|
||||
final List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
|
||||
if (scorers.isEmpty()) {
|
||||
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
|
||||
nonePref.setTitle(R.string.network_scorer_picker_none_preference);
|
||||
nonePref.setChecked(true);
|
||||
screen.addPreference(nonePref);
|
||||
return;
|
||||
}
|
||||
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());
|
||||
|
@@ -17,14 +17,16 @@ package com.android.settings.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.NetworkScorerAppData;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link PreferenceController} that shows the active network scorer and toggles the preference
|
||||
* based on {@link Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED}.
|
||||
* based on whether or not there are valid scorers installed.
|
||||
*/
|
||||
public class NetworkScorerPickerPreferenceController extends PreferenceController {
|
||||
|
||||
@@ -45,8 +47,9 @@ public class NetworkScorerPickerPreferenceController extends PreferenceControlle
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
boolean enabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, 0) == 1;
|
||||
final List<NetworkScorerAppData> allValidScorers =
|
||||
mNetworkScoreManager.getAllValidScorers();
|
||||
boolean enabled = !allValidScorers.isEmpty();
|
||||
preference.setEnabled(enabled);
|
||||
if (!enabled) {
|
||||
preference.setSummary(null);
|
||||
|
Reference in New Issue
Block a user