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

Commit 365227ef authored by Michael Webster's avatar Michael Webster
Browse files

Gesture updates:

- User can now define unlock and sound toggle gestures.
- Lockscreen tabs can now be fully disabled, but ONLY if there is
  some other method of unlocking the device enabled.  This includes:
  Trackball unlock, menu key unlock, and gesture unlock.
- Changed default gesture sensitivity to 3
- Users are prevented from creating gestures that cannot be
  reproduced on the lock screen (namely vertical single-leg swipes)

Change-Id: I553ab3c9828d0478fb46821f2c36e87e865d7680
parent 855284cb
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -20,14 +20,35 @@
    android:layout_height="match_parent"

    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/gestures_explain_create_screen"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:paddingBottom="10dip" />
    <Button android:id="@+id/shortcut_picker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/gestures_shortcut_picker_button_label"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:onClick="pickShortcut" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <Button android:id="@+id/unlock_pick"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/gestures_unlock_only"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:onClick="pickUnlockOnly" />
        <Button android:id="@+id/sound_pick"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/gestures_toggle_sound"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:onClick="pickSoundOnly" />
    </LinearLayout>
    <android.gesture.GestureOverlayView
        android:id="@+id/gestures_overlay"
        android:layout_width="match_parent"
+5 −1
Original line number Diff line number Diff line
@@ -489,5 +489,9 @@
    <string name="gestures_delete">Delete</string>
    <string name="gestures_delete_success">Gesture deleted</string>
    <string name="gestures_error_loading">Problem with gesture file operation.</string>

    <string name="gestures_unlock_only">Unlock phone</string>
    <string name="gestures_toggle_sound">Toggle sound</string>
    <string name="pref_lockscreen_disable_unlock_tab">Disable unlock slider</string>
    <string name="pref_lockscreen_disable_unlock_tab_summary">Note: You need to enable trackball, menu key, or gesture unlocking before this option becomes available</string>
    <string name="gestures_explain_create_screen">Pick an action to perform (or select Unlock or Sound) and draw a gesture on the screen.\nNote that single-leg vertical (up or down) gestures are invalid.</string>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -47,6 +47,11 @@

        <CheckBoxPreference android:key="pref_menu_unlock"
            android:title="@string/pref_menu_unlock_title" android:summary="@string/pref_menu_unlock_summary" />

        <CheckBoxPreference android:key="lockscreen_disable_unlock_tab"
            android:title="@string/pref_lockscreen_disable_unlock_tab"
            android:summary="@string/pref_lockscreen_disable_unlock_tab_summary" />

        <Preference
            android:key="pref_user_defined_key1"
            android:title="@string/user_defined_key1"
+21 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.MotionEvent;
import android.gesture.GestureOverlayView;
import android.gesture.Gesture;
import android.gesture.GestureLibrary;
import android.graphics.RectF;
import android.widget.Button;
import android.widget.Toast;

@@ -117,6 +118,15 @@ public class GestureCreateActivity extends Activity {
            if (mGesture.getLength() < LENGTH_THRESHOLD) {
                overlay.clear(false);
            }
            // check vertical state - can't be less than 45 deg from vertical
            // I'd like to fix this but for now... keep people from making
            // gestures they can't reproduce on the lockscreen
            if (mGesture.getStrokesCount() == 1) {
                RectF box = mGesture.getBoundingBox();
                if (Math.abs(box.width() / box.height()) < 1.0) {
                    overlay.clear(false);
                }
            }
            mDoneButton.setEnabled(true);
        }

@@ -143,6 +153,17 @@ public class GestureCreateActivity extends Activity {
        startActivityForResult(pickIntent, REQUEST_PICK_SHORTCUT);
    }

    public void pickUnlockOnly(View v) {
        mShortcutButton.setText(getString(R.string.gestures_unlock_only));
        mUri = "UNLOCK___UNLOCK";
    }

    public void pickSoundOnly(View v) {
        mShortcutButton.setText(getString(R.string.gestures_toggle_sound));
        mUri = "SOUND___SOUND";
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

+8 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.Environment;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -14,8 +15,14 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.util.Log;

import java.io.File;
import java.util.List;

import com.cyanogenmod.cmparts.R;
import android.gesture.GestureLibrary;
import android.gesture.GestureLibraries;

public class GestureMenuActivity extends PreferenceActivity
        implements SharedPreferences.OnSharedPreferenceChangeListener {
@@ -29,7 +36,6 @@ public class GestureMenuActivity extends PreferenceActivity
    private CheckBoxPreference mGesturesTrail;
    private ListPreference mGesturesSensitivity;


    public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
            PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {

@@ -81,7 +87,7 @@ public class GestureMenuActivity extends PreferenceActivity
                    Settings.System.LOCKSCREEN_GESTURES_TRAIL, 0) != 0);
            mGesturesSensitivity.setValue(Integer.toString(Settings.System.getInt(
                    getContentResolver(),
                    Settings.System.LOCKSCREEN_GESTURES_SENSITIVITY, 0)));
                    Settings.System.LOCKSCREEN_GESTURES_SENSITIVITY, 3)));
            mGesturesSensitivity.setSummary(mGesturesSensitivity.getEntry());
    }

Loading