-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
436 additions
and
15 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import com.guru.composecookbook.build.dependencies.addBiometricDependency | ||
import com.guru.composecookbook.build.dependencies.addComposeOfficialDependencies | ||
import com.guru.composecookbook.build.dependencies.addComposeThirdPartyDependencies | ||
|
||
|
||
plugins { | ||
/** | ||
* See [common-compose-module-configs-script-plugin.gradle.kts] file | ||
*/ | ||
id("common-compose-module-configs-script-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":theme")) | ||
implementation(project(":data")) | ||
implementation(project(":animations:lottie")) | ||
implementation(project(":components:tags")) | ||
implementation(project(":templates:onboarding")) | ||
|
||
addComposeOfficialDependencies() | ||
addComposeThirdPartyDependencies() | ||
addBiometricDependency() | ||
} |
24 changes: 24 additions & 0 deletions
24
templates/pinlock/src/androidTest/java/com/guru/pinlock/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.guru.pinlock | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.guru.pinlock.test", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.guru.pinlock"> | ||
|
||
<application> | ||
<activity | ||
android:name=".BiometricActivity" | ||
android:exported="true" | ||
android:theme="@style/Theme.Transparent"/> | ||
</application> | ||
|
||
</manifest> |
56 changes: 56 additions & 0 deletions
56
templates/pinlock/src/main/java/com/guru/pinlock/BiometricActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.guru.pinlock | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.biometric.BiometricPrompt | ||
import androidx.compose.foundation.ExperimentalFoundationApi | ||
import androidx.compose.material.ExperimentalMaterialApi | ||
import androidx.core.content.ContextCompat | ||
import androidx.fragment.app.FragmentActivity | ||
|
||
@ExperimentalFoundationApi | ||
class BiometricActivity : FragmentActivity() { | ||
|
||
@ExperimentalMaterialApi | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
val biometricPromt = createBiometricPrompt(this) | ||
val promptInfo = BiometricPrompt.PromptInfo.Builder() | ||
.setTitle("Verify Identity to login") | ||
.setSubtitle("Log in using your biometric credential") | ||
.setNegativeButtonText("Use pin password") | ||
.build() | ||
biometricPromt.authenticate(promptInfo) | ||
} | ||
|
||
companion object { | ||
fun newIntent(context: Context) = Intent(context, BiometricActivity::class.java) | ||
} | ||
} | ||
|
||
private fun createBiometricPrompt(activity: FragmentActivity): BiometricPrompt { | ||
val executor = ContextCompat.getMainExecutor(activity) | ||
|
||
val callback = object : BiometricPrompt.AuthenticationCallback() { | ||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { | ||
super.onAuthenticationError(errorCode, errString) | ||
// if (errorCode == BiometricPrompt.ERROR_NEGATIVE_BUTTON) { | ||
// activity.finish() | ||
// } | ||
activity.finish() | ||
} | ||
|
||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { | ||
super.onAuthenticationSucceeded(result) | ||
activity.setResult(Activity.RESULT_OK) | ||
activity.finish() | ||
} | ||
} | ||
val biometricPrompt = BiometricPrompt(activity, executor, callback) | ||
|
||
return biometricPrompt | ||
} | ||
|
||
|
Oops, something went wrong.