Skip to content

Commit 7bccb3e

Browse files
committed
Address lint warnings. Cleanup.
1 parent 5bcfa46 commit 7bccb3e

17 files changed

+44
-663
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
<application
1010
android:name=".CredentialsApplication"
11-
android:allowBackup="true"
1211
android:icon="@mipmap/ic_launcher"
1312
android:label="@string/app_name"
1413
android:supportsRtl="true"

app/src/main/java/com/appliedrec/credentials/app/BlinkLicenceKeyUpdater.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.Context;
44
import android.content.SharedPreferences;
5-
import android.net.Uri;
65

76
import androidx.preference.PreferenceManager;
87

app/src/main/java/com/appliedrec/credentials/app/DialView.java

Lines changed: 0 additions & 113 deletions
This file was deleted.

app/src/main/java/com/appliedrec/credentials/app/DocumentData.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
public class DocumentData implements Parcelable {
1010

11-
private String firstName;
12-
private String lastName;
13-
private String address;
14-
private String dateOfBirth;
15-
private String dateOfExpiry;
16-
private String dateOfIssue;
17-
private String documentNumber;
18-
private String sex;
11+
private final String firstName;
12+
private final String lastName;
13+
private final String address;
14+
private final String dateOfBirth;
15+
private final String dateOfExpiry;
16+
private final String dateOfIssue;
17+
private final String documentNumber;
18+
private final String sex;
1919
private String rawBarcode;
2020

2121
public DocumentData(UsdlCombinedRecognizer.Result result) {
@@ -41,7 +41,7 @@ public DocumentData(BlinkIdCombinedRecognizer.Result result) {
4141
sex = result.getSex();
4242
}
4343

44-
protected DocumentData(Parcel in) {
44+
private DocumentData(Parcel in) {
4545
firstName = in.readString();
4646
lastName = in.readString();
4747
address = in.readString();

app/src/main/java/com/appliedrec/credentials/app/DocumentDetailsActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public class DocumentDetailsActivity extends RxVerIDActivity {
2525

2626
static class DocumentPropertyViewHolder extends RecyclerView.ViewHolder {
2727

28-
private TextView keyTextView;
29-
private TextView valueTextView;
28+
private final TextView keyTextView;
29+
private final TextView valueTextView;
3030

31-
public DocumentPropertyViewHolder(@NonNull View itemView) {
31+
DocumentPropertyViewHolder(@NonNull View itemView) {
3232
super(itemView);
3333
keyTextView = itemView.findViewById(R.id.key);
3434
valueTextView = itemView.findViewById(R.id.value);
@@ -42,8 +42,8 @@ void bind(String name, String value) {
4242

4343
static class DocumentDetailsAdapter extends RecyclerView.Adapter<DocumentPropertyViewHolder> {
4444

45-
private LayoutInflater layoutInflater;
46-
private List<Pair<String,String>> documentProperties;
45+
private final LayoutInflater layoutInflater;
46+
private final List<Pair<String,String>> documentProperties;
4747

4848
DocumentDetailsAdapter(Context context, List<Pair<String,String>> documentProperties) {
4949
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -80,7 +80,7 @@ protected void onCreate(Bundle savedInstanceState) {
8080
if (documentData.getRawBarcode() != null) {
8181
try {
8282
SecureStorage secureStorage = new SecureStorage(this);
83-
String intellicheckSecret = secureStorage.getValueForKey(SecureStorage.CommonKeys.INTELLICHECK_API_KEY);
83+
String intellicheckSecret = secureStorage.getValueForKey();
8484
if (intellicheckSecret != null) {
8585
IntellicheckBarcodeVerifier barcodeVerifier = new IntellicheckBarcodeVerifier(this, intellicheckSecret);
8686
addDisposable(barcodeVerifier.parseBarcode(documentData.getRawBarcode()).toList().observeOn(AndroidSchedulers.mainThread()).subscribe(

app/src/main/java/com/appliedrec/credentials/app/IntellicheckBarcodeVerifier.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@
99
import androidx.core.util.Pair;
1010
import androidx.preference.PreferenceManager;
1111

12-
import com.google.gson.Gson;
1312
import com.google.gson.stream.JsonReader;
1413

1514
import java.io.ByteArrayInputStream;
1615
import java.io.ByteArrayOutputStream;
17-
import java.io.InputStream;
1816
import java.io.InputStreamReader;
1917
import java.io.OutputStream;
20-
import java.net.MalformedURLException;
2118
import java.net.URL;
2219
import java.nio.charset.StandardCharsets;
2320
import java.util.List;
21+
import java.util.Objects;
2422
import java.util.UUID;
2523

2624
import javax.net.ssl.HttpsURLConnection;
@@ -29,12 +27,12 @@
2927
import io.reactivex.Observable;
3028
import io.reactivex.schedulers.Schedulers;
3129

32-
public class IntellicheckBarcodeVerifier {
30+
class IntellicheckBarcodeVerifier {
3331

34-
private String url;
35-
private SharedPreferences sharedPreferences;
36-
private String password;
37-
private String appId;
32+
private final String url;
33+
private final SharedPreferences sharedPreferences;
34+
private final String password;
35+
private final String appId;
3836

3937
public IntellicheckBarcodeVerifier(Context context, String password) {
4038
this.url = BuildConfig.INTELLICHECK_URL;
@@ -70,10 +68,10 @@ public Completable testPassword() {
7068
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
7169
connection.setDoOutput(true);
7270
connection.setDoInput(true);
73-
byte[] body = new Uri.Builder()
71+
byte[] body = Objects.requireNonNull(new Uri.Builder()
7472
.appendQueryParameter("device_id", getDeviceId())
7573
.appendQueryParameter("app_id", appId)
76-
.appendQueryParameter("password", password).build().getQuery().getBytes(StandardCharsets.UTF_8);
74+
.appendQueryParameter("password", password).build().getQuery()).getBytes(StandardCharsets.UTF_8);
7775
OutputStream outputStream = connection.getOutputStream();
7876
ByteArrayInputStream inputStream = new ByteArrayInputStream(body);
7977
int read;
@@ -121,7 +119,7 @@ public Observable<Pair<String,String>> parseBarcode(String barcode) {
121119
.appendQueryParameter("data", Base64.encodeToString(barcodeData, Base64.NO_WRAP))
122120
.build()
123121
.getQuery();
124-
ByteArrayInputStream inputStream = new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8));
122+
ByteArrayInputStream inputStream = new ByteArrayInputStream(Objects.requireNonNull(body).getBytes(StandardCharsets.UTF_8));
125123
OutputStream outputStream = connection.getOutputStream();
126124
int read;
127125
byte[] buffer = new byte[512];

app/src/main/java/com/appliedrec/credentials/app/SecureStorage.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ static class CommonKeys {
2222
sharedPreferences = EncryptedSharedPreferences.create("credentialsAppSecureStore", MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC), context, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM);
2323
}
2424

25-
void setValueForKey(String value, String key) {
26-
sharedPreferences.edit().putString(key, value).apply();
25+
void setValueForKey(String value) {
26+
sharedPreferences.edit().putString(CommonKeys.INTELLICHECK_API_KEY, value).apply();
2727
}
2828

29-
String getValueForKey(String key) {
30-
return sharedPreferences.getString(key, null);
29+
String getValueForKey() {
30+
return sharedPreferences.getString(CommonKeys.INTELLICHECK_API_KEY, null);
3131
}
3232

33-
void deleteValueForKey(String key) {
34-
sharedPreferences.edit().remove(key).apply();
33+
void deleteValueForKey() {
34+
sharedPreferences.edit().remove(CommonKeys.INTELLICHECK_API_KEY).apply();
3535
}
3636
}

app/src/main/java/com/appliedrec/credentials/app/SettingsActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected void onCreate(Bundle savedInstanceState) {
2323
ProgressBar progressBar = findViewById(R.id.progressBar);
2424
progressBar.setVisibility(View.INVISIBLE);
2525
SecureStorage secureStorage = new SecureStorage(this);
26-
String password = secureStorage.getValueForKey(SecureStorage.CommonKeys.INTELLICHECK_API_KEY);
26+
String password = secureStorage.getValueForKey();
2727
EditText passwordEditText = findViewById(R.id.password);
2828
Button testButton = findViewById(R.id.button);
2929
passwordEditText.setText(password);
@@ -43,10 +43,10 @@ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
4343
public void afterTextChanged(Editable editable) {
4444
String password = editable.toString().trim();
4545
if (password.isEmpty()) {
46-
secureStorage.deleteValueForKey(SecureStorage.CommonKeys.INTELLICHECK_API_KEY);
46+
secureStorage.deleteValueForKey();
4747
testButton.setEnabled(false);
4848
} else {
49-
secureStorage.setValueForKey(password, SecureStorage.CommonKeys.INTELLICHECK_API_KEY);
49+
secureStorage.setValueForKey(password);
5050
testButton.setEnabled(true);
5151
}
5252
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
package com.appliedrec.credentials.app;
22

3-
import androidx.appcompat.app.AppCompatActivity;
4-
53
import android.content.Intent;
64
import android.os.Bundle;
75
import android.webkit.WebView;
86

9-
public class WebViewActivity extends AppCompatActivity {
7+
import androidx.appcompat.app.AppCompatActivity;
108

11-
private WebView webView;
9+
public class WebViewActivity extends AppCompatActivity {
1210

1311
@Override
1412
protected void onCreate(Bundle savedInstanceState) {
1513
super.onCreate(savedInstanceState);
1614
setContentView(R.layout.activity_web_view);
17-
webView = findViewById(R.id.webView);
15+
WebView webView = findViewById(R.id.webView);
1816
Intent intent = getIntent();
1917
String url = intent.getStringExtra(Intent.EXTRA_TEXT);
2018
if (url != null) {
2119
webView.loadUrl(url);
2220
}
2321
}
2422

25-
void loadUrl(String url) {
26-
webView.loadUrl(url);
27-
}
2823
}

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
app:srcCompat="@drawable/woman_with_licence" />
4040

4141
<TextView
42+
android:id="@+id/textView"
4243
android:layout_width="wrap_content"
4344
android:layout_height="wrap_content"
4445
android:text="@string/home_instructions"

0 commit comments

Comments
 (0)