diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2020-04-21 13:11:27 +0530 |
|---|---|---|
| committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-04-21 15:55:25 +0530 |
| commit | d505151662da1c9a9d9ce5434db2a370d4167e36 (patch) | |
| tree | e0a3fdafc56c07dba5980ae92b1a76477992f97b /app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt | |
| parent | e1921b26e0fdc9d4fdb9df2f31278aba051edf0f (diff) | |
| download | HardenedPass-d505151662da1c9a9d9ce5434db2a370d4167e36.tar.gz HardenedPass-d505151662da1c9a9d9ce5434db2a370d4167e36.zip | |
treewide: use edit extension and cleanup some deprecation
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt index c3186db5..bd22f4a4 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt @@ -11,10 +11,9 @@ import android.content.IntentSender import android.content.SharedPreferences import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.edit import com.zeapo.pwdstore.PasswordStore import com.zeapo.pwdstore.utils.splitLines -import java.util.ArrayList -import java.util.Arrays import org.eclipse.jgit.util.StringUtils import timber.log.Timber @@ -71,17 +70,17 @@ class AutofillActivity : AppCompatActivity() { } else { applicationContext.getSharedPreferences("autofill_web", Context.MODE_PRIVATE) } - val editor = prefs.edit() - when (val preference = prefs.getString(packageName, "")) { - "", "/first", "/never" -> editor.putString(packageName, path) - else -> { - val matches = ArrayList(Arrays.asList(*preference!!.trim { it <= ' ' }.splitLines())) - matches.add(path) - val paths = StringUtils.join(matches, "\n") - editor.putString(packageName, paths) + prefs.edit { + when (val preference = prefs.getString(packageName, "")) { + "", "/first", "/never" -> putString(packageName, path) + else -> { + val matches = arrayListOf(*preference!!.trim { it <= ' ' }.splitLines()) + matches.add(path) + val paths = StringUtils.join(matches, "\n") + putString(packageName, paths) + } } } - editor.apply() } } super.onActivityResult(requestCode, resultCode, data) |
