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

Commit 35dfa1f5 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "Provide haptic feedback on long pressing keys in lockscreen." into jellybean

parents 9106ac77 600bf6a9
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -805,6 +805,15 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
        if (action != null) {
            String uri = Settings.System.getString(context.getContentResolver(), action);
            if (uri != null && runAction(context, uri) != ACTION_RESULT_NOTRUN) {
                long[] pattern = getLongPressVibePattern(context);
                if (pattern != null) {
                    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
                    if (pattern.length == 1) {
                        v.vibrate(pattern[0]);
                    } else {
                        v.vibrate(pattern, -1);
                    }
                }
                return true;
            }
        }
@@ -839,6 +848,26 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
        }
    }

    private static long[] getLongPressVibePattern(Context context) {
        if (Settings.System.getInt(context.getContentResolver(),
                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0) {
            return null;
        }

        int[] defaultPattern = context.getResources().getIntArray(
                com.android.internal.R.array.config_longPressVibePattern);
        if (defaultPattern == null) {
            return null;
        }

        long[] pattern = new long[defaultPattern.length];
        for (int i = 0; i < defaultPattern.length; i++) {
            pattern[i] = defaultPattern[i];
        }

        return pattern;
    }

    void updateConfiguration() {
        Configuration newConfig = getResources().getConfiguration();
        if (newConfig.orientation != mCreationOrientation) {