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

Commit 83527974 authored by Danesh M's avatar Danesh M Committed by Danesh M
Browse files

Lockscreen : Update shortcuts in onAttachWindow

Since KeyguardBottomAreaView is a window and gets detached/attached
frequently, we need register in onAttach as well.

Change-Id: Ibfc9b20fc3fae4bfcc1b2fe98b138d5725fd98c3
parent 82fb2e0b
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -53,9 +53,15 @@ public class LockscreenShortcutsHelper {
        if (listener != null) {
            mListener = listener;
            mHandler = new Handler(Looper.getMainLooper());
            registerAndFetchTargets();
        } else {
            fetchTargets();
        }
    }

    public void registerAndFetchTargets() {
        mContext.getContentResolver().registerContentObserver(
                CMSettings.Secure.getUriFor(CMSettings.Secure.LOCKSCREEN_TARGETS), false, mObserver);
        }
        fetchTargets();
    }

@@ -76,7 +82,6 @@ public class LockscreenShortcutsHelper {

    public void cleanup() {
        mContext.getContentResolver().unregisterContentObserver(mObserver);
        mListener = null;
    }

    public static class TargetInfo {
+12 −0
Original line number Diff line number Diff line
@@ -899,6 +899,18 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        updateCustomShortcuts();
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (mAccessibilityController != null) {
            mAccessibilityController.addStateChangedCallback(this);
        }
        mShortcutHelper.registerAndFetchTargets();
        updateCustomShortcuts();
        mUnlockMethodCache.addListener(this);
        watchForCameraPolicyChanges();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();