Merge "Fix colors in bubble settings so they're more visible" into udc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a72794d..9c713f6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10564,7 +10564,7 @@
<string name="change_nfc_tag_apps_detail_switch">Allow launch on NFC scan</string>
<!-- Special app access > Launch via NFC > Description. [CHAR LIMIT=NONE] -->
- <string name="change_nfc_tag_apps_detail_summary">Allow this app to launch when a NFC tag is scanned.\nIf this permission is on, the app will be available as an option whenever a tag is detected.</string>
+ <string name="change_nfc_tag_apps_detail_summary">Allow this app to launch when an NFC tag is scanned.\nIf this permission is on, the app will be available as an option whenever a tag is detected.</string>
<!-- Title for media output settings -->
<string name="media_output_title">Play media to</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 53766e7..fe15226 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -420,7 +420,7 @@
<style name="WorkChallengeEmergencyButtonStyle">
<item name="android:background">@drawable/work_challenge_emergency_button_background</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textColor">@android:color/system_accent3_900</item>
<item name="android:outlineProvider">none</item>
<item name="android:paddingTop">15dp</item>
<item name="android:paddingBottom">15dp</item>
diff --git a/src/com/android/settings/bluetooth/BlockingPrefWithSliceController.java b/src/com/android/settings/bluetooth/BlockingPrefWithSliceController.java
index b443047..93a2747 100644
--- a/src/com/android/settings/bluetooth/BlockingPrefWithSliceController.java
+++ b/src/com/android/settings/bluetooth/BlockingPrefWithSliceController.java
@@ -113,15 +113,27 @@
@Override
public void onStart() {
- if (mLiveData != null) {
+ if (mLiveData == null) {
+ return;
+ }
+
+ try {
mLiveData.observeForever(this);
+ } catch (SecurityException e) {
+ Log.w(TAG, "observeForever - no permission");
}
}
@Override
public void onStop() {
- if (mLiveData != null) {
+ if (mLiveData == null) {
+ return;
+ }
+
+ try {
mLiveData.removeObserver(this);
+ } catch (SecurityException e) {
+ Log.w(TAG, "removeObserver - no permission");
}
}
diff --git a/src/com/android/settings/language/OnDeviceRecognitionPreferenceController.java b/src/com/android/settings/language/OnDeviceRecognitionPreferenceController.java
index 01f37b1..cd9f266 100644
--- a/src/com/android/settings/language/OnDeviceRecognitionPreferenceController.java
+++ b/src/com/android/settings/language/OnDeviceRecognitionPreferenceController.java
@@ -16,9 +16,14 @@
package com.android.settings.language;
+import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
@@ -26,8 +31,12 @@
import com.android.internal.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
+import com.android.settings.dashboard.profileselector.UserAdapter;
+import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.List;
import java.util.Optional;
/** Controller of the On-device recognition preference. */
@@ -37,6 +46,8 @@
private Optional<Intent> mIntent;
+ private WeakReference<Dialog> mProfileSelectDialog = new WeakReference<>(null);
+
public OnDeviceRecognitionPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@@ -59,6 +70,48 @@
}
}
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ return super.handlePreferenceTreeClick(preference);
+ }
+ show(preference);
+ return true;
+ }
+
+ private void show(Preference preference) {
+ final List<UserHandle> userHandles = new ArrayList<>();
+ for (UserInfo userInfo : UserManager.get(mContext).getUsers()) {
+ userHandles.add(userInfo.getUserHandle());
+ }
+
+ // Only a single profile is installed. Proceed with its settings.
+ if (userHandles.size() == 1) {
+ mContext.startActivityAsUser(preference.getIntent(), userHandles.get(0));
+ return;
+ }
+
+ // Multiple profiles are installed. Show a dialog to the user to pick one to proceed with.
+ createAndShowProfileSelectDialog(preference.getIntent(), userHandles);
+ }
+
+ private UserAdapter.OnClickListener createProfileDialogClickCallback(
+ Intent intent, List<UserHandle> userHandles) {
+ return (int position) -> {
+ mContext.startActivityAsUser(intent, userHandles.get(position));
+ if (mProfileSelectDialog.get() != null) {
+ mProfileSelectDialog.get().dismiss();
+ }
+ };
+ }
+
+ private void createAndShowProfileSelectDialog(Intent intent, List<UserHandle> userHandles) {
+ Dialog profileSelectDialog = ProfileSelectDialog.createDialog(
+ mContext, userHandles, createProfileDialogClickCallback(intent, userHandles));
+ mProfileSelectDialog = new WeakReference<>(profileSelectDialog);
+ profileSelectDialog.show();
+ }
+
/**
* Create an {@link Intent} for the activity in the default on-device recognizer service if
* there is a properly defined speech recognition xml meta-data for that service.
diff --git a/src/com/android/settings/slices/SlicePreferenceController.java b/src/com/android/settings/slices/SlicePreferenceController.java
index eb10bd4..9a88b56 100644
--- a/src/com/android/settings/slices/SlicePreferenceController.java
+++ b/src/com/android/settings/slices/SlicePreferenceController.java
@@ -44,7 +44,6 @@
LiveData<Slice> mLiveData;
@VisibleForTesting
SlicePreference mSlicePreference;
- private boolean mIsObservering = false;
private Uri mUri;
public SlicePreferenceController(Context context, String preferenceKey) {
@@ -74,9 +73,14 @@
@Override
public void onStart() {
- if (mLiveData != null && !mIsObservering) {
- mIsObservering = true;
+ if (mLiveData == null) {
+ return;
+ }
+
+ try {
mLiveData.observeForever(this);
+ } catch (SecurityException e) {
+ Log.w(TAG, "observeForever - no permission");
}
}
@@ -91,9 +95,14 @@
}
private void removeLiveDataObserver() {
- if (mLiveData != null && mIsObservering && mLiveData.hasActiveObservers()) {
- mIsObservering = false;
+ if (mLiveData == null) {
+ return;
+ }
+
+ try {
mLiveData.removeObserver(this);
+ } catch (SecurityException e) {
+ Log.w(TAG, "removeLiveDataObserver - no permission");
}
}
}