mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-02-15 11:00:38 +01:00
adding a letters fastscroller at the dialpad
This commit is contained in:
parent
5fc98ddaa3
commit
a0d9596968
@ -3,6 +3,7 @@ package com.simplemobiletools.dialer.activities
|
|||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -13,6 +14,7 @@ import android.view.KeyEvent
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.REQUEST_CODE_SET_DEFAULT_DIALER
|
import com.simplemobiletools.commons.helpers.REQUEST_CODE_SET_DEFAULT_DIALER
|
||||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
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.*
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder
|
import kotlinx.android.synthetic.main.activity_dialpad.dialpad_holder
|
||||||
import kotlinx.android.synthetic.main.dialpad.*
|
import kotlinx.android.synthetic.main.dialpad.*
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class DialpadActivity : SimpleActivity() {
|
class DialpadActivity : SimpleActivity() {
|
||||||
private var contacts = ArrayList<SimpleContact>()
|
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())
|
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.setImageDrawable(callIcon)
|
||||||
dialpad_call_button.background.applyColorFilter(getAdjustedPrimaryColor())
|
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() {
|
override fun onResume() {
|
||||||
@ -177,6 +187,16 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
!it.doesContainPhoneNumber(text)
|
!it.doesContainPhoneNumber(text)
|
||||||
}).toMutableList() as ArrayList<SimpleContact>
|
}).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) {
|
ContactsAdapter(this, filtered, dialpad_list, text) {
|
||||||
startCallIntent((it as SimpleContact).phoneNumber)
|
startCallIntent((it as SimpleContact).phoneNumber)
|
||||||
}.apply {
|
}.apply {
|
||||||
|
@ -17,6 +17,23 @@
|
|||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_input"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_input"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
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
|
<TextView
|
||||||
android:id="@+id/dialpad_divider"
|
android:id="@+id/dialpad_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -24,6 +41,14 @@
|
|||||||
android:background="@drawable/divider"
|
android:background="@drawable/divider"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_input" />
|
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
|
<com.simplemobiletools.commons.views.MyEditText
|
||||||
android:id="@+id/dialpad_input"
|
android:id="@+id/dialpad_input"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user