diff options
| author | Harsh Shandilya <msfjarvis@gmail.com> | 2019-10-02 18:04:18 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-02 18:04:18 +0530 |
| commit | f1f59dc1ed26c2351dc31e55902ff8e4b5a6ed0e (patch) | |
| tree | 2afb98c921714ccefcd22f35a7340584d1bfba53 /app/src/main/java/com/zeapo/pwdstore/autofill | |
| parent | 9a1a54a6fcfa6fd6cf142f2af9804375255d14cf (diff) | |
| download | HardenedPass-f1f59dc1ed26c2351dc31e55902ff8e4b5a6ed0e.tar.gz HardenedPass-f1f59dc1ed26c2351dc31e55902ff8e4b5a6ed0e.zip | |
Add Spotless to regulate codestyle (#550)
* Add Spotless to regulate codestyle
* treewide: Run spotless
* Add spotlessCheck to CI test
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill')
5 files changed, 21 insertions, 29 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 48b72c38..c37e253a 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillActivity.kt @@ -28,7 +28,6 @@ class AutofillActivity : AppCompatActivity() { } catch (e: IntentSender.SendIntentException) { Log.e(AutofillService.Constants.TAG, "SendIntentException", e) } - } else if (extras != null && extras.containsKey("pick")) { val intent = Intent(applicationContext, PasswordStore::class.java) intent.putExtra("matchWith", true) @@ -41,10 +40,10 @@ class AutofillActivity : AppCompatActivity() { } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - finish() // go back to the password field app + finish() // go back to the password field app when (requestCode) { REQUEST_CODE_DECRYPT_AND_VERIFY -> if (resultCode == RESULT_OK) { - AutofillService.instance?.setResultData(data!!) // report the result to service + AutofillService.instance?.setResultData(data!!) // report the result to service } REQUEST_CODE_PICK -> if (resultCode == RESULT_OK) { AutofillService.instance?.setPickedPassword(data!!.getStringExtra("path")) diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt index 04b8d7ef..55a84d19 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.kt @@ -26,7 +26,6 @@ import com.zeapo.pwdstore.R import com.zeapo.pwdstore.utils.resolveAttribute import com.zeapo.pwdstore.utils.splitLines - class AutofillFragment : DialogFragment() { private var adapter: ArrayAdapter<String>? = null private var isWeb: Boolean = false @@ -116,8 +115,8 @@ class AutofillFragment : DialogFragment() { val editor = prefs.edit() if (isWeb) { builder.setNeutralButton(R.string.autofill_apps_delete) { _, _ -> - if (callingActivity.recyclerAdapter != null - && packageName != null && packageName != "") { + if (callingActivity.recyclerAdapter != null && + packageName != null && packageName != "") { editor.remove(packageName) callingActivity.recyclerAdapter?.removeWebsite(packageName) editor.apply() diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt index 43f2f33f..cb647c04 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt @@ -136,7 +136,6 @@ class AutofillPreferenceActivity : AppCompatActivity() { } catch (e: PackageManager.NameNotFoundException) { allApps.add(AutofillRecyclerAdapter.AppInfo(key, key, true, null)) } - } weakReference.get()?.recyclerAdapter = AutofillRecyclerAdapter(allApps, weakReference.get()!!) return null diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt index 7cd7fcb7..6ebd0977 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt @@ -18,8 +18,8 @@ import java.util.ArrayList import java.util.Locale internal class AutofillRecyclerAdapter( - allApps: List<AppInfo>, - private val activity: AutofillPreferenceActivity + allApps: List<AppInfo>, + private val activity: AutofillPreferenceActivity ) : RecyclerView.Adapter<AutofillRecyclerAdapter.ViewHolder>() { private val apps: SortedList<AppInfo> @@ -86,8 +86,8 @@ internal class AutofillRecyclerAdapter( holder.secondary.setText(R.string.autofill_apps_match) holder.secondary.append(" " + preference!!.splitLines()[0]) if (preference.trim { it <= ' ' }.splitLines().size - 1 > 0) { - holder.secondary.append(" and " - + (preference.trim { it <= ' ' }.splitLines().size - 1) + " more") + holder.secondary.append(" and " + + (preference.trim { it <= ' ' }.splitLines().size - 1) + " more") } } } @@ -164,6 +164,5 @@ internal class AutofillRecyclerAdapter( override fun onClick(v: View) { activity.showDialog(packageName, appName, isWeb) } - } } diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt index d9f42b00..796b4518 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt @@ -85,17 +85,17 @@ class AutofillService : AccessibilityService() { } // if returning to the source app from a successful AutofillActivity - if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED - && event.packageName != null && event.packageName == packageName - && resultData != null) { + if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED && + event.packageName != null && event.packageName == packageName && + resultData != null) { bindDecryptAndVerify() } // look for webView and trigger accessibility events if window changes // or if page changes in chrome - if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || (event.eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED - && event.packageName != null - && (event.packageName == "com.android.chrome" || event.packageName == "com.android.browser"))) { + if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || (event.eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED && + event.packageName != null && + (event.packageName == "com.android.chrome" || event.packageName == "com.android.browser"))) { // there is a chance for getRootInActiveWindow() to return null at any time. save it. try { val root = rootInActiveWindow @@ -116,23 +116,20 @@ class AutofillService : AccessibilityService() { webViewURL = URL("http://" + node.text.toString()).host } catch (ignored: MalformedURLException) { } - } } - } } } catch (e: Exception) { // sadly we were unable to access the data we wanted return } - } // nothing to do if field is keychain app or system ui - if (event.eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED - || event.packageName != null && event.packageName == "org.sufficientlysecure.keychain" - || event.packageName != null && event.packageName == "com.android.systemui") { + if (event.eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || + event.packageName != null && event.packageName == "org.sufficientlysecure.keychain" || + event.packageName != null && event.packageName == "com.android.systemui") { dismissDialog(event) return } @@ -281,8 +278,8 @@ class AutofillService : AccessibilityService() { // means use default, so ignore it. val value = prefs.getString(key, null) val keyLowerCase = key.toLowerCase(Locale.ROOT) - if (value != null && value != "" - && (webViewUrlLowerCase.contains(keyLowerCase) || keyLowerCase.contains(webViewUrlLowerCase))) { + if (value != null && value != "" && + (webViewUrlLowerCase.contains(keyLowerCase) || keyLowerCase.contains(webViewUrlLowerCase))) { preference = value settingsURL = key } @@ -397,7 +394,7 @@ class AutofillService : AccessibilityService() { dialog = null } builder.setNeutralButton("Settings") { _, _ -> - //TODO make icon? gear? + // TODO make icon? gear? // the user will have to return to the app themselves. val intent = Intent(this@AutofillService, AutofillPreferenceActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) @@ -426,7 +423,7 @@ class AutofillService : AccessibilityService() { startActivity(intent) } else -> { - lastWhichItem-- // will add one element to items, so lastWhichItem=items.size()+1 + lastWhichItem-- // will add one element to items, so lastWhichItem=items.size()+1 val intent = Intent(this@AutofillService, AutofillActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK) intent.putExtra("pickMatchWith", true) @@ -512,7 +509,6 @@ class AutofillService : AccessibilityService() { } catch (e: UnsupportedEncodingException) { Log.e(Constants.TAG, "UnsupportedEncodingException", e) } - } OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED -> { Log.i("PgpHandler", "RESULT_CODE_USER_INTERACTION_REQUIRED") |
