fix #288, add an option to show letters at dialpad
This commit is contained in:
parent
9adc9ff7bf
commit
8d12becafb
|
@ -7,6 +7,7 @@ import android.net.Uri
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Telephony.Sms.Intents.SECRET_CODE_ACTION
|
||||
import android.telephony.PhoneNumberUtils
|
||||
import android.telephony.TelephonyManager
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
|
@ -58,6 +59,11 @@ class DialpadActivity : SimpleActivity() {
|
|||
val callIcon = resources.getColoredDrawableWithColor(R.drawable.ic_phone_huge, if (isBlackAndWhiteTheme()) Color.BLACK else Color.WHITE)
|
||||
dialpad_call_button.setImageDrawable(callIcon)
|
||||
dialpad_call_button.background.applyColorFilter(getAdjustedPrimaryColor())
|
||||
|
||||
val showLetters = config.showDialpadLetters
|
||||
arrayOf(dialpad_2_letters, dialpad_3_letters, dialpad_4_letters, dialpad_5_letters, dialpad_6_letters, dialpad_7_letters, dialpad_8_letters, dialpad_9_letters).forEach {
|
||||
it.beVisibleIf(showLetters)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -159,8 +165,18 @@ class DialpadActivity : SimpleActivity() {
|
|||
return
|
||||
}
|
||||
|
||||
val showLetters = config.showDialpadLetters
|
||||
(dialpad_list.adapter as? ContactsAdapter)?.finishActMode()
|
||||
val filtered = contacts.filter { it.doesContainPhoneNumber(text) } as ArrayList<Contact>
|
||||
val filtered = contacts.filter {
|
||||
val convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.getNameToDisplay())
|
||||
it.doesContainPhoneNumber(text) || (showLetters && convertedName.contains(text, true))
|
||||
}.sortedWith(compareBy {
|
||||
if (showLetters) {
|
||||
!it.doesContainPhoneNumber(text)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}).toMutableList() as ArrayList<Contact>
|
||||
|
||||
ContactsAdapter(this, filtered, null, LOCATION_DIALPAD, null, dialpad_list, dialpad_fastscroller, text) {
|
||||
callContact(it as Contact)
|
||||
|
|
|
@ -42,6 +42,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupFilterDuplicates()
|
||||
setupShowCallConfirmation()
|
||||
setupShowDialpadButton()
|
||||
setupShowDialpadLetters()
|
||||
setupOnContactClick()
|
||||
updateTextColors(settings_holder)
|
||||
}
|
||||
|
@ -147,6 +148,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupShowDialpadLetters() {
|
||||
settings_show_dialpad_letters.isChecked = config.showDialpadLetters
|
||||
settings_show_dialpad_letters_holder.setOnClickListener {
|
||||
settings_show_dialpad_letters.toggle()
|
||||
config.showDialpadLetters = settings_show_dialpad_letters.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupOnContactClick() {
|
||||
settings_on_contact_click.text = getOnContactClickText()
|
||||
settings_on_contact_click_holder.setOnClickListener {
|
||||
|
|
|
@ -64,4 +64,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var showDialpadButton: Boolean
|
||||
get() = prefs.getBoolean(SHOW_DIALPAD_BUTTON, true)
|
||||
set(showDialpadButton) = prefs.edit().putBoolean(SHOW_DIALPAD_BUTTON, showDialpadButton).apply()
|
||||
|
||||
var showDialpadLetters: Boolean
|
||||
get() = prefs.getBoolean(SHOW_DIALPAD_LETTERS, false)
|
||||
set(showDialpadLetters) = prefs.edit().putBoolean(SHOW_DIALPAD_LETTERS, showDialpadLetters).apply()
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ const val SHOW_TABS = "show_tabs"
|
|||
const val FILTER_DUPLICATES = "filter_duplicates"
|
||||
const val SHOW_CALL_CONFIRMATION = "show_call_confirmation"
|
||||
const val SHOW_DIALPAD_BUTTON = "show_dialpad_button"
|
||||
const val SHOW_DIALPAD_LETTERS = "show_dialpad_letters"
|
||||
|
||||
const val CONTACT_ID = "contact_id"
|
||||
const val SMT_PRIVATE = "smt_private" // used at the contact source of local contacts hidden from other apps
|
||||
|
|
|
@ -90,6 +90,17 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_1"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_2_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ABC"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_5"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_3"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_1"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_3"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -102,6 +113,18 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_2"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_3_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:text="DEF"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_6"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_2"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_4"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -114,6 +137,18 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_4_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:text="GHI"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_7"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_5"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_5"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -125,6 +160,17 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_4"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_5_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="JKL"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_8"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_6"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_4"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_6"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -137,6 +183,18 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_5"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_6_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:text="MNO"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_9"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_5"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_7"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -149,6 +207,18 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_7_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:text="PQRS"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_asterisk"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_8"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_8"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -160,6 +230,17 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_7"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_8_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TUV"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_0_holder"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_9"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_7"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_9"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
@ -172,6 +253,18 @@
|
|||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_8"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_9_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:text="WXYZ"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_hashtag"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_8"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_asterisk"
|
||||
style="@style/DialpadNumberStyle"
|
||||
|
|
|
@ -340,6 +340,30 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_dialpad_letters_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_show_dialpad_letters"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:text="@string/show_dialpad_letters"
|
||||
app:switchPadding="@dimen/medium_margin"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_on_contact_click_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -4,10 +4,16 @@
|
|||
|
||||
<style name="DialpadNumberStyle">
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:paddingBottom">@dimen/medium_margin</item>
|
||||
<item name="android:paddingBottom">@dimen/normal_margin</item>
|
||||
<item name="android:paddingTop">@dimen/normal_margin</item>
|
||||
<item name="android:textSize">@dimen/dialpad_text_size</item>
|
||||
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
|
||||
</style>
|
||||
|
||||
<style name="DialpadLetterStyle">
|
||||
<item name="android:gravity">center_horizontal</item>
|
||||
<item name="android:textSize">@dimen/smaller_text_size</item>
|
||||
<item name="android:alpha">0.8</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue