Override switch bar string for wifi/battery saver screen

Bug: 69462439
Test: visual
Change-Id: I18d03ee1664f111222d7b9bb7ee893e4ce0e1343
This commit is contained in:
Fan Zhang
2018-01-11 13:31:43 -08:00
parent 66898b0cc9
commit 87d120a7e1
8 changed files with 46 additions and 2 deletions

View File

@@ -793,6 +793,9 @@
<string name="Accounts_settings_title">Accounts</string>
<!-- Main Settings screen setting option title for the item to take you to the location screen -->
<string name="location_settings_title">Location</string>
<!-- Used in the location settings to control turning on/off the feature entirely -->
<string name="location_settings_master_switch_title">Use location</string>
<!-- Main Settings screen setting option title for the item to take you to the accounts screen [CHAR LIMIT=22] -->
<string name="account_settings_title">Accounts</string>
<!-- Main Settings screen setting option title for the item to take you to the security screen -->
@@ -1722,6 +1725,9 @@
<string name="wifi_quick_toggle_summary">Turn on Wi\u2011Fi</string>
<!-- Used in the 1st-level settings screen to go to the 2nd-level settings screen [CHAR LIMIT=20]-->
<string name="wifi_settings">Wi\u2011Fi</string>
<!-- Used in the Wi-Fi settings screen to control turning on/off Wi-Fi entirely [CHAR LIMIT=30]-->
<string name="wifi_settings_master_switch_title">Use Wi\u2011Fi</string>
<!-- Title of the Wi-fi settings screen -->
<string name="wifi_settings_category">Wi\u2011Fi settings</string>
<!-- Title of the Wi-fi settings entry in the left top level menu -->
@@ -4394,6 +4400,12 @@
<string name="accessibility_autoclick_preference_title">Click after pointer stops moving</string>
<!-- Title for accessibility preference for configuring amount of time that has to pass after pointer stops moving before click action can be performed (if automatic click after pointer stops moving feature is enabled). [CHAR LIMIT=NONE] -->
<string name="accessibility_autoclick_delay_preference_title">Delay before click</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
<string name="accessibility_service_master_switch_title">Use service</string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
<string name="accessibility_caption_master_switch_title">Use captions</string>
<!-- Preference's state when enabled. Note: UPPERCASE -->
<string name="accessibility_summary_state_enabled">ON</string>
@@ -5049,6 +5061,9 @@
<!-- [CHAR_LIMIT=40] Battery saver: Label for feature, title + menu item -->
<string name="battery_saver">Battery Saver</string>
<!-- Used in the Battery Saver settings screen to control turning on/off the feature entirely -->
<string name="battery_saver_master_switch_title">Use Battery Saver</string>
<!-- [CHAR_LIMIT=40] Battery saver: Title for automatic entry option -->
<string name="battery_saver_turn_on_automatically_title">Turn on automatically</string>
@@ -8720,6 +8735,9 @@
<!-- Preference title for the automatic storage manager toggle. [CHAR LIMIT=60]-->
<string name="automatic_storage_manager_preference_title">Storage manager</string>
<!-- Used in the storage manager settings screen to control turning on/off the feature entirely -->
<string name="automatic_storage_manager_master_switch_title">Use Storage manager</string>
<!-- Category title for the automatic settings in the storage manager settings. [CHAR LIMIT=40] -->
<string name="deletion_helper_automatic_title">Automatic</string>

View File

@@ -158,6 +158,8 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
final boolean enabled = mCaptioningManager.isEnabled();
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
mSwitchBar.setSwitchBarText(R.string.accessibility_caption_master_switch_title,
R.string.accessibility_caption_master_switch_title);
mSwitchBar.setCheckedInternal(enabled);
mToggleSwitch = mSwitchBar.getSwitch();

View File

@@ -93,6 +93,12 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
mSwitchBar.removeOnSwitchChangeListener(this);
}
@Override
protected void updateSwitchBarText(SwitchBar switchBar) {
switchBar.setSwitchBarText(R.string.accessibility_daltonizer_master_switch_title,
R.string.accessibility_daltonizer_master_switch_title);
}
private void initPreferences() {
final String value = Integer.toString(
Settings.Secure.getInt(getContentResolver(), TYPE, DEFAULT_TYPE));

View File

@@ -23,6 +23,7 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.View;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.widget.SwitchBar;
@@ -55,6 +56,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
updateSwitchBarText(mSwitchBar);
mToggleSwitch = mSwitchBar.getSwitch();
onProcessArguments(getArguments());
@@ -83,6 +85,12 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
removeActionBarToggleSwitch();
}
protected void updateSwitchBarText(SwitchBar switchBar) {
// Implement this to provide meaningful text in switch bar
switchBar.setSwitchBarText(R.string.accessibility_service_master_switch_title,
R.string.accessibility_service_master_switch_title);
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
protected void onInstallSwitchBarToggleSwitch() {

View File

@@ -81,6 +81,8 @@ public class AutomaticStorageManagerSettings extends DashboardFragment
private void initializeSwitchBar() {
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBar = activity.getSwitchBar();
mSwitchBar.setSwitchBarText(R.string.automatic_storage_manager_master_switch_title,
R.string.automatic_storage_manager_master_switch_title);
mSwitchBar.show();
mSwitchController =
new AutomaticStorageManagerSwitchBarController(

View File

@@ -87,6 +87,8 @@ public class BatterySaverSettings extends SettingsPreferenceFragment
.setTitle(com.android.internal.R.string.battery_saver_description);
mContext = getActivity();
mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
mSwitchBar.setSwitchBarText(R.string.battery_saver_master_switch_title,
R.string.battery_saver_master_switch_title);
mSwitch = mSwitchBar.getSwitch();
mSwitchBar.show();

View File

@@ -31,6 +31,7 @@ import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.location.RecentLocationApps;
@@ -91,8 +92,10 @@ public class LocationSettings extends DashboardFragment {
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final SettingsActivity activity = (SettingsActivity) getActivity();
mSwitchBarController = new LocationSwitchBarController(
activity, activity.getSwitchBar(), getLifecycle());
final SwitchBar switchBar = activity.getSwitchBar();
switchBar.setSwitchBarText(R.string.location_settings_master_switch_title,
R.string.location_settings_master_switch_title);
mSwitchBarController = new LocationSwitchBarController(activity, switchBar, getLifecycle());
}
@Override

View File

@@ -190,6 +190,9 @@ public class WifiSettings extends RestrictedSettingsFragment
.findViewById(R.id.progress_bar_animation);
setProgressBarVisible(false);
}
((SettingsActivity) activity).getSwitchBar().setSwitchBarText(
R.string.wifi_settings_master_switch_title,
R.string.wifi_settings_master_switch_title);
}
@Override