mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-03-14 02:10:10 +01:00
copying some Dialpad related things from Contacts to this app
This commit is contained in:
parent
3a564542fc
commit
e5f0d3c6f1
@ -36,6 +36,6 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.27.18'
|
||||
implementation 'com.simplemobiletools:commons:5.27.20'
|
||||
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
||||
|
||||
@ -51,6 +52,25 @@
|
||||
android:label="@string/settings"
|
||||
android:parentActivityName=".activities.MainActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.DialpadActivity"
|
||||
android:label="@string/dialpad"
|
||||
android:parentActivityName=".activities.MainActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.DIAL" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:scheme="tel" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.DIAL" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity-alias
|
||||
android:name=".activities.SplashActivity.Red"
|
||||
android:enabled="false"
|
||||
@ -59,8 +79,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -72,8 +92,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -85,8 +105,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -98,8 +118,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -111,8 +131,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -124,8 +144,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -137,8 +157,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -150,8 +170,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -163,8 +183,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -176,8 +196,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -189,8 +209,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -202,8 +222,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -215,8 +235,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -228,8 +248,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -240,8 +260,8 @@
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -253,8 +273,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -266,8 +286,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -279,8 +299,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
|
||||
@ -292,8 +312,8 @@
|
||||
android:targetActivity=".activities.SplashActivity">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity-alias>
|
||||
</application>
|
||||
|
@ -0,0 +1,208 @@
|
||||
package com.simplemobiletools.dialer.activities
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
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
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.REQUEST_CODE_SET_DEFAULT_DIALER
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.dialer.extensions.addCharacter
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.extensions.getKeyEvent
|
||||
import com.simplemobiletools.dialer.extensions.startCallIntent
|
||||
import com.simplemobiletools.dialer.helpers.KEY_PHONE
|
||||
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.*
|
||||
|
||||
class DialpadActivity : SimpleActivity() {
|
||||
private var contacts = ArrayList<SimpleContact>()
|
||||
private var speedDialValues = ArrayList<SpeedDial>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_dialpad)
|
||||
|
||||
if (checkAppSideloading()) {
|
||||
return
|
||||
}
|
||||
|
||||
speedDialValues = config.getSpeedDialValues()
|
||||
|
||||
dialpad_0_holder.setOnClickListener { dialpadPressed('0', it) }
|
||||
dialpad_1.setOnClickListener { dialpadPressed('1', it) }
|
||||
dialpad_2.setOnClickListener { dialpadPressed('2', it) }
|
||||
dialpad_3.setOnClickListener { dialpadPressed('3', it) }
|
||||
dialpad_4.setOnClickListener { dialpadPressed('4', it) }
|
||||
dialpad_5.setOnClickListener { dialpadPressed('5', it) }
|
||||
dialpad_6.setOnClickListener { dialpadPressed('6', it) }
|
||||
dialpad_7.setOnClickListener { dialpadPressed('7', it) }
|
||||
dialpad_8.setOnClickListener { dialpadPressed('8', it) }
|
||||
dialpad_9.setOnClickListener { dialpadPressed('9', it) }
|
||||
|
||||
dialpad_1.setOnLongClickListener { speedDial(1); true }
|
||||
dialpad_2.setOnLongClickListener { speedDial(2); true }
|
||||
dialpad_3.setOnLongClickListener { speedDial(3); true }
|
||||
dialpad_4.setOnLongClickListener { speedDial(4); true }
|
||||
dialpad_5.setOnLongClickListener { speedDial(5); true }
|
||||
dialpad_6.setOnLongClickListener { speedDial(6); true }
|
||||
dialpad_7.setOnLongClickListener { speedDial(7); true }
|
||||
dialpad_8.setOnLongClickListener { speedDial(8); true }
|
||||
dialpad_9.setOnLongClickListener { speedDial(9); true }
|
||||
|
||||
dialpad_0_holder.setOnLongClickListener { dialpadPressed('+', null); true }
|
||||
dialpad_asterisk.setOnClickListener { dialpadPressed('*', it) }
|
||||
dialpad_hashtag.setOnClickListener { dialpadPressed('#', it) }
|
||||
dialpad_clear_char.setOnClickListener { clearChar(it) }
|
||||
dialpad_clear_char.setOnLongClickListener { clearInput(); true }
|
||||
dialpad_call_button.setOnClickListener { initCall() }
|
||||
dialpad_input.onTextChangeListener { dialpadValueChanged(it) }
|
||||
SimpleContactsHelper(this).getAvailableContacts { gotContacts(it) }
|
||||
disableKeyboardPopping()
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateTextColors(dialpad_holder)
|
||||
dialpad_clear_char.applyColorFilter(config.textColor)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_dialpad, menu)
|
||||
updateMenuItemColors(menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.add_number_to_contact -> addNumberToContact()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun checkDialIntent(): Boolean {
|
||||
return if (intent.action == Intent.ACTION_DIAL && intent.data != null && intent.dataString?.contains("tel:") == true) {
|
||||
val number = Uri.decode(intent.dataString).substringAfter("tel:")
|
||||
dialpad_input.setText(number)
|
||||
dialpad_input.setSelection(number.length)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun addNumberToContact() {
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_INSERT_OR_EDIT
|
||||
type = "vnd.android.cursor.item/contact"
|
||||
putExtra(KEY_PHONE, dialpad_input.value)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dialpadPressed(char: Char, view: View?) {
|
||||
dialpad_input.addCharacter(char)
|
||||
view?.performHapticFeedback()
|
||||
}
|
||||
|
||||
private fun clearChar(view: View) {
|
||||
dialpad_input.dispatchKeyEvent(dialpad_input.getKeyEvent(KeyEvent.KEYCODE_DEL))
|
||||
view.performHapticFeedback()
|
||||
}
|
||||
|
||||
private fun clearInput() {
|
||||
dialpad_input.setText("")
|
||||
}
|
||||
|
||||
private fun disableKeyboardPopping() {
|
||||
dialpad_input.showSoftInputOnFocus = false
|
||||
}
|
||||
|
||||
private fun gotContacts(newContacts: ArrayList<SimpleContact>) {
|
||||
contacts = newContacts
|
||||
if (!checkDialIntent() && dialpad_input.value.isEmpty()) {
|
||||
runOnUiThread {
|
||||
dialpadValueChanged("")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.O)
|
||||
private fun dialpadValueChanged(text: String) {
|
||||
val len = text.length
|
||||
if (len > 8 && text.startsWith("*#*#") && text.endsWith("#*#*")) {
|
||||
val secretCode = text.substring(4, text.length - 4)
|
||||
if (isOreoPlus()) {
|
||||
if (isDefaultDialer()) {
|
||||
getSystemService(TelephonyManager::class.java)?.sendDialerSpecialCode(secretCode)
|
||||
} else {
|
||||
launchSetDefaultDialerIntent()
|
||||
}
|
||||
} else {
|
||||
val intent = Intent(SECRET_CODE_ACTION, Uri.parse("android_secret_code://$secretCode"))
|
||||
sendBroadcast(intent)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
(dialpad_list.adapter as? ContactsAdapter)?.finishActMode()
|
||||
val filtered = contacts.filter {
|
||||
val convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.name.normalizeString())
|
||||
it.doesContainPhoneNumber(text) || (convertedName.contains(text, true))
|
||||
}.sortedWith(compareBy {
|
||||
!it.doesContainPhoneNumber(text)
|
||||
}).toMutableList() as ArrayList<SimpleContact>
|
||||
|
||||
ContactsAdapter(this, filtered, dialpad_list, text) {
|
||||
startCallIntent((it as SimpleContact).phoneNumber)
|
||||
}.apply {
|
||||
dialpad_list.adapter = this
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, resultData)
|
||||
if (requestCode == REQUEST_CODE_SET_DEFAULT_DIALER && isDefaultDialer()) {
|
||||
dialpadValueChanged(dialpad_input.value)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initCall(number: String = dialpad_input.value) {
|
||||
if (number.isNotEmpty()) {
|
||||
startCallIntent(number)
|
||||
}
|
||||
}
|
||||
|
||||
private fun speedDial(id: Int) {
|
||||
if (dialpad_input.value.isEmpty()) {
|
||||
val speedDial = speedDialValues.firstOrNull { it.id == id }
|
||||
if (speedDial?.isValid() == true) {
|
||||
initCall(speedDial.number)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,15 @@ class MainActivity : SimpleActivity() {
|
||||
checkContactPermissions()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val dialpadIcon = resources.getColoredDrawableWithColor(R.drawable.ic_dialpad_vector, getFABIconColor())
|
||||
main_dialpad_button.apply {
|
||||
setImageDrawable(dialpadIcon)
|
||||
background.applyColorFilter(getAdjustedPrimaryColor())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
config.lastUsedViewPagerPage = viewpager.currentItem
|
||||
@ -121,6 +130,12 @@ class MainActivity : SimpleActivity() {
|
||||
invalidateOptionsMenu()
|
||||
}, 100L)
|
||||
}
|
||||
|
||||
main_dialpad_button.setOnClickListener {
|
||||
Intent(applicationContext, DialpadActivity::class.java).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTabIcon(position: Int): Drawable {
|
||||
|
@ -7,6 +7,9 @@ import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.highlightTextFromNumbers
|
||||
import com.simplemobiletools.commons.extensions.highlightTextPart
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
@ -14,8 +17,11 @@ import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import java.util.*
|
||||
|
||||
class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||
class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleContact>, recyclerView: MyRecyclerView, highlightText: String = "",
|
||||
itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
|
||||
|
||||
private var textToHighlight = highlightText
|
||||
private var adjustedPrimaryColor = activity.getAdjustedPrimaryColor()
|
||||
|
||||
override fun getActionMenuId() = 0
|
||||
|
||||
@ -47,6 +53,19 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
|
||||
|
||||
override fun getItemCount() = contacts.size
|
||||
|
||||
fun updateItems(newItems: ArrayList<SimpleContact>, highlightText: String = "") {
|
||||
if (newItems.hashCode() != contacts.hashCode()) {
|
||||
contacts = newItems.clone() as ArrayList<SimpleContact>
|
||||
textToHighlight = highlightText
|
||||
notifyDataSetChanged()
|
||||
finishActMode()
|
||||
} else if (textToHighlight != highlightText) {
|
||||
textToHighlight = highlightText
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
fastScroller?.measureRecyclerView()
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
@ -56,8 +75,14 @@ class ContactsAdapter(activity: SimpleActivity, var contacts: ArrayList<SimpleCo
|
||||
|
||||
private fun setupView(view: View, contact: SimpleContact) {
|
||||
view.apply {
|
||||
findViewById<TextView>(R.id.item_contact_name).text = contact.name
|
||||
findViewById<TextView>(R.id.item_contact_name).setTextColor(textColor)
|
||||
findViewById<TextView>(R.id.item_contact_name).text = if (textToHighlight.isEmpty()) contact.name else {
|
||||
if (contact.name.contains(textToHighlight, true)) {
|
||||
contact.name.highlightTextPart(textToHighlight, adjustedPrimaryColor)
|
||||
} else {
|
||||
contact.name.highlightTextFromNumbers(textToHighlight, adjustedPrimaryColor)
|
||||
}
|
||||
}
|
||||
|
||||
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.name)
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.simplemobiletools.dialer.dialogs
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.telecom.PhoneAccountHandle
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.extensions.config
|
||||
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
|
||||
import kotlinx.android.synthetic.main.dialog_select_sim.view.*
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
class SelectSIMDialog(val activity: BaseSimpleActivity, val phoneNumber: String, val callback: (handle: PhoneAccountHandle) -> Unit) {
|
||||
private var dialog: AlertDialog? = null
|
||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, null)
|
||||
|
||||
init {
|
||||
val radioGroup = view.select_sim_radio_group
|
||||
|
||||
activity.getAvailableSIMCardLabels().forEachIndexed { index, SIMAccount ->
|
||||
val radioButton = (activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply {
|
||||
text = SIMAccount.label
|
||||
id = index
|
||||
setOnClickListener { selectedSIM(SIMAccount.handle, SIMAccount.label) }
|
||||
}
|
||||
radioGroup!!.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
||||
}
|
||||
|
||||
dialog = AlertDialog.Builder(activity)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this)
|
||||
}
|
||||
}
|
||||
|
||||
private fun selectedSIM(handle: PhoneAccountHandle, label: String) {
|
||||
if (view.select_sim_remember.isChecked) {
|
||||
activity.config.saveCustomSIM(phoneNumber, label)
|
||||
}
|
||||
|
||||
callback(handle)
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.simplemobiletools.dialer.extensions
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.telecom.PhoneAccount
|
||||
import android.telecom.PhoneAccountHandle
|
||||
import android.telecom.TelecomManager
|
||||
import com.simplemobiletools.commons.extensions.isDefaultDialer
|
||||
import com.simplemobiletools.commons.extensions.launchCallIntent
|
||||
import com.simplemobiletools.commons.extensions.telecomManager
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_PHONE_STATE
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.dialogs.SelectSIMDialog
|
||||
|
||||
fun SimpleActivity.startCallIntent(recipient: String) {
|
||||
if (isDefaultDialer()) {
|
||||
getHandleToUse(null, recipient) { handle ->
|
||||
launchCallIntent(recipient, handle)
|
||||
}
|
||||
} else {
|
||||
launchCallIntent(recipient, null)
|
||||
}
|
||||
}
|
||||
|
||||
// used at devices with multiple SIM cards
|
||||
@SuppressLint("MissingPermission")
|
||||
fun SimpleActivity.getHandleToUse(intent: Intent?, phoneNumber: String, callback: (PhoneAccountHandle) -> Unit) {
|
||||
handlePermission(PERMISSION_READ_PHONE_STATE) {
|
||||
if (it) {
|
||||
val defaultHandle = telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL)
|
||||
when {
|
||||
intent?.hasExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE) == true -> callback(intent.getParcelableExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)!!)
|
||||
config.getCustomSIM(phoneNumber)?.isNotEmpty() == true -> {
|
||||
val storedLabel = Uri.decode(config.getCustomSIM(phoneNumber))
|
||||
val availableSIMs = getAvailableSIMCardLabels()
|
||||
val firstornull = availableSIMs.firstOrNull { it.label == storedLabel }?.handle ?: availableSIMs.first().handle
|
||||
callback(firstornull)
|
||||
}
|
||||
defaultHandle != null -> callback(defaultHandle)
|
||||
else -> {
|
||||
SelectSIMDialog(this, phoneNumber) { handle ->
|
||||
callback(handle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,27 @@
|
||||
package com.simplemobiletools.dialer.extensions
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.simplemobiletools.commons.extensions.telecomManager
|
||||
import com.simplemobiletools.dialer.helpers.Config
|
||||
import com.simplemobiletools.dialer.models.SIMAccount
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
fun Context.getAvailableSIMCardLabels(): ArrayList<SIMAccount> {
|
||||
val SIMAccounts = ArrayList<SIMAccount>()
|
||||
telecomManager.callCapablePhoneAccounts.forEach { account ->
|
||||
val phoneAccount = telecomManager.getPhoneAccount(account)
|
||||
var label = phoneAccount.label.toString()
|
||||
var address = phoneAccount.address.toString()
|
||||
if (address.startsWith("tel:") && address.substringAfter("tel:").isNotEmpty()) {
|
||||
address = Uri.decode(address.substringAfter("tel:"))
|
||||
label += " ($address)"
|
||||
}
|
||||
val SIM = SIMAccount(phoneAccount.accountHandle, label)
|
||||
SIMAccounts.add(SIM)
|
||||
}
|
||||
return SIMAccounts
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.simplemobiletools.dialer.extensions
|
||||
|
||||
import android.view.KeyEvent
|
||||
import android.widget.EditText
|
||||
|
||||
fun EditText.addCharacter(char: Char) {
|
||||
dispatchKeyEvent(getKeyEvent(getCharKeyCode(char)))
|
||||
}
|
||||
|
||||
fun EditText.getKeyEvent(keyCode: Int) = KeyEvent(0, 0, KeyEvent.ACTION_DOWN, keyCode, 0)
|
||||
|
||||
private fun getCharKeyCode(char: Char) = when (char) {
|
||||
'0' -> KeyEvent.KEYCODE_0
|
||||
'1' -> KeyEvent.KEYCODE_1
|
||||
'2' -> KeyEvent.KEYCODE_2
|
||||
'3' -> KeyEvent.KEYCODE_3
|
||||
'4' -> KeyEvent.KEYCODE_4
|
||||
'5' -> KeyEvent.KEYCODE_5
|
||||
'6' -> KeyEvent.KEYCODE_6
|
||||
'7' -> KeyEvent.KEYCODE_7
|
||||
'8' -> KeyEvent.KEYCODE_8
|
||||
'9' -> KeyEvent.KEYCODE_9
|
||||
'*' -> KeyEvent.KEYCODE_STAR
|
||||
'+' -> KeyEvent.KEYCODE_PLUS
|
||||
else -> KeyEvent.KEYCODE_POUND
|
||||
}
|
@ -1,10 +1,38 @@
|
||||
package com.simplemobiletools.dialer.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||
import com.simplemobiletools.dialer.models.SpeedDial
|
||||
|
||||
class Config(context: Context) : BaseConfig(context) {
|
||||
companion object {
|
||||
fun newInstance(context: Context) = Config(context)
|
||||
}
|
||||
|
||||
var speedDial: String
|
||||
get() = prefs.getString(SPEED_DIAL, "")!!
|
||||
set(speedDial) = prefs.edit().putString(SPEED_DIAL, speedDial).apply()
|
||||
|
||||
fun getSpeedDialValues(): ArrayList<SpeedDial> {
|
||||
val speedDialType = object : TypeToken<List<SpeedDial>>() {}.type
|
||||
val speedDialValues = Gson().fromJson<ArrayList<SpeedDial>>(speedDial, speedDialType) ?: ArrayList(1)
|
||||
|
||||
for (i in 1..9) {
|
||||
val speedDial = SpeedDial(i, "", "")
|
||||
if (speedDialValues.firstOrNull { it.id == i } == null) {
|
||||
speedDialValues.add(speedDial)
|
||||
}
|
||||
}
|
||||
|
||||
return speedDialValues
|
||||
}
|
||||
|
||||
fun saveCustomSIM(number: String, SIMlabel: String) {
|
||||
prefs.edit().putString(REMEMBER_SIM_PREFIX + number, Uri.encode(SIMlabel)).apply()
|
||||
}
|
||||
|
||||
fun getCustomSIM(number: String) = prefs.getString(REMEMBER_SIM_PREFIX + number, "")
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package com.simplemobiletools.dialer.helpers
|
||||
|
||||
// shared prefs
|
||||
const val SPEED_DIAL = "speed_dial"
|
||||
const val REMEMBER_SIM_PREFIX = "remember_sim_"
|
||||
|
||||
const val CONTACTS_TAB_MASK = 1
|
||||
const val FAVORITES_TAB_MASK = 2
|
||||
const val RECENTS_TAB_MASK = 4
|
||||
const val ALL_TABS_MASK = CONTACTS_TAB_MASK or FAVORITES_TAB_MASK or RECENTS_TAB_MASK
|
||||
|
||||
val tabsList = arrayListOf(CONTACTS_TAB_MASK, RECENTS_TAB_MASK)
|
||||
|
||||
const val KEY_PHONE = "phone"
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.simplemobiletools.dialer.models
|
||||
|
||||
import android.telecom.PhoneAccountHandle
|
||||
|
||||
data class SIMAccount(val handle: PhoneAccountHandle, val label: String)
|
@ -0,0 +1,5 @@
|
||||
package com.simplemobiletools.dialer.models
|
||||
|
||||
data class SpeedDial(val id: Int, var number: String, var displayName: String) {
|
||||
fun isValid() = number.trim().isNotEmpty()
|
||||
}
|
9
app/src/main/res/drawable/ic_backspace_vector.xml
Normal file
9
app/src/main/res/drawable/ic_backspace_vector.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M22,3L7,3c-0.69,0 -1.23,0.35 -1.59,0.88L0,12l5.41,8.11c0.36,0.53 0.9,0.89 1.59,0.89h15c1.1,0 2,-0.9 2,-2L24,5c0,-1.1 -0.9,-2 -2,-2zM19,15.59L17.59,17 14,13.41 10.41,17 9,15.59 12.59,12 9,8.41 10.41,7 14,10.59 17.59,7 19,8.41 15.41,12 19,15.59z" />
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_dialpad_vector.xml
Normal file
9
app/src/main/res/drawable/ic_dialpad_vector.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,19c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM6,1c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM6,7c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM6,13c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,5c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,13c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,13c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,7c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,7c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,1c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
</vector>
|
73
app/src/main/res/layout/activity_dialpad.xml
Normal file
73
app/src/main/res/layout/activity_dialpad.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/dialpad_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:focusableInTouchMode="true">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/dialpad_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_input"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialpad_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@drawable/divider"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_input" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyEditText
|
||||
android:id="@+id/dialpad_input"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:gravity="center"
|
||||
android:inputType="phone"
|
||||
android:textCursorDrawable="@null"
|
||||
android:textSize="@dimen/dialpad_text_size"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_wrapper"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_clear_char"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialpad_clear_char"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:paddingStart="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:src="@drawable/ic_backspace_vector"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/dialpad_input"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/dialpad_input" />
|
||||
|
||||
<include
|
||||
android:id="@+id/dialpad_wrapper"
|
||||
layout="@layout/dialpad"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_call_button" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialpad_call_button"
|
||||
android:layout_width="@dimen/dialpad_button_size"
|
||||
android:layout_height="@dimen/dialpad_button_size"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:background="@drawable/circle_background"
|
||||
android:elevation="@dimen/medium_margin"
|
||||
android:padding="@dimen/normal_margin"
|
||||
android:src="@drawable/ic_phone_vector"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -20,4 +20,16 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/main_tabs_holder" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/main_dialpad_button"
|
||||
android:layout_width="@dimen/dialpad_button_size"
|
||||
android:layout_height="@dimen/dialpad_button_size"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:background="@drawable/circle_background"
|
||||
android:elevation="@dimen/medium_margin"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:src="@drawable/ic_dialpad_vector" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
35
app/src/main/res/layout/dialog_select_sim.xml
Normal file
35
app/src/main/res/layout/dialog_select_sim.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/select_sim_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/select_sim_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/small_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/select_sim"
|
||||
android:textSize="@dimen/normal_text_size" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/select_sim_radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/small_margin" />
|
||||
|
||||
<include layout="@layout/divider" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/select_sim_remember"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/always_use_this_sim" />
|
||||
|
||||
</LinearLayout>
|
269
app/src/main/res/layout/dialpad.xml
Normal file
269
app/src/main/res/layout/dialpad.xml
Normal file
@ -0,0 +1,269 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/dialpad_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_1"
|
||||
style="@style/DialpadNumberStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:text="1"
|
||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_4"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_2"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_2"
|
||||
style="@style/DialpadNumberStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2"
|
||||
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_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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:text="3"
|
||||
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_3_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:text="4"
|
||||
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_4_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="5"
|
||||
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_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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:text="6"
|
||||
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_6_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:text="7"
|
||||
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_7_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="8"
|
||||
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_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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:text="9"
|
||||
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_9_letters"
|
||||
style="@style/DialpadLetterStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@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"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:text="*"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_0_holder"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/dialpad_7" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/dialpad_0_holder"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
app:layout_constraintEnd_toStartOf="@+id/dialpad_hashtag"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_asterisk"
|
||||
app:layout_constraintTop_toTopOf="@+id/dialpad_asterisk">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_0"
|
||||
style="@style/DialpadNumberStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="0" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_plus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/dialpad_0"
|
||||
android:layout_alignBottom="@+id/dialpad_0"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_toEndOf="@+id/dialpad_0"
|
||||
android:gravity="center"
|
||||
android:paddingStart="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:text="+"
|
||||
android:textSize="@dimen/actionbar_text_size" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialpad_hashtag"
|
||||
style="@style/DialpadNumberStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:text="#"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/dialpad_0_holder"
|
||||
app:layout_constraintTop_toTopOf="@+id/dialpad_0_holder" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
9
app/src/main/res/menu/menu_dialpad.xml
Normal file
9
app/src/main/res/menu/menu_dialpad.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/add_number_to_contact"
|
||||
android:icon="@drawable/ic_plus_vector"
|
||||
android:title="@string/add_number_to_contact"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
6
app/src/main/res/values/dimens.xml
Normal file
6
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="dialpad_button_size">60dp</dimen>
|
||||
|
||||
<dimen name="dialpad_text_size">34sp</dimen>
|
||||
</resources>
|
@ -9,4 +9,22 @@
|
||||
<string name="no_previous_calls">No previous calls have been found</string>
|
||||
<string name="could_not_access_the_call_history">Could not access the call history</string>
|
||||
<string name="request_access">Request access</string>
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="add_number_to_contact">Add number to contact</string>
|
||||
|
||||
<!-- Dialer -->
|
||||
<string name="dialer">Dialer</string>
|
||||
<string name="accept">Accept</string>
|
||||
<string name="decline">Decline</string>
|
||||
<string name="unknown_caller">Unknown Caller</string>
|
||||
<string name="is_calling">Is Calling…</string>
|
||||
<string name="dialing">Dialing…</string>
|
||||
<string name="call_ended">Call Ended</string>
|
||||
<string name="call_ending">Call Ending</string>
|
||||
<string name="ongoing_call">Ongoing Call</string>
|
||||
<string name="select_sim">Select a SIM for this call</string>
|
||||
<string name="always_use_this_sim">Always use this SIM for this number</string>
|
||||
|
||||
</resources>
|
||||
|
@ -2,4 +2,18 @@
|
||||
|
||||
<style name="AppTheme" parent="AppTheme.Base" />
|
||||
|
||||
<style name="DialpadNumberStyle">
|
||||
<item name="android:gravity">center</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…
x
Reference in New Issue
Block a user