diff options
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | app/build.gradle | 2 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt | 3 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt | 2 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt | 7 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt | 8 | ||||
-rw-r--r-- | app/src/main/res/layout/autofill_recycler_view.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/layout/password_recycler_view.xml | 2 | ||||
-rw-r--r-- | dependencies.gradle | 1 |
9 files changed, 30 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2244ab43..e8a033fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. ## Unreleased +### Added +- Fast scroller with alphabetic hints + ### Changed - Logging is now enabled in release builds diff --git a/app/build.gradle b/app/build.gradle index c73f9c13..fdc2347d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -90,7 +90,7 @@ dependencies { implementation deps.androidx.material implementation deps.third_party.commons_io implementation deps.third_party.commons_codec - + implementation deps.third_party.fastscroll implementation(deps.third_party.jgit) { exclude group: 'org.apache.httpcomponents', module: 'httpclient' } diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt index 279869bc..61437731 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt @@ -26,6 +26,7 @@ import com.zeapo.pwdstore.utils.PasswordRepository.PasswordSortOrder.Companion.g import java.io.File import java.util.Locale import java.util.Stack +import me.zhanghai.android.fastscroll.FastScrollerBuilder /** * A fragment representing a list of Items. @@ -67,6 +68,8 @@ class PasswordFragment : Fragment() { recyclerView.addItemDecoration(DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)) // Set the adapter recyclerView.adapter = recyclerAdapter + // Setup fast scroller + FastScrollerBuilder(recyclerView).build() val fab: FloatingActionButton = view.findViewById(R.id.fab) fab.setOnClickListener { (requireActivity() as PasswordStore).createPassword() } registerForContextMenu(recyclerView) 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 3fe5e9e7..5c49bf81 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt @@ -21,6 +21,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton import com.zeapo.pwdstore.R import java.lang.ref.WeakReference import java.util.ArrayList +import me.zhanghai.android.fastscroll.FastScrollerBuilder class AutofillPreferenceActivity : AppCompatActivity() { @@ -39,6 +40,7 @@ class AutofillPreferenceActivity : AppCompatActivity() { val layoutManager = LinearLayoutManager(this) recyclerView!!.layoutManager = layoutManager recyclerView!!.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL)) + FastScrollerBuilder(recyclerView!!).build() pm = packageManager 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 139f9582..47937a32 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillRecyclerAdapter.kt @@ -20,11 +20,12 @@ import com.zeapo.pwdstore.R import com.zeapo.pwdstore.utils.splitLines import java.util.ArrayList import java.util.Locale +import me.zhanghai.android.fastscroll.PopupTextProvider internal class AutofillRecyclerAdapter( allApps: List<AppInfo>, private val activity: AutofillPreferenceActivity -) : RecyclerView.Adapter<AutofillRecyclerAdapter.ViewHolder>() { +) : RecyclerView.Adapter<AutofillRecyclerAdapter.ViewHolder>(), PopupTextProvider { private val apps: SortedList<AppInfo> private val allApps: ArrayList<AppInfo> // for filtering, maintain a list of all @@ -56,6 +57,10 @@ internal class AutofillRecyclerAdapter( } } + override fun getPopupText(position: Int): String { + return allApps[position].appName[0].toString().toUpperCase(Locale.getDefault()) + } + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val v = LayoutInflater.from(parent.context) .inflate(R.layout.autofill_row_layout, parent, false) diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt index 6ddfa777..81aa4f05 100644 --- a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt +++ b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt @@ -19,9 +19,11 @@ import com.zeapo.pwdstore.utils.PasswordItem import com.zeapo.pwdstore.widget.MultiselectableConstraintLayout import java.io.File import java.util.ArrayList +import java.util.Locale import java.util.TreeSet +import me.zhanghai.android.fastscroll.PopupTextProvider -abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<PasswordItem>) : RecyclerView.Adapter<EntryRecyclerAdapter.ViewHolder>() { +abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<PasswordItem>) : RecyclerView.Adapter<EntryRecyclerAdapter.ViewHolder>(), PopupTextProvider { internal val selectedItems: MutableSet<Int> = TreeSet() internal var settings: SharedPreferences? = null @@ -30,6 +32,10 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P return values.size } + override fun getPopupText(position: Int): String { + return values[position].name[0].toString().toUpperCase(Locale.getDefault()) + } + fun clear() { this.values.clear() this.notifyDataSetChanged() diff --git a/app/src/main/res/layout/autofill_recycler_view.xml b/app/src/main/res/layout/autofill_recycler_view.xml index 7a987e5f..c3a4a9f3 100644 --- a/app/src/main/res/layout/autofill_recycler_view.xml +++ b/app/src/main/res/layout/autofill_recycler_view.xml @@ -1,14 +1,17 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto"> + android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/autofill_recycler" android:layout_width="match_parent" android:layout_height="match_parent" - android:scrollbars="vertical" /> + android:scrollbars="none" + tools:listitem="@layout/autofill_row_layout" + tools:itemCount="20"/> <ProgressBar android:id="@+id/progress_bar" diff --git a/app/src/main/res/layout/password_recycler_view.xml b/app/src/main/res/layout/password_recycler_view.xml index 69dc8867..07596335 100644 --- a/app/src/main/res/layout/password_recycler_view.xml +++ b/app/src/main/res/layout/password_recycler_view.xml @@ -9,7 +9,7 @@ <androidx.recyclerview.widget.RecyclerView android:id="@+id/pass_recycler" - android:scrollbars="vertical" + android:scrollbars="none" android:layout_width="match_parent" android:layout_height="match_parent" tools:listitem="@layout/password_row_layout" diff --git a/dependencies.gradle b/dependencies.gradle index 3a76707b..43847abe 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -38,6 +38,7 @@ ext.deps = [ third_party: [ commons_io: 'commons-io:commons-io:2.5', commons_codec: 'commons-codec:commons-codec:1.13', + fastscroll: 'me.zhanghai.android.fastscroll:library:1.1.0', jsch: 'com.jcraft:jsch:0.1.55', jgit: 'org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r', openpgp_ktx: 'com.github.android-password-store:openpgp-ktx:1.2.0', |