mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
show the "Create new contact" button over favorites too
This commit is contained in:
parent
e396e4987c
commit
324d9ef399
@ -104,7 +104,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
||||
val currAdapter = group_contacts_list.adapter
|
||||
if (currAdapter == null) {
|
||||
ContactsAdapter(this, contacts, this, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) {
|
||||
contactClicked(it as Contact, false)
|
||||
contactClicked(it as Contact)
|
||||
}.apply {
|
||||
group_contacts_list.adapter = this
|
||||
}
|
||||
@ -123,8 +123,8 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
||||
refreshContacts()
|
||||
}
|
||||
|
||||
override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) {
|
||||
handleGenericContactClick(contact!!)
|
||||
override fun contactClicked(contact: Contact) {
|
||||
handleGenericContactClick(contact)
|
||||
}
|
||||
|
||||
override fun removeFromGroup(contacts: ArrayList<Contact>) {
|
||||
|
@ -96,6 +96,12 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
|
||||
insert_or_edit_tabs_holder.beVisibleIf(skippedTabs == 0)
|
||||
|
||||
select_contact_label?.setTextColor(getAdjustedPrimaryColor())
|
||||
new_contact_tmb?.setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_new_contact_vector, config.textColor))
|
||||
new_contact_holder?.setOnClickListener {
|
||||
createNewContact()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupTabColors() {
|
||||
@ -130,54 +136,52 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
}
|
||||
|
||||
override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) {
|
||||
if (contact != null) {
|
||||
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
||||
val email = getEmailFromIntent(intent) ?: ""
|
||||
override fun contactClicked(contact: Contact) {
|
||||
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
||||
val email = getEmailFromIntent(intent) ?: ""
|
||||
|
||||
Intent(applicationContext, EditContactActivity::class.java).apply {
|
||||
data = getContactPublicUri(contact)
|
||||
action = ADD_NEW_CONTACT_NUMBER
|
||||
Intent(applicationContext, EditContactActivity::class.java).apply {
|
||||
data = getContactPublicUri(contact)
|
||||
action = ADD_NEW_CONTACT_NUMBER
|
||||
|
||||
if (phoneNumber.isNotEmpty()) {
|
||||
putExtra(KEY_PHONE, phoneNumber)
|
||||
}
|
||||
|
||||
if (email.isNotEmpty()) {
|
||||
putExtra(KEY_EMAIL, email)
|
||||
}
|
||||
|
||||
putExtra(IS_PRIVATE, contact.isPrivate())
|
||||
startActivityForResult(this, START_EDIT_ACTIVITY)
|
||||
finish()
|
||||
if (phoneNumber.isNotEmpty()) {
|
||||
putExtra(KEY_PHONE, phoneNumber)
|
||||
}
|
||||
} else if (isCreateNewContact) {
|
||||
val name = intent.getStringExtra(KEY_NAME) ?: ""
|
||||
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
||||
val email = getEmailFromIntent(intent) ?: ""
|
||||
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_INSERT
|
||||
data = ContactsContract.Contacts.CONTENT_URI
|
||||
if (email.isNotEmpty()) {
|
||||
putExtra(KEY_EMAIL, email)
|
||||
}
|
||||
|
||||
if (phoneNumber.isNotEmpty()) {
|
||||
putExtra(KEY_PHONE, phoneNumber)
|
||||
}
|
||||
putExtra(IS_PRIVATE, contact.isPrivate())
|
||||
startActivityForResult(this, START_EDIT_ACTIVITY)
|
||||
}
|
||||
}
|
||||
|
||||
if (name.isNotEmpty()) {
|
||||
putExtra(KEY_NAME, name)
|
||||
}
|
||||
private fun createNewContact() {
|
||||
val name = intent.getStringExtra(KEY_NAME) ?: ""
|
||||
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
||||
val email = getEmailFromIntent(intent) ?: ""
|
||||
|
||||
if (email.isNotEmpty()) {
|
||||
putExtra(KEY_EMAIL, email)
|
||||
}
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_INSERT
|
||||
data = ContactsContract.Contacts.CONTENT_URI
|
||||
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivityForResult(this, START_INSERT_ACTIVITY)
|
||||
finish()
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
if (phoneNumber.isNotEmpty()) {
|
||||
putExtra(KEY_PHONE, phoneNumber)
|
||||
}
|
||||
|
||||
if (name.isNotEmpty()) {
|
||||
putExtra(KEY_NAME, name)
|
||||
}
|
||||
|
||||
if (email.isNotEmpty()) {
|
||||
putExtra(KEY_EMAIL, email)
|
||||
}
|
||||
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivityForResult(this, START_INSERT_ACTIVITY)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -560,8 +560,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
||||
}
|
||||
}
|
||||
|
||||
override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) {
|
||||
handleGenericContactClick(contact!!)
|
||||
override fun contactClicked(contact: Contact) {
|
||||
handleGenericContactClick(contact)
|
||||
}
|
||||
|
||||
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
|
||||
|
@ -21,11 +21,7 @@ import com.simplemobiletools.contacts.pro.helpers.*
|
||||
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
|
||||
import com.simplemobiletools.contacts.pro.models.Contact
|
||||
import com.simplemobiletools.contacts.pro.models.Group
|
||||
import kotlinx.android.synthetic.main.fragment_insert_or_edit_contacts.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_layout.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_fastscroller
|
||||
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_list
|
||||
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_wrapper
|
||||
|
||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) {
|
||||
protected var activity: SimpleActivity? = null
|
||||
@ -192,7 +188,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||
forceListRedraw = false
|
||||
val location = if (this is FavoritesFragment) LOCATION_FAVORITES_TAB else LOCATION_CONTACTS_TAB
|
||||
ContactsAdapter(activity as SimpleActivity, contacts, activity as RefreshContactsListener, location, null, fragment_list, fragment_fastscroller) {
|
||||
(activity as RefreshContactsListener).contactClicked(it as Contact, false)
|
||||
(activity as RefreshContactsListener).contactClicked(it as Contact)
|
||||
}.apply {
|
||||
fragment_list.adapter = this
|
||||
}
|
||||
@ -303,11 +299,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
||||
fragment_fastscroller.updateBubbleColors()
|
||||
fragment_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||
fragment_placeholder_2?.setTextColor(context.getAdjustedPrimaryColor())
|
||||
select_contact_label?.setTextColor(context.getAdjustedPrimaryColor())
|
||||
new_contact_tmb?.setImageDrawable(resources.getColoredDrawableWithColor(R.drawable.ic_new_contact_vector, context.config.textColor))
|
||||
new_contact_holder?.setOnClickListener {
|
||||
(activity as RefreshContactsListener).contactClicked(null, true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupViewVisibility(hasItemsToShow: Boolean) {
|
||||
|
@ -5,5 +5,5 @@ import com.simplemobiletools.contacts.pro.models.Contact
|
||||
interface RefreshContactsListener {
|
||||
fun refreshContacts(refreshTabsMask: Int)
|
||||
|
||||
fun contactClicked(contact: Contact?, isCreateNewContact: Boolean)
|
||||
fun contactClicked(contact: Contact)
|
||||
}
|
||||
|
@ -15,10 +15,55 @@
|
||||
app:tabMinWidth="150dp"
|
||||
app:tabSelectedTextColor="@android:color/white" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/new_contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/insert_or_edit_tabs_holder"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingTop="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/medium_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/new_contact_tmb"
|
||||
android:layout_width="@dimen/normal_icon_size"
|
||||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_new_contact_vector" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/new_contact_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/new_contact_tmb"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/small_margin"
|
||||
android:text="@string/create_new_contact"
|
||||
android:textSize="@dimen/big_text_size" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/select_contact_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/new_contact_holder"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:text="@string/add_to_existing_contact"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/smaller_text_size" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/insert_or_edit_tabs_holder" />
|
||||
android:layout_below="@+id/select_contact_label" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -11,55 +11,10 @@
|
||||
android:layout_width="match_parent"
|
||||
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:paddingTop="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/medium_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/new_contact_tmb"
|
||||
android:layout_width="@dimen/normal_icon_size"
|
||||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_new_contact_vector" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/new_contact_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@+id/new_contact_tmb"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/small_margin"
|
||||
android:text="@string/create_new_contact"
|
||||
android:textSize="@dimen/big_text_size" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/select_contact_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/new_contact_holder"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:text="@string/add_to_existing_contact"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/smaller_text_size" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||
android:id="@+id/fragment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/select_contact_label"
|
||||
android:clipToPadding="false"
|
||||
android:scrollbars="none"
|
||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||
@ -68,8 +23,7 @@
|
||||
android:id="@+id/fragment_fastscroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/select_contact_label"
|
||||
android:layout_alignTop="@+id/select_contact_list"
|
||||
android:layout_alignTop="@+id/fragment_list"
|
||||
android:layout_alignBottom="@+id/fragment_list"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/normal_margin">
|
||||
|
Loading…
x
Reference in New Issue
Block a user