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

Commit ce8c204e authored by Robert Snoeberger's avatar Robert Snoeberger
Browse files

Add custom typographic clock face.

Bug: 122301289
Test: Used adb to enable clock face.
Change-Id: I052367c9671697f621cba4ecb7e6b21c0cec784c
parent 1f2ef22c
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2019 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.
  -->
<com.android.keyguard.clock.ClockLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
  >
  <com.android.keyguard.clock.TypographicClock
      android:id="@+id/type_clock"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
    >
    <TextView
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        style="@style/widget_big"
        android:textColor="@color/typeClockAccentColor"
        android:text="@string/type_clock_header"
        android:textSize="40dp"
    />
    <TextView
        android:id="@+id/hour"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        style="@style/widget_big"
        android:textSize="40dp"
    />
    <TextView
        android:id="@+id/minute"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="50dp"
        style="@style/widget_big"
        android:textSize="40dp"
    />
  </com.android.keyguard.clock.TypographicClock>
</com.android.keyguard.clock.ClockLayout>
+2 −0
Original line number Diff line number Diff line
@@ -19,4 +19,6 @@
  <color name="bubbleHourHandColor">#C97343</color>
  <!-- Default color for minute hand of Bubble clock. -->
  <color name="bubbleMinuteHandColor">#F5C983</color>
  <!-- Accent color for Typographic clock. -->
  <color name="typeClockAccentColor">#F5C983</color>
</resources>
+83 −0
Original line number Diff line number Diff line
@@ -402,4 +402,87 @@ number">%d</xliff:g> remaining attempt before SIM becomes permanently unusable.
number">%d</xliff:g> remaining attempts before SIM becomes permanently unusable. Contact carrier for details.</item>
    </plurals>

    <!-- Header for typographic clock face. [CHAR LIMIT=8] -->
    <string name="type_clock_header">It\u2019s</string>

    <!-- Hour displayed in words on the typographic clock face. [CHAR LIMIT=8] -->
    <string-array name="type_clock_hours">
        <item>Twelve</item>
        <item>One</item>
        <item>Two</item>
        <item>Three</item>
        <item>Four</item>
        <item>Five</item>
        <item>Six</item>
        <item>Seven</item>
        <item>Eight</item>
        <item>Nine</item>
        <item>Ten</item>
        <item>Eleven</item>
    </string-array>

    <!-- Minutes displayed in words on the typographic clock face. [CHAR LIMIT=16] -->
    <string-array name="type_clock_minutes">
        <item>O\u2019Clock</item>
        <item>O\u2019One</item>
        <item>O\u2019Two</item>
        <item>O\u2019Three</item>
        <item>O\u2019Four</item>
        <item>O\u2019Five</item>
        <item>O\u2019Six</item>
        <item>O\u2019Seven</item>
        <item>O\u2019Eight</item>
        <item>O\u2019Nine</item>
        <item>Ten</item>
        <item>Eleven</item>
        <item>Twelve</item>
        <item>Thirteen</item>
        <item>Fourteen</item>
        <item>Fifteen</item>
        <item>Sixteen</item>
        <item>Seventeen</item>
        <item>Eighteen</item>
        <item>Nineteen</item>
        <item>Twenty</item>
        <item>Twenty\nOne</item>
        <item>Twenty\nTwo</item>
        <item>Twenty\nThree</item>
        <item>Twenty\nFour</item>
        <item>Twenty\nFive</item>
        <item>Twenty\nSix</item>
        <item>Twenty\nSeven</item>
        <item>Twenty\nEight</item>
        <item>Twenty\nNine</item>
        <item>Thirty</item>
        <item>Thirty\nOne</item>
        <item>Thirty\nTwo</item>
        <item>Thirty\nThree</item>
        <item>Thirty\nFour</item>
        <item>Thirty\nFive</item>
        <item>Thirty\nSix</item>
        <item>Thirty\nSeven</item>
        <item>Thirty\nEight</item>
        <item>Thirty\nNine</item>
        <item>Forty</item>
        <item>Forty\nOne</item>
        <item>Forty\nTwo</item>
        <item>Forty\nThree</item>
        <item>Forty\nFour</item>
        <item>Forty\nFive</item>
        <item>Forty\nSix</item>
        <item>Forty\nSeven</item>
        <item>Forty\nEight</item>
        <item>Forty\nNine</item>
        <item>Fifty</item>
        <item>Fifty\nOne</item>
        <item>Fifty\nTwo</item>
        <item>Fifty\nThree</item>
        <item>Fifty\nFour</item>
        <item>Fifty\nFive</item>
        <item>Fifty\nSix</item>
        <item>Fifty\nSeven</item>
        <item>Fifty\nEight</item>
        <item>Fifty\nNine</item>
    </string-array>

</resources>
+7 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import androidx.annotation.VisibleForTesting;

import com.android.keyguard.clock.BubbleClockController;
import com.android.keyguard.clock.StretchAnalogClockController;
import com.android.keyguard.clock.TypeClockController;
import com.android.systemui.Dependency;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.statusbar.StatusBarState;
@@ -153,6 +154,12 @@ public class KeyguardClockSwitch extends RelativeLayout {
                                Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE,
                                StretchAnalogClockController.class.getName(),
                                () -> StretchAnalogClockController.build(mLayoutInflater)))
                .withDefault(
                        new SettingsGattedSupplier(
                                mContentResolver,
                                Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE,
                                TypeClockController.class.getName(),
                                () -> TypeClockController.build(mLayoutInflater)))
                .build();
        mContentResolver.registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE),
+8 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public class ClockLayout extends FrameLayout {
     */
    private View mDigitalClock;
    private View mAnalogClock;
    private View mTypeClock;

    /**
     * Pixel shifting amplitidues used to prevent screen burn-in.
@@ -60,6 +61,7 @@ public class ClockLayout extends FrameLayout {
        super.onFinishInflate();
        mDigitalClock = findViewById(R.id.digital_clock);
        mAnalogClock = findViewById(R.id.analog_clock);
        mTypeClock = findViewById(R.id.type_clock);

        // Get pixel shifting X, Y amplitudes from resources.
        Resources resources = getResources();
@@ -89,5 +91,11 @@ public class ClockLayout extends FrameLayout {
            mAnalogClock.setY(Math.max(0f, 0.5f * (getHeight() - mAnalogClock.getHeight()))
                    + offsetY);
        }

        // Put the typographic clock part way down the screen.
        if (mTypeClock != null) {
            mTypeClock.setX(offsetX);
            mTypeClock.setY(0.2f * getHeight() + offsetY);
        }
    }
}
Loading