mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-01-31 07:55:03 +01:00
adding a button at the dialpad for creating new contact from number
This commit is contained in:
parent
57f2ccf2f9
commit
282594c125
@ -1,12 +1,17 @@
|
||||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.KeyEvent
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.commons.helpers.isLollipopPlus
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.adapters.ContactsAdapter
|
||||
@ -14,6 +19,7 @@ import com.simplemobiletools.contacts.extensions.afterTextChanged
|
||||
import com.simplemobiletools.contacts.extensions.callContact
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.helpers.KEY_PHONE
|
||||
import com.simplemobiletools.contacts.helpers.LOCATION_DIALPAD
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
import kotlinx.android.synthetic.main.activity_dialpad.*
|
||||
@ -49,6 +55,32 @@ class DialpadActivity : SimpleActivity() {
|
||||
dialpad_clear_char.applyColorFilter(config.textColor)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_dialpad, menu)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.create_new_contact -> createNewContact()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun createNewContact() {
|
||||
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: String) {
|
||||
dialpad_input.dispatchKeyEvent(getKeyEvent(getCharKeyCode(char)))
|
||||
}
|
||||
|
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/create_new_contact"
|
||||
android:icon="@drawable/ic_plus"
|
||||
android:title="@string/create_new_contact_from_number"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Göstərmək üçün sahəni seç</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Sichtbare Felder auswählen</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Επιλογή εμφάνισης πεδίων</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Sélectionner les champs à afficher</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Odaberi polja za prikaz</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">表示する項目を選択</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Select fields to show</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Pasirinkti rodomus laukelius</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Selecione os campos a mostrar</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Выберите отображаемые поля</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Číselník</string>
|
||||
<string name="create_new_contact_from_number">Vytvoriť nový kontakt z čísla</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Zvoľte polia na zobrazenie</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Välj vilka fält som ska visas</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Görüntülenecek alanları seç</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">選擇要顯示的欄位</string>
|
||||
|
@ -97,6 +97,7 @@
|
||||
|
||||
<!-- Dialpad -->
|
||||
<string name="dialpad">Dialpad</string>
|
||||
<string name="create_new_contact_from_number">Create new contact from number</string>
|
||||
|
||||
<!-- Visible fields -->
|
||||
<string name="select_fields_to_show">Select fields to show</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user