[Settings] Support master switch of inline toggle of Settings Injection v2

Allow developers to inject MasterSwitchPreference, a switch
preference with two tap targets, to Settings page.

Developers should declare keyhint and switch_uri for the activity
in AndroidManifest,and then implement a SwitchesProvider.

Bug: 132808482
Test: robotest
Change-Id: I64cdf18268be0cfcd38aab2c059144536dd79b32
This commit is contained in:
Jason Chiu
2019-10-24 17:30:34 +08:00
parent bac5987c8e
commit 10e675d6b5
5 changed files with 34 additions and 8 deletions

View File

@@ -38,6 +38,7 @@ import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerListHelper;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.MasterSwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -453,7 +454,9 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
Preference createPreference(Tile tile) {
return tile instanceof ProviderTile
? new SwitchPreference(getPrefContext())
: new Preference(getPrefContext());
: tile.hasSwitch()
? new MasterSwitchPreference(getPrefContext())
: new Preference(getPrefContext());
}
@VisibleForTesting