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

Commit 5d7cae9a 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

Change-Id: Icdc039d13fd2676c1eb979a81fb77f9a6ec59b4a
parent 03ee7668
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -112,6 +112,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
@@ -33,4 +33,23 @@
        android:layout_width="wrap_content"
        android:clipToPadding="false"
        android:clipChildren="false" />

    <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
+11 −1
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver;
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;
@@ -73,7 +74,7 @@ import java.util.Objects;
 */
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;

@@ -183,6 +184,9 @@ public class QuickStatusBarHeader extends RelativeLayout implements
        mClockView = findViewById(R.id.clock);
        mClockView.setOnClickListener(this);
        mDateView = findViewById(R.id.date);

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

    private void updateStatusText() {
@@ -608,4 +612,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"));
    }
}
+95 −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;

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

    private Clock mActiveClock, mCenterClock, mLeftClock, mRightClock;
    private View mCenterClockLayout, mRightClockLayout;

    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);

        mCenterClockLayout = statusBar.findViewById(R.id.center_clock_layout);
        mRightClockLayout = statusBar.findViewById(R.id.right_clock_layout);

        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();
    }

    public View getClockLayout() {
        // We default to center, but it has no effect as long the clock itself is invisible
        return mClockPosition == CLOCK_POSITION_RIGHT ? mRightClockLayout : mCenterClockLayout;
    }
}
+10 −5
Original line number Diff line number Diff line
@@ -56,12 +56,12 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
    private KeyguardMonitor mKeyguardMonitor;
    private NetworkController mNetworkController;
    private LinearLayout mSystemIconArea;
    private View mClockView;
    private View mNotificationIconAreaInner;
    private int mDisabled1;
    private StatusBar mStatusBarComponent;
    private DarkIconManager mDarkIconManager;
    private View mOperatorNameFrame;
    private ClockController mClockController;

    private SignalCallback mSignalCallback = new SignalCallback() {
        @Override
@@ -95,7 +95,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
        mDarkIconManager.setShouldLog(true);
        Dependency.get(StatusBarIconController.class).addIconGroup(mDarkIconManager);
        mSystemIconArea = mStatusBar.findViewById(R.id.system_icon_area);
        mClockView = mStatusBar.findViewById(R.id.clock);
        mClockController = new ClockController(mStatusBar);
        showSystemIconArea(false);
        showClock(false);
        initEmergencyCryptkeeperText();
@@ -167,7 +167,8 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
        }
        // The clock may have already been hidden, but we might want to shift its
        // visibility to GONE from INVISIBLE or vice versa
        if ((diff1 & DISABLE_CLOCK) != 0 || mClockView.getVisibility() != clockHiddenMode()) {
        if ((diff1 & DISABLE_CLOCK) != 0 ||
                mClockController.getClock().getVisibility() != clockHiddenMode()) {
            if ((state1 & DISABLE_CLOCK) != 0) {
                hideClock(animate);
            } else {
@@ -207,18 +208,20 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue

    public void hideSystemIconArea(boolean animate) {
        animateHide(mSystemIconArea, animate);
        animateHide(mClockController.getClockLayout(), animate);
    }

    public void showSystemIconArea(boolean animate) {
        animateShow(mSystemIconArea, animate);
        animateShow(mClockController.getClockLayout(), animate);
    }

    public void hideClock(boolean animate) {
        animateHiddenState(mClockView, clockHiddenMode(), animate);
        animateHiddenState(mClockController.getClock(), clockHiddenMode(), animate);
    }

    public void showClock(boolean animate) {
        animateShow(mClockView, animate);
        animateShow(mClockController.getClock(), animate);
    }

    /**
@@ -234,10 +237,12 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue

    public void hideNotificationIconArea(boolean animate) {
        animateHide(mNotificationIconAreaInner, animate);
        animateHide(mClockController.getClockLayout(), animate);
    }

    public void showNotificationIconArea(boolean animate) {
        animateShow(mNotificationIconAreaInner, animate);
        animateShow(mClockController.getClockLayout(), animate);
    }

    public void hideOperatorName(boolean animate) {
Loading