From 79c41edb9f9476e891e61f92110769e89a55be9e Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Thu, 29 Apr 2021 13:24:03 +0200 Subject: [PATCH 1/4] make lock activities available out of the box --- app/src/main/AndroidManifest.xml | 48 ++---------------------------- app/src/main/res/values/styles.xml | 12 -------- lib/src/main/AndroidManifest.xml | 41 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 57 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aa7c9f038..547ab583c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,65 +2,23 @@ xmlns:tools="http://schemas.android.com/tools" package="com.auth0.android.lock.app"> - - - - + tools:ignore="GoogleAppIndexingWarning"> + android:label="@string/app_name"> - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 19ab0dfcf..5885930df 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,16 +8,4 @@ @color/colorAccent - - diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml index 64a98f986..9d52208d6 100644 --- a/lib/src/main/AndroidManifest.xml +++ b/lib/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + @@ -20,6 +21,46 @@ android:scheme="${auth0Scheme}" /> + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 870ead56192372b217d3154a25b775cd94239e67 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Thu, 29 Apr 2021 13:31:35 +0200 Subject: [PATCH 2/4] update docs to reflect the removal of manifest changes --- README.md | 98 ++++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 7c1b66863..9fc5ff4b8 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,22 @@ Since June 2017 new Applications no longer have the **Password Grant Type** enab ## Requirements -Android API Level 21+ is required in order to use Lock's UI. +Android API Level 21+ & Java version 8 or above is required in order to use Lock's UI. + +Here’s what you need in build.gradle to target Java 8 byte code for the Android and Kotlin plugins respectively. + +```groovy +android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } +} +``` ## Install @@ -40,6 +55,14 @@ If you haven't done yet, go to [Auth0](https://auth0.com) and create an Account, https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback ``` +If you plan to use Passwordless authentication with SMS or Email connections, the Callback URL you will register looks like this: + +``` +https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/sms +// or +https://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/email +``` + The *package name* value required in the Callback URL can be found in your app's `build.gradle` file in the `applicationId` property. Both the *domain* and *client id* values can be found at the top of your Auth0 Application's settings. You're going to use them to setup the SDK. It's good practice to add them to the `strings.xml` file as string resources that you can reference later from the code. This guide will follow that practice. ```xml @@ -49,7 +72,7 @@ The *package name* value required in the Callback URL can be found in your app's ``` -In your `app/build.gradle` file add the **Manifest Placeholders** for the Auth0 Domain and Auth0 Scheme properties, which are going to be used internally by the library to register an **intent-filter** that will capture the authentication result. +In your `app/build.gradle` file add the **Manifest Placeholders** for the Auth0 Domain and Auth0 Scheme properties, which are going to be used internally by the library to declare the Lock activities and register **intent-filters** that will capture the authentication result. ```groovy apply plugin: 'com.android.application' @@ -91,27 +114,7 @@ val account = Auth0("{YOUR_AUTH0_CLIENT_ID}", "{YOUR_AUTH0_DOMAIN}", "{THE_CONFI ### Email/Password, Enterprise & Social authentication -Modify the `AndroidManifest.xml` file, to include the Internet permission: - -```xml - -``` - -Next, add the `LockActivity` inside the `application` tag: - -```xml - -``` - -Make sure the Activity's `launchMode` is declared as `singleTask` or the authentication result won't come back into your application. - - -Then, in any of your Activities, you need to initialize **Lock** and handle the release of its resources appropriately after you're done using it. +Initialize **Lock** and handle the release of its resources appropriately after you're done using it. ```kotlin // This activity will show Lock @@ -151,7 +154,7 @@ class MyActivity : AppCompatActivity() { } ``` -To start `LockActivity` from inside your `Activity`, create a new intent and launch it. +Start `LockActivity` from inside your `Activity`. For this, create a new intent from the Lock instance and launch it. ```kotlin startActivity(lock.newIntent(this)) @@ -163,50 +166,7 @@ The Passwordless feature requires your Application to have the *Passwordless OTP `PasswordlessLockActivity` authenticates users by sending them an Email or SMS (similar to how WhatsApp authenticates you). In order to be able to authenticate the user, your application must have the SMS/Email connection enabled and configured in your [dashboard](https://manage.auth0.com/#/connections/passwordless). - -Modify the `AndroidManifest.xml` file, to include the Internet permission: - -```xml - -``` - -Next, add the `PasswordlessLockActivity` inside the `application` tag. Note that this time, you must define an intent-filter that matches the passwordless callback URL: - -```xml - - - - - - - - - - -``` - -The `data` attribute of the intent-filter defines which format of "Callback URL" your app is going to capture. In the above case, it's going to capture calls from `email` passwordless connections. In case you're using the `sms` passwordless connection, the `pathPrefix` should end in `sms` instead. - -Make sure the Activity's `launchMode` is declared as `singleTask` or the result won't come back in the authentication. - -When the Passwordless connection is SMS you must also add the `CountryCodeActivity` to allow the user to change the **Country Code** prefix of the phone number. - -```xml - -``` - - -Then, in any of your Activities, you need to initialize **PasswordlessLock** and handle the release of its resources appropriately after you're doing using it. +Initialize **PasswordlessLock** and handle the release of its resources appropriately after you're doing using it. ```kotlin // This activity will show PasswordlessLock @@ -246,7 +206,7 @@ class MyActivity : AppCompatActivity() { } ``` -To start `PasswordlessLockActivity` from inside your `Activity`, create a new intent and launch it. +Start `PasswordlessLockActivity` from inside your `Activity`. For this, create a new intent and launch it. ```kotlin startActivity(lock.newIntent(this)) From 365e49b6482c43f2f098ec091f49ee8f721248c5 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Thu, 29 Apr 2021 13:40:23 +0200 Subject: [PATCH 3/4] update migration guide --- MIGRATION_GUIDE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 4cd81d5cf..a0fb3dabc 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -6,6 +6,7 @@ The new version makes use of the latest Auth0.Android SDK, bringing improvements - Open ID Connect compliant practices. - ID token verification for Web Authentication flows. - A new customizable networking stack. + - Simpler Android app set up. Some of these features were previously available, but only enforced when the "OIDC" flag was explicitly enabled. @@ -38,6 +39,15 @@ As part of removing legacy APIs or authentication flows no longer recommended fo Continue reading for the detail of classes and methods that were impacted. +## Changes to the AndroidManifest file +In the previous version you had to declare the Lock activities you planned to use. These activities are now declared internally by the library with intent filters configured using the Manifest Placeholders that you provide for the Domain and Scheme. The Manifest Merger tool will process these and include them as part of your Android application. + +If your `AndroidManifest.xml` file includes declarations for `LockActivity`, `PasswordlessLockActivity` or `CountryCodeActivity`, you should remove them to avoid duplicated intent filter declarations. + +If you are using a custom style for the theme or need to override the intent-filter declarations in any of these activities, you will have to declare an activity with the same component name and annotate it with `tools:node="replace"`. + +Find details about the merging rules that will be used in the [Android Manifest Merger article](https://developer.android.com/studio/build/manifest-merge). + ### Removed classes - `VoidCallback` is no longer available. Please, use `Callback` instead. From 8c63129d24161f07e93fc03321fc1df20597cc90 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Thu, 29 Apr 2021 21:12:02 +0200 Subject: [PATCH 4/4] fix tests by providing test values for the manifest placeholders --- lib/build.gradle | 7 +++++++ lib/src/test/AndroidManifest.xml | 25 ------------------------- 2 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 lib/src/test/AndroidManifest.xml diff --git a/lib/build.gradle b/lib/build.gradle index 900389981..998fe603c 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -51,6 +51,13 @@ android { } } + unitTestVariants.all { + it.mergedFlavor.manifestPlaceholders += [ + auth0Domain: "johndoe.auth0.com", + auth0Scheme: "test" + ] + } + compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 diff --git a/lib/src/test/AndroidManifest.xml b/lib/src/test/AndroidManifest.xml deleted file mode 100644 index bd640a7d7..000000000 --- a/lib/src/test/AndroidManifest.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file