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

Commit f84effa5 authored by Bruno Martins's avatar Bruno Martins
Browse files

StatusBarSettings: Fix NW traffic not being properly hidden from search

On devices with notches (those that obviously set the overlay config),
the network traffic monitor preference can still appear in settings
search results. Fix this by not depending on whether the user has ever
opened status bar settings. Additionally turn the static boolean variable
into non-static since it no longer makes sense.

Change-Id: I7d4ed3d8fc84949a67e6d5f98c9a6e8719385ab0
parent 3cf195cc
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014-2015 The CyanogenMod Project
 *               2017-2019 The LineageOS Project
 *               2017-2020 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.
@@ -35,6 +35,7 @@ import org.lineageos.lineageparts.R;
import org.lineageos.lineageparts.SettingsPreferenceFragment;
import org.lineageos.lineageparts.search.BaseSearchIndexProvider;
import org.lineageos.lineageparts.search.Searchable;
import org.lineageos.lineageparts.utils.DeviceUtils;

import java.util.Set;

@@ -70,7 +71,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment
    private PreferenceCategory mStatusBarClockCategory;
    private PreferenceScreen mNetworkTrafficPref;

    private static boolean sHasNotch;
    private boolean mHasNotch;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -79,10 +80,8 @@ public class StatusBarSettings extends SettingsPreferenceFragment

        mNetworkTrafficPref = (PreferenceScreen) findPreference(NETWORK_TRAFFIC_SETTINGS);

        sHasNotch = getResources().getBoolean(
                org.lineageos.platform.internal.R.bool.config_haveNotch);

        if (sHasNotch) {
        mHasNotch = DeviceUtils.hasNotch(getActivity());
        if (mHasNotch) {
            getPreferenceScreen().removePreference(mNetworkTrafficPref);
        }

@@ -135,7 +134,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment
            mStatusBarAmPm.setSummary(R.string.status_bar_am_pm_info);
        }

        final boolean disallowCenteredClock = sHasNotch || getNetworkTrafficStatus() != 0;
        final boolean disallowCenteredClock = mHasNotch || getNetworkTrafficStatus() != 0;

        // Adjust status bar preferences for RTL
        if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
@@ -203,7 +202,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment
    }

    private void updateNetworkTrafficStatus(int clockPosition) {
        if (sHasNotch) {
        if (mHasNotch) {
            // Unconditional no network traffic for you
            return;
        }
@@ -233,7 +232,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment
        public Set<String> getNonIndexableKeys(Context context) {
            final Set<String> result = new ArraySet<String>();

            if (sHasNotch) {
            if (DeviceUtils.hasNotch(context)) {
                result.add(NETWORK_TRAFFIC_SETTINGS);
            }
            return result;
+6 −0
Original line number Diff line number Diff line
@@ -39,6 +39,12 @@ import static org.lineageos.internal.util.DeviceKeysConstants.*;

public class DeviceUtils {

    /* returns whether the device has a notch or not. */
    public static boolean hasNotch(Context context) {
        return context.getResources().getBoolean(
                org.lineageos.platform.internal.R.bool.config_haveNotch);
    }

    /* returns whether the device has volume rocker or not. */
    public static boolean hasVolumeRocker(Context context) {
        final int deviceKeys = context.getResources().getInteger(