Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gesture locking #81

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/java/de/Maxr1998/xposed/maxlock/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public abstract class Common {
public static final String MASTER_SWITCH_ON = "master_switch_on";
public static final String KEY_PREFERENCE = "key";
public static final String APP_KEY_PREFERENCE = "_key";
public static final String APP_KEY_GESTURE = "_gesture";
public static final String MASTER_GESTURE_NAME = "master";
public static final String THEME_PKG = "theme_pkg";

public static final String LOCKING_TYPE_SETTINGS = "locking_type_settings";
Expand All @@ -46,6 +48,7 @@ public abstract class Common {
public static final String LOCKING_TYPE_PIN = "locking_type_pin";
public static final String LOCKING_TYPE_KNOCK_CODE = "locking_type_knock_code";
public static final String LOCKING_TYPE_PATTERN = "locking_type_pattern";
public static final String LOCKING_TYPE_GESTURE = "locking_type_gesture";

public static final String LOCKING_UI_SETTINGS = "locking_ui_settings";
/* UI */
Expand All @@ -66,6 +69,7 @@ public abstract class Common {
public static final String SHADOW_FINGERPRINT = "shadow_fingerprint";
public static final String CATEGORY_FINGERPRINT = "cat_fingerprint";
public static final String DISABLE_FINGERPRINT = "disable_fingerprint";
public static final String SHOW_GESTURE = "show_gesture";


public static final String LOCKING_OPTIONS = "locking_options";
Expand Down Expand Up @@ -109,6 +113,7 @@ public abstract class Common {
public static final String PREF_VALUE_PIN = "pin";
public static final String PREF_VALUE_KNOCK_CODE = "knock_code";
public static final String PREF_VALUE_PATTERN = "pattern";
public static final String PREF_VALUE_GESTURE = "gesture";

// Preference files //
public static final String PREFS_KEY = "keys";
Expand All @@ -125,6 +130,8 @@ public abstract class Common {
public static final String EXTERNAL_FILES_DIR = Environment.getExternalStorageDirectory() + "/MaxLock/";
public static final String BACKUP_DIR = EXTERNAL_FILES_DIR + "Backup/";

public static final String GESTURES_FILE = "/maxlock_gestures";

// URLS //
public static final Uri WEBSITE_URI = Uri.parse("http://maxlock.maxr1998.de/?client=inapp&lang=" + Util.getLanguageCode());
public static final Uri MAXR1998_URI = Uri.parse("http://maxr1998.de/");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package de.Maxr1998.xposed.maxlock.ui.lockscreen;

import android.content.Context;
import android.content.res.Configuration;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.Prediction;
import android.graphics.Color;
import android.view.MotionEvent;
import android.view.ViewGroup;

import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;

import de.Maxr1998.xposed.maxlock.Common;
import de.Maxr1998.xposed.maxlock.ui.settings.lockingtype.GestureSetupFragment;

/**
* Created by rijul on 8/3/16.
*/
public class GestureActivityView extends LockGestureView implements LockGestureView.OnLockGestureListener {
private LockView mLockView;
private final Runnable mClearRunnable = new Runnable() {
@Override
public void run() {
clearGesture();
setGestureColor(READY_COLOR);
}
};

public GestureActivityView(Context context, LockView lockView) {
super(context);
mLockView = lockView;
setOnGestureListener(this);
switch (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
case Configuration.SCREENLAYOUT_SIZE_LARGE:
case Configuration.SCREENLAYOUT_SIZE_XLARGE: {
final int size = mLockView.getDimens(com.haibison.android.lockpattern.R.dimen.alp_42447968_lockpatternview_size);
ViewGroup.LayoutParams lp = getLayoutParams();
lp.width = size;
lp.height = size;
break;
}
}
setInStealthMode(!mLockView.getPrefs().getBoolean(Common.SHOW_GESTURE, true));
}

@Override
public void onGestureStart() {

}

@Override
public void onGestureCleared() {

}

@Override
public void onGestureDetected(Gesture gesture) {
if (gesture.getLength()< GestureSetupFragment.LENGTH_THRESHOLD) {
clearGesture();
} else {
if (mLockView.checkInput(gesture)) {
setDisplayMode(LockGestureView.DisplayMode.Correct);
} else {
setDisplayMode(LockGestureView.DisplayMode.Wrong);
postDelayed(mClearRunnable, 300);
}
}
}
}
Loading