Skip to content

Commit 4faed1f

Browse files
authored
Improve compatibility with Kotlin and run Lint on CI (#596)
* fix lint issues and improve compatibility with kotlin * run lint on CI * fix playground button style
1 parent d4f7bc9 commit 4faed1f

File tree

94 files changed

+549
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+549
-318
lines changed

.circleci/config.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ jobs:
1010
- checkout
1111
- restore_cache:
1212
keys:
13-
- v1-dep-{{ .Branch }}-
13+
- v1-dep-{{ checksum "lib/build.gradle" }}
1414
- run: ./gradlew androidDependencies
1515
- save_cache:
16-
key: v1-dep-{{ .Branch }}-{{ epoch }}
16+
key: v1-dep-{{ checksum "lib/build.gradle" }}
1717
paths:
1818
- ~/.gradle
1919
- ~/.android
2020
- /usr/local/android-sdk-linux/extras
21-
- run: ./gradlew clean test --continue --console=plain --max-workers=4
21+
- run:
22+
name: Run checks
23+
command: ./gradlew clean test lint --continue --console=plain --max-workers=4
24+
- store_artifacts:
25+
path: lib/build/reports
26+
destination: reports
27+
- store_test_results:
28+
path: lib/build/test-results

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ As in the previous version, `Lock` can be configured with extra options. Check b
734734

735735
#### Renamed options from v1
736736

737-
- shouldUseWebView: Renamed to `useBrowser`. Whether to use the WebView or the Browser to request calls to the `/authorize` endpoint. Using the Browser has some [restrictions](#some-restrictions).
738737
- shouldUseEmail: Renamed to `withUsernameStyle`. Defines if it should ask for email only, username only, or both of them. By default, it'll respect the Dashboard configuration of the parameter `requires_username`.
739738
- isClosable: Renamed to `closable`. Defines if the LockActivity can be closed. By default, it's not closable.
740739
- setFullscreen: Renamed to `fullscreen`. Defines if the LockActivity it's displayed in fullscreen. By default, it's not fullscreen.

app/src/main/java/com/auth0/android/lock/app/DemoActivity.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ private void showResult(String message) {
282282
Snackbar.make(rootLayout, message, Snackbar.LENGTH_LONG).show();
283283
}
284284

285-
private LockCallback callback = new AuthenticationCallback() {
285+
private final LockCallback callback = new AuthenticationCallback() {
286286
@Override
287-
public void onAuthentication(Credentials credentials) {
287+
public void onAuthentication(@NonNull Credentials credentials) {
288288
showResult("OK > " + credentials.getAccessToken());
289289
}
290290

@@ -294,12 +294,12 @@ public void onCanceled() {
294294
}
295295

296296
@Override
297-
public void onError(LockException error) {
297+
public void onError(@NonNull LockException error) {
298298
showResult(error.getMessage());
299299
}
300300
};
301301

302-
private AuthCallback loginCallback = new AuthCallback() {
302+
private final AuthCallback loginCallback = new AuthCallback() {
303303
@Override
304304
public void onFailure(@NonNull Dialog dialog) {
305305
dialog.show();
@@ -316,9 +316,9 @@ public void onSuccess(@NonNull Credentials credentials) {
316316
}
317317
};
318318

319-
private VoidCallback logoutCallback = new VoidCallback() {
319+
private final VoidCallback logoutCallback = new VoidCallback() {
320320
@Override
321-
public void onFailure(Auth0Exception error) {
321+
public void onFailure(@NonNull Auth0Exception error) {
322322
showResult("Log out cancelled");
323323
}
324324

lib/build.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ android {
3333
consumerProguardFiles '../proguard/proguard-gson.pro', '../proguard/proguard-otto.pro', '../proguard/proguard-lock-2.pro'
3434
}
3535

36+
lintOptions {
37+
disable 'ContentDescription', 'SyntheticAccessor'
38+
abortOnError true
39+
}
40+
3641
testOptions {
3742
unitTests {
3843
includeAndroidResources = true

lib/src/main/java/com/auth0/android/lock/Auth0Parcelable.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import android.os.Parcel;
2828
import android.os.Parcelable;
29+
import android.support.annotation.NonNull;
2930

3031
import com.auth0.android.Auth0;
3132
import com.auth0.android.util.Telemetry;
@@ -38,12 +39,13 @@ public class Auth0Parcelable implements Parcelable {
3839

3940
private static final double WITHOUT_DATA = 0x00;
4041
private static final double WITH_DATA = 0x01;
41-
private Auth0 auth0;
42+
private final Auth0 auth0;
4243

43-
public Auth0Parcelable(Auth0 auth0) {
44+
public Auth0Parcelable(@NonNull Auth0 auth0) {
4445
this.auth0 = auth0;
4546
}
4647

48+
@NonNull
4749
public Auth0 getAuth0() {
4850
return auth0;
4951
}
@@ -55,7 +57,7 @@ public int describeContents() {
5557
}
5658

5759
@Override
58-
public void writeToParcel(Parcel dest, int flags) {
60+
public void writeToParcel(@NonNull Parcel dest, int flags) {
5961
dest.writeString(auth0.getClientId());
6062
dest.writeString(auth0.getDomainUrl());
6163
dest.writeString(auth0.getConfigurationUrl());
@@ -80,7 +82,8 @@ public Auth0Parcelable[] newArray(int size) {
8082
}
8183
};
8284

83-
private Auth0Parcelable(Parcel in) {
85+
@SuppressWarnings("ConstantConditions")
86+
private Auth0Parcelable(@NonNull Parcel in) {
8487
String clientId = in.readString();
8588
String domain = in.readString();
8689
String configurationDomain = in.readString();

lib/src/main/java/com/auth0/android/lock/AuthenticationCallback.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.auth0.android.lock;
2626

2727
import android.content.Intent;
28+
import android.support.annotation.NonNull;
2829
import android.util.Log;
2930

3031
import com.auth0.android.result.Credentials;
@@ -43,15 +44,15 @@ public abstract class AuthenticationCallback implements LockCallback {
4344
*
4445
* @param credentials with the tokens.
4546
*/
46-
public abstract void onAuthentication(Credentials credentials);
47+
public abstract void onAuthentication(@NonNull Credentials credentials);
4748

4849
/**
4950
* Called when the user goes back and closes the activity, without using an Authentication flow.
5051
*/
5152
public abstract void onCanceled();
5253

5354
@Override
54-
public void onEvent(@LockEvent int event, Intent data) {
55+
public void onEvent(@LockEvent int event, @NonNull Intent data) {
5556
switch (event) {
5657
case LockEvent.CANCELED:
5758
onCanceled();

lib/src/main/java/com/auth0/android/lock/CountryCodeActivity.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import android.content.Intent;
5252
import android.os.AsyncTask;
5353
import android.os.Bundle;
54+
import android.support.annotation.Nullable;
5455
import android.support.v7.app.ActionBar;
5556
import android.support.v7.app.AppCompatActivity;
5657
import android.text.Editable;
@@ -82,7 +83,7 @@ public class CountryCodeActivity extends AppCompatActivity {
8283
ListView listView;
8384

8485
@Override
85-
public void onCreate(Bundle savedInstanceState) {
86+
public void onCreate(@Nullable Bundle savedInstanceState) {
8687
super.onCreate(savedInstanceState);
8788

8889
setContentView(R.layout.com_auth0_lock_passwordless_activity_country_code);

0 commit comments

Comments
 (0)