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

This commit is contained in:
Betty Chang
2023-02-16 02:27:00 +00:00
committed by Android (Google) Code Review
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);
} }
} }
} }