To fix the footer link is not clickable in the Bluetooth Settings

- Links are not allowed in footer preference title now. So follow the
   Wi-Fi UX design to add the string "Change". Let the user to click and
   go to the Bluetooth scanninng settings

Bug: 265167737
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=BluetoothSwitchPreferenceControllerTest

Change-Id: If9e666df7b987e0dbe3d550ac0af03b9d79230de
This commit is contained in:
changbetty
2023-02-15 14:19:54 +00:00
parent 96968c3dc5
commit 3512374f62
2 changed files with 9 additions and 9 deletions

View File

@@ -1438,7 +1438,9 @@
<!-- Bluetooth settings. Text displayed when Bluetooth is off and device list is empty [CHAR LIMIT=50]--> <!-- Bluetooth settings. Text displayed when Bluetooth is off and device list is empty [CHAR LIMIT=50]-->
<string name="bluetooth_empty_list_bluetooth_off">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.</string> <string name="bluetooth_empty_list_bluetooth_off">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.</string>
<!-- Bluetooth settings. Text displayed when Bluetooth is off and bluetooth scanning is turned on [CHAR LIMIT=NONE] --> <!-- Bluetooth settings. Text displayed when Bluetooth is off and bluetooth scanning is turned on [CHAR LIMIT=NONE] -->
<string name="bluetooth_scanning_on_info_message">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.\n\nTo improve device experience, apps and services can still scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services. You can change this in <annotation id="link">Bluetooth scanning settings</annotation>.</string> <string name="bluetooth_scanning_on_info_message">When Bluetooth is turned on, your device can communicate with other nearby Bluetooth devices.\n\nTo improve device experience, apps and services can still scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services. You can change this in Bluetooth scanning settings.</string>
<!-- Bluetooth settings. Link text to bring the user to "scanning settings" screen. [CHAR LIMIT=NONE]-->
<string name="bluetooth_scan_change">Change</string>
<!-- Title of device details screen [CHAR LIMIT=28]--> <!-- Title of device details screen [CHAR LIMIT=28]-->
<string name="device_details_title">Device details</string> <string name="device_details_title">Device details</string>

View File

@@ -25,7 +25,6 @@ import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.location.BluetoothScanningFragment; import com.android.settings.location.BluetoothScanningFragment;
import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.FeatureFactory;
import com.android.settings.utils.AnnotationSpan;
import com.android.settings.widget.SwitchWidgetController; import com.android.settings.widget.SwitchWidgetController;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -121,15 +120,14 @@ public class BluetoothSwitchPreferenceController
} }
@VisibleForTesting void updateText(boolean isChecked) { @VisibleForTesting void updateText(boolean isChecked) {
if (!isChecked if (!isChecked && Utils.isBluetoothScanningEnabled(mContext)) {
&& Utils.isBluetoothScanningEnabled(mContext)) { mFooterPreference.setTitle(R.string.bluetooth_scanning_on_info_message);
AnnotationSpan.LinkInfo info = new AnnotationSpan.LinkInfo( mFooterPreference.setLearnMoreText(mContext.getString(R.string.bluetooth_scan_change));
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, this); mFooterPreference.setLearnMoreAction(v -> onClick(v));
CharSequence text = AnnotationSpan.linkify(
mContext.getText(R.string.bluetooth_scanning_on_info_message), info);
mFooterPreference.setTitle(text);
} else { } else {
mFooterPreference.setTitle(R.string.bluetooth_empty_list_bluetooth_off); mFooterPreference.setTitle(R.string.bluetooth_empty_list_bluetooth_off);
mFooterPreference.setLearnMoreText("");
mFooterPreference.setLearnMoreAction(null);
} }
} }
} }