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

This commit is contained in:
Betty Chang
2023-03-24 15:01:48 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 9 deletions

View File

@@ -2031,7 +2031,9 @@
<!-- 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>
<!-- 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>
<!-- Message to describe "BLE scan always available feature" when Bluetooth is off. The
place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring
the user to "scanning settings" screen. -->
@@ -2042,6 +2044,7 @@
<!-- Bluetooth connecting error message [CHAR LIMIT=NONE] -->
<string name="bluetooth_connect_failed">Couldn\'t connect. Try again.</string>
<!-- Title of device details screen [CHAR LIMIT=28]-->
<string name="device_details_title">Device details</string>
<!-- Title of the item to show device MAC address -->

View File

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