Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global: set an import order rule and reformat with it #924

Merged
merged 1 commit into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/src/main/java/com/zeapo/pwdstore/ClipboardService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class ClipboardService : Service() {
}

companion object {

private const val ACTION_CLEAR = "ACTION_CLEAR_CLIPBOARD"
const val ACTION_START = "ACTION_START_CLIPBOARD_TIMER"
private const val CHANNEL_ID = "NotificationService"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/zeapo/pwdstore/LaunchActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class LaunchActivity : AppCompatActivity() {
}

companion object {

const val ACTION_DECRYPT_PASS = "DECRYPT_PASS"
}
}
5 changes: 4 additions & 1 deletion app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ import com.zeapo.pwdstore.utils.PasswordItem
import com.zeapo.pwdstore.utils.PasswordRepository
import com.zeapo.pwdstore.utils.PreferenceKeys
import com.zeapo.pwdstore.utils.viewBinding
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.io.File
import me.zhanghai.android.fastscroll.FastScrollerBuilder

class PasswordFragment : Fragment(R.layout.password_recycler_view) {

private lateinit var recyclerAdapter: PasswordItemRecyclerAdapter
private lateinit var listener: OnFragmentInteractionListener
private lateinit var settings: SharedPreferences
Expand Down Expand Up @@ -280,6 +281,7 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
}

companion object {

const val ITEM_CREATION_REQUEST_KEY = "creation_key"
const val ACTION_KEY = "action"
const val ACTION_FOLDER = "folder"
Expand All @@ -301,6 +303,7 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
}

interface OnFragmentInteractionListener {

fun onFragmentInteraction(item: PasswordItem)
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ import com.zeapo.pwdstore.utils.contains
import com.zeapo.pwdstore.utils.isInsideRepository
import com.zeapo.pwdstore.utils.listFilesRecursively
import com.zeapo.pwdstore.utils.requestInputFocusOnView
import java.io.File
import java.lang.Character.UnicodeBlock
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.errors.GitAPIException
import org.eclipse.jgit.revwalk.RevCommit
import java.io.File
import java.lang.Character.UnicodeBlock

class PasswordStore : AppCompatActivity(R.layout.activity_pwdstore) {

Expand Down Expand Up @@ -904,6 +904,7 @@ class PasswordStore : AppCompatActivity(R.layout.activity_pwdstore) {
get() = getSortOrder(settings)

companion object {

const val REQUEST_ARG_PATH = "PATH"
const val CLONE_REPO_BUTTON = 401
const val NEW_REPO_BUTTON = 402
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import com.zeapo.pwdstore.autofill.oreo.DirectoryStructure
import com.zeapo.pwdstore.utils.PasswordItem
import com.zeapo.pwdstore.utils.PasswordRepository
import com.zeapo.pwdstore.utils.PreferenceKeys
import java.io.File
import java.text.Collator
import java.util.Locale
import java.util.Stack
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.FlowPreview
Expand All @@ -45,10 +49,6 @@ import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.yield
import me.zhanghai.android.fastscroll.PopupTextProvider
import java.io.File
import java.text.Collator
import java.util.Locale
import java.util.Stack

private fun File.toPasswordItem(root: File) = if (isFile)
PasswordItem.newPassword(name, this, root)
Expand Down Expand Up @@ -380,6 +380,7 @@ class SearchableRepositoryViewModel(application: Application) : AndroidViewModel
}

private object PasswordItemDiffCallback : DiffUtil.ItemCallback<PasswordItem>() {

override fun areItemsTheSame(oldItem: PasswordItem, newItem: PasswordItem) =
oldItem.file.absolutePath == newItem.file.absolutePath

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.zeapo.pwdstore.utils.PasswordRepository


class SelectFolderActivity : AppCompatActivity(R.layout.select_folder_layout) {

private lateinit var passwordList: SelectFolderFragment

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import com.zeapo.pwdstore.databinding.PasswordRecyclerViewBinding
import com.zeapo.pwdstore.ui.adapters.PasswordItemRecyclerAdapter
import com.zeapo.pwdstore.utils.PasswordItem
import com.zeapo.pwdstore.utils.viewBinding
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.io.File
import me.zhanghai.android.fastscroll.FastScrollerBuilder

class SelectFolderFragment : Fragment(R.layout.password_recycler_view) {

private val binding by viewBinding(PasswordRecyclerViewBinding::bind)
private lateinit var recyclerAdapter: PasswordItemRecyclerAdapter
private lateinit var listener: OnFragmentInteractionListener
Expand Down Expand Up @@ -70,6 +71,7 @@ class SelectFolderFragment : Fragment(R.layout.password_recycler_view) {
get() = model.currentDir.value!!

interface OnFragmentInteractionListener {

fun onFragmentInteraction(item: PasswordItem)
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ import com.zeapo.pwdstore.utils.PasswordRepository
import com.zeapo.pwdstore.utils.PreferenceKeys
import com.zeapo.pwdstore.utils.autofillManager
import com.zeapo.pwdstore.utils.getEncryptedPrefs
import me.msfjarvis.openpgpktx.util.OpenPgpUtils
import java.io.File
import java.io.IOException
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.Calendar
import java.util.HashSet
import java.util.TimeZone
import me.msfjarvis.openpgpktx.util.OpenPgpUtils

typealias ClickListener = Preference.OnPreferenceClickListener
typealias ChangeListener = Preference.OnPreferenceChangeListener
Expand All @@ -74,6 +74,7 @@ class UserPreference : AppCompatActivity() {
private lateinit var prefsFragment: PrefsFragment

class PrefsFragment : PreferenceFragmentCompat() {

private var autoFillEnablePreference: SwitchPreferenceCompat? = null
private var oreoAutofillChromeCompatFix: SwitchPreferenceCompat? = null
private var clearSavedPassPreference: Preference? = null
Expand Down Expand Up @@ -843,6 +844,7 @@ class UserPreference : AppCompatActivity() {
}

companion object {

private const val TAG = "UserPreference"

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class AutofillActivity : AppCompatActivity() {
}

companion object {

const val REQUEST_CODE_DECRYPT_AND_VERIFY = 9913
const val REQUEST_CODE_PICK = 777
const val REQUEST_CODE_PICK_MATCH_WITH = 778
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ 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

Expand Down Expand Up @@ -225,6 +226,7 @@ class AutofillFragment : DialogFragment() {
}

companion object {

private const val MATCH_WITH = 777
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.databinding.AutofillRecyclerViewBinding
import com.zeapo.pwdstore.utils.viewBinding
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import java.lang.ref.WeakReference
import java.util.ArrayList
import me.zhanghai.android.fastscroll.FastScrollerBuilder

class AutofillPreferenceActivity : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import androidx.recyclerview.widget.SortedList
import androidx.recyclerview.widget.SortedListAdapterCallback
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.utils.splitLines
import me.zhanghai.android.fastscroll.PopupTextProvider
import java.util.ArrayList
import java.util.Locale
import me.zhanghai.android.fastscroll.PopupTextProvider

internal class AutofillRecyclerAdapter(
allApps: List<AppInfo>,
Expand Down Expand Up @@ -161,6 +161,7 @@ internal class AutofillRecyclerAdapter(
}

internal inner class ViewHolder(var view: View) : RecyclerView.ViewHolder(view), View.OnClickListener {

var name: AppCompatTextView = view.findViewById(R.id.app_name)
var icon: AppCompatImageView = view.findViewById(R.id.app_icon)
var secondary: AppCompatTextView = view.findViewById(R.id.secondary_text)
Expand Down
22 changes: 13 additions & 9 deletions app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ import com.zeapo.pwdstore.model.PasswordEntry
import com.zeapo.pwdstore.utils.PasswordRepository
import com.zeapo.pwdstore.utils.PreferenceKeys
import com.zeapo.pwdstore.utils.splitLines
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import me.msfjarvis.openpgpktx.util.OpenPgpApi
import me.msfjarvis.openpgpktx.util.OpenPgpServiceConnection
import org.openintents.openpgp.IOpenPgpService2
import org.openintents.openpgp.OpenPgpError
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.IOException
Expand All @@ -53,8 +44,18 @@ import java.net.MalformedURLException
import java.net.URL
import java.util.ArrayList
import java.util.Locale
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import me.msfjarvis.openpgpktx.util.OpenPgpApi
import me.msfjarvis.openpgpktx.util.OpenPgpServiceConnection
import org.openintents.openpgp.IOpenPgpService2
import org.openintents.openpgp.OpenPgpError

class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope(Dispatchers.Default) {

private var serviceConnection: OpenPgpServiceConnection? = null
private var settings: SharedPreferences? = null
private var info: AccessibilityNodeInfo? = null // the original source of the event (the edittext field)
Expand Down Expand Up @@ -560,10 +561,12 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope
}

internal object Constants {

const val TAG = "Keychain"
}

private inner class OnBoundListener : OpenPgpServiceConnection.OnBound {

override fun onBound(service: IOpenPgpService2) {
decryptAndVerify()
}
Expand All @@ -574,6 +577,7 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope
}

companion object {

var instance: AutofillService? = null
private set
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ val AssistStructure.ViewNode.webOrigin: String?

data class Credentials(val username: String?, val password: String?, val otp: String?) {
companion object {

fun fromStoreEntry(
context: Context,
file: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AutofillPublisherChangedException(val formOrigin: FormOrigin) :
class AutofillMatcher {

companion object {

private const val MAX_NUM_MATCHES = 10

private const val PREFERENCE_PREFIX_TOKEN = "token;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ enum class DirectoryStructure(val value: String) {
}

companion object {

const val PREFERENCE = "oreo_autofill_directory_structure"
private val DEFAULT = FileBased

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum class AutofillAction {
sealed class AutofillScenario<out T : Any> {

companion object {

const val BUNDLE_KEY_USERNAME_ID = "usernameId"
const val BUNDLE_KEY_FILL_USERNAME = "fillUsername"
const val BUNDLE_KEY_OTP_ID = "otpId"
Expand Down Expand Up @@ -64,6 +65,7 @@ sealed class AutofillScenario<out T : Any> {
}

class Builder<T : Any> {

var username: T? = null
var fillUsername = false
var otp: T? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class AutofillRule private constructor(
) {

companion object {

private var ruleId = 1
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/zeapo/pwdstore/autofill/oreo/Form.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ sealed class FormOrigin(open val identifier: String) {
data class App(override val identifier: String) : FormOrigin(identifier)

companion object {

private const val BUNDLE_KEY_WEB_IDENTIFIER = "webIdentifier"
private const val BUNDLE_KEY_APP_IDENTIFIER = "appIdentifier"

Expand Down Expand Up @@ -74,6 +75,7 @@ sealed class FormOrigin(open val identifier: String) {
private class Form(context: Context, structure: AssistStructure, isManualRequest: Boolean) {

companion object {

private val SUPPORTED_SCHEMES = listOf("http", "https")
}

Expand Down Expand Up @@ -202,6 +204,7 @@ class FillableForm private constructor(
) {

companion object {

fun makeFillInDataset(
context: Context,
credentials: Credentials,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.zeapo.pwdstore.utils.hasFlag
class OreoAutofillService : AutofillService() {

companion object {

// TODO: Provide a user-configurable denylist
private val DENYLISTED_PACKAGES = listOf(
BuildConfig.APPLICATION_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlinx.coroutines.runBlocking
import mozilla.components.lib.publicsuffixlist.PublicSuffixList

private object PublicSuffixListCache {

private lateinit var publicSuffixList: PublicSuffixList

fun getOrCachePublicSuffixList(context: Context): PublicSuffixList {
Expand Down