diff options
Diffstat (limited to 'app/src/main/java')
4 files changed, 18 insertions, 2 deletions
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() |