adding a letters fastscroller at the dialpad

This commit is contained in:
tibbi 2020-05-10 23:07:09 +02:00
parent 5fc98ddaa3
commit a0d9596968
2 changed files with 45 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.dialer.activities
import android.annotation.TargetApi
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
@ -13,6 +14,7 @@ import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.View
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.REQUEST_CODE_SET_DEFAULT_DIALER
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
@ -29,6 +31,8 @@ import com.simplemobiletools.dialer.models.SpeedDial
import kotlinx.android.synthetic.main.activity_dialpad.*
import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder
import kotlinx.android.synthetic.main.dialpad.*
import java.util.*
import kotlin.collections.ArrayList
class DialpadActivity : SimpleActivity() {
private var contacts = ArrayList<SimpleContact>()
@ -78,6 +82,12 @@ class DialpadActivity : SimpleActivity() {
val callIcon = resources.getColoredDrawableWithColor(R.drawable.ic_phone_vector, if (isBlackAndWhiteTheme()) Color.BLACK else config.primaryColor.getContrastColor())
dialpad_call_button.setImageDrawable(callIcon)
dialpad_call_button.background.applyColorFilter(getAdjustedPrimaryColor())
letter_fastscroller.textColor = config.textColor.getColorStateList()
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
letter_fastscroller_thumb.textColor = config.primaryColor.getContrastColor()
dialpad_bottom_background.background = ColorDrawable(config.backgroundColor)
}
override fun onResume() {
@ -177,6 +187,16 @@ class DialpadActivity : SimpleActivity() {
!it.doesContainPhoneNumber(text)
}).toMutableList() as ArrayList<SimpleContact>
letter_fastscroller.setupWithRecyclerView(dialpad_list, { position ->
try {
val name = filtered[position].name
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
FastScrollItemIndicator.Text(character.toUpperCase(Locale.getDefault()))
} catch (e: Exception) {
FastScrollItemIndicator.Text("")
}
})
ContactsAdapter(this, filtered, dialpad_list, text) {
startCallIntent((it as SimpleContact).phoneNumber)
}.apply {

View File

@ -17,6 +17,23 @@
app:layout_constraintBottom_toTopOf="@+id/dialpad_input"
app:layout_constraintTop_toTopOf="parent" />
<com.reddit.indicatorfastscroll.FastScrollerView
android:id="@+id/letter_fastscroller"
android:layout_width="32dp"
android:layout_height="wrap_content"
android:gravity="top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/dialpad_list" />
<com.reddit.indicatorfastscroll.FastScrollerThumbView
android:id="@+id/letter_fastscroller_thumb"
android:layout_width="@dimen/fab_size"
android:layout_height="0dp"
android:layout_marginEnd="@dimen/activity_margin"
app:layout_constraintBottom_toBottomOf="@+id/dialpad_list"
app:layout_constraintEnd_toStartOf="@+id/letter_fastscroller"
app:layout_constraintTop_toTopOf="@+id/dialpad_list" />
<TextView
android:id="@+id/dialpad_divider"
android:layout_width="match_parent"
@ -24,6 +41,14 @@
android:background="@drawable/divider"
app:layout_constraintBottom_toTopOf="@+id/dialpad_input" />
<ImageView
android:id="@+id/dialpad_bottom_background"
android:layout_width="match_parent"
android:layout_height="0dp"
android:src="@color/theme_dark_background_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="@+id/dialpad_divider" />
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/dialpad_input"
android:layout_width="0dp"