Update summary for WifiTetherDisablePreference accordingly

The summary of this preference is depenent on other two preferences for
USB tether and Bluetooth tether. The summary is updated accordingly.

Bug: 146818850
Test: CodeInspectionTest, WifiTetherDisablePreferenceControllerTest,
manually test.

Change-Id: I366d10a43814ea0d7def466b1976928f17875029
This commit is contained in:
Zhen Zhang
2020-02-11 17:22:12 -08:00
parent ec966cb7a3
commit 15ec99114d
3 changed files with 18 additions and 2 deletions

View File

@@ -3744,6 +3744,14 @@
<!-- Tethering controls, footer note displayed when tethering is disabled because Data Saver mode is on [CHAR LIMIT=none]--> <!-- Tethering controls, footer note displayed when tethering is disabled because Data Saver mode is on [CHAR LIMIT=none]-->
<string name="tether_settings_disabled_on_data_saver">"Can\u2019t tether or use portable hotspots while Data Saver is on"</string> <string name="tether_settings_disabled_on_data_saver">"Can\u2019t tether or use portable hotspots while Data Saver is on"</string>
<!-- Disable Wifi Hotspot option-->
<!-- Don't use Wi-Fi hotspot summary when USB tethering is chosen [CHAR LIMIT=NONE]-->
<string name="disable_wifi_hotspot_when_usb_on">Only share internet via USB</string>
<!-- Don't use Wi-Fi hotspot summary when Bluetooth tethering is chosen [CHAR LIMIT=NONE]-->
<string name="disable_wifi_hotspot_when_bluetooth_on">Only share internet via Bluetooth</string>
<!-- Don't use Wi-Fi hotspot summary when USB tethering and Bluetooth tethering are chosen [CHAR LIMIT=NONE]-->
<string name="disable_wifi_hotspot_when_usb_and_bluetooth_on">Only share internet via USB and Bluetooth</string>
<!-- USB Tethering options --> <!-- USB Tethering options -->
<string name="usb_title">USB</string> <string name="usb_title">USB</string>
<string name="usb_tethering_button_text">USB tethering</string> <string name="usb_tethering_button_text">USB tethering</string>

View File

@@ -74,6 +74,7 @@
<SwitchPreference <SwitchPreference
android:key="disable_wifi_tethering" android:key="disable_wifi_tethering"
android:title="Don't use Wi-Fi hotspot" android:title="Don't use Wi-Fi hotspot"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.network.WifiTetherDisablePreferenceController" settings:controller="com.android.settings.network.WifiTetherDisablePreferenceController"
settings:keywords="@string/keywords_hotspot_tethering" /> settings:keywords="@string/keywords_hotspot_tethering" />
</PreferenceCategory> </PreferenceCategory>

View File

@@ -30,6 +30,7 @@ import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference; import androidx.preference.SwitchPreference;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.TetherUtil; import com.android.settingslib.TetherUtil;
@@ -95,8 +96,14 @@ public final class WifiTetherDisablePreferenceController extends BasePreferenceC
@Override @Override
public CharSequence getSummary() { public CharSequence getSummary() {
// TODO(b/146818850): Update summary accordingly. if (mUSBTetherEnabled && mBluetoothTetherEnabled) {
return super.getSummary(); return mContext.getString(R.string.disable_wifi_hotspot_when_usb_and_bluetooth_on);
} else if (mUSBTetherEnabled) {
return mContext.getString(R.string.disable_wifi_hotspot_when_usb_on);
} else if (mBluetoothTetherEnabled) {
return mContext.getString(R.string.disable_wifi_hotspot_when_bluetooth_on);
}
return mContext.getString(R.string.summary_placeholder);
} }
@Override @Override