launch Create New intent at placeholder click
This commit is contained in:
parent
567fb8212a
commit
ef3b07eddd
|
@ -41,24 +41,20 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||||
setTextColor(context.config.primaryColor)
|
setTextColor(context.config.primaryColor)
|
||||||
underlineText()
|
underlineText()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
|
if (context.hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
|
launchCreateNewIntent()
|
||||||
|
} else {
|
||||||
requestReadContactsPermission()
|
requestReadContactsPermission()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
letter_fastscroller.textColor = context.config.textColor.getColorStateList()
|
letter_fastscroller.textColor = context.config.textColor.getColorStateList()
|
||||||
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
|
||||||
letter_fastscroller_thumb.textColor = context.config.primaryColor.getContrastColor()
|
letter_fastscroller_thumb.textColor = context.config.primaryColor.getContrastColor()
|
||||||
|
|
||||||
fragment_fab.setOnClickListener {
|
fragment_fab.setOnClickListener {
|
||||||
Intent(Intent.ACTION_INSERT).apply {
|
launchCreateNewIntent()
|
||||||
data = ContactsContract.Contacts.CONTENT_URI
|
|
||||||
|
|
||||||
if (resolveActivity(context.packageManager) != null) {
|
|
||||||
activity?.startActivity(this)
|
|
||||||
} else {
|
|
||||||
context.toast(R.string.no_app_found)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +168,9 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||||
if (it) {
|
if (it) {
|
||||||
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
fragment_placeholder.text = context.getString(R.string.no_contacts_found)
|
||||||
fragment_placeholder_2.text = context.getString(R.string.create_new)
|
fragment_placeholder_2.text = context.getString(R.string.create_new)
|
||||||
|
fragment_placeholder_2.setOnClickListener {
|
||||||
|
launchCreateNewIntent()
|
||||||
|
}
|
||||||
|
|
||||||
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
SimpleContactsHelper(context).getAvailableContacts(false) { contacts ->
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
|
@ -181,4 +180,16 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun launchCreateNewIntent() {
|
||||||
|
Intent().apply {
|
||||||
|
action = Intent.ACTION_INSERT
|
||||||
|
data = ContactsContract.Contacts.CONTENT_URI
|
||||||
|
if (resolveActivity(context.packageManager) != null) {
|
||||||
|
context.startActivity(this)
|
||||||
|
} else {
|
||||||
|
context.toast(R.string.no_app_found)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue