diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a8324bf..77e570b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jan 8 01:52:21 CET 2018 +#Tue Sep 10 22:40:11 COT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip diff --git a/library/build.gradle b/library/build.gradle index 24868aa..a941fe1 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -26,6 +26,7 @@ android { dependencies { api fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.preference:preference:1.1.0' implementation 'com.google.android.material:material:1.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/library/src/main/java/com/github/javiersantos/piracychecker/utils/SaltUtils.kt b/library/src/main/java/com/github/javiersantos/piracychecker/utils/SaltUtils.kt index 8e0a3c7..dde338e 100644 --- a/library/src/main/java/com/github/javiersantos/piracychecker/utils/SaltUtils.kt +++ b/library/src/main/java/com/github/javiersantos/piracychecker/utils/SaltUtils.kt @@ -1,7 +1,7 @@ package com.github.javiersantos.piracychecker.utils import android.content.Context -import android.preference.PreferenceManager +import androidx.preference.PreferenceManager import java.util.Random /** @@ -16,10 +16,8 @@ internal object SaltUtils { val sb = StringBuilder() mSalt?.let { for (i in it.indices) { - if (i > 0) { - sb.append(" ") - } - sb.append(java.lang.Byte.toString(it[i])) + if (i > 0) sb.append(" ") + sb.append(it[i].toString()) } } return sb.toString() @@ -34,10 +32,8 @@ internal object SaltUtils { } } context ?: return - val saltStr = saltString PreferenceManager.getDefaultSharedPreferences(context) - .edit().putString(KEY_SALT, saltStr) - .apply() + .edit().putString(KEY_SALT, saltString).apply() } private fun bytesFromString(string: String): ByteArray { @@ -54,20 +50,15 @@ internal object SaltUtils { mSalt = context?.let { try { val prefs = PreferenceManager.getDefaultSharedPreferences(context) - if (prefs.contains( - KEY_SALT)) { - bytesFromString( - prefs.getString( - KEY_SALT, - null)) + if (prefs.contains(KEY_SALT)) { + val saltFromPrefs = prefs.getString(KEY_SALT, null) + saltFromPrefs?.let { bytesFromString(it) } } else null } catch (e: Exception) { null } } - if (mSalt == null) { - generateSalt(context) - } + if (mSalt == null) generateSalt(context) } return mSalt }