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

Commit 1d0c11ef authored by narinder Rana's avatar narinder Rana
Browse files

set observer in StatusIconContainer.java

parent 8e8e942c
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -465,23 +465,11 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue

            Log.e("showHideNotificationIcon", "Testing....onChange................selfChange...... "+selfChange+".....Uri...."+uri);



            int hide_notificationIcon_left_system_icon = LineageSettings.System.getIntForUser(
                    getContext().getContentResolver(), uri.getLastPathSegment(), 0, mUser);


            Log.e("showHideNotificationIcon", "onChange................hide_notificationIcon_left_system_icon..... "+hide_notificationIcon_left_system_icon);


            showHideNotificationIcon(hide_notificationIcon_left_system_icon);
//
//            updateShowPercent();
//            if (TextUtils.equals(uri.getLastPathSegment(),
//                    Settings.Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME)) {
//                // update the text for sure if the estimate in the cache was updated
//                updatePercentText();
//            }

        }
    }

+64 −8
Original line number Diff line number Diff line
@@ -43,6 +43,18 @@ import java.util.List;
import lineageos.providers.LineageSettings;
import android.util.Log;


import android.content.SharedPreferences;
import android.preference.PreferenceManager;
// LineageSettings.System.HIDE_NOTIFICATIONICON_LEFT_SYSTEM_ICON
import android.database.ContentObserver;

import android.net.Uri;
import android.os.Handler;
import android.app.ActivityManager;

import static lineageos.providers.LineageSettings.System.HIDE_NOTIFICATIONICON_LEFT_SYSTEM_ICON;

/**
 * A container for Status bar system icons. Limits the number of system icons and handles overflow
 * similar to {@link NotificationIconContainer}.
@@ -74,14 +86,39 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
    // Any ignored icon will never be added as a child
    private ArrayList<String> mIgnoredSlots = new ArrayList<>();

    private SettingObserver mSettingObserver;
    private int mUser;



    public StatusIconContainer(Context context) {
        this(context, null);
        mSettingObserver = new SettingObserver(new Handler(context.getMainLooper()));

        //unRegister
        context.getContentResolver().unregisterContentObserver(mSettingObserver);
        //register
        mUser = ActivityManager.getCurrentUser();
        context.getContentResolver().registerContentObserver(
                LineageSettings.System.getUriFor(HIDE_NOTIFICATIONICON_LEFT_SYSTEM_ICON),
                false, mSettingObserver, mUser);
    }

    public StatusIconContainer(Context context, AttributeSet attrs) {
        super(context, attrs);
        initDimens();
        setWillNotDraw(!DEBUG_OVERFLOW);

        mSettingObserver = new SettingObserver(new Handler(context.getMainLooper()));


        //unRegister
        context.getContentResolver().unregisterContentObserver(mSettingObserver);
        //register
        mUser = ActivityManager.getCurrentUser();
        context.getContentResolver().registerContentObserver(
                LineageSettings.System.getUriFor(HIDE_NOTIFICATIONICON_LEFT_SYSTEM_ICON),
                false, mSettingObserver, mUser);
    }

    @Override
@@ -330,14 +367,14 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
            }
        }

        // Stole this from NotificationIconContainer. Not optimal but keeps the layout logic clean
//        if (isLayoutRtl()) {
//            for (int i = 0; i < childCount; i++) {
//                View child = getChildAt(i);
//                StatusIconState state = getViewStateFromChild(child);
//                state.xTranslation = width - state.xTranslation - child.getWidth();
//            }
//        }
         Stole this from NotificationIconContainer. Not optimal but keeps the layout logic clean
        if (isLayoutRtl()) {
            for (int i = 0; i < childCount; i++) {
                View child = getChildAt(i);
                StatusIconState state = getViewStateFromChild(child);
                state.xTranslation = width - state.xTranslation - child.getWidth();
            }
        }
    }

    public void moveLeftRightSystemIcon(){
@@ -476,4 +513,23 @@ public class StatusIconContainer extends AlphaOptimizedLinearLayout {
            return mAnimationFilter;
        }
    }.setDuration(200);

    private final class SettingObserver extends ContentObserver {
        public SettingObserver(Handler handler) {
            super(handler);
        }

        @Override
        public void onChange(boolean selfChange, Uri uri) {
            super.onChange(selfChange, uri);

            Log.e("showHideNotificationIcon", "Testing....onChange................selfChange...... "+selfChange+".....Uri...."+uri);

            int hide_notificationIcon_left_system_icon = LineageSettings.System.getIntForUser(
                    getContext().getContentResolver(), uri.getLastPathSegment(), 0, mUser);
            Log.e("showHideNotificationIcon", "onChange................hide_notificationIcon_left_system_icon..... "+hide_notificationIcon_left_system_icon);
            showHideNotificationIcon(hide_notificationIcon_left_system_icon);

        }
    }
}