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

Commit d166291a authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge remote-tracking branch 'origin/lineage-23.2' into a16.2

parents 555010b7 57b0c58b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     SPDX-FileCopyrightText: 2014 The CyanogenMod Project
     SPDX-FileCopyrightText: 2017 The LineageOS Project
     SPDX-FileCopyrightText: 2017-2026 The LineageOS Project
     SPDX-License-Identifier: Apache-2.0
-->
<resources>
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     SPDX-FileCopyrightText: 2015 The CyanogenMod Project
     SPDX-FileCopyrightText: 2017-2025 The LineageOS Project
     SPDX-FileCopyrightText: 2017-2026 The LineageOS Project
     SPDX-License-Identifier: Apache-2.0
-->
<resources>
+11 −1
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2015-2016 The CyanogenMod Project
 * SPDX-FileCopyrightText: 2017-2025 The LineageOS Project
 * SPDX-FileCopyrightText: 2017-2026 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -2918,6 +2918,15 @@ public final class LineageSettings {
        /** @hide */
        public static final Validator NETWORK_TRAFFIC_AUTOHIDE_VALIDATOR = sBooleanValidator;

        /**
         * Whether or not to hide network traffic direction arrows
         * @hide
         */
        public static final String NETWORK_TRAFFIC_HIDE_ARROWS = "network_traffic_hide_arrows";

        /** @hide */
        public static final Validator NETWORK_TRAFFIC_HIDE_ARROWS_VALIDATOR = sBooleanValidator;

        /**
         * Measurement unit preference for network traffic
         * 0 = kBit/s
@@ -3004,6 +3013,7 @@ public final class LineageSettings {
            VALIDATORS.put(NETWORK_TRAFFIC_MODE, NETWORK_TRAFFIC_MODE_VALIDATOR);
            VALIDATORS.put(NETWORK_TRAFFIC_POSITION, NETWORK_TRAFFIC_POSITION_VALIDATOR);
            VALIDATORS.put(NETWORK_TRAFFIC_AUTOHIDE, NETWORK_TRAFFIC_AUTOHIDE_VALIDATOR);
            VALIDATORS.put(NETWORK_TRAFFIC_HIDE_ARROWS, NETWORK_TRAFFIC_HIDE_ARROWS_VALIDATOR);
            VALIDATORS.put(NETWORK_TRAFFIC_UNITS, NETWORK_TRAFFIC_UNITS_VALIDATOR);
            VALIDATORS.put(NETWORK_TRAFFIC_SHOW_UNITS, NETWORK_TRAFFIC_SHOW_UNITS_VALIDATOR);
            VALIDATORS.put(TRUST_WARNINGS, TRUST_WARNINGS_VALIDATOR);
+8 −6
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2018 The LineageOS project
 * SPDX-FileCopyrightText: 2018-2026 The LineageOS project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -14,17 +14,19 @@ import java.util.ArrayList;
public class LineageStatusBarItem {

    public interface Manager {
        public void addDarkReceiver(DarkReceiver darkReceiver);
        public void addVisibilityReceiver(VisibilityReceiver visibilityReceiver);
        void addDarkReceiver(DarkReceiver darkReceiver);
        void removeDarkReceiver(DarkReceiver darkReceiver);
        void addVisibilityReceiver(VisibilityReceiver visibilityReceiver);
        void removeVisibilityReceiver(VisibilityReceiver visibilityReceiver);
    }

    public interface DarkReceiver {
        public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint);
        public void setFillColors(int darkColor, int lightColor);
        void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint);
        void setFillColors(int darkColor, int lightColor);
    }

    public interface VisibilityReceiver {
        public void onVisibilityChanged(boolean isVisible);
        void onVisibilityChanged(boolean isVisible);
    }

    // Locate parent LineageStatusBarItem.Manager
+26 −6
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2017-2025 The LineageOS project
 * SPDX-FileCopyrightText: 2017-2026 The LineageOS project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -93,6 +93,7 @@ public class NetworkTraffic extends TextView {
    private long mLastRxBytes;
    private long mLastUpdateTime;
    private boolean mAutoHide;
    private boolean mHideArrows;
    private long mAutoHideThreshold;
    private int mUnits;
    private int mShowUnits;
@@ -109,6 +110,8 @@ public class NetworkTraffic extends TextView {
    // to current stats have changed.
    private boolean mNetworksChanged = true;

    private LineageStatusBarItem.Manager mManager;

    public NetworkTraffic(Context context) {
        this(context, null);
    }
@@ -394,10 +397,11 @@ public class NetworkTraffic extends TextView {
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        LineageStatusBarItem.Manager manager =
                LineageStatusBarItem.findManager((View) this);
        manager.addDarkReceiver(mDarkReceiver);
        manager.addVisibilityReceiver(mVisibilityReceiver);
        mManager = LineageStatusBarItem.findManager(this);
        if (mManager != null) {
            mManager.addDarkReceiver(mDarkReceiver);
            mManager.addVisibilityReceiver(mVisibilityReceiver);
        }

        mObserver.observe();
        updateSettings();
@@ -406,7 +410,15 @@ public class NetworkTraffic extends TextView {
    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        if (mManager != null) {
            mManager.removeDarkReceiver(mDarkReceiver);
            mManager.removeVisibilityReceiver(mVisibilityReceiver);
            mManager = null;
        }

        mObserver.unobserve();
        mTrafficHandler.removeCallbacksAndMessages(null);
        unregisterNetworkCallbacks();
    }

@@ -426,6 +438,9 @@ public class NetworkTraffic extends TextView {
            resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
                    LineageSettings.Secure.NETWORK_TRAFFIC_AUTOHIDE),
                    false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
                    LineageSettings.Secure.NETWORK_TRAFFIC_HIDE_ARROWS),
                    false, this, UserHandle.USER_ALL);
            resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
                    LineageSettings.Secure.NETWORK_TRAFFIC_UNITS),
                    false, this, UserHandle.USER_ALL);
@@ -457,6 +472,8 @@ public class NetworkTraffic extends TextView {
                LineageSettings.Secure.NETWORK_TRAFFIC_POSITION, POSITION_CENTER);
        mAutoHide = LineageSettings.Secure.getInt(resolver,
                LineageSettings.Secure.NETWORK_TRAFFIC_AUTOHIDE, 0) == 1;
        mHideArrows = LineageSettings.Secure.getInt(resolver,
                LineageSettings.Secure.NETWORK_TRAFFIC_HIDE_ARROWS, 0) == 1;
        mUnits = LineageSettings.Secure.getInt(resolver,
                LineageSettings.Secure.NETWORK_TRAFFIC_UNITS, UNITS_KILOBYTES);
        mShowUnits = LineageSettings.Secure.getInt(resolver,
@@ -495,7 +512,9 @@ public class NetworkTraffic extends TextView {

    private void updateTrafficDrawable() {
        final int drawableResId;
        if (mMode == MODE_UPSTREAM_AND_DOWNSTREAM) {
        if (mHideArrows) {
            drawableResId = 0;
        } else if (mMode == MODE_UPSTREAM_AND_DOWNSTREAM) {
            drawableResId = R.drawable.stat_sys_network_traffic_updown;
        } else if (mMode == MODE_UPSTREAM_ONLY) {
            drawableResId = R.drawable.stat_sys_network_traffic_up;
@@ -505,6 +524,7 @@ public class NetworkTraffic extends TextView {
            drawableResId = 0;
        }
        mDrawable = drawableResId != 0 ? getResources().getDrawable(drawableResId) : null;
        setCompoundDrawablePadding(0);
        setCompoundDrawablesWithIntrinsicBounds(null, null, mDrawable, null);
        updateTrafficDrawableColor();
    }