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

Commit 901d54cf authored by Luca Stefani's avatar Luca Stefani Committed by Bruno Martins
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

Change-Id: Icdc039d13fd2676c1eb979a81fb77f9a6ec59b4a
parent 08f08ad5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -137,6 +137,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>
+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
@@ -57,6 +57,7 @@ import androidx.lifecycle.LifecycleRegistry;

import com.android.settingslib.Utils;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.Dependency;
import com.android.systemui.DualToneHandler;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
@@ -75,6 +76,7 @@ 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.util.RingerModeTracker;
import com.android.systemui.tuner.TunerService;

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

@@ -229,6 +231,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);
    }

    public QuickQSPanel getHeaderQsPanel() {
@@ -640,4 +645,10 @@ public class QuickStatusBarHeader extends RelativeLayout implements
            updateHeaderTextContainerAlphaAnimator();
        }
    }

    @Override
    public void onTuningChanged(String key, String newValue) {
        mClockView.setClockVisibleByUser(!StatusBarIconController.getIconBlacklist(
                mContext, newValue).contains("clock"));
    }
}
+94 −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.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_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 = TunerService.parseInteger(newValue, CLOCK_POSITION_LEFT);
        } else {
            mBlackListed = StatusBarIconController.getIconBlacklist(
                    mContext, newValue).contains("clock");
        }
        updateActiveClock();
    }
}
Loading