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

Commit 1bc23736 authored by Greg Ross's avatar Greg Ross Committed by Michael Bestas
Browse files

DeskClock: Add screensaver display options

This patch addes the following options to the screensaver function:
    * Select color
    * Bold text
    * Hide/show AM/PM
    * Night mode follows DND setting
    * Night mode color
    * Night mode brightness

Change-Id: I4a7edad096721689805ad26265f4c67fb731cd76
parent 057796bb
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2012-2016 The CyanogenMod Project
     Copyright (C) 2017-2018 The LineageOS Project
     Copyright (C) 2017-2024 The LineageOS Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
@@ -66,4 +66,43 @@
    <string name="widget_name_transparent">Unbacked</string>
    <!-- Name of the solid widget layout -->
    <string name="widget_name_solid">Backed</string>

    <!-- Clock brightness percentage for screensaver settings page, aka 0% to 100%.
         Make sure to use a double percent sign as this string will be used in String.format()
     -->
    <string name="clock_brightness_percentage">%s%%</string>

    <!-- Title for switch to enable very dim display diminuation during screen saver -->
    <string name="night_mode_enabled_title">Enabled</string>
    <!-- Title for switch to pick Night Mode follows Do Not Disturb state -->
    <string name="night_mode_dnd_title">Follow DND state</string>
    <!-- Describes night mode follows do not disturb state -->
    <string name="night_mode_dnd_summary">Night mode follows Do Not Disturb state</string>
    <!-- Title for swtich to pick if the AM/PM is displayed on a 12 hour text clock -->
    <string name="show_ampm_title">Show AM/PM</string>
    <!-- Describes if the AM/PM on the screensaver is displayed on a 12 hour text clock -->
    <string name="show_ampm_summary">If the AM/PM descriptor is displayed in the digital clock</string>
    <!-- Title for switch to pick if the clock text is displayed in bold -->
    <string name="bold_text_title">Bold clock text</string>
    <!-- Describes if the text on the screensaver is displayed in bold -->
    <string name="bold_text_summary">If the digital clock text should be in bold</string>
    <!-- Title for slider to pick if the brightness of the clock in night mode -->
    <string name="night_mode_brightness_text_title">Brightness</string>

    <!-- Title for screen saver clock color -->
    <string name="clock_color_title">Color</string>
    <!-- Color choices for screensaver -->
    <string-array name="clock_color_entries">
        <item>White</item>
        <item>Red</item>
        <item>Green</item>
        <item>Blue</item>
    </string-array>

    <string-array name="clock_color_values" translatable="false">
        <item>FFFFFF</item>
        <item>FF0000</item>
        <item>00FF00</item>
        <item>0000FF</item>
    </string-array>
</resources>
+12 −0
Original line number Diff line number Diff line
@@ -27,6 +27,18 @@
    <string name="full_wday_month_day_no_year">EEEEMMMMd</string>
    <!-- Default clock style. -->
    <string name="default_clock_style">digital</string>
    <!-- Default screensaver clock color. -->
    <string name="default_clock_color">FFFFFF</string>
    <!-- Default screensaver night mode. -->
    <bool name="default_clock_night_mode">true</bool>
    <!-- Default screensaver bold text. -->
    <bool name="default_clock_bold_text">false</bool>
    <!-- Default screensaver show AM/PM. -->
    <bool name="default_clock_show_ampm">true</bool>
    <!-- Default screensaver night mode follows do no disturbe. -->
    <bool name="default_clock_night_mode_dnd">false</bool>
    <!-- Default screensaver night mode brightness. -->
    <string name="default_clock_night_mode_brightness">40</string>
    <!-- ⏰ (A custom font replaces the A glyph with a clock icon) -->
    <string name="clock_emoji">A</string>
    <!-- String for the date in the DigitalAppWidget preview -->
+63 −5
Original line number Diff line number Diff line
@@ -26,11 +26,69 @@
        android:title="@string/clock_style"
        app:iconSpaceReserved="false" />

    <CheckBoxPreference
        android:defaultValue="true"
    <ListPreference
        android:defaultValue="@string/default_clock_color"
        android:entries="@array/clock_color_entries"
        android:entryValues="@array/clock_color_values"
        android:key="screensaver_clock_color"
        android:title="@string/clock_color_title"
        app:iconSpaceReserved="false" />

    <SwitchPreferenceCompat
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:defaultValue="@bool/default_clock_bold_text"
        android:key="screensaver_bold_text"
        android:summary="@string/bold_text_summary"
        android:title="@string/bold_text_title"
        app:iconSpaceReserved="false" />

    <SwitchPreferenceCompat
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:defaultValue="@bool/default_clock_show_ampm"
        android:key="screensaver_show_ampm"
        android:summary="@string/show_ampm_summary"
        android:title="@string/show_ampm_title"
        app:iconSpaceReserved="false" />

    <PreferenceCategory
        android:title="@string/night_mode_title"
        app:iconSpaceReserved="false" >

        <SwitchPreferenceCompat
            android:defaultValue="@bool/default_clock_night_mode"
            android:key="screensaver_night_mode"
            android:summary="@string/night_mode_summary"
        android:title="@string/night_mode_title"
            android:title="@string/night_mode_enabled_title"
            app:iconSpaceReserved="false" />

        <SwitchPreferenceCompat
            android:defaultValue="@bool/default_clock_night_mode_dnd"
            android:key="screensaver_clock_night_mode_dnd"
            android:summary="@string/night_mode_dnd_summary"
            android:title="@string/night_mode_dnd_title"
            android:dependency="screensaver_night_mode"
            app:iconSpaceReserved="false" />

        <ListPreference
            android:defaultValue="@string/default_clock_color"
            android:entries="@array/clock_color_entries"
            android:entryValues="@array/clock_color_values"
            android:key="screensaver_clock_night_mode_color"
            android:title="@string/clock_color_title"
            android:dependency="screensaver_night_mode"
            app:iconSpaceReserved="false" />

        <SeekBarPreference
            android:defaultValue="@string/default_clock_night_mode_brightness"
            android:key="screensaver_clock_night_mode_brightness"
            android:title="@string/night_mode_brightness_text_title"
            android:dependency="screensaver_night_mode"
            android:min="0"
            android:max="100"
            app:iconSpaceReserved="false" />

    </PreferenceCategory>

</PreferenceScreen>
+21 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;

import com.android.deskclock.data.DataModel;
import com.android.deskclock.uidata.UiDataModel;

/**
@@ -40,6 +41,11 @@ public final class MoveScreensaverRunnable implements Runnable {
    /** The duration over which the fade in/out animations occur. */
    private static final long FADE_TIME = 3000L;

    /** The duration (in ms) to delay the start of the fade in animation to allow Do Not Disturb
     * mode to activate.
     */
    private static final int START_DELAY = 5;

    /** Accelerate the hide animation. */
    private final Interpolator mAcceleration = new AccelerateInterpolator();

@@ -113,6 +119,16 @@ public final class MoveScreensaverRunnable implements Runnable {
            mActiveAnimator = getAlphaAnimator(mSaverView, 0f, 1f);
            mActiveAnimator.setDuration(FADE_TIME);
            mActiveAnimator.setInterpolator(mDeceleration);
            // Add a slight delay to allow DND mode to engage for the call to Utils.dimClockView().
            mActiveAnimator.setStartDelay(START_DELAY);
            mActiveAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    // Re-dim the display in case DnD has been enabled and we're following it.
                    Utils.dimClockView(DataModel.getDataModel().getScreensaverNightModeOn(),
                            mSaverView);
                }
            });
        } else {
            // Select a new random position anywhere in mContentView that will fit mSaverView.
            final float newX = getRandomPoint(mContentView.getWidth() - mSaverView.getWidth());
@@ -128,6 +144,8 @@ public final class MoveScreensaverRunnable implements Runnable {
            // Fade in and grow the saver view after altering its position.
            final AnimatorSet show = new AnimatorSet();
            show.setDuration(FADE_TIME);
            // Add a slight delay to allow DND mode to engage for the call to Utils.dimClockView().
            show.setStartDelay(START_DELAY);
            show.setInterpolator(mDeceleration);
            show.play(getAlphaAnimator(mSaverView, 0f, 1f))
                    .with(getScaleAnimator(mSaverView, 0.85f, 1f));
@@ -136,6 +154,9 @@ public final class MoveScreensaverRunnable implements Runnable {
                public void onAnimationStart(Animator animation) {
                    mSaverView.setX(newX);
                    mSaverView.setY(newY);
                    // Re-dim the display in case DnD has been enabled and we're following it.
                    Utils.dimClockView(DataModel.getDataModel().getScreensaverNightModeOn(),
                            mSaverView);
                }
            });

+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ public final class Screensaver extends DreamService {

    private void setClockStyle() {
        Utils.setScreensaverClockStyle(mDigitalClock, mAnalogClock);
        final boolean dimNightMode = DataModel.getDataModel().getScreensaverNightModeOn();
        boolean dimNightMode = DataModel.getDataModel().getScreensaverNightModeOn();
        Utils.dimClockView(dimNightMode, mMainClockView);
        setScreenBright(!dimNightMode);
    }
Loading