From 8d72c42ec1e617209ca67c727d29ca315b79103b Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Wed, 3 Jan 2018 20:06:20 +0700 Subject: [PATCH 01/16] doing chang text step --- .../lollipin/CustomApplication.java | 2 + .../lib/managers/AppLockActivity.java | 65 ++++++++++--------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java index 8aac76e8..a501f83e 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java @@ -19,5 +19,7 @@ public void onCreate() { LockManager lockManager = LockManager.getInstance(); lockManager.enableAppLock(this, CustomPinActivity.class); lockManager.getAppLock().setLogoId(R.drawable.security_lock); + lockManager.getAppLock().setFingerprintAuthEnabled(true); + lockManager.getAppLock().setShouldShowForgot(false); } } diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java index c2c72574..eca5dff6 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java @@ -33,7 +33,7 @@ public abstract class AppLockActivity extends PinActivity implements KeyboardBut public static final String TAG = AppLockActivity.class.getSimpleName(); public static final String ACTION_CANCEL = TAG + ".actionCancelled"; - private static final int DEFAULT_PIN_LENGTH = 4; + private static final int DEFAULT_PIN_LENGTH = 5; protected TextView mStepTextView; protected TextView mForgotTextView; @@ -113,16 +113,16 @@ private void initLayout(Intent intent) { enableAppLockerIfDoesNotExist(); mLockManager.getAppLock().setPinChallengeCancelled(false); - mStepTextView = (TextView) this.findViewById(R.id.pin_code_step_textview); - mPinCodeRoundView = (PinCodeRoundView) this.findViewById(R.id.pin_code_round_view); + mStepTextView = this.findViewById(R.id.pin_code_step_textview); + mPinCodeRoundView = this.findViewById(R.id.pin_code_round_view); mPinCodeRoundView.setPinLength(this.getPinLength()); - mForgotTextView = (TextView) this.findViewById(R.id.pin_code_forgot_textview); + mForgotTextView = this.findViewById(R.id.pin_code_forgot_textview); mForgotTextView.setOnClickListener(this); - mKeyboardView = (KeyboardView) this.findViewById(R.id.pin_code_keyboard_view); + mKeyboardView = this.findViewById(R.id.pin_code_keyboard_view); mKeyboardView.setKeyboardButtonClickedListener(this); int logoId = mLockManager.getAppLock().getLogoId(); - ImageView logoImage = ((ImageView) findViewById(R.id.pin_code_logo_imageview)); + ImageView logoImage = findViewById(R.id.pin_code_logo_imageview); if (logoId != AppLock.LOGO_ID_NONE) { logoImage.setVisibility(View.VISIBLE); logoImage.setImageResource(logoId); @@ -130,7 +130,7 @@ private void initLayout(Intent intent) { mForgotTextView.setText(getForgotText()); setForgotTextVisibility(); - setStepText(); + setStepText(null); } /** @@ -182,36 +182,39 @@ private void enableAppLockerIfDoesNotExist() { /** * Init the {@link #mStepTextView} based on {@link #mType} */ - private void setStepText() { - mStepTextView.setText(getStepText(mType)); + public void setStepText(String msgStepText) { + mStepTextView.setText(getStepText(mType, msgStepText)); } /** * Gets the {@link String} to be used in the {@link #mStepTextView} based on {@link #mType} * * @param reason The {@link #mType} to return a {@link String} for + * @param msgStepText * @return The {@link String} for the {@link AppLockActivity} */ - public String getStepText(int reason) { - String msg = null; - switch (reason) { - case AppLock.DISABLE_PINLOCK: - msg = getString(R.string.pin_code_step_disable, this.getPinLength()); - break; - case AppLock.ENABLE_PINLOCK: - msg = getString(R.string.pin_code_step_create, this.getPinLength()); - break; - case AppLock.CHANGE_PIN: - msg = getString(R.string.pin_code_step_change, this.getPinLength()); - break; - case AppLock.UNLOCK_PIN: - msg = getString(R.string.pin_code_step_unlock, this.getPinLength()); - break; - case AppLock.CONFIRM_PIN: - msg = getString(R.string.pin_code_step_enable_confirm, this.getPinLength()); - break; + public String getStepText(int reason, String msgStepText) { + if (msgStepText == null) { + switch (reason) { + case AppLock.DISABLE_PINLOCK: + msgStepText = getString(R.string.pin_code_step_disable, this.getPinLength()); + break; + case AppLock.ENABLE_PINLOCK: + msgStepText = getString(R.string.pin_code_step_create, this.getPinLength()); + break; + case AppLock.CHANGE_PIN: + msgStepText = getString(R.string.pin_code_step_change, this.getPinLength()); + break; + case AppLock.UNLOCK_PIN: + msgStepText = getString(R.string.pin_code_step_unlock, this.getPinLength()); + break; + case AppLock.CONFIRM_PIN: + msgStepText = getString(R.string.pin_code_step_enable_confirm, this.getPinLength()); + break; + } } - return msg; + + return msgStepText; } public String getForgotText() { @@ -296,7 +299,7 @@ protected void onPinCodeInputed() { mOldPinCode = mPinCode; setPinCode(""); mType = AppLock.CONFIRM_PIN; - setStepText(); + setStepText(null); setForgotTextVisibility(); break; case AppLock.CONFIRM_PIN: @@ -309,7 +312,7 @@ protected void onPinCodeInputed() { mOldPinCode = ""; setPinCode(""); mType = AppLock.ENABLE_PINLOCK; - setStepText(); + setStepText(null); setForgotTextVisibility(); onPinCodeError(); } @@ -317,7 +320,7 @@ protected void onPinCodeInputed() { case AppLock.CHANGE_PIN: if (mLockManager.getAppLock().checkPasscode(mPinCode)) { mType = AppLock.ENABLE_PINLOCK; - setStepText(); + setStepText(null); setForgotTextVisibility(); setPinCode(""); onPinCodeSuccess(); From 15bb8ae04790870ab8d33e5bdd223ad53bc2360b Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Thu, 4 Jan 2018 14:34:36 +0700 Subject: [PATCH 02/16] cusstomize step msg ok --- .../lollipin/CustomApplication.java | 5 + build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../lollipin/lib/managers/AppLock.java | 55 +++++++++++ .../lib/managers/AppLockActivity.java | 97 +++++++++++++------ .../lollipin/lib/managers/AppLockImpl.java | 76 +++++++++++++++ 6 files changed, 208 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java index a501f83e..403f1617 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java @@ -21,5 +21,10 @@ public void onCreate() { lockManager.getAppLock().setLogoId(R.drawable.security_lock); lockManager.getAppLock().setFingerprintAuthEnabled(true); lockManager.getAppLock().setShouldShowForgot(false); + lockManager.getAppLock().setDisablePinlockMessage("A"); + lockManager.getAppLock().setEnablePinlockMessage("B"); + lockManager.getAppLock().setChangePinMessage("C"); + lockManager.getAppLock().setUnlockPinMessage("D"); + lockManager.getAppLock().setConfirmPinMessage("E"); } } diff --git a/build.gradle b/build.gradle index dbe7511e..8ac31ed6 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 451394e5..9180ef61 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java index d2fcc686..a2bb695d 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java @@ -202,4 +202,59 @@ public void removeIgnoredActivity(Class clazz) { * Otherwise returns true */ public abstract boolean shouldLockSceen(Activity activity); + + /** + * + */ + public abstract String getDisablePinlockMessage(); + + /** + * + * @param disablePinlockMessage + */ + public abstract void setDisablePinlockMessage(String disablePinlockMessage); + + /** + * + */ + public abstract String getEnablePinlockMessage(); + + /** + * + * @param enablePinlockMessage + */ + public abstract void setEnablePinlockMessage(String enablePinlockMessage); + + /** + * + */ + public abstract String getChangePinMessage(); + + /** + * + * @param changePinMessage + */ + public abstract void setChangePinMessage(String changePinMessage); + + /** + * + */ + public abstract String getUnlockPinMessage(); + + /** + * + * @param unlockPinMessage + */ + public abstract void setUnlockPinMessage(String unlockPinMessage); + + /** + * + */ + public abstract String getConfirmPinMessageMessage(); + + /** + * + * @param confirmPinMessage + */ + public abstract void setConfirmPinMessage(String confirmPinMessage); } diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java index eca5dff6..59286b9c 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java @@ -130,7 +130,7 @@ private void initLayout(Intent intent) { mForgotTextView.setText(getForgotText()); setForgotTextVisibility(); - setStepText(null); + setStepText(); } /** @@ -182,39 +182,82 @@ private void enableAppLockerIfDoesNotExist() { /** * Init the {@link #mStepTextView} based on {@link #mType} */ - public void setStepText(String msgStepText) { - mStepTextView.setText(getStepText(mType, msgStepText)); + private void setStepText() { + mStepTextView.setText(getStepText(mType)); } /** * Gets the {@link String} to be used in the {@link #mStepTextView} based on {@link #mType} * * @param reason The {@link #mType} to return a {@link String} for - * @param msgStepText * @return The {@link String} for the {@link AppLockActivity} */ - public String getStepText(int reason, String msgStepText) { - if (msgStepText == null) { - switch (reason) { - case AppLock.DISABLE_PINLOCK: - msgStepText = getString(R.string.pin_code_step_disable, this.getPinLength()); - break; - case AppLock.ENABLE_PINLOCK: - msgStepText = getString(R.string.pin_code_step_create, this.getPinLength()); - break; - case AppLock.CHANGE_PIN: - msgStepText = getString(R.string.pin_code_step_change, this.getPinLength()); - break; - case AppLock.UNLOCK_PIN: - msgStepText = getString(R.string.pin_code_step_unlock, this.getPinLength()); - break; - case AppLock.CONFIRM_PIN: - msgStepText = getString(R.string.pin_code_step_enable_confirm, this.getPinLength()); - break; - } + public String getStepText(int reason) { + switch (reason) { + case AppLock.DISABLE_PINLOCK: + return getDisablePinlockMessage(); + case AppLock.ENABLE_PINLOCK: + return getEnablePinlockMessage(); + case AppLock.CHANGE_PIN: + return getChangePinMessage(); + case AppLock.UNLOCK_PIN: + return getUnlockPinMessage(); + case AppLock.CONFIRM_PIN: + return getConfirmPinMessage(); + default: + return getString(R.string.pin_code_step_create, this.getPinLength()); + } + + } + + private String getDisablePinlockMessage() { + String msg = mLockManager.getAppLock().getDisablePinlockMessage(); + if (msg != null) { + return msg; + + } + + return getString(R.string.pin_code_step_disable, this.getPinLength()); + } + + private String getEnablePinlockMessage() { + String msg = mLockManager.getAppLock().getEnablePinlockMessage(); + if (msg != null) { + return msg; + + } + + return getString(R.string.pin_code_step_create, this.getPinLength()); + } + + private String getChangePinMessage() { + String msg = mLockManager.getAppLock().getChangePinMessage(); + if (msg != null) { + return msg; + + } + + return getString(R.string.pin_code_step_change, this.getPinLength()); + } + + private String getUnlockPinMessage() { + String msg = mLockManager.getAppLock().getUnlockPinMessage(); + if (msg != null) { + return msg; + + } + + return getString(R.string.pin_code_step_unlock, this.getPinLength()); + } + + private String getConfirmPinMessage() { + String msg = mLockManager.getAppLock().getConfirmPinMessageMessage(); + if (msg != null) { + return msg; + } - return msgStepText; + return getString(R.string.pin_code_step_enable_confirm, this.getPinLength()); } public String getForgotText() { @@ -299,7 +342,7 @@ protected void onPinCodeInputed() { mOldPinCode = mPinCode; setPinCode(""); mType = AppLock.CONFIRM_PIN; - setStepText(null); + setStepText(); setForgotTextVisibility(); break; case AppLock.CONFIRM_PIN: @@ -312,7 +355,7 @@ protected void onPinCodeInputed() { mOldPinCode = ""; setPinCode(""); mType = AppLock.ENABLE_PINLOCK; - setStepText(null); + setStepText(); setForgotTextVisibility(); onPinCodeError(); } @@ -320,7 +363,7 @@ protected void onPinCodeInputed() { case AppLock.CHANGE_PIN: if (mLockManager.getAppLock().checkPasscode(mPinCode)) { mType = AppLock.ENABLE_PINLOCK; - setStepText(null); + setStepText(); setForgotTextVisibility(); setPinCode(""); onPinCodeSuccess(); diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java index e6413c1b..f7b42a26 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java @@ -65,6 +65,17 @@ public class AppLockImpl extends AppLock implements L * This value defaults to true for backwards compatibility. */ private static final String FINGERPRINT_AUTH_ENABLED_PREFERENCE_KEY = "FINGERPRINT_AUTH_ENABLED_PREFERENCE_KEY"; + + private static final String DISABLE_PINLOCK_MESSAGE = "DISABLE_PINLOCK_MESSAGE"; + + private static final String ENABLE_PINLOCK_MESSAGE = "ENABLE_PINLOCK_MESSAGE"; + + private static final String CHANGE_PIN_MESSAGE = "CHANGE_PIN_MESSAGE"; + + private static final String UNLOCK_PIN_MESSAGE = "UNLOCK_PIN_MESSAGE"; + + private static final String CONFIRM_PIN_MESSAGE = "CONFIRM_PIN_MESSAGE"; + /** * The default password salt */ @@ -418,4 +429,69 @@ public void onActivityResumed(Activity activity) { setLastActiveMillis(); } } + + @Override + public String getDisablePinlockMessage() { + return mSharedPreferences.getString(DISABLE_PINLOCK_MESSAGE, null); + + } + + @Override + public void setDisablePinlockMessage(String disablePinlockMessage) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putString(DISABLE_PINLOCK_MESSAGE, disablePinlockMessage); + editor.apply(); + } + + @Override + public String getEnablePinlockMessage() { + return mSharedPreferences.getString(ENABLE_PINLOCK_MESSAGE, null); + + } + + @Override + public void setEnablePinlockMessage(String enablePinlockMessage) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putString(ENABLE_PINLOCK_MESSAGE, enablePinlockMessage); + editor.apply(); + } + + @Override + public String getChangePinMessage() { + return mSharedPreferences.getString(CHANGE_PIN_MESSAGE, null); + + } + + @Override + public void setChangePinMessage(String changePinMessage) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putString(CHANGE_PIN_MESSAGE, changePinMessage); + editor.apply(); + } + + @Override + public String getUnlockPinMessage() { + return mSharedPreferences.getString(UNLOCK_PIN_MESSAGE, null); + + } + + @Override + public void setUnlockPinMessage(String unlockPinMessage) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putString(UNLOCK_PIN_MESSAGE, unlockPinMessage); + editor.apply(); + } + + @Override + public String getConfirmPinMessageMessage() { + return mSharedPreferences.getString(CONFIRM_PIN_MESSAGE, null); + + } + + @Override + public void setConfirmPinMessage(String confirmPinMessage) { + SharedPreferences.Editor editor = mSharedPreferences.edit(); + editor.putString(CONFIRM_PIN_MESSAGE, confirmPinMessage); + editor.apply(); + } } From 466f57e96cf79d7748bfc30d67f33f75c7e33a47 Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Thu, 4 Jan 2018 14:41:35 +0700 Subject: [PATCH 03/16] change default pin count to 4 --- .../omadahealth/lollipin/lib/managers/AppLockActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java index 59286b9c..ce863180 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java @@ -33,7 +33,7 @@ public abstract class AppLockActivity extends PinActivity implements KeyboardBut public static final String TAG = AppLockActivity.class.getSimpleName(); public static final String ACTION_CANCEL = TAG + ".actionCancelled"; - private static final int DEFAULT_PIN_LENGTH = 5; + private static final int DEFAULT_PIN_LENGTH = 4; protected TextView mStepTextView; protected TextView mForgotTextView; From a3c8797a7072aae6689bc3b24ea8a521948eab3a Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Thu, 4 Jan 2018 15:27:02 +0700 Subject: [PATCH 04/16] fix gradle for jitpack --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8ac31ed6..dbe7511e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9180ef61..451394e5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip From 603037c28040794264b6e49dec8a0d8845afa0c9 Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Thu, 4 Jan 2018 16:37:35 +0700 Subject: [PATCH 05/16] change build tool version and android support lib version for compatible my project --- lib/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/build.gradle b/lib/build.gradle index 55f30cb8..be163027 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 26 - buildToolsVersion '26.0.1' + buildToolsVersion '26.0.2' defaultConfig { minSdkVersion 14 @@ -26,9 +26,9 @@ dependencies { compile 'com.github.omadahealth.typefaceview:typefaceview:1.5.0@aar' //TypefaceTextView //Compat - compile 'com.android.support:support-v4:26.0.2' - compile 'com.android.support:appcompat-v7:26.0.2' - compile "com.android.support:support-v13:26.0.2" + compile 'com.android.support:support-v4:26.1.0' + compile 'com.android.support:appcompat-v7:26.1.0' + compile "com.android.support:support-v13:26.1.0" } repositories { maven { From 1a121e6850f9ef99e576c50cda904ecec4b6058c Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Thu, 4 Jan 2018 17:04:49 +0700 Subject: [PATCH 06/16] upgraded --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index dbe7511e..8ac31ed6 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' + classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 451394e5..9180ef61 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip From 94d147d6079296d2abcdffa04def1638f8873f4a Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Sat, 6 Jan 2018 11:45:30 +0700 Subject: [PATCH 07/16] change method name --- .../com/github/omadahealth/lollipin/lib/managers/AppLock.java | 2 +- .../omadahealth/lollipin/lib/managers/AppLockActivity.java | 2 +- .../github/omadahealth/lollipin/lib/managers/AppLockImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java index a2bb695d..9464f6c0 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java @@ -250,7 +250,7 @@ public void removeIgnoredActivity(Class clazz) { /** * */ - public abstract String getConfirmPinMessageMessage(); + public abstract String getConfirmPinMessage(); /** * diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java index ce863180..3b88a6fa 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java @@ -251,7 +251,7 @@ private String getUnlockPinMessage() { } private String getConfirmPinMessage() { - String msg = mLockManager.getAppLock().getConfirmPinMessageMessage(); + String msg = mLockManager.getAppLock().getConfirmPinMessage(); if (msg != null) { return msg; diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java index f7b42a26..72f9078d 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java @@ -483,7 +483,7 @@ public void setUnlockPinMessage(String unlockPinMessage) { } @Override - public String getConfirmPinMessageMessage() { + public String getConfirmPinMessage() { return mSharedPreferences.getString(CONFIRM_PIN_MESSAGE, null); } From 1f5a188652e14168979abab31515f0cd1eee0158 Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Sat, 6 Jan 2018 11:50:40 +0700 Subject: [PATCH 08/16] fixed --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8ac31ed6..dbe7511e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9180ef61..451394e5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip From ddfcf05dda2aaf341668eb5dc7a4887f403e8855 Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Sat, 6 Jan 2018 12:16:38 +0700 Subject: [PATCH 09/16] add custom step message in readme --- README.md | 20 +++++++++++++++++++ .../lollipin/CustomApplication.java | 15 +++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 03015903..c1856415 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,26 @@ By supplying alternate drawable resources for app:lp_empty_pin_dot and app:lp_fu app:lp_full_pin_dot="@drawable/pin_full_dot"/> ``` +Step message: +------------------- +You can customize step message by setter method. Normally I suggest developer add this code in Custom application class. + +``` +public class CustomApplication extends Application { + @Override + public void onCreate() { + super.onCreate(); + LockManager lockManager = LockManager.getInstance(); + lockManager.enableAppLock(this, CustomPinActivity.class); + lockManager.getAppLock().setDisablePinlockMessage("Disable pinlock step message"); + lockManager.getAppLock().setEnablePinlockMessage("Enable pinlock step message"); + lockManager.getAppLock().setChangePinMessage("Change pin step message"); + lockManager.getAppLock().setUnlockPinMessage("Unlock pin step message"); + lockManager.getAppLock().setConfirmPinMessage("Confirm pinlock step message"); + } +} +``` + ======== ### Credits diff --git a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java index 403f1617..02c900c0 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java @@ -4,8 +4,6 @@ import com.github.omadahealth.lollipin.lib.managers.LockManager; -import lollipin.orangegangsters.github.com.lollipin.R; - /** * Created by oliviergoutay on 1/14/15. */ @@ -18,13 +16,10 @@ public void onCreate() { LockManager lockManager = LockManager.getInstance(); lockManager.enableAppLock(this, CustomPinActivity.class); - lockManager.getAppLock().setLogoId(R.drawable.security_lock); - lockManager.getAppLock().setFingerprintAuthEnabled(true); - lockManager.getAppLock().setShouldShowForgot(false); - lockManager.getAppLock().setDisablePinlockMessage("A"); - lockManager.getAppLock().setEnablePinlockMessage("B"); - lockManager.getAppLock().setChangePinMessage("C"); - lockManager.getAppLock().setUnlockPinMessage("D"); - lockManager.getAppLock().setConfirmPinMessage("E"); + lockManager.getAppLock().setDisablePinlockMessage("Disable pinlock step message"); + lockManager.getAppLock().setEnablePinlockMessage("Enable pinlock step message"); + lockManager.getAppLock().setChangePinMessage("Change pin step message"); + lockManager.getAppLock().setUnlockPinMessage("Unlock pin step message"); + lockManager.getAppLock().setConfirmPinMessage("Confirm pinlock step message"); } } From 153a1238a69586e7abfd866b0774f64f48116f86 Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Sat, 6 Jan 2018 12:19:38 +0700 Subject: [PATCH 10/16] fixed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1856415..6cec6694 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ By supplying alternate drawable resources for app:lp_empty_pin_dot and app:lp_fu Step message: ------------------- -You can customize step message by setter method. Normally I suggest developer add this code in Custom application class. +You can customize step message by setter method. Normally, I suggest developer add this code in Custom application class. ``` public class CustomApplication extends Application { From 53869ea4507cd056ab7b45e2231af30d05fb6514 Mon Sep 17 00:00:00 2001 From: "oat msi\\oatrice" Date: Sat, 6 Jan 2018 12:49:33 +0700 Subject: [PATCH 11/16] add gravity center for step message --- .../com/github/omadahealth/lollipin/CustomApplication.java | 5 +++++ lib/src/main/res/layout/activity_pin_code.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java index 02c900c0..6802b24c 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java @@ -4,6 +4,8 @@ import com.github.omadahealth.lollipin.lib.managers.LockManager; +import lollipin.orangegangsters.github.com.lollipin.R; + /** * Created by oliviergoutay on 1/14/15. */ @@ -16,6 +18,9 @@ public void onCreate() { LockManager lockManager = LockManager.getInstance(); lockManager.enableAppLock(this, CustomPinActivity.class); + lockManager.getAppLock().setLogoId(R.drawable.security_lock); + lockManager.getAppLock().setFingerprintAuthEnabled(true); + lockManager.getAppLock().setShouldShowForgot(false); lockManager.getAppLock().setDisablePinlockMessage("Disable pinlock step message"); lockManager.getAppLock().setEnablePinlockMessage("Enable pinlock step message"); lockManager.getAppLock().setChangePinMessage("Change pin step message"); diff --git a/lib/src/main/res/layout/activity_pin_code.xml b/lib/src/main/res/layout/activity_pin_code.xml index 5e087a6a..5d82976f 100644 --- a/lib/src/main/res/layout/activity_pin_code.xml +++ b/lib/src/main/res/layout/activity_pin_code.xml @@ -32,6 +32,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/pin_code_logo_imageview" android:layout_centerHorizontal="true" + android:gravity="center" android:textColor="@color/dark_grey_color" android:textSize="@dimen/pin_code_step_text_size" /> From dee6cded9b8c42f8e71bfb968e7e978e551aacad Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Sun, 14 Jan 2018 13:13:15 +0700 Subject: [PATCH 12/16] can get encrypted passcode --- .../github/omadahealth/lollipin/lib/managers/AppLock.java | 6 ++++++ .../omadahealth/lollipin/lib/managers/AppLockImpl.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java index 9464f6c0..f2dc1318 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java @@ -162,6 +162,12 @@ public void removeIgnoredActivity(Class clazz) { */ public abstract boolean setPasscode(String passcode); + /** + * Get the passcode (store his SHA1 into {@link android.content.SharedPreferences}) using the + * {@link com.github.omadahealth.lollipin.lib.encryption.Encryptor} class. + */ + public abstract String getPasscodeEncrypted(); + /** * Check the {@link android.content.SharedPreferences} to see if fingerprint authentication is * enabled. diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java index 72f9078d..acae559b 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java @@ -314,6 +314,12 @@ public boolean setPasscode(String passcode) { return true; } + @Override + public String getPasscodeEncrypted() { + String passcodeEncrypted = mSharedPreferences.getString(PASSWORD_PREFERENCE_KEY, null); + return passcodeEncrypted; + } + /** * Set the algorithm used in {@link #setPasscode(String)} */ From 79d5e60b6ed0e36de2b4dcdd3383675545ffdb08 Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Sun, 14 Jan 2018 23:39:27 +0700 Subject: [PATCH 13/16] create nothing pin mode for login only. --- .../lollipin/lib/managers/AppLock.java | 5 ++++ .../lib/managers/AppLockActivity.java | 24 ++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java index f2dc1318..b40e9fd7 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java @@ -26,6 +26,11 @@ public abstract class AppLock { */ public static final int UNLOCK_PIN = 4; + /** + * NOTHING_PIN type, uses to get pin, what user type. + */ + public static final int NOTHING_PIN = 5; + /** * LOGO_ID_NONE used to denote when a user has not set a logoId using {@link #setLogoId(int)} */ diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java index 3b88a6fa..e6686fae 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java @@ -204,6 +204,8 @@ public String getStepText(int reason) { return getUnlockPinMessage(); case AppLock.CONFIRM_PIN: return getConfirmPinMessage(); + case AppLock.NOTHING_PIN: + return getUnlockPinMessage(); default: return getString(R.string.pin_code_step_create, this.getPinLength()); } @@ -360,22 +362,28 @@ protected void onPinCodeInputed() { onPinCodeError(); } break; - case AppLock.CHANGE_PIN: + case AppLock.NOTHING_PIN: + mLockManager.getAppLock().setPasscode(mPinCode); + setResult(RESULT_OK); + onPinCodeSuccess(); + finish(); + break; + case AppLock.UNLOCK_PIN: if (mLockManager.getAppLock().checkPasscode(mPinCode)) { - mType = AppLock.ENABLE_PINLOCK; - setStepText(); - setForgotTextVisibility(); - setPinCode(""); + setResult(RESULT_OK); onPinCodeSuccess(); + finish(); } else { onPinCodeError(); } break; - case AppLock.UNLOCK_PIN: + case AppLock.CHANGE_PIN: if (mLockManager.getAppLock().checkPasscode(mPinCode)) { - setResult(RESULT_OK); + mType = AppLock.ENABLE_PINLOCK; + setStepText(); + setForgotTextVisibility(); + setPinCode(""); onPinCodeSuccess(); - finish(); } else { onPinCodeError(); } From 25e862f1e2ee816158ab1ff304774633e3d51595 Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Sat, 20 Jan 2018 12:04:47 +0700 Subject: [PATCH 14/16] disable salt --- .../java/com/github/omadahealth/lollipin/MainActivity.java | 2 +- .../com/github/omadahealth/lollipin/lib/managers/AppLock.java | 2 +- .../github/omadahealth/lollipin/lib/managers/AppLockImpl.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java b/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java index 07651b75..fb90b6a3 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java @@ -32,7 +32,7 @@ public void onClick(View v) { Intent intent = new Intent(MainActivity.this, CustomPinActivity.class); switch (v.getId()) { case R.id.button_enable_pin: - intent.putExtra(AppLock.EXTRA_TYPE, AppLock.ENABLE_PINLOCK); + intent.putExtra(AppLock.EXTRA_TYPE, AppLock.NOTHING_PIN); startActivityForResult(intent, REQUEST_CODE_ENABLE); break; case R.id.button_change_pin: diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java index b40e9fd7..1a5a4647 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java @@ -171,7 +171,7 @@ public void removeIgnoredActivity(Class clazz) { * Get the passcode (store his SHA1 into {@link android.content.SharedPreferences}) using the * {@link com.github.omadahealth.lollipin.lib.encryption.Encryptor} class. */ - public abstract String getPasscodeEncrypted(); + public abstract String getPasscode(); /** * Check the {@link android.content.SharedPreferences} to see if fingerprint authentication is diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java index acae559b..fc10a75b 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java @@ -156,7 +156,7 @@ private String generateSalt() { byte[] salt = new byte[KEY_LENGTH]; try { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); - sr.setSeed(System.currentTimeMillis()); +// sr.setSeed(System.currentTimeMillis()); sr.nextBytes(salt); return Arrays.toString(salt); } catch (Exception e) { @@ -315,7 +315,7 @@ public boolean setPasscode(String passcode) { } @Override - public String getPasscodeEncrypted() { + public String getPasscode() { String passcodeEncrypted = mSharedPreferences.getString(PASSWORD_PREFERENCE_KEY, null); return passcodeEncrypted; } From b0331374667093c95f56f6dcc0bc1be2744cf959 Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Sat, 20 Jan 2018 12:33:03 +0700 Subject: [PATCH 15/16] set config salt ok --- .../lollipin/CustomApplication.java | 1 + .../omadahealth/lollipin/MainActivity.java | 4 +++ .../lollipin/lib/encryption/Encryptor.java | 2 +- .../lollipin/lib/managers/AppLock.java | 10 +++--- .../lib/managers/AppLockActivity.java | 6 ++-- .../lollipin/lib/managers/AppLockImpl.java | 31 +++++++++++++------ 6 files changed, 35 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java index 6802b24c..41e488e6 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/CustomApplication.java @@ -21,6 +21,7 @@ public void onCreate() { lockManager.getAppLock().setLogoId(R.drawable.security_lock); lockManager.getAppLock().setFingerprintAuthEnabled(true); lockManager.getAppLock().setShouldShowForgot(false); + lockManager.getAppLock().setDisableSalt(true); lockManager.getAppLock().setDisablePinlockMessage("Disable pinlock step message"); lockManager.getAppLock().setEnablePinlockMessage("Enable pinlock step message"); lockManager.getAppLock().setChangePinMessage("Change pin step message"); diff --git a/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java b/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java index fb90b6a3..0c5e9cad 100644 --- a/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java +++ b/app/src/main/java/com/github/omadahealth/lollipin/MainActivity.java @@ -2,11 +2,13 @@ import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.Toast; import com.github.omadahealth.lollipin.lib.PinActivity; import com.github.omadahealth.lollipin.lib.managers.AppLock; +import com.github.omadahealth.lollipin.lib.managers.LockManager; import lollipin.orangegangsters.github.com.lollipin.R; @@ -57,6 +59,8 @@ public void onClick(View v) { protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); + String passcodeEncrypted = LockManager.getInstance().getAppLock().getPasscodeEncrypted(); + Log.d("onActivityResult", "passcodeEncrypted: " + passcodeEncrypted); switch (requestCode){ case REQUEST_CODE_ENABLE: Toast.makeText(this, "PinCode enabled", Toast.LENGTH_SHORT).show(); diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/encryption/Encryptor.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/encryption/Encryptor.java index b04acf23..5dd9a870 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/encryption/Encryptor.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/encryption/Encryptor.java @@ -57,7 +57,7 @@ public static String getSHA(String text, Algorithm algorithm) { /** * Gets the default {@link MessageDigest} to use. - * Select {@link Algorithm#SHA256} in {@link com.github.omadahealth.lollipin.lib.managers.AppLockImpl#setPasscode(String)} + * Select {@link Algorithm#SHA256} in {@link com.github.omadahealth.lollipin.lib.managers.AppLockImpl#setPasscodeEncrypted(String)} * but can be {@link Algorithm#SHA1} for older versions. * * @param algorithm The {@link Algorithm} to use diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java index 1a5a4647..e6a71e30 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLock.java @@ -161,17 +161,15 @@ public void removeIgnoredActivity(Class clazz) { */ public abstract void setLastActiveMillis(); + public abstract void setDisableSalt(boolean isDisable); + /** * Set the passcode (store his SHA1 into {@link android.content.SharedPreferences}) using the * {@link com.github.omadahealth.lollipin.lib.encryption.Encryptor} class. */ - public abstract boolean setPasscode(String passcode); + public abstract boolean setPasscodeEncrypted(String passcode); - /** - * Get the passcode (store his SHA1 into {@link android.content.SharedPreferences}) using the - * {@link com.github.omadahealth.lollipin.lib.encryption.Encryptor} class. - */ - public abstract String getPasscode(); + public abstract String getPasscodeEncrypted(); /** * Check the {@link android.content.SharedPreferences} to see if fingerprint authentication is diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java index e6686fae..2702669d 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockActivity.java @@ -333,7 +333,7 @@ protected void onPinCodeInputed() { case AppLock.DISABLE_PINLOCK: if (mLockManager.getAppLock().checkPasscode(mPinCode)) { setResult(RESULT_OK); - mLockManager.getAppLock().setPasscode(null); + mLockManager.getAppLock().setPasscodeEncrypted(null); onPinCodeSuccess(); finish(); } else { @@ -350,7 +350,7 @@ protected void onPinCodeInputed() { case AppLock.CONFIRM_PIN: if (mPinCode.equals(mOldPinCode)) { setResult(RESULT_OK); - mLockManager.getAppLock().setPasscode(mPinCode); + mLockManager.getAppLock().setPasscodeEncrypted(mPinCode); onPinCodeSuccess(); finish(); } else { @@ -363,7 +363,7 @@ protected void onPinCodeInputed() { } break; case AppLock.NOTHING_PIN: - mLockManager.getAppLock().setPasscode(mPinCode); + mLockManager.getAppLock().setPasscodeEncrypted(mPinCode); setResult(RESULT_OK); onPinCodeSuccess(); finish(); diff --git a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java index fc10a75b..56cce121 100644 --- a/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java +++ b/lib/src/main/java/com/github/omadahealth/lollipin/lib/managers/AppLockImpl.java @@ -108,6 +108,8 @@ public class AppLockImpl extends AppLock implements L */ private static AppLockImpl mInstance; + private boolean isDisableSalt; + /** * Static method that allows to get back the current static Instance of {@link AppLockImpl} * @@ -138,12 +140,17 @@ public void setTimeout(long timeout) { } public String getSalt() { - String salt = mSharedPreferences.getString(PASSWORD_SALT_PREFERENCE_KEY, null); - if (salt == null) { - salt = generateSalt(); - setSalt(salt); + if (isDisableSalt) { + return ""; + + } else { + String salt = mSharedPreferences.getString(PASSWORD_SALT_PREFERENCE_KEY, null); + if (salt == null) { + salt = generateSalt(); + setSalt(salt); + } + return salt; } - return salt; } private void setSalt(String salt) { @@ -156,7 +163,7 @@ private String generateSalt() { byte[] salt = new byte[KEY_LENGTH]; try { SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); -// sr.setSeed(System.currentTimeMillis()); + sr.setSeed(System.currentTimeMillis()); sr.nextBytes(salt); return Arrays.toString(salt); } catch (Exception e) { @@ -294,7 +301,13 @@ public boolean checkPasscode(String passcode) { } @Override - public boolean setPasscode(String passcode) { + public void setDisableSalt(boolean isDisable) { + isDisableSalt = isDisable; + + } + + @Override + public boolean setPasscodeEncrypted(String passcode) { String salt = getSalt(); SharedPreferences.Editor editor = mSharedPreferences.edit(); @@ -315,13 +328,13 @@ public boolean setPasscode(String passcode) { } @Override - public String getPasscode() { + public String getPasscodeEncrypted() { String passcodeEncrypted = mSharedPreferences.getString(PASSWORD_PREFERENCE_KEY, null); return passcodeEncrypted; } /** - * Set the algorithm used in {@link #setPasscode(String)} + * Set the algorithm used in {@link #setPasscodeEncrypted(String)} */ private void setAlgorithm(Algorithm algorithm) { SharedPreferences.Editor editor = mSharedPreferences.edit(); From 15fe2c1643733e8f2ad3e66954d48db96b037d4e Mon Sep 17 00:00:00 2001 From: Anirut Teerabut Date: Sat, 20 Jan 2018 12:36:54 +0700 Subject: [PATCH 16/16] edit version --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 666168a0..d5fe0789 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #VERSION_NAME=1.0.0-SNAPSHOT -VERSION_NAME=2.1.0 -VERSION_CODE=29 +VERSION_NAME=1.0.8 +VERSION_CODE=30 GROUP=com.github.omadahealth POM_DESCRIPTION=Pin code/ fingerprint based lockscreen for you app