handle note inserting and updating
This commit is contained in:
parent
ac99c14c96
commit
85c998b9a8
|
@ -164,6 +164,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
contact_email_image.applyColorFilter(textColor)
|
contact_email_image.applyColorFilter(textColor)
|
||||||
contact_address_image.applyColorFilter(textColor)
|
contact_address_image.applyColorFilter(textColor)
|
||||||
contact_event_image.applyColorFilter(textColor)
|
contact_event_image.applyColorFilter(textColor)
|
||||||
|
contact_notes_image.applyColorFilter(textColor)
|
||||||
contact_source_image.applyColorFilter(textColor)
|
contact_source_image.applyColorFilter(textColor)
|
||||||
|
|
||||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||||
|
@ -235,6 +236,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
setupPhoneNumbers()
|
setupPhoneNumbers()
|
||||||
setupEmails()
|
setupEmails()
|
||||||
setupAddresses()
|
setupAddresses()
|
||||||
|
setupNotes()
|
||||||
setupEvents()
|
setupEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +285,10 @@ class EditContactActivity : ContactActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupNotes() {
|
||||||
|
contact_notes.setText(contact!!.notes)
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupEvents() {
|
private fun setupEvents() {
|
||||||
contact!!.events.forEachIndexed { index, event ->
|
contact!!.events.forEachIndexed { index, event ->
|
||||||
var eventHolder = contact_events_holder.getChildAt(index)
|
var eventHolder = contact_events_holder.getChildAt(index)
|
||||||
|
@ -501,6 +507,7 @@ class EditContactActivity : ContactActivity() {
|
||||||
events = getFilledEvents()
|
events = getFilledEvents()
|
||||||
source = contact!!.source
|
source = contact!!.source
|
||||||
starred = if (isContactStarred()) 1 else 0
|
starred = if (isContactStarred()) 1 else 0
|
||||||
|
notes = contact_notes.value.replace("\n", "\\n")
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
config.lastUsedContactSource = source
|
config.lastUsedContactSource = source
|
||||||
|
|
|
@ -216,8 +216,8 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
private fun getNotes(contactId: Int): String {
|
private fun getNotes(contactId: Int): String {
|
||||||
val uri = ContactsContract.Data.CONTENT_URI
|
val uri = ContactsContract.Data.CONTENT_URI
|
||||||
val projection = arrayOf(Note.NOTE)
|
val projection = arrayOf(Note.NOTE)
|
||||||
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = '${Note.CONTENT_ITEM_TYPE}'"
|
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = ?"
|
||||||
val selectionArgs = arrayOf(contactId.toString())
|
val selectionArgs = arrayOf(contactId.toString(), Note.CONTENT_ITEM_TYPE)
|
||||||
|
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
try {
|
||||||
|
@ -457,6 +457,15 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// notes
|
||||||
|
ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).apply {
|
||||||
|
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = ?"
|
||||||
|
val selectionArgs = arrayOf(contact.id.toString(), Note.CONTENT_ITEM_TYPE)
|
||||||
|
withSelection(selection, selectionArgs)
|
||||||
|
withValue(Note.NOTE, contact.notes)
|
||||||
|
operations.add(build())
|
||||||
|
}
|
||||||
|
|
||||||
// favorite
|
// favorite
|
||||||
try {
|
try {
|
||||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contact.contactId.toString())
|
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, contact.contactId.toString())
|
||||||
|
@ -583,6 +592,14 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// notes
|
||||||
|
ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).apply {
|
||||||
|
withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||||
|
withValue(ContactsContract.Data.MIMETYPE, Note.CONTENT_ITEM_TYPE)
|
||||||
|
withValue(Note.NOTE, contact.notes)
|
||||||
|
operations.add(build())
|
||||||
|
}
|
||||||
|
|
||||||
// photo (inspired by https://gist.github.com/slightfoot/5985900)
|
// photo (inspired by https://gist.github.com/slightfoot/5985900)
|
||||||
var fullSizePhotoData: ByteArray? = null
|
var fullSizePhotoData: ByteArray? = null
|
||||||
var scaledSizePhotoData: ByteArray?
|
var scaledSizePhotoData: ByteArray?
|
||||||
|
|
|
@ -289,6 +289,30 @@
|
||||||
android:paddingTop="@dimen/medium_margin"
|
android:paddingTop="@dimen/medium_margin"
|
||||||
android:src="@drawable/ic_plus"/>
|
android:src="@drawable/ic_plus"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/contact_notes_image"
|
||||||
|
android:layout_width="@dimen/contact_icons_size"
|
||||||
|
android:layout_height="@dimen/contact_icons_size"
|
||||||
|
android:layout_alignTop="@+id/contact_notes"
|
||||||
|
android:paddingBottom="@dimen/small_margin"
|
||||||
|
android:paddingEnd="@dimen/small_margin"
|
||||||
|
android:paddingRight="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/medium_margin"
|
||||||
|
android:src="@drawable/ic_label"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyEditText
|
||||||
|
android:id="@+id/contact_notes"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/contact_event_add_new"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginTop="@dimen/normal_margin"
|
||||||
|
android:layout_toRightOf="@+id/contact_notes_image"
|
||||||
|
android:hint="@string/notes"
|
||||||
|
android:inputType="textCapWords|textMultiLine"
|
||||||
|
android:textCursorDrawable="@null"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/contact_source_image"
|
android:id="@+id/contact_source_image"
|
||||||
android:layout_width="@dimen/contact_icons_size"
|
android:layout_width="@dimen/contact_icons_size"
|
||||||
|
@ -304,7 +328,7 @@
|
||||||
android:id="@+id/contact_source"
|
android:id="@+id/contact_source"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/contact_event_add_new"
|
android:layout_below="@+id/contact_notes"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginTop="@dimen/medium_margin"
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
android:layout_toRightOf="@+id/contact_name_image"
|
android:layout_toRightOf="@+id/contact_name_image"
|
||||||
|
|
Loading…
Reference in New Issue