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

Unverified Commit 8dfc4272 authored by Luca Stefani's avatar Luca Stefani Committed by Michael Bestas
Browse files

SystemUI: Add tunables for clock position

Author: Hendrik Hagendorn <git@finnq.de>
Date:   Sun Jan 15 10:00:12 2017 +0100
    Tuner: Move clock seconds option to status bar settings

    Change-Id: I532c179f06b934009d48433e50b69660247ee295

Author: Luca Stefani <luca.stefani.ge1@gmail.com>
Date:   Sun Jul 29 14:19:08 2018 +0200
    SystemUI: Fix default clock blacklist value

    Change-Id: Ibdc4f6a707569ddb417854760cf579daca989ebb

Author: LuK1337 <priv.luk@gmail.com>
Date:   Wed Aug 1 18:10:39 2018 +0200
    SystemUI: Initialize mClockVisibleByUser to android:visibility

    * Fixes ~ triple clock ~ after leaving from Google SUW.

    Change-Id: I3ceea4400b3057e2b6b1f221f9074b1d451133ea

Author: LuK1337 <priv.luk@gmail.com>
Date:   Thu Sep 27 12:24:19 2018 +0200
    SystemUI: Fix clock icon blacklist handling

    * This makes sure clock isn't on blacklist before
      calling showClock(animate);

    Change-Id: I7f77a83aa6c109e1682d764fb22701375ae5ba1e

Author: LuK1337 <priv.luk@gmail.com>
Date:   Tue Apr 2 20:56:25 2019 +0200
    SystemUI: Don't hide right clock when heads up is visible

    * https://gitlab.com/LineageOS/issues/android/issues/436



    Change-Id: I85a6cd2dff79e6b97d8a7db552c22d611bf25dbd

Author: LuK1337 <priv.luk@gmail.com>
Date:   Wed Oct 30 15:48:38 2019 +0100
    SystemUI: Fix up right clock handling when showing heads up

    * Oops, we somehow forgot to import this code from 16.0 ;-;

    Change-Id: Ic4195a30da2870f569f07fc323e4b939320ab6c8

Author: Michael W <baddaemon87@gmail.com>
Date:   Mon Jun 1 14:43:31 2020 +0200
    SystemUI: Make clock truly invisible

    * When the clock is set to left and then hidden, the notification
      icons, which would appear on the left first transition to the
      right to make place for the clock then finally snap into place
    * The same happens when the clock was set to show right and then
      is hidden: The battery, wifi, etc. icons do leave space for the
      (not displayed) clock and then snap to the right
    * This patch fixes the behavior

    Change-Id: Ic68b1001becb91da6f1aeaca95a7312b36e1d2a1

Author: LuK1337 <priv.luk@gmail.com>
Date:   Sat Apr 10 22:52:25 2021 +0200
    SystemUI: Make center clock layout safe insets aware

    This effectively fixes wrongly centered clock layout on
    devices with side notch / hole punch.

    Change-Id: I7cb8cbbe628397c50d37e23ba1853368e61a1fc9

Author: LuK1337 <priv.luk@gmail.com>
Date:   Sun Apr 11 09:47:17 2021 +0200
    SystemUI: Move network traffic monitor under same layout as clock

    This effectively fixes wrongly network monitor layout on
    devices with side notch / hole punch.

    Change-Id: I217b886d8da75eab7636066f4822f5fd6dbc9aff

Author: Volodymyr Zhdanov <wight554@gmail.com>
Date:   Tue Nov 9 20:53:56 2021 +0200
    SystemUI: fix clock dark/light mode switching

    * move ClockController init to PhoneStatusBarView
    * move add/remove dark receiver logic to ClockController

    Change-Id: I6464af6e8aa130ea54fe7bfa19858c8930a29b1e

Change-Id: Icdc039d13fd2676c1eb979a81fb77f9a6ec59b4a
Signed-off-by: default avatarVolodymyr Zhdanov <wight554@gmail.com>
parent cfa04152
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -123,6 +123,24 @@
        </com.android.keyguard.AlphaOptimizedLinearLayout>
    </LinearLayout>

    <com.android.keyguard.AlphaOptimizedLinearLayout
        android:id="@+id/centered_area"
        android:gravity="center"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        <com.android.systemui.statusbar.policy.Clock
            android:id="@+id/clock_center"
            android:textAppearance="@style/TextAppearance.StatusBar.Clock"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:gravity="center"
            android:visibility="gone"
        />
    </com.android.keyguard.AlphaOptimizedLinearLayout>

    <ViewStub
        android:id="@+id/emergency_cryptkeeper_text"
        android:layout_width="wrap_content"
+19 −0
Original line number Diff line number Diff line
@@ -35,4 +35,23 @@
        android:clipToPadding="false"
        android:clipChildren="false"
        systemui:textAppearance="@style/TextAppearance.StatusBar.Clock" />

    <com.android.keyguard.AlphaOptimizedLinearLayout
        android:id="@+id/right_clock_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >
        <com.android.systemui.statusbar.policy.Clock
            android:id="@+id/clock_right"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:textAppearance="@style/TextAppearance.StatusBar.Clock"
            android:singleLine="true"
            android:paddingStart="@dimen/status_bar_clock_starting_padding"
            android:paddingEnd="@dimen/status_bar_clock_end_padding"
            android:gravity="center_vertical|start"
            android:visibility="gone"
        />
    </com.android.keyguard.AlphaOptimizedLinearLayout>
</LinearLayout>
+3 −4
Original line number Diff line number Diff line
@@ -91,10 +91,9 @@

    <!-- secure -->

    <com.android.systemui.tuner.ClockPreference
        android:title="@string/tuner_time"
        android:summary="%s"
        android:entries="@array/clock_options" />
    <com.android.systemui.tuner.StatusBarSwitch
        android:key="clock"
        android:title="@string/clock" />

    <com.android.systemui.tuner.TunerSwitch
        android:key="low_priority"
+13 −1
Original line number Diff line number Diff line
@@ -36,13 +36,16 @@ import androidx.annotation.NonNull;

import com.android.settingslib.Utils;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetail.Callback;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
import com.android.systemui.statusbar.phone.StatusBarWindowView;
import com.android.systemui.statusbar.phone.StatusIconContainer;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.policy.VariableDateView;
import com.android.systemui.tuner.TunerService;

import java.util.List;

@@ -50,7 +53,7 @@ import java.util.List;
 * View that contains the top-most bits of the QS panel (primarily the status bar with date, time,
 * battery, carrier info and privacy icons) and also contains the {@link QuickQSPanel}.
 */
public class QuickStatusBarHeader extends FrameLayout {
public class QuickStatusBarHeader extends FrameLayout implements TunerService.Tunable {

    private boolean mExpanded;
    private boolean mQsDisabled;
@@ -153,6 +156,9 @@ public class QuickStatusBarHeader extends FrameLayout {
                .addFloat(mIconContainer, "alpha", 0, 1)
                .addFloat(mBatteryRemainingIcon, "alpha", 0, 1)
                .build();

        Dependency.get(TunerService.class).addTunable(this,
                StatusBarIconController.ICON_HIDE_LIST);
    }

    void onAttach(TintedIconManager iconManager,
@@ -543,4 +549,10 @@ public class QuickStatusBarHeader extends FrameLayout {
        mClockIconsView.setScrollY(scrollY);
        mDatePrivacyView.setScrollY(scrollY);
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        mClockView.setClockVisibleByUser(!StatusBarIconController.getIconHideList(
                mContext, newValue).contains("clock"));
    }
}
+105 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 * 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.systemui.statusbar.phone;

import android.content.Context;
import android.util.Log;
import android.view.View;

import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.tuner.TunerService;

import lineageos.providers.LineageSettings;

public class ClockController implements TunerService.Tunable {

    private static final String TAG = "ClockController";

    private static final String CLOCK_POSITION =
            "lineagesystem:" + LineageSettings.System.STATUS_BAR_CLOCK;

    private static final int CLOCK_POSITION_RIGHT = 0;
    private static final int CLOCK_POSITION_CENTER = 1;
    private static final int CLOCK_POSITION_LEFT = 2;

    private Context mContext;
    private Clock mActiveClock, mCenterClock, mLeftClock, mRightClock;

    private int mClockPosition = CLOCK_POSITION_LEFT;
    private boolean mBlackListed = false;

    public ClockController(Context context, View statusBar) {
        mContext = context;

        mCenterClock = statusBar.findViewById(R.id.clock_center);
        mLeftClock = statusBar.findViewById(R.id.clock);
        mRightClock = statusBar.findViewById(R.id.clock_right);

        mActiveClock = mLeftClock;

        Dependency.get(TunerService.class).addTunable(this,
                StatusBarIconController.ICON_HIDE_LIST, CLOCK_POSITION);
    }

    public Clock getClock() {
        switch (mClockPosition) {
            case CLOCK_POSITION_RIGHT:
                return mRightClock;
            case CLOCK_POSITION_CENTER:
                return mCenterClock;
            case CLOCK_POSITION_LEFT:
            default:
                return mLeftClock;
        }
    }

    private void updateActiveClock() {
        mActiveClock.setClockVisibleByUser(false);
        removeDarkReceiver();
        mActiveClock = getClock();
        mActiveClock.setClockVisibleByUser(true);
        addDarkReceiver();

        // Override any previous setting
        mActiveClock.setClockVisibleByUser(!mBlackListed);
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        Log.d(TAG, "onTuningChanged key=" + key + " value=" + newValue);

        if (CLOCK_POSITION.equals(key)) {
            mClockPosition = TunerService.parseInteger(newValue, CLOCK_POSITION_LEFT);
        } else {
            mBlackListed = StatusBarIconController.getIconHideList(
                    mContext, newValue).contains("clock");
        }
        updateActiveClock();
    }

    public void addDarkReceiver() {
        Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mActiveClock);
    }

    public void removeDarkReceiver() {
        Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(mActiveClock);
    }
}
Loading