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

Commit 5e0404f6 authored by Luca Stefani's avatar Luca Stefani Committed by Michael Bestas
Browse files

SystemUI: Add tunables for clock position

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: 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:   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:   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: 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: dianlujitao <dianlujitao@lineageos.org>
Date:   Thu Nov 15 11:33:20 2018 +0800

    TunerServiceImpl: Blacklist Lineage settings from tuner reset

     * They use the tunable infrastructure but are real user settings and
       shouldn't be reset with tuner settings. Moreover, setting them to
       null would cause a IllegalArgumentException.

    Change-Id: Ie05910efaee867632a3bd2e84625d7735259130e

Change-Id: Icdc039d13fd2676c1eb979a81fb77f9a6ec59b4a
parent eb7c2293
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -122,6 +122,24 @@
        </com.android.keyguard.AlphaOptimizedLinearLayout>
    </LinearLayout>

    <com.android.keyguard.AlphaOptimizedLinearLayout
        android:id="@+id/center_clock_layout"
        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>
 No newline at end of file
+3 −4
Original line number Diff line number Diff line
@@ -89,10 +89,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"
+12 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import androidx.annotation.VisibleForTesting;

import com.android.settingslib.Utils;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.Dependency;
import com.android.systemui.DualToneHandler;
import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter;
@@ -66,6 +67,7 @@ import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.policy.DateView;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;

import java.util.Locale;
import java.util.Objects;
@@ -80,7 +82,7 @@ import javax.inject.Named;
 */
public class QuickStatusBarHeader extends RelativeLayout implements
        View.OnClickListener, NextAlarmController.NextAlarmChangeCallback,
        ZenModeController.Callback {
        ZenModeController.Callback, TunerService.Tunable {
    private static final String TAG = "QuickStatusBarHeader";
    private static final boolean DEBUG = false;

@@ -205,6 +207,9 @@ public class QuickStatusBarHeader extends RelativeLayout implements
        mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ESTIMATE);
        mRingerModeTextView.setSelected(true);
        mNextAlarmTextView.setSelected(true);

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

    private void updateStatusText() {
@@ -532,4 +537,10 @@ public class QuickStatusBarHeader extends RelativeLayout implements
            lp.rightMargin = sideMargins;
        }
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        mClockView.setClockVisibleByUser(!StatusBarIconController.getIconBlacklist(newValue)
                .contains("clock"));
    }
}
+86 −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.util.Log;
import android.view.View;

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

public class ClockController implements TunerService.Tunable {

    private static final String TAG = "ClockController";

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

    public static final String CLOCK_POSITION = "lineagesystem:status_bar_clock";

    private Clock mActiveClock, mCenterClock, mLeftClock, mRightClock;

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

    public ClockController(View statusBar) {
        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_BLACKLIST, 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);
        mActiveClock = getClock();
        mActiveClock.setClockVisibleByUser(true);

        // 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 = newValue == null ? CLOCK_POSITION_LEFT : Integer.valueOf(newValue);
        } else {
            mBlackListed = StatusBarIconController.getIconBlacklist(newValue).contains("clock");
        }
        updateActiveClock();
    }
}
Loading