From 4df047d88879c1ea9d328af0435f15f8195e0515 Mon Sep 17 00:00:00 2001 From: Julius Date: Thu, 9 Feb 2017 17:15:40 +0200 Subject: [PATCH 1/2] fixing lint issues --- devicesetup/build.gradle | 6 +-- devicesetup/devicesetup.iml | 41 ++++++++++--------- devicesetup/lint.xml | 9 ++++ .../loaders/WifiScanResultLoader.java | 5 ++- .../ui/DiscoverDeviceActivity.java | 3 +- .../io/particle/android/sdk/utils/Crypto.java | 6 ++- .../io/particle/android/sdk/utils/SSID.java | 4 +- .../sdk/utils/SoftAPConfigRemover.java | 2 +- .../main/res/layout/activity_connecting.xml | 5 +++ .../res/layout/activity_discover_device.xml | 1 + .../res/layout/activity_password_entry.xml | 8 ++-- .../main/res/layout/brand_image_header.xml | 7 +++- .../main/res/layout/row_wifi_scan_result.xml | 13 +++++- devicesetup/src/main/res/values/themes.xml | 9 ++-- exampleapp/build.gradle | 2 +- exampleapp/exampleapp.iml | 38 ++++++++--------- exampleapp/lint.xml | 12 ++++++ 17 files changed, 111 insertions(+), 60 deletions(-) create mode 100644 devicesetup/lint.xml create mode 100644 exampleapp/lint.xml diff --git a/devicesetup/build.gradle b/devicesetup/build.gradle index a139f27..c45fb32 100644 --- a/devicesetup/build.gradle +++ b/devicesetup/build.gradle @@ -90,9 +90,9 @@ dependencies { compile 'com.squareup.phrase:phrase:1.0.3' compile 'uk.co.chrisjenx:calligraphy:2.2.0' - compile 'com.android.support:appcompat-v7:25.1.0' - compile 'com.android.support:recyclerview-v7:25.1.0' - compile 'com.android.support:support-annotations:25.1.0' + compile 'com.android.support:appcompat-v7:25.1.1' + compile 'com.android.support:recyclerview-v7:25.1.1' + compile 'com.android.support:support-annotations:25.1.1' retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.3.0' diff --git a/devicesetup/devicesetup.iml b/devicesetup/devicesetup.iml index cf91a5f..92c8b1d 100644 --- a/devicesetup/devicesetup.iml +++ b/devicesetup/devicesetup.iml @@ -67,14 +67,6 @@ - - - - - - - - @@ -83,6 +75,15 @@ + + + + + + + + + @@ -96,29 +97,31 @@ + + - - - - - - + + + + - - - - - + + + + + + + \ No newline at end of file diff --git a/devicesetup/lint.xml b/devicesetup/lint.xml new file mode 100644 index 0000000..56af983 --- /dev/null +++ b/devicesetup/lint.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/loaders/WifiScanResultLoader.java b/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/loaders/WifiScanResultLoader.java index 380e303..c789e85 100644 --- a/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/loaders/WifiScanResultLoader.java +++ b/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/loaders/WifiScanResultLoader.java @@ -6,6 +6,7 @@ import android.net.wifi.WifiManager; import java.util.List; +import java.util.Locale; import java.util.Set; import io.particle.android.sdk.devicesetup.R; @@ -93,8 +94,8 @@ public Set loadInBackground() { if (input == null || !truthy(input.SSID)) { return false; } - String softApPrefix = (getContext().getString(R.string.network_name_prefix) + "-").toLowerCase(); - return input.SSID.toLowerCase().startsWith(softApPrefix); + String softApPrefix = (getContext().getString(R.string.network_name_prefix) + "-").toLowerCase(Locale.ROOT); + return input.SSID.toLowerCase(Locale.ROOT).startsWith(softApPrefix); }; } diff --git a/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/ui/DiscoverDeviceActivity.java b/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/ui/DiscoverDeviceActivity.java index 4eeac1e..d365b8d 100644 --- a/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/ui/DiscoverDeviceActivity.java +++ b/devicesetup/src/main/java/io/particle/android/sdk/devicesetup/ui/DiscoverDeviceActivity.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.security.PublicKey; +import java.util.Locale; import java.util.Set; import io.particle.android.sdk.accountsetup.LoginActivity; @@ -397,7 +398,7 @@ public void doTheThing() throws SetupStepException { try { DeviceIdCommand.Response response = client.sendCommand( new DeviceIdCommand(), DeviceIdCommand.Response.class); - detectedDeviceID = response.deviceIdHex.toLowerCase(); + detectedDeviceID = response.deviceIdHex.toLowerCase(Locale.ROOT); DeviceSetupState.deviceToBeSetUpId = detectedDeviceID; isDetectedDeviceClaimed = truthy(response.isClaimed); } catch (IOException e) { diff --git a/devicesetup/src/main/java/io/particle/android/sdk/utils/Crypto.java b/devicesetup/src/main/java/io/particle/android/sdk/utils/Crypto.java index 0702e3d..4297b7a 100644 --- a/devicesetup/src/main/java/io/particle/android/sdk/utils/Crypto.java +++ b/devicesetup/src/main/java/io/particle/android/sdk/utils/Crypto.java @@ -9,6 +9,7 @@ import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; +import java.util.Locale; import javax.annotation.ParametersAreNonnullByDefault; import javax.crypto.BadPaddingException; @@ -48,13 +49,14 @@ public static String encryptAndEncodeToHex(String inputString, PublicKey publicK String hex = ByteString.of(encryptedBytes).hex(); // forcing lowercase here because of a bug in the early firmware that didn't accept // hex encoding in uppercase - return hex.toLowerCase(); + return hex.toLowerCase(Locale.ROOT); } + @SuppressLint("TrulyRandom") static byte[] encryptWithKey(byte[] inputData, PublicKey publicKey) throws CryptoException { try { @SuppressLint("GetInstance") // the warning doesn't apply to how we're using this - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); return cipher.doFinal(inputData); diff --git a/devicesetup/src/main/java/io/particle/android/sdk/utils/SSID.java b/devicesetup/src/main/java/io/particle/android/sdk/utils/SSID.java index c1a12b3..3668c21 100644 --- a/devicesetup/src/main/java/io/particle/android/sdk/utils/SSID.java +++ b/devicesetup/src/main/java/io/particle/android/sdk/utils/SSID.java @@ -7,6 +7,8 @@ import android.os.Parcelable; import android.support.annotation.NonNull; +import java.util.Locale; + /** * Simple value wrapper for SSID strings. Eliminates case comparison issues and the quoting @@ -59,7 +61,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return ssidString.toLowerCase().hashCode(); + return ssidString.toLowerCase(Locale.ROOT).hashCode(); } @Override diff --git a/devicesetup/src/main/java/io/particle/android/sdk/utils/SoftAPConfigRemover.java b/devicesetup/src/main/java/io/particle/android/sdk/utils/SoftAPConfigRemover.java index 97a37ee..c9ee4d6 100644 --- a/devicesetup/src/main/java/io/particle/android/sdk/utils/SoftAPConfigRemover.java +++ b/devicesetup/src/main/java/io/particle/android/sdk/utils/SoftAPConfigRemover.java @@ -78,6 +78,6 @@ private void saveWithKey(String key, Set ssids) { Set asStrings = transformSet(ssids, SSID::toString); prefs.edit() .putStringSet(key, asStrings) - .commit(); + .apply(); } } diff --git a/devicesetup/src/main/res/layout/activity_connecting.xml b/devicesetup/src/main/res/layout/activity_connecting.xml index b3a308b..568de36 100644 --- a/devicesetup/src/main/res/layout/activity_connecting.xml +++ b/devicesetup/src/main/res/layout/activity_connecting.xml @@ -99,6 +99,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="left|center_vertical" + android:contentDescription="@null" android:src="@drawable/checkmark" android:visibility="gone"/> @@ -136,6 +137,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="left|center_vertical" + android:contentDescription="@null" android:src="@drawable/checkmark" android:visibility="gone" tools:ignore="DuplicateIds"/> @@ -174,6 +176,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="left|center_vertical" + android:contentDescription="@null" android:src="@drawable/checkmark" android:visibility="gone" tools:ignore="DuplicateIds"/> @@ -212,6 +215,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="left|center_vertical" + android:contentDescription="@null" android:src="@drawable/checkmark" android:visibility="gone" tools:ignore="DuplicateIds"/> @@ -250,6 +254,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="left|center_vertical" + android:contentDescription="@null" android:src="@drawable/checkmark" android:visibility="gone" tools:ignore="DuplicateIds"/> diff --git a/devicesetup/src/main/res/layout/activity_discover_device.xml b/devicesetup/src/main/res/layout/activity_discover_device.xml index aa3ee11..8ba27d1 100644 --- a/devicesetup/src/main/res/layout/activity_discover_device.xml +++ b/devicesetup/src/main/res/layout/activity_discover_device.xml @@ -24,6 +24,7 @@ android:layout_height="96dp" android:layout_marginBottom="4dp" android:layout_marginTop="8dp" + android:contentDescription="@null" android:src="@drawable/device_image_small"/> + tools:ignore="HardcodedText,Deprecated"/> + tools:ignore="HardcodedText,MissingPrefix,Deprecated"/> diff --git a/devicesetup/src/main/res/layout/brand_image_header.xml b/devicesetup/src/main/res/layout/brand_image_header.xml index 28076b0..a9dd8e9 100644 --- a/devicesetup/src/main/res/layout/brand_image_header.xml +++ b/devicesetup/src/main/res/layout/brand_image_header.xml @@ -2,10 +2,13 @@ + android:src="@drawable/brand_image_horizontal" + tools:ignore="Overdraw"/> diff --git a/devicesetup/src/main/res/layout/row_wifi_scan_result.xml b/devicesetup/src/main/res/layout/row_wifi_scan_result.xml index 414c4e2..65c3123 100644 --- a/devicesetup/src/main/res/layout/row_wifi_scan_result.xml +++ b/devicesetup/src/main/res/layout/row_wifi_scan_result.xml @@ -13,7 +13,10 @@ android:layout_gravity="center_vertical" android:layout_weight="1" android:gravity="center_vertical" + android:paddingEnd="0dp" android:paddingLeft="8dp" + android:paddingRight="0dp" + android:paddingStart="8dp" android:text="[SSID will go here]" android:textSize="@dimen/text_size_medium" tools:ignore="HardcodedText"/> @@ -22,17 +25,23 @@ android:id="@+id/wifi_security_indicator_icon" android:layout_width="24dp" android:layout_height="24dp" - android:layout_gravity="right|center_vertical" + android:layout_gravity="end|center_vertical" + android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:layout_marginTop="1dp" + android:contentDescription="@null" android:src="@drawable/lock"/> \ No newline at end of file diff --git a/devicesetup/src/main/res/values/themes.xml b/devicesetup/src/main/res/values/themes.xml index 2b0ae9e..da84e6f 100644 --- a/devicesetup/src/main/res/values/themes.xml +++ b/devicesetup/src/main/res/values/themes.xml @@ -1,5 +1,6 @@ - + - - - + +