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

Migrate to AndroidX #609

Merged
merged 7 commits into from
Apr 12, 2021
Merged

Migrate to AndroidX #609

merged 7 commits into from
Apr 12, 2021

Conversation

lbalmaceda
Copy link
Contributor

@lbalmaceda lbalmaceda commented Apr 8, 2021

This PR migrates to AndroidX dependencies, mostly achieved by running the AndroidX migration tool. It also updates other dependencies, including testing dependencies. It fixes compilation issues and replaces deprecated methods.

It also removes the Bintray gradle plugin. No longer required as we're now uploading packages directly to Central.

@lbalmaceda lbalmaceda added the large Large review label Apr 8, 2021
@lbalmaceda lbalmaceda added this to the Major - v3 milestone Apr 8, 2021
@lbalmaceda lbalmaceda marked this pull request as ready for review April 9, 2021 13:46
@lbalmaceda lbalmaceda requested a review from a team as a code owner April 9, 2021 13:46
android.enableJetifier=true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will remain true until we reach the end of the project and try to turn it off.

@@ -1,5 +1,5 @@
plugins {
id "com.auth0.gradle.oss-library.android" version "0.12.1"
id "com.auth0.gradle.oss-library.android" version "0.15.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latest release plugin version

versionCode 1
versionName project.version
consumerProguardFiles '../proguard/proguard-gson.pro', '../proguard/proguard-otto.pro', '../proguard/proguard-lock-2.pro'
// Required since Android Gradle Plugin 4.1 - https://issuetracker.google.com/issues/154275579
buildConfigField "String", "VERSION_NAME", "\"$versionName\""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value was historically available but got removed recently. We use it to construct the auth0 user info header.

@@ -26,7 +26,7 @@

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes are repeated all over the diff. This is the migration to AndroidX.

@@ -80,9 +81,11 @@ public void shouldCreateAccountFromResources() {
Mockito.when(activity.getApplicationContext()).thenReturn(RuntimeEnvironment.application);
Mockito.when(activity.registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class))).thenReturn(null);
Mockito.when(activity.getResources()).thenReturn(resources);
Mockito.when(resources.getIdentifier(anyString(), anyString(), anyString())).thenReturn(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer expecting "anything" but rather matching against the 2 specific values I know we consume

@@ -528,7 +529,7 @@ public void shouldCallEnterpriseOAuthAuthenticationWithActiveFlow() {
public void shouldCallOAuthAuthenticationWithCustomProvider() {
AuthProvider customProvider = mock(AuthProvider.class);
AuthHandler handler = mock(AuthHandler.class);
when(handler.providerFor(anyString(), eq("custom-connection"))).thenReturn(customProvider);
when(handler.providerFor((String) isNull(), eq("custom-connection"))).thenReturn(customProvider);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matches against a null value, I have to cast to String because Java

@@ -77,12 +80,14 @@ public void shouldThrowIfAccountIsMissingAlsoFromResources() {
public void shouldCreateAccountFromResources() {
Activity activity = Mockito.mock(Activity.class);
Resources resources = Mockito.mock(Resources.class);
Mockito.when(activity.getApplicationContext()).thenReturn(RuntimeEnvironment.application);
Mockito.when(activity.getApplicationContext()).thenReturn(ApplicationProvider.getApplicationContext());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old way is deprecated and will probably be updated across more files if I see them

Mockito.when(activity.registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class))).thenReturn(null);
Mockito.when(activity.getResources()).thenReturn(resources);
Mockito.when(resources.getIdentifier(anyString(), anyString(), anyString())).thenReturn(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer expecting "anything" but rather matching against the 2 specific values I know we consume

@lbalmaceda lbalmaceda merged commit bfa158e into v3 Apr 12, 2021
@lbalmaceda lbalmaceda deleted the target-sdk branch April 12, 2021 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants