implement the "Create new contact" button on the insert_or_Edit screen

This commit is contained in:
tibbi 2018-09-26 12:13:05 +02:00
parent e429b140e4
commit 5d8d0dd7b0
22 changed files with 85 additions and 1 deletions

View File

@ -1,18 +1,43 @@
package com.simplemobiletools.contacts.activities package com.simplemobiletools.contacts.activities
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.provider.ContactsContract
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.helpers.KEY_PHONE
import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
class InsertOrEditContactActivity : ContactActivity() { class InsertOrEditContactActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_insert_edit_contact) setContentView(R.layout.activity_insert_edit_contact)
title = getString(R.string.select_contact) title = getString(R.string.select_contact)
updateTextColors(insert_edit_contact_holder)
handlePermission(PERMISSION_READ_CONTACTS) { handlePermission(PERMISSION_READ_CONTACTS) {
// we do not really care about the permission request result. Even if it was denied, load private contacts // we do not really care about the permission request result. Even if it was denied, load private contacts
setupViews()
}
}
private fun setupViews() {
new_contact_tmb.setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_new_contact, config.textColor))
new_contact_holder.setOnClickListener {
Intent().apply {
action = Intent.ACTION_INSERT
data = ContactsContract.Contacts.CONTENT_URI
putExtra(KEY_PHONE, intent.getStringExtra(KEY_PHONE))
if (resolveActivity(packageManager) != null) {
startActivity(this)
} else {
toast(R.string.no_app_found)
}
}
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

View File

@ -5,4 +5,32 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/new_contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingRight="@dimen/activity_margin">
<ImageView
android:id="@+id/new_contact_tmb"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_alignTop="@+id/new_contact_name"
android:layout_alignBottom="@+id/new_contact_name"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_new_contact"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/new_contact_name"
android:layout_width="match_parent"
android:layout_height="@dimen/create_new_contact_height"
android:layout_toRightOf="@+id/new_contact_tmb"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/create_new_contact"
android:textSize="@dimen/big_text_size"/>
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Grupa e-poçt göndər</string> <string name="send_email_to_group">Grupa e-poçt göndər</string>
<string name="call_person">%s şəxsinə zng et</string> <string name="call_person">%s şəxsinə zng et</string>
<string name="request_the_required_permissions">Lazım olan icazələri istə</string> <string name="request_the_required_permissions">Lazım olan icazələri istə</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Yeni kontakt</string> <string name="new_contact">Yeni kontakt</string>
<string name="edit_contact">Redaktə et</string> <string name="edit_contact">Redaktə et</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Sende E-Mail an Gruppe</string> <string name="send_email_to_group">Sende E-Mail an Gruppe</string>
<string name="call_person">%s anrufen</string> <string name="call_person">%s anrufen</string>
<string name="request_the_required_permissions">Benötigte Berechtigungen anfordern</string> <string name="request_the_required_permissions">Benötigte Berechtigungen anfordern</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Neuer Kontakt</string> <string name="new_contact">Neuer Kontakt</string>
<string name="edit_contact">Kontakt bearbeiten</string> <string name="edit_contact">Kontakt bearbeiten</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Αποστολή email σε ομάδες</string> <string name="send_email_to_group">Αποστολή email σε ομάδες</string>
<string name="call_person">Κλήση %s</string> <string name="call_person">Κλήση %s</string>
<string name="request_the_required_permissions">Ζητούνται τα απαιτούμενα δικαιώματα</string> <string name="request_the_required_permissions">Ζητούνται τα απαιτούμενα δικαιώματα</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Νέα επαφή</string> <string name="new_contact">Νέα επαφή</string>
<string name="edit_contact">Επεξεργασία επαφής</string> <string name="edit_contact">Επεξεργασία επαφής</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Envoyer un e-mail au groupe</string> <string name="send_email_to_group">Envoyer un e-mail au groupe</string>
<string name="call_person">Call %s</string> <string name="call_person">Call %s</string>
<string name="request_the_required_permissions">Demander les autorisations requises</string> <string name="request_the_required_permissions">Demander les autorisations requises</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Nouveau contact</string> <string name="new_contact">Nouveau contact</string>
<string name="edit_contact">Modifier contact</string> <string name="edit_contact">Modifier contact</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Pošalji e-poštu grupi</string> <string name="send_email_to_group">Pošalji e-poštu grupi</string>
<string name="call_person">Nazovi %s</string> <string name="call_person">Nazovi %s</string>
<string name="request_the_required_permissions">Zatraži potrebna dopuštenja</string> <string name="request_the_required_permissions">Zatraži potrebna dopuštenja</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Novi kontakt</string> <string name="new_contact">Novi kontakt</string>
<string name="edit_contact">Uredi kontakt</string> <string name="edit_contact">Uredi kontakt</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">グループにメールを送信</string> <string name="send_email_to_group">グループにメールを送信</string>
<string name="call_person">Call %s</string> <string name="call_person">Call %s</string>
<string name="request_the_required_permissions">Request the required permissions</string> <string name="request_the_required_permissions">Request the required permissions</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">新しい連絡先</string> <string name="new_contact">新しい連絡先</string>
<string name="edit_contact">連絡先を編集</string> <string name="edit_contact">連絡先を編集</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Send email to group</string> <string name="send_email_to_group">Send email to group</string>
<string name="call_person">Call %s</string> <string name="call_person">Call %s</string>
<string name="request_the_required_permissions">Request the required permissions</string> <string name="request_the_required_permissions">Request the required permissions</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">새로운 연락처</string> <string name="new_contact">새로운 연락처</string>
<string name="edit_contact">연락처 수정</string> <string name="edit_contact">연락처 수정</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Send email to group</string> <string name="send_email_to_group">Send email to group</string>
<string name="call_person">Call %s</string> <string name="call_person">Call %s</string>
<string name="request_the_required_permissions">Request the required permissions</string> <string name="request_the_required_permissions">Request the required permissions</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Naujas kontaktas</string> <string name="new_contact">Naujas kontaktas</string>
<string name="edit_contact">Redaguoti kontaktą</string> <string name="edit_contact">Redaguoti kontaktą</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Enviar e-mail para o grupo</string> <string name="send_email_to_group">Enviar e-mail para o grupo</string>
<string name="call_person">Ligar a %s</string> <string name="call_person">Ligar a %s</string>
<string name="request_the_required_permissions">Pedir a permissão necessária</string> <string name="request_the_required_permissions">Pedir a permissão necessária</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Novo contacto</string> <string name="new_contact">Novo contacto</string>
<string name="edit_contact">Editar contacto</string> <string name="edit_contact">Editar contacto</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Отправить письмо группе</string> <string name="send_email_to_group">Отправить письмо группе</string>
<string name="call_person">Вызов %s</string> <string name="call_person">Вызов %s</string>
<string name="request_the_required_permissions">Запрос необходимых разрешений</string> <string name="request_the_required_permissions">Запрос необходимых разрешений</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Новый контакт</string> <string name="new_contact">Новый контакт</string>
<string name="edit_contact">Редактировать контакт</string> <string name="edit_contact">Редактировать контакт</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Poslať skupine email</string> <string name="send_email_to_group">Poslať skupine email</string>
<string name="call_person">Zavolať %s</string> <string name="call_person">Zavolať %s</string>
<string name="request_the_required_permissions">Vyžiadať potrebné oprávnenia</string> <string name="request_the_required_permissions">Vyžiadať potrebné oprávnenia</string>
<string name="create_new_contact">Vytvoriť nový kontakt</string>
<string name="add_to_existing_contact">Pridať k existujúcemu kontaktu</string>
<string name="new_contact">Nový kontakt</string> <string name="new_contact">Nový kontakt</string>
<string name="edit_contact">Upraviť kontakt</string> <string name="edit_contact">Upraviť kontakt</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Skicka e-post till grupp</string> <string name="send_email_to_group">Skicka e-post till grupp</string>
<string name="call_person">Ring %s</string> <string name="call_person">Ring %s</string>
<string name="request_the_required_permissions">Begär de behörigheter som krävs</string> <string name="request_the_required_permissions">Begär de behörigheter som krävs</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Ny kontakt</string> <string name="new_contact">Ny kontakt</string>
<string name="edit_contact">Redigera kontakt</string> <string name="edit_contact">Redigera kontakt</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Gruba e-posta gönder</string> <string name="send_email_to_group">Gruba e-posta gönder</string>
<string name="call_person">Call %s</string> <string name="call_person">Call %s</string>
<string name="request_the_required_permissions">Request the required permissions</string> <string name="request_the_required_permissions">Request the required permissions</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">Yeni kişi</string> <string name="new_contact">Yeni kişi</string>
<string name="edit_contact">Kişiyi düzenle</string> <string name="edit_contact">Kişiyi düzenle</string>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">發送電子郵件給群組</string> <string name="send_email_to_group">發送電子郵件給群組</string>
<string name="call_person">打電話給 %s</string> <string name="call_person">打電話給 %s</string>
<string name="request_the_required_permissions">請求必要的權限</string> <string name="request_the_required_permissions">請求必要的權限</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">新聯絡人</string> <string name="new_contact">新聯絡人</string>
<string name="edit_contact">編輯聯絡人</string> <string name="edit_contact">編輯聯絡人</string>

View File

@ -4,6 +4,7 @@
<dimen name="contact_actions_size">45dp</dimen> <dimen name="contact_actions_size">45dp</dimen>
<dimen name="contact_icons_size">40dp</dimen> <dimen name="contact_icons_size">40dp</dimen>
<dimen name="contact_item_height">52dp</dimen> <dimen name="contact_item_height">52dp</dimen>
<dimen name="create_new_contact_height">68dp</dimen>
<dimen name="dialpad_button_size">60dp</dimen> <dimen name="dialpad_button_size">60dp</dimen>
<dimen name="dialpad_text_size">44sp</dimen> <dimen name="dialpad_text_size">44sp</dimen>
<dimen name="dialpad_input_text_size">40sp</dimen> <dimen name="dialpad_input_text_size">40sp</dimen>

View File

@ -15,6 +15,8 @@
<string name="send_email_to_group">Send email to group</string> <string name="send_email_to_group">Send email to group</string>
<string name="call_person">Call %s</string> <string name="call_person">Call %s</string>
<string name="request_the_required_permissions">Request the required permissions</string> <string name="request_the_required_permissions">Request the required permissions</string>
<string name="create_new_contact">Create new contact</string>
<string name="add_to_existing_contact">Add to an existing contact</string>
<string name="new_contact">New contact</string> <string name="new_contact">New contact</string>
<string name="edit_contact">Edit contact</string> <string name="edit_contact">Edit contact</string>