diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
new file mode 100644
index 0000000..2ee81c3
--- /dev/null
+++ b/.idea/assetWizardSettings.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_animated_vector_drawable_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_animated_vector_drawable_25_3_0_aar.xml
new file mode 100644
index 0000000..705ae49
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_animated_vector_drawable_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_appcompat_v7_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_appcompat_v7_25_3_0_aar.xml
new file mode 100644
index 0000000..54213c6
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_appcompat_v7_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_annotations_25_3_0_jar.xml b/.idea/libraries/Gradle__com_android_support_support_annotations_25_3_0_jar.xml
new file mode 100644
index 0000000..66210f3
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_annotations_25_3_0_jar.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_compat_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_compat_25_3_0_aar.xml
new file mode 100644
index 0000000..64394cf
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_compat_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_core_ui_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_core_ui_25_3_0_aar.xml
new file mode 100644
index 0000000..d8cf0b2
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_core_ui_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_core_utils_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_core_utils_25_3_0_aar.xml
new file mode 100644
index 0000000..4b56344
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_core_utils_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_fragment_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_fragment_25_3_0_aar.xml
new file mode 100644
index 0000000..13055a2
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_fragment_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_media_compat_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_media_compat_25_3_0_aar.xml
new file mode 100644
index 0000000..c02c485
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_media_compat_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_v4_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_v4_25_3_0_aar.xml
new file mode 100644
index 0000000..4bff4b3
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_v4_25_3_0_aar.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__com_android_support_support_vector_drawable_25_3_0_aar.xml b/.idea/libraries/Gradle__com_android_support_support_vector_drawable_25_3_0_aar.xml
new file mode 100644
index 0000000..5c813ff
--- /dev/null
+++ b/.idea/libraries/Gradle__com_android_support_support_vector_drawable_25_3_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_0_0_aar.xml b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_0_0_aar.xml
new file mode 100644
index 0000000..9b2a311
--- /dev/null
+++ b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_0_0_aar.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_0_2_jar.xml b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_0_2_jar.xml
new file mode 100644
index 0000000..b9229a0
--- /dev/null
+++ b/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_0_2_jar.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_0_jar.xml b/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_0_jar.xml
new file mode 100644
index 0000000..f4fcefc
--- /dev/null
+++ b/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_0_jar.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e7a55e6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PatternLockView.iml b/PatternLockView.iml
new file mode 100644
index 0000000..d315539
--- /dev/null
+++ b/PatternLockView.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/app.iml b/app/app.iml
new file mode 100644
index 0000000..6fdb1f0
--- /dev/null
+++ b/app/app.iml
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 482d3d4..ceca6ee 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -35,6 +35,12 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
app:aspectRatio="square"
+ android:drawingCacheQuality="high"
+ app:dotNormalSize="40dp"
+ app:dotSelectedSize="50dp"
+ app:normalStateColor="#2196F3"
+ app:wrongStateColor="#C73047"
+ app:correctStateColor="#34A242"
app:aspectRatioEnabled="true"
app:dotAnimationDuration="150"
app:dotCount="3"/>
diff --git a/patternlockview-reactive/patternlockview-reactive.iml b/patternlockview-reactive/patternlockview-reactive.iml
new file mode 100644
index 0000000..69dc56a
--- /dev/null
+++ b/patternlockview-reactive/patternlockview-reactive.iml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/patternlockview/patternlockview.iml b/patternlockview/patternlockview.iml
new file mode 100644
index 0000000..9dd3e02
--- /dev/null
+++ b/patternlockview/patternlockview.iml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/patternlockview/src/main/java/com/andrognito/patternlockview/PatternLockView.java b/patternlockview/src/main/java/com/andrognito/patternlockview/PatternLockView.java
index 1624fd0..025f113 100755
--- a/patternlockview/src/main/java/com/andrognito/patternlockview/PatternLockView.java
+++ b/patternlockview/src/main/java/com/andrognito/patternlockview/PatternLockView.java
@@ -5,10 +5,12 @@
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Debug;
import android.os.Parcel;
@@ -17,6 +19,7 @@
import android.support.annotation.ColorInt;
import android.support.annotation.Dimension;
import android.support.annotation.IntDef;
+import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
@@ -124,9 +127,10 @@ public class PatternLockView extends View {
private int mDotSelectedSize;
private int mDotAnimationDuration;
private int mPathEndAnimationDuration;
-
private Paint mDotPaint;
private Paint mPathPaint;
+ private Bitmap mBitmap;
+ private Drawable mDotDrawable;
private List mPatternListeners;
// The pattern represented as a list of connected {@link Dot}
@@ -191,6 +195,10 @@ public PatternLockView(Context context, AttributeSet attrs) {
DEFAULT_DOT_ANIMATION_DURATION);
mPathEndAnimationDuration = typedArray.getInt(R.styleable.PatternLockView_pathEndAnimationDuration,
DEFAULT_PATH_END_ANIMATION_DURATION);
+ mDotDrawable = typedArray.getDrawable(R.styleable.PatternLockView_dotDrawable);
+ if (mDotDrawable != null) {
+ mBitmap = getBitmapFromVectorDrawable(mDotDrawable);
+ }
} finally {
typedArray.recycle();
}
@@ -205,6 +213,11 @@ public PatternLockView(Context context, AttributeSet attrs) {
for (int j = 0; j < sDotCount; j++) {
mDotStates[i][j] = new DotState();
mDotStates[i][j].mSize = mDotNormalSize;
+ if (mBitmap != null) {
+ mDotStates[i][j].mDotView = new View(context);
+ Canvas canvas = new Canvas(mBitmap);
+ mDotStates[i][j].mDotView.draw(canvas);
+ }
}
}
@@ -236,6 +249,7 @@ private void initView() {
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(
getContext(), android.R.interpolator.linear_out_slow_in);
}
+
}
@Override
@@ -314,18 +328,6 @@ protected void onDraw(Canvas canvas) {
Path currentPath = mCurrentPath;
currentPath.rewind();
- // Draw the dots
- for (int i = 0; i < sDotCount; i++) {
- float centerY = getCenterYForRow(i);
- for (int j = 0; j < sDotCount; j++) {
- DotState dotState = mDotStates[i][j];
- float centerX = getCenterXForColumn(j);
- float size = dotState.mSize * dotState.mScale;
- float translationY = dotState.mTranslateY;
- drawCircle(canvas, (int) centerX, (int) centerY + translationY,
- size, drawLookupTable[i][j], dotState.mAlpha);
- }
- }
// Draw the path of the pattern (unless we are in stealth mode)
boolean drawPath = !mInStealthMode;
@@ -363,7 +365,24 @@ protected void onDraw(Canvas canvas) {
lastX = centerX;
lastY = centerY;
}
+ // Draw the dots
+ for (int i = 0; i < sDotCount; i++) {
+ float centerY = getCenterYForRow(i);
+ for (int j = 0; j < sDotCount; j++) {
+ DotState dotState = mDotStates[i][j];
+ float centerX = getCenterXForColumn(j);
+ float size = dotState.mSize * dotState.mScale;
+ float translationY = dotState.mTranslateY;
+ if (mBitmap != null) {
+ drawDrawable(canvas, (int) centerX, (int) centerY + translationY,
+ size, drawLookupTable[i][j], dotState.mAlpha);
+ } else {
+ drawCircle(canvas, (int) centerX, (int) centerY + translationY,
+ size, drawLookupTable[i][j], dotState.mAlpha);
+ }
+ }
+ }
// Draw last in progress section
if ((mPatternInProgress || mPatternViewMode == AUTO_DRAW)
&& anyCircles) {
@@ -875,15 +894,39 @@ private void startSizeAnimation(float start, float end, long duration,
Interpolator interpolator, final DotState state,
final Runnable endRunnable) {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(start, end);
- valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ if (mBitmap != null) {
+ valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- state.mSize = (Float) animation.getAnimatedValue();
- invalidate();
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ state.mSize = (Float) animation.getAnimatedValue();
+ invalidate();
+ }
+
+ });
+ if (endRunnable != null) {
+ valueAnimator.addListener(new AnimatorListenerAdapter() {
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (endRunnable != null) {
+ endRunnable.run();
+ }
+ }
+ });
}
+ } else {
- });
+ valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ state.mSize = (Float) animation.getAnimatedValue();
+ invalidate();
+ }
+
+ });
+ }
if (endRunnable != null) {
valueAnimator.addListener(new AnimatorListenerAdapter() {
@@ -1142,6 +1185,28 @@ private void drawCircle(Canvas canvas, float centerX, float centerY,
canvas.drawCircle(centerX, centerY, size / 2, mDotPaint);
}
+ private void drawDrawable(Canvas canvas, float centerX, float centerY, float size, boolean partOfPattern, float alpha) {
+ mDotPaint.setColor(getCurrentColor(partOfPattern));
+ mDotPaint.setAlpha((int) (alpha * 255));
+ Bitmap scaledBitmap = Bitmap.createScaledBitmap(mBitmap, (int) size, (int) size, false);
+ canvas.drawBitmap(scaledBitmap, centerX - (scaledBitmap.getWidth() / 2f), centerY - (scaledBitmap.getHeight() / 2f), mDotPaint);
+ }
+
+ /**
+ * using for
+ */
+ public Bitmap getBitmapFromVectorDrawable(Drawable drawable) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+ drawable = (DrawableCompat.wrap(drawable)).mutate();
+ }
+
+ Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
+ drawable.draw(canvas);
+ return bitmap;
+ }
+
/**
* Represents a cell in the matrix of the pattern view
*/
diff --git a/patternlockview/src/main/res/drawable/ic_favorite_heart_button.xml b/patternlockview/src/main/res/drawable/ic_favorite_heart_button.xml
new file mode 100644
index 0000000..71d682f
--- /dev/null
+++ b/patternlockview/src/main/res/drawable/ic_favorite_heart_button.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/patternlockview/src/main/res/drawable/ic_keys_hole.xml b/patternlockview/src/main/res/drawable/ic_keys_hole.xml
new file mode 100644
index 0000000..9e5476a
--- /dev/null
+++ b/patternlockview/src/main/res/drawable/ic_keys_hole.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/patternlockview/src/main/res/drawable/ic_star.xml b/patternlockview/src/main/res/drawable/ic_star.xml
new file mode 100644
index 0000000..77564bd
--- /dev/null
+++ b/patternlockview/src/main/res/drawable/ic_star.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/patternlockview/src/main/res/values/attrs.xml b/patternlockview/src/main/res/values/attrs.xml
index c4d8d7d..6172263 100644
--- a/patternlockview/src/main/res/values/attrs.xml
+++ b/patternlockview/src/main/res/values/attrs.xml
@@ -16,5 +16,6 @@
+
\ No newline at end of file