freeotp / freeotp-android

Apache License 2.0
1.44k stars 303 forks source link

Simplify the code by method SharedPreferences#contains #310

Open simvesel opened 1 year ago

simvesel commented 1 year ago

Exists method SharedPreferences#contains: https://developer.android.com/reference/android/content/SharedPreferences#contains(java.lang.String)

Then you can simplify the code of the following functions: https://github.com/freeotp/freeotp-android/blob/67f1c1c2261adb67db1aee9f980f89c0194207ed/mobile/src/main/java/org/fedorahosted/freeotp/TokenPersistence.java#L79 https://github.com/freeotp/freeotp-android/blob/67f1c1c2261adb67db1aee9f980f89c0194207ed/mobile/src/main/java/org/fedorahosted/freeotp/TokenPersistence.java#L103-L110

In general it is incorrect compare String like as this: if (key == restore_uuid) {

justin-stephenson commented 1 year ago

Thank you for the recommendation, PRs are welcome.

simvesel commented 1 year ago

I'm sorry, but I don't have the Android SDK installed to change code and make unit tests.