mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
show the "Create new contact" button over favorites too
This commit is contained in:
@ -104,7 +104,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
|||||||
val currAdapter = group_contacts_list.adapter
|
val currAdapter = group_contacts_list.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
ContactsAdapter(this, contacts, this, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) {
|
ContactsAdapter(this, contacts, this, LOCATION_GROUP_CONTACTS, this, group_contacts_list, group_contacts_fastscroller) {
|
||||||
contactClicked(it as Contact, false)
|
contactClicked(it as Contact)
|
||||||
}.apply {
|
}.apply {
|
||||||
group_contacts_list.adapter = this
|
group_contacts_list.adapter = this
|
||||||
}
|
}
|
||||||
@ -123,8 +123,8 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
|
|||||||
refreshContacts()
|
refreshContacts()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) {
|
override fun contactClicked(contact: Contact) {
|
||||||
handleGenericContactClick(contact!!)
|
handleGenericContactClick(contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removeFromGroup(contacts: ArrayList<Contact>) {
|
override fun removeFromGroup(contacts: ArrayList<Contact>) {
|
||||||
|
@ -96,6 +96,12 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
insert_or_edit_tabs_holder.beVisibleIf(skippedTabs == 0)
|
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() {
|
private fun setupTabColors() {
|
||||||
@ -130,54 +136,52 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun contactClicked(contact: Contact?, isCreateNewContact: Boolean) {
|
override fun contactClicked(contact: Contact) {
|
||||||
if (contact != null) {
|
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
||||||
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
val email = getEmailFromIntent(intent) ?: ""
|
||||||
val email = getEmailFromIntent(intent) ?: ""
|
|
||||||
|
|
||||||
Intent(applicationContext, EditContactActivity::class.java).apply {
|
Intent(applicationContext, EditContactActivity::class.java).apply {
|
||||||
data = getContactPublicUri(contact)
|
data = getContactPublicUri(contact)
|
||||||
action = ADD_NEW_CONTACT_NUMBER
|
action = ADD_NEW_CONTACT_NUMBER
|
||||||
|
|
||||||
if (phoneNumber.isNotEmpty()) {
|
if (phoneNumber.isNotEmpty()) {
|
||||||
putExtra(KEY_PHONE, phoneNumber)
|
putExtra(KEY_PHONE, phoneNumber)
|
||||||
}
|
|
||||||
|
|
||||||
if (email.isNotEmpty()) {
|
|
||||||
putExtra(KEY_EMAIL, email)
|
|
||||||
}
|
|
||||||
|
|
||||||
putExtra(IS_PRIVATE, contact.isPrivate())
|
|
||||||
startActivityForResult(this, START_EDIT_ACTIVITY)
|
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
} else if (isCreateNewContact) {
|
|
||||||
val name = intent.getStringExtra(KEY_NAME) ?: ""
|
|
||||||
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
|
||||||
val email = getEmailFromIntent(intent) ?: ""
|
|
||||||
|
|
||||||
Intent().apply {
|
if (email.isNotEmpty()) {
|
||||||
action = Intent.ACTION_INSERT
|
putExtra(KEY_EMAIL, email)
|
||||||
data = ContactsContract.Contacts.CONTENT_URI
|
}
|
||||||
|
|
||||||
if (phoneNumber.isNotEmpty()) {
|
putExtra(IS_PRIVATE, contact.isPrivate())
|
||||||
putExtra(KEY_PHONE, phoneNumber)
|
startActivityForResult(this, START_EDIT_ACTIVITY)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name.isNotEmpty()) {
|
private fun createNewContact() {
|
||||||
putExtra(KEY_NAME, name)
|
val name = intent.getStringExtra(KEY_NAME) ?: ""
|
||||||
}
|
val phoneNumber = getPhoneNumberFromIntent(intent) ?: ""
|
||||||
|
val email = getEmailFromIntent(intent) ?: ""
|
||||||
|
|
||||||
if (email.isNotEmpty()) {
|
Intent().apply {
|
||||||
putExtra(KEY_EMAIL, email)
|
action = Intent.ACTION_INSERT
|
||||||
}
|
data = ContactsContract.Contacts.CONTENT_URI
|
||||||
|
|
||||||
if (resolveActivity(packageManager) != null) {
|
if (phoneNumber.isNotEmpty()) {
|
||||||
startActivityForResult(this, START_INSERT_ACTIVITY)
|
putExtra(KEY_PHONE, phoneNumber)
|
||||||
finish()
|
}
|
||||||
} else {
|
|
||||||
toast(R.string.no_app_found)
|
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) {
|
override fun contactClicked(contact: Contact) {
|
||||||
handleGenericContactClick(contact!!)
|
handleGenericContactClick(contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
|
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.interfaces.RefreshContactsListener
|
||||||
import com.simplemobiletools.contacts.pro.models.Contact
|
import com.simplemobiletools.contacts.pro.models.Contact
|
||||||
import com.simplemobiletools.contacts.pro.models.Group
|
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.*
|
||||||
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) {
|
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) {
|
||||||
protected var activity: SimpleActivity? = null
|
protected var activity: SimpleActivity? = null
|
||||||
@ -192,7 +188,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
forceListRedraw = false
|
forceListRedraw = false
|
||||||
val location = if (this is FavoritesFragment) LOCATION_FAVORITES_TAB else LOCATION_CONTACTS_TAB
|
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) {
|
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 {
|
}.apply {
|
||||||
fragment_list.adapter = this
|
fragment_list.adapter = this
|
||||||
}
|
}
|
||||||
@ -303,11 +299,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
fragment_fastscroller.updateBubbleColors()
|
fragment_fastscroller.updateBubbleColors()
|
||||||
fragment_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
fragment_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||||
fragment_placeholder_2?.setTextColor(context.getAdjustedPrimaryColor())
|
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) {
|
private fun setupViewVisibility(hasItemsToShow: Boolean) {
|
||||||
|
@ -5,5 +5,5 @@ import com.simplemobiletools.contacts.pro.models.Contact
|
|||||||
interface RefreshContactsListener {
|
interface RefreshContactsListener {
|
||||||
fun refreshContacts(refreshTabsMask: Int)
|
fun refreshContacts(refreshTabsMask: Int)
|
||||||
|
|
||||||
fun contactClicked(contact: Contact?, isCreateNewContact: Boolean)
|
fun contactClicked(contact: Contact)
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,55 @@
|
|||||||
app:tabMinWidth="150dp"
|
app:tabMinWidth="150dp"
|
||||||
app:tabSelectedTextColor="@android:color/white" />
|
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
|
<com.simplemobiletools.commons.views.MyViewPager
|
||||||
android:id="@+id/viewpager"
|
android:id="@+id/viewpager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/insert_or_edit_tabs_holder" />
|
android:layout_below="@+id/select_contact_label" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -11,55 +11,10 @@
|
|||||||
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: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
|
<com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
android:id="@+id/fragment_list"
|
android:id="@+id/fragment_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/select_contact_label"
|
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager" />
|
||||||
@ -68,8 +23,7 @@
|
|||||||
android:id="@+id/fragment_fastscroller"
|
android:id="@+id/fragment_fastscroller"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/select_contact_label"
|
android:layout_alignTop="@+id/fragment_list"
|
||||||
android:layout_alignTop="@+id/select_contact_list"
|
|
||||||
android:layout_alignBottom="@+id/fragment_list"
|
android:layout_alignBottom="@+id/fragment_list"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:paddingStart="@dimen/normal_margin">
|
android:paddingStart="@dimen/normal_margin">
|
||||||
|
Reference in New Issue
Block a user