Merge "Handles Flash Notifications intro if there's no valid camera" into udc-dev

This commit is contained in:
TreeHugger Robot
2023-03-28 07:54:00 +00:00
committed by Android (Google) Code Review
3 changed files with 55 additions and 2 deletions

View File

@@ -11970,6 +11970,8 @@
<string name="flash_notifications_summary_on_camera_and_screen">On / Camera and screen flash</string> <string name="flash_notifications_summary_on_camera_and_screen">On / Camera and screen flash</string>
<!-- Introduction in Flash Notification page to introduce flash notifications feature. [CHAR LIMIT=NONE] --> <!-- Introduction in Flash Notification page to introduce flash notifications feature. [CHAR LIMIT=NONE] -->
<string name="flash_notifications_intro">Flash the camera light or the screen when you receive notifications or when alarms sound</string> <string name="flash_notifications_intro">Flash the camera light or the screen when you receive notifications or when alarms sound</string>
<!-- Introduction in Flash Notification page to introduce flash notifications feature without camera flash option. [CHAR LIMIT=NONE] -->
<string name="flash_notifications_intro_without_camera_flash">Flash the screen when you receive notifications or when alarms sound</string>
<!-- Notes in Flash Notification page footer for something should be aware. [CHAR LIMIT=NONE] --> <!-- Notes in Flash Notification page footer for something should be aware. [CHAR LIMIT=NONE] -->
<string name="flash_notifications_note">Use flash notifications with caution if you\u0027re light sensitive</string> <string name="flash_notifications_note">Use flash notifications with caution if you\u0027re light sensitive</string>
<!-- Label of the button to preview the selected Flash Notification effects. [CHAR LIMIT=20]--> <!-- Label of the button to preview the selected Flash Notification effects. [CHAR LIMIT=20]-->

View File

@@ -21,7 +21,7 @@
<com.android.settingslib.widget.TopIntroPreference <com.android.settingslib.widget.TopIntroPreference
android:key="flash_notifications_intro" android:key="flash_notifications_intro"
android:title="@string/flash_notifications_intro" /> settings:controller="com.android.settings.accessibility.FlashNotificationsIntroPreferenceController" />
<com.android.settingslib.widget.IllustrationPreference <com.android.settingslib.widget.IllustrationPreference
android:key="flash_notifications_illustration" android:key="flash_notifications_illustration"

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import android.content.Context;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
/** Preference controller that controls the text content of Flash Notifications intro. */
public class FlashNotificationsIntroPreferenceController extends BasePreferenceController {
public FlashNotificationsIntroPreferenceController(Context context,
String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final int titleResource = FlashNotificationsUtil.isTorchAvailable(mContext)
? R.string.flash_notifications_intro
: R.string.flash_notifications_intro_without_camera_flash;
final Preference preference = screen.findPreference(getPreferenceKey());
if (preference != null) {
preference.setTitle(titleResource);
}
}
}