Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa33027c authored by Angela Wang's avatar Angela Wang
Browse files

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
parent df292224
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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]-->
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@

    <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"
+51 −0
Original line number Diff line number Diff line
/*
 * 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);
        }
    }
}