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_address_image.applyColorFilter(textColor)
|
||||
contact_event_image.applyColorFilter(textColor)
|
||||
contact_notes_image.applyColorFilter(textColor)
|
||||
contact_source_image.applyColorFilter(textColor)
|
||||
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
|
@ -235,6 +236,7 @@ class EditContactActivity : ContactActivity() {
|
|||
setupPhoneNumbers()
|
||||
setupEmails()
|
||||
setupAddresses()
|
||||
setupNotes()
|
||||
setupEvents()
|
||||
}
|
||||
|
||||
|
@ -283,6 +285,10 @@ class EditContactActivity : ContactActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupNotes() {
|
||||
contact_notes.setText(contact!!.notes)
|
||||
}
|
||||
|
||||
private fun setupEvents() {
|
||||
contact!!.events.forEachIndexed { index, event ->
|
||||
var eventHolder = contact_events_holder.getChildAt(index)
|
||||
|
@ -501,6 +507,7 @@ class EditContactActivity : ContactActivity() {
|
|||
events = getFilledEvents()
|
||||
source = contact!!.source
|
||||
starred = if (isContactStarred()) 1 else 0
|
||||
notes = contact_notes.value.replace("\n", "\\n")
|
||||
|
||||
Thread {
|
||||
config.lastUsedContactSource = source
|
||||
|
|
|
@ -216,8 +216,8 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
private fun getNotes(contactId: Int): String {
|
||||
val uri = ContactsContract.Data.CONTENT_URI
|
||||
val projection = arrayOf(Note.NOTE)
|
||||
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = '${Note.CONTENT_ITEM_TYPE}'"
|
||||
val selectionArgs = arrayOf(contactId.toString())
|
||||
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ? AND ${ContactsContract.Data.MIMETYPE} = ?"
|
||||
val selectionArgs = arrayOf(contactId.toString(), Note.CONTENT_ITEM_TYPE)
|
||||
|
||||
var cursor: Cursor? = null
|
||||
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
|
||||
try {
|
||||
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)
|
||||
var fullSizePhotoData: ByteArray? = null
|
||||
var scaledSizePhotoData: ByteArray?
|
||||
|
|
|
@ -289,6 +289,30 @@
|
|||
android:paddingTop="@dimen/medium_margin"
|
||||
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
|
||||
android:id="@+id/contact_source_image"
|
||||
android:layout_width="@dimen/contact_icons_size"
|
||||
|
@ -304,7 +328,7 @@
|
|||
android:id="@+id/contact_source"
|
||||
android:layout_width="match_parent"
|
||||
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_marginTop="@dimen/medium_margin"
|
||||
android:layout_toRightOf="@+id/contact_name_image"
|
||||
|
|
Loading…
Reference in New Issue