Add fastscroller with alphabetic hints (#616)
* Setup basic fast scroll Work towards #558 * Implement PopupTextProvider Fixes #558 * Update changes * Hide system scrollbars * Port fastscroll to autofill preferences * Spotless Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
052467518e
commit
27e1952375
9 changed files with 30 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue