diff options
Diffstat (limited to 'app')
7 files changed, 26 insertions, 7 deletions
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" |