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

Commit 20efbbbb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixing notification dots settings not updated properly" into sc-dev

parents 7a5b6f86 58530bd6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class RecentsAnimationDeviceState implements
            SettingsCache.OnChangeListener onChangeListener =
                    enabled -> mIsOneHandedModeEnabled = enabled;
            settingsCache.register(oneHandedUri, onChangeListener);
            settingsCache.dispatchOnChange(oneHandedUri);
            mIsOneHandedModeEnabled = settingsCache.getValue(oneHandedUri);
            runOnDestroy(() -> settingsCache.unregister(oneHandedUri, onChangeListener));
        } else {
            mIsOneHandedModeEnabled = false;
@@ -199,7 +199,7 @@ public class RecentsAnimationDeviceState implements
        SettingsCache.OnChangeListener onChangeListener =
                enabled -> mIsSwipeToNotificationEnabled = enabled;
        settingsCache.register(swipeBottomNotificationUri, onChangeListener);
        settingsCache.dispatchOnChange(swipeBottomNotificationUri);
        mIsSwipeToNotificationEnabled = settingsCache.getValue(swipeBottomNotificationUri);
        runOnDestroy(() -> settingsCache.unregister(swipeBottomNotificationUri, onChangeListener));

        Uri setupCompleteUri = Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE);
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class SettingsChangeLogger implements
        SettingsCache mSettingsCache = SettingsCache.INSTANCE.get(context);
        mSettingsCache.register(NOTIFICATION_BADGING_URI,
                this::onNotificationDotsChanged);
        mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
        onNotificationDotsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));
    }

    private static ArrayMap<String, LoggablePref> loadPrefKeys(Context context) {
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public class LauncherAppState {
        mNotificationSettingsChangedListener = this::onNotificationSettingsChanged;
        mSettingsCache.register(NOTIFICATION_BADGING_URI,
                mNotificationSettingsChangedListener);
        mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
        onNotificationSettingsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));
    }

    public LauncherAppState(Context context, @Nullable String iconCacheFileName) {
+3 −3
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@

package com.android.launcher3.notification;

import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;

import android.annotation.TargetApi;
import android.app.Notification;
@@ -37,8 +37,8 @@ import androidx.annotation.AnyThread;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;

import com.android.launcher3.util.SettingsCache;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.SettingsCache;

import java.util.ArrayList;
import java.util.Arrays;
@@ -213,7 +213,7 @@ public class NotificationListener extends NotificationListenerService {
        mNotificationSettingsChangedListener = this::onNotificationSettingsChanged;
        mSettingsCache.register(NOTIFICATION_BADGING_URI,
                mNotificationSettingsChangedListener);
        mSettingsCache.dispatchOnChange(NOTIFICATION_BADGING_URI);
        onNotificationSettingsChanged(mSettingsCache.getValue(NOTIFICATION_BADGING_URI));

        onNotificationFullRefresh();
    }
+34 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ package com.android.launcher3.settings;

import static com.android.launcher3.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
import static com.android.launcher3.settings.SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGS;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;

import android.app.AlertDialog;
import android.app.Dialog;
@@ -24,6 +26,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.ContentObserver;
import android.os.Bundle;
import android.provider.Settings;
import android.util.AttributeSet;
@@ -49,6 +52,14 @@ public class NotificationDotsPreference extends Preference
    /** Hidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS */
    private static final String NOTIFICATION_ENABLED_LISTENERS = "enabled_notification_listeners";

    private final ContentObserver mListenerListObserver =
            new ContentObserver(MAIN_EXECUTOR.getHandler()) {
        @Override
        public void onChange(boolean selfChange) {
            updateUI();
        }
    };

    public NotificationDotsPreference(
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
@@ -66,6 +77,29 @@ public class NotificationDotsPreference extends Preference
        super(context);
    }

    @Override
    public void onAttached() {
        super.onAttached();
        SettingsCache.INSTANCE.get(getContext()).register(NOTIFICATION_BADGING_URI, this);
        getContext().getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(NOTIFICATION_ENABLED_LISTENERS),
                false, mListenerListObserver);
        updateUI();
    }

    private void updateUI() {
        onSettingsChanged(SettingsCache.INSTANCE.get(getContext())
                .getValue(NOTIFICATION_BADGING_URI));
    }

    @Override
    public void onDetached() {
        super.onDetached();
        SettingsCache.INSTANCE.get(getContext()).unregister(NOTIFICATION_BADGING_URI, this);
        getContext().getContentResolver().unregisterContentObserver(mListenerListObserver);

    }

    private void setWidgetFrameVisible(boolean isVisible) {
        if (mWidgetFrameVisible != isVisible) {
            mWidgetFrameVisible = isVisible;
Loading