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

Commit 241683a2 authored by Danesh M's avatar Danesh M
Browse files

SystemUI : Add ability to disable lockscreen targets

Change-Id: Iec684028a3056de47163058c44c0cfc252098fe1
parent 35faff94
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ public class LockscreenShortcutsHelper {
        }
    }

    public static final String DEFAULT = "default";
    public static final String NONE = "none";
    private static final String DELIMITER = "|";
    private static final String SYSTEM_UI_PKGNAME = "com.android.systemui";
@@ -83,10 +84,9 @@ public class LockscreenShortcutsHelper {
        int itemsToPad = Shortcuts.values().length - mTargetActivities.size();
        if (itemsToPad > 0) {
            for (int i = 0; i < itemsToPad; i++) {
                mTargetActivities.add(NONE);
                mTargetActivities.add(DEFAULT);
            }
        }

    }

    public List<TargetInfo> getDrawablesForTargets() {
@@ -132,7 +132,7 @@ public class LockscreenShortcutsHelper {
    }

    public Drawable getDrawableFromSystemUI(String name) {
        Resources res = null;
        Resources res;
        if (mContext.getPackageName().equals(SYSTEM_UI_PKGNAME)) {
            res = mContext.getResources();
        } else {
@@ -185,20 +185,30 @@ public class LockscreenShortcutsHelper {
    }

    public boolean isTargetCustom(Shortcuts shortcut) {
        if (mTargetActivities == null || mTargetActivities.isEmpty()) {
            return false;
        }
        String action = mTargetActivities.get(shortcut.index);
        if (DEFAULT.equals(action)) {
            return false;
        }

        return NONE.equals(action) || getIntent(shortcut) != null;
    }

    public boolean isTargetEmpty(Shortcuts shortcut) {
        return mTargetActivities != null &&
                !mTargetActivities.isEmpty() &&
                !mTargetActivities.get(shortcut.index).equals(NONE);
                mTargetActivities.get(shortcut.index).equals(NONE);
    }

    public Intent getIntent(Shortcuts shortcut) {
        Intent intent = null;
        if (isTargetCustom(shortcut)) {
        try {
            intent = Intent.parseUri(mTargetActivities.get(shortcut.index), 0);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        }
        return intent;
    }

+16 −2
Original line number Diff line number Diff line
@@ -265,14 +265,28 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
                mLockPatternUtils.getCurrentUser());
        boolean visible = !isCameraDisabledByDpm() && resolved != null
                && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance);
        visible = visible || mShortcutHelper.isTargetCustom(
        visible = updateVisibilityCheck(visible,
                LockscreenShortcutsHelper.Shortcuts.RIGHT_SHORTCUT);
        mCameraImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
    }

    private boolean updateVisibilityCheck(boolean visible, LockscreenShortcutsHelper.Shortcuts
            shortcut) {
        boolean customTarget = mShortcutHelper.isTargetCustom(shortcut);
        if (customTarget) {
            boolean isEmpty = mShortcutHelper.isTargetEmpty(shortcut);
            if (visible && isEmpty) {
                visible = false;
            } else {
                visible = true;
            }
        }
        return visible;
    }

    private void updatePhoneVisibility() {
        boolean visible = isPhoneVisible();
        visible = visible || mShortcutHelper.isTargetCustom(
        visible = updateVisibilityCheck(visible,
                LockscreenShortcutsHelper.Shortcuts.LEFT_SHORTCUT);
        mPhoneImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
    }