Handles Flash Notifications intro if there's no valid camera
If there is no valid camera found on the device, the camera flash option will be hidden by default. It seems weired if the intro still mentions the camera light will flash while there's no camera flash option at all. Updates the intro string without mentioning camera light if there's no valid camera found. Bug: 274565006 Test: check the string on device without valid camera manually Change-Id: I93b1fe372fe9f9e2634e56b19b30898847d68c9c
This commit is contained in:
@@ -11970,6 +11970,8 @@
|
||||
<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] -->
|
||||
<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] -->
|
||||
<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]-->
|
||||
|
@@ -21,12 +21,12 @@
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="flash_notifications_intro"
|
||||
android:title="@string/flash_notifications_intro" />
|
||||
settings:controller="com.android.settings.accessibility.FlashNotificationsIntroPreferenceController" />
|
||||
|
||||
<com.android.settingslib.widget.IllustrationPreference
|
||||
android:key="flash_notifications_illustration"
|
||||
settings:searchable="false"
|
||||
settings:lottie_rawRes="@drawable/flash_notifications_illustration"/>
|
||||
settings:lottie_rawRes="@drawable/flash_notifications_illustration" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="camera_flash_notification_preference"
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user