*
- * @param phoneType String
+ * @param phoneType PhoneType
* @return This InsertContactIntentBuilder for method chaining
*/
- fun phoneType(phoneType: String): InsertContactIntentBuilder {
+ fun phoneType(phoneType: PhoneType): InsertContactIntentBuilder {
this.phoneType = phoneType
return this
}
@@ -128,11 +126,10 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* Set the field for the phone isprimary flag.
*
Type: boolean
*
- * @param phoneIsPrimary Boolean
* @return This InsertContactIntentBuilder for method chaining
*/
- fun phoneIsPrimary(phoneIsPrimary: Boolean): InsertContactIntentBuilder {
- this.phoneIsPrimary = phoneIsPrimary
+ fun phoneIsPrimary(): InsertContactIntentBuilder {
+ this.phoneIsPrimary = true
return this
}
@@ -153,10 +150,10 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @link CommonDataKinds.Phone,
* or a string specifying a custom label.
*
- * @param secondaryPhoneType String
+ * @param secondaryPhoneType PhoneType
* @return This InsertContactIntentBuilder for method chaining
*/
- fun secondaryPhoneType(secondaryPhoneType: String): InsertContactIntentBuilder {
+ fun secondaryPhoneType(secondaryPhoneType: PhoneType): InsertContactIntentBuilder {
this.secondaryPhoneType = secondaryPhoneType
return this
}
@@ -181,7 +178,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @param tertiaryPhoneType String
* @return This InsertContactIntentBuilder for method chaining
*/
- fun tertiaryPhoneType(tertiaryPhoneType: String): InsertContactIntentBuilder {
+ fun tertiaryPhoneType(tertiaryPhoneType: PhoneType): InsertContactIntentBuilder {
this.tertiaryPhoneType = tertiaryPhoneType
return this
}
@@ -203,23 +200,21 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* {@link CommonDataKinds.Email}
* or a string specifying a custom label.
*
- * @param emailType String
+ * @param emailType EmailAddressType
* @return This InsertContactIntentBuilder for method chaining
*/
- fun emailType(emailType: String): InsertContactIntentBuilder {
+ fun emailType(emailType: EmailAddressType): InsertContactIntentBuilder {
this.emailType = emailType
return this
}
/**
* Set the field for the email isprimary flag.
- *
Type: boolean
*
- * @param emailIsPrimary Boolean
* @return This InsertContactIntentBuilder for method chaining
*/
- fun emailIsPrimary(emailIsPrimary: Boolean): InsertContactIntentBuilder {
- this.emailIsPrimary = emailIsPrimary
+ fun emailIsPrimary(): InsertContactIntentBuilder {
+ this.emailIsPrimary = true
return this
}
@@ -240,10 +235,10 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* {@link CommonDataKinds.Email}
* or a string specifying a custom label.
*
- * @param secondaryEmailType String
+ * @param secondaryEmailType EmailAddressType
* @return This InsertContactIntentBuilder for method chaining
*/
- fun secondaryEmailType(secondaryEmailType: String): InsertContactIntentBuilder {
+ fun secondaryEmailType(secondaryEmailType: EmailAddressType): InsertContactIntentBuilder {
this.secondaryEmailType = secondaryEmailType
return this
}
@@ -265,10 +260,10 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* {@link CommonDataKinds.Email}
* or a string specifying a custom label.
*
- * @param tertiaryEmailType String
+ * @param tertiaryEmailType EmailAddressType
* @return This InsertContactIntentBuilder for method chaining
*/
- fun tertiaryEmailType(tertiaryEmailType: String): InsertContactIntentBuilder {
+ fun tertiaryEmailType(tertiaryEmailType: EmailAddressType): InsertContactIntentBuilder {
this.tertiaryEmailType = tertiaryEmailType
return this
}
@@ -299,46 +294,10 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
/**
* Set the extra field for the postal isprimary flag.
*
- * @param postalIsPrimary Boolean
- * @return This InsertContactIntentBuilder for method chaining
- */
- fun postalIsPrimary(postalIsPrimary: Boolean): InsertContactIntentBuilder {
- this.postalIsPrimary = postalIsPrimary
- return this
- }
-
- /**
- * Set the field for an IM handle.
- *
Type: String
- *
- * @param imHandle String
- * @return This InsertContactIntentBuilder for method chaining
- */
- fun imHandle(imHandle: String): InsertContactIntentBuilder {
- this.imHandle = imHandle
- return this
- }
-
- /**
- * Set the field for the IM protocol
- *
- * @param imProtocol String
- * @return This InsertContactIntentBuilder for method chaining
- */
- fun imProtocol(imProtocol: String): InsertContactIntentBuilder {
- this.imProtocol = imProtocol
- return this
- }
-
- /**
- * Set the field for the IM isprimary flag.
- *
Type: Either an String value to create custom type
+ *
+ * @param customPhoneType String
+ * @return This InsertContactIntentBuilder for method chaining
+ */
+ fun phoneType(customPhoneType: String): InsertContactIntentBuilder {
+ this.customPhoneType = customPhoneType
+ return this
+ }
+
/**
* Set the field for the phone isprimary flag.
*
Type: boolean
@@ -158,6 +176,18 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
return this
}
+ /**
+ * Set the field for the contact phone number type.
+ * Type: Either an String value to create custom type
+ *
+ * @param customSecondaryPhoneType String
+ * @return This InsertContactIntentBuilder for method chaining
+ */
+ fun secondaryPhoneType(customSecondaryPhoneType: String): InsertContactIntentBuilder {
+ this.customSecondaryPhoneType = customSecondaryPhoneType
+ return this
+ }
+
/**
* Set the field for the tertiary contact phone number.
*
@@ -183,6 +213,18 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
return this
}
+ /**
+ * Set the field for the contact phone number type.
+ * Type: Either an String value to create custom type
+ *
+ * @param customTertiaryPhoneType String
+ * @return This InsertContactIntentBuilder for method chaining
+ */
+ fun tertiaryPhoneType(customTertiaryPhoneType: String): InsertContactIntentBuilder {
+ this.customTertiaryPhoneType = customTertiaryPhoneType
+ return this
+ }
+
/**
* Set the field for the contact email address.
*
@@ -208,6 +250,18 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
return this
}
+ /**
+ * Set the field for the contact email type.
+ * Type: Either a String for custom type
+ *
+ * @param customEmailType String
+ * @return This InsertContactIntentBuilder for method chaining
+ */
+ fun emailType(customEmailType: String): InsertContactIntentBuilder {
+ this.customEmailType = customEmailType
+ return this
+ }
+
/**
* Set the field for the email isprimary flag.
*
@@ -243,6 +297,18 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
return this
}
+ /**
+ * Set the field for the contact email type.
+ * Type: Either a String for custom type
+ *
+ * @param customSecondaryEmailType String
+ * @return This InsertContactIntentBuilder for method chaining
+ */
+ fun secondaryEmailType(customSecondaryEmailType: String): InsertContactIntentBuilder {
+ this.customSecondaryEmailType = customSecondaryEmailType
+ return this
+ }
+
/**
* Set the field for the contact tertiary email address.
*
@@ -268,6 +334,18 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
return this
}
+ /**
+ * Set the field for the contact email type.
+ * Type: Either a String for custom type
+ *
+ * @param customSecondaryEmailType String
+ * @return This InsertContactIntentBuilder for method chaining
+ */
+ fun tertiaryEmailType(customTertiaryEmailType: String): InsertContactIntentBuilder {
+ this.customTertiaryEmailType = customTertiaryEmailType
+ return this
+ }
+
/**
* Set the field for the contact postal address.
*
@@ -306,89 +384,120 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
type = ContactsContract.Contacts.CONTENT_TYPE
name?.let {
- putExtra(ContactsContract.Intents.Insert.NAME, name)
+ putExtra(ContactsContract.Intents.Insert.NAME, it)
}
- putExtra(ContactsContract.Intents.Insert.FULL_MODE, fullMode)
+ if (fullMode) {
+ putExtra(ContactsContract.Intents.Insert.FULL_MODE, fullMode)
+ }
phoneticName?.let {
- putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, phoneticName)
+ putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, it)
}
company?.let {
- putExtra(ContactsContract.Intents.Insert.COMPANY, company)
+ putExtra(ContactsContract.Intents.Insert.COMPANY, it)
}
jobTitle?.let {
- putExtra(ContactsContract.Intents.Insert.JOB_TITLE, jobTitle)
+ putExtra(ContactsContract.Intents.Insert.JOB_TITLE, it)
}
notes?.let {
- putExtra(ContactsContract.Intents.Insert.NOTES, notes)
+ putExtra(ContactsContract.Intents.Insert.NOTES, it)
}
phone?.let {
- putExtra(ContactsContract.Intents.Insert.PHONE, phone)
+ putExtra(ContactsContract.Intents.Insert.PHONE, it)
}
phoneType?.let {
- putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, phoneType!!.type)
+ putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, it.type)
+ } ?: run {
+ customPhoneType?.let {
+ putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, it)
+ }
}
- putExtra(ContactsContract.Intents.Insert.PHONE_ISPRIMARY, phoneIsPrimary)
-
+ if (phoneIsPrimary) {
+ putExtra(ContactsContract.Intents.Insert.PHONE_ISPRIMARY, phoneIsPrimary)
+ }
secondaryPhone?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, secondaryPhone)
+ putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, it)
}
secondaryPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, secondaryPhoneType!!.type)
+ putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, it.type)
+ } ?: run {
+ customSecondaryPhoneType?.let {
+ putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, it)
+ }
}
tertiaryPhone?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE, tertiaryPhone)
+ putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE, it)
}
tertiaryPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, tertiaryPhoneType!!.type)
+ putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, it.type)
+ } ?: run {
+ customTertiaryPhoneType?.let {
+ putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, it)
+ }
}
email?.let {
- putExtra(ContactsContract.Intents.Insert.EMAIL, email)
+ putExtra(ContactsContract.Intents.Insert.EMAIL, it)
}
emailType?.let {
- putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, emailType!!.type)
+ putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, it.type)
+ } ?: run {
+ customEmailType?.let {
+ putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, it)
+ }
}
- putExtra(ContactsContract.Intents.Insert.EMAIL_ISPRIMARY, emailIsPrimary)
+ if (emailIsPrimary) {
+ putExtra(ContactsContract.Intents.Insert.EMAIL_ISPRIMARY, emailIsPrimary)
+ }
secondaryEmail?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL, secondaryEmail)
+ putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL, it)
}
secondaryEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, secondaryEmailType!!.type)
+ putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, it.type)
+ } ?: run {
+ customSecondaryEmailType?.let {
+ putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, it)
+ }
}
tertiaryEmail?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL, tertiaryEmail)
+ putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL, it)
}
tertiaryEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, tertiaryEmailType!!.type)
+ putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, it.type)
+ } ?: run {
+ customTertiaryEmailType?.let {
+ putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, it)
+ }
}
postal?.let {
- putExtra(ContactsContract.Intents.Insert.POSTAL, postal)
+ putExtra(ContactsContract.Intents.Insert.POSTAL, it)
}
postalType?.let {
- putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, postalType)
+ putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, it)
}
- putExtra(ContactsContract.Intents.Insert.POSTAL_ISPRIMARY, postalIsPrimary)
+ if (postalIsPrimary) {
+ putExtra(ContactsContract.Intents.Insert.POSTAL_ISPRIMARY, postalIsPrimary)
+ }
}
}
diff --git a/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java b/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java
index 75c67cf..e5a78eb 100644
--- a/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java
+++ b/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java
@@ -259,16 +259,16 @@ private void onInsertContactClicked() {
.phoneType(PhoneType.TYPE_HOME)
.phoneIsPrimary()
.secondaryPhone("88000001008")
- .secondaryPhoneType(PhoneType.TYPE_HOME)
+ .secondaryPhoneType("YOUR_CUSTOM_TYPE")
.tertiaryPhone("888888888")
.tertiaryPhoneType(PhoneType.TYPE_WORK_MOBILE)
.email("develop@omega-r.com")
.emailType(EmailAddressType.TYPE_HOME)
.emailIsPrimary()
.secondaryEmail("secondaryEmail")
- .secondaryEmailType(EmailAddressType.TYPE_HOME)
+ .secondaryEmailType(EmailAddressType.TYPE_WORK)
.tertiaryEmail("tertiaryEmail")
- .tertiaryEmailType(EmailAddressType.TYPE_OTHER)
+ .tertiaryEmailType("YOUR_CUSTOM_EMAIL_TYPE")
.postal("postal")
.postalType("Home")
.postalIsPrimary()
From 8c5453ce4bdd0fe2d71a9291b37f8f8dd90bf4d0 Mon Sep 17 00:00:00 2001
From: just-d-a
Date: Fri, 9 Oct 2020 10:25:25 +0300
Subject: [PATCH 10/13] refactor
---
.../builders/InsertContactIntentBuilder.kt | 61 ++++++++++---------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
index 279b348..5ac84f9 100644
--- a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
+++ b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
@@ -3,6 +3,7 @@ package com.omega_r.libs.omegaintentbuilder.builders
import android.content.Context
import android.content.Intent
import android.provider.ContactsContract
+import android.provider.ContactsContract.Intents.Insert.*
import com.omega_r.libs.omegaintentbuilder.types.EmailAddressType
import com.omega_r.libs.omegaintentbuilder.types.PhoneType
@@ -338,7 +339,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* Set the field for the contact email type.
* Type: Either a String for custom type
*
- * @param customSecondaryEmailType String
+ * @param customTertiaryEmailType String
* @return This InsertContactIntentBuilder for method chaining
*/
fun tertiaryEmailType(customTertiaryEmailType: String): InsertContactIntentBuilder {
@@ -384,119 +385,119 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
type = ContactsContract.Contacts.CONTENT_TYPE
name?.let {
- putExtra(ContactsContract.Intents.Insert.NAME, it)
+ putExtra(NAME, it)
}
if (fullMode) {
- putExtra(ContactsContract.Intents.Insert.FULL_MODE, fullMode)
+ putExtra(FULL_MODE, fullMode)
}
phoneticName?.let {
- putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, it)
+ putExtra(PHONETIC_NAME, it)
}
company?.let {
- putExtra(ContactsContract.Intents.Insert.COMPANY, it)
+ putExtra(COMPANY, it)
}
jobTitle?.let {
- putExtra(ContactsContract.Intents.Insert.JOB_TITLE, it)
+ putExtra(JOB_TITLE, it)
}
notes?.let {
- putExtra(ContactsContract.Intents.Insert.NOTES, it)
+ putExtra(NOTES, it)
}
phone?.let {
- putExtra(ContactsContract.Intents.Insert.PHONE, it)
+ putExtra(PHONE, it)
}
phoneType?.let {
- putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, it.type)
+ putExtra(PHONE_TYPE, it.type)
} ?: run {
customPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, it)
+ putExtra(PHONE_TYPE, it)
}
}
if (phoneIsPrimary) {
- putExtra(ContactsContract.Intents.Insert.PHONE_ISPRIMARY, phoneIsPrimary)
+ putExtra(PHONE_ISPRIMARY, phoneIsPrimary)
}
secondaryPhone?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, it)
+ putExtra(SECONDARY_PHONE, it)
}
secondaryPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, it.type)
+ putExtra(SECONDARY_PHONE_TYPE, it.type)
} ?: run {
customSecondaryPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, it)
+ putExtra(SECONDARY_PHONE_TYPE, it)
}
}
tertiaryPhone?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE, it)
+ putExtra(TERTIARY_PHONE, it)
}
tertiaryPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, it.type)
+ putExtra(TERTIARY_PHONE_TYPE, it.type)
} ?: run {
customTertiaryPhoneType?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, it)
+ putExtra(TERTIARY_PHONE_TYPE, it)
}
}
email?.let {
- putExtra(ContactsContract.Intents.Insert.EMAIL, it)
+ putExtra(EMAIL, it)
}
emailType?.let {
- putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, it.type)
+ putExtra(EMAIL_TYPE, it.type)
} ?: run {
customEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, it)
+ putExtra(EMAIL_TYPE, it)
}
}
if (emailIsPrimary) {
- putExtra(ContactsContract.Intents.Insert.EMAIL_ISPRIMARY, emailIsPrimary)
+ putExtra(EMAIL_ISPRIMARY, emailIsPrimary)
}
secondaryEmail?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL, it)
+ putExtra(SECONDARY_EMAIL, it)
}
secondaryEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, it.type)
+ putExtra(SECONDARY_EMAIL_TYPE, it.type)
} ?: run {
customSecondaryEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, it)
+ putExtra(SECONDARY_EMAIL_TYPE, it)
}
}
tertiaryEmail?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL, it)
+ putExtra(TERTIARY_EMAIL, it)
}
tertiaryEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, it.type)
+ putExtra(TERTIARY_EMAIL_TYPE, it.type)
} ?: run {
customTertiaryEmailType?.let {
- putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, it)
+ putExtra(TERTIARY_EMAIL_TYPE, it)
}
}
postal?.let {
- putExtra(ContactsContract.Intents.Insert.POSTAL, it)
+ putExtra(POSTAL, it)
}
postalType?.let {
- putExtra(ContactsContract.Intents.Insert.POSTAL_TYPE, it)
+ putExtra(POSTAL_TYPE, it)
}
if (postalIsPrimary) {
- putExtra(ContactsContract.Intents.Insert.POSTAL_ISPRIMARY, postalIsPrimary)
+ putExtra(POSTAL_ISPRIMARY, postalIsPrimary)
}
}
From fccb287e3e538b1e02ff99043d10a51844157559 Mon Sep 17 00:00:00 2001
From: just-d-a
Date: Fri, 9 Oct 2020 11:40:35 +0300
Subject: [PATCH 11/13] correction of comments
---
.../builders/InsertContactIntentBuilder.kt | 25 +++++++++++--------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
index 5ac84f9..3a4b405 100644
--- a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
+++ b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
@@ -125,6 +125,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun phoneType(phoneType: PhoneType): InsertContactIntentBuilder {
+ customPhoneType = null
this.phoneType = phoneType
return this
}
@@ -137,6 +138,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun phoneType(customPhoneType: String): InsertContactIntentBuilder {
+ phoneType = null
this.customPhoneType = customPhoneType
return this
}
@@ -173,6 +175,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun secondaryPhoneType(secondaryPhoneType: PhoneType): InsertContactIntentBuilder {
+ customSecondaryPhoneType = null
this.secondaryPhoneType = secondaryPhoneType
return this
}
@@ -185,6 +188,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun secondaryPhoneType(customSecondaryPhoneType: String): InsertContactIntentBuilder {
+ secondaryPhoneType = null
this.customSecondaryPhoneType = customSecondaryPhoneType
return this
}
@@ -210,6 +214,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun tertiaryPhoneType(tertiaryPhoneType: PhoneType): InsertContactIntentBuilder {
+ customTertiaryPhoneType = null
this.tertiaryPhoneType = tertiaryPhoneType
return this
}
@@ -222,6 +227,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun tertiaryPhoneType(customTertiaryPhoneType: String): InsertContactIntentBuilder {
+ tertiaryPhoneType = null
this.customTertiaryPhoneType = customTertiaryPhoneType
return this
}
@@ -247,6 +253,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun emailType(emailType: EmailAddressType): InsertContactIntentBuilder {
+ customEmailType = null
this.emailType = emailType
return this
}
@@ -259,6 +266,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun emailType(customEmailType: String): InsertContactIntentBuilder {
+ emailType = null
this.customEmailType = customEmailType
return this
}
@@ -294,6 +302,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun secondaryEmailType(secondaryEmailType: EmailAddressType): InsertContactIntentBuilder {
+ customSecondaryEmailType = null
this.secondaryEmailType = secondaryEmailType
return this
}
@@ -306,6 +315,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun secondaryEmailType(customSecondaryEmailType: String): InsertContactIntentBuilder {
+ secondaryEmailType = null
this.customSecondaryEmailType = customSecondaryEmailType
return this
}
@@ -331,6 +341,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun tertiaryEmailType(tertiaryEmailType: EmailAddressType): InsertContactIntentBuilder {
+ customTertiaryEmailType = null
this.tertiaryEmailType = tertiaryEmailType
return this
}
@@ -343,6 +354,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* @return This InsertContactIntentBuilder for method chaining
*/
fun tertiaryEmailType(customTertiaryEmailType: String): InsertContactIntentBuilder {
+ tertiaryEmailType = null
this.customTertiaryEmailType = customTertiaryEmailType
return this
}
@@ -420,9 +432,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
}
}
- if (phoneIsPrimary) {
- putExtra(PHONE_ISPRIMARY, phoneIsPrimary)
- }
+ putExtra(PHONE_ISPRIMARY, phoneIsPrimary)
secondaryPhone?.let {
putExtra(SECONDARY_PHONE, it)
@@ -459,10 +469,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
putExtra(EMAIL_TYPE, it)
}
}
-
- if (emailIsPrimary) {
- putExtra(EMAIL_ISPRIMARY, emailIsPrimary)
- }
+ putExtra(EMAIL_ISPRIMARY, emailIsPrimary)
secondaryEmail?.let {
putExtra(SECONDARY_EMAIL, it)
@@ -496,9 +503,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
putExtra(POSTAL_TYPE, it)
}
- if (postalIsPrimary) {
- putExtra(POSTAL_ISPRIMARY, postalIsPrimary)
- }
+ putExtra(POSTAL_ISPRIMARY, postalIsPrimary)
}
}
From 3aa0866f7f223b318c3cc188e174ad3a6b865d18 Mon Sep 17 00:00:00 2001
From: just-d-a
Date: Fri, 9 Oct 2020 11:43:16 +0300
Subject: [PATCH 12/13] merge commits
---
.../omegaintentbuilder/builders/InsertContactIntentBuilder.kt | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
index 3a4b405..23e5abc 100644
--- a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
+++ b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
@@ -469,6 +469,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
putExtra(EMAIL_TYPE, it)
}
}
+
putExtra(EMAIL_ISPRIMARY, emailIsPrimary)
secondaryEmail?.let {
From 9bbb6d6cce5334a12944dd96e1cd6a7994e68c08 Mon Sep 17 00:00:00 2001
From: just-d-a
Date: Fri, 9 Oct 2020 12:34:33 +0300
Subject: [PATCH 13/13] change Boolean logic
---
.../builders/InsertContactIntentBuilder.kt | 33 ++++++++++++-------
.../omegaintentbuilder/MainActivity.java | 6 ++--
2 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
index 23e5abc..a2c7fa7 100644
--- a/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
+++ b/core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/InsertContactIntentBuilder.kt
@@ -17,7 +17,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
private var phone: String? = null
private var phoneType: PhoneType? = null
private var customPhoneType: String? = null
- private var phoneIsPrimary = false
+ private var phoneIsPrimary: Boolean? = null
private var secondaryPhone: String? = null
private var secondaryPhoneType: PhoneType? = null
private var customSecondaryPhoneType: String? = null
@@ -27,7 +27,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
private var email: String? = null
private var emailType: EmailAddressType? = null
private var customEmailType: String? = null
- private var emailIsPrimary = false
+ private var emailIsPrimary: Boolean? = null
private var secondaryEmail: String? = null
private var secondaryEmailType: EmailAddressType? = null
private var customSecondaryEmailType: String? = null
@@ -36,7 +36,7 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
private var customTertiaryEmailType: String? = null
private var postal: String? = null
private var postalType: String? = null
- private var postalIsPrimary = false
+ private var postalIsPrimary: Boolean? = null
/**
* Set the extra field for the contact name.
@@ -147,10 +147,11 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
* Set the field for the phone isprimary flag.
*
Type: boolean
*
+ * @param phoneIsPrimary Boolean
* @return This InsertContactIntentBuilder for method chaining
*/
- fun phoneIsPrimary(): InsertContactIntentBuilder {
- this.phoneIsPrimary = true
+ fun phoneIsPrimary(phoneIsPrimary: Boolean): InsertContactIntentBuilder {
+ this.phoneIsPrimary = phoneIsPrimary
return this
}
@@ -274,10 +275,11 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
/**
* Set the field for the email isprimary flag.
*
+ * @param emailIsPrimary Boolean
* @return This InsertContactIntentBuilder for method chaining
*/
- fun emailIsPrimary(): InsertContactIntentBuilder {
- this.emailIsPrimary = true
+ fun emailIsPrimary(emailIsPrimary: Boolean): InsertContactIntentBuilder {
+ this.emailIsPrimary = emailIsPrimary
return this
}
@@ -385,10 +387,11 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
/**
* Set the extra field for the postal isprimary flag.
*
+ * @param postalIsPrimary Boolean
* @return This InsertContactIntentBuilder for method chaining
*/
- fun postalIsPrimary(): InsertContactIntentBuilder {
- this.postalIsPrimary = true
+ fun postalIsPrimary(postalIsPrimary: Boolean): InsertContactIntentBuilder {
+ this.postalIsPrimary = postalIsPrimary
return this
}
@@ -432,7 +435,9 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
}
}
- putExtra(PHONE_ISPRIMARY, phoneIsPrimary)
+ phoneIsPrimary?.let {
+ putExtra(PHONE_ISPRIMARY, it)
+ }
secondaryPhone?.let {
putExtra(SECONDARY_PHONE, it)
@@ -470,7 +475,9 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
}
}
- putExtra(EMAIL_ISPRIMARY, emailIsPrimary)
+ emailIsPrimary?.let {
+ putExtra(EMAIL_ISPRIMARY, it)
+ }
secondaryEmail?.let {
putExtra(SECONDARY_EMAIL, it)
@@ -504,7 +511,9 @@ class InsertContactIntentBuilder : BaseActivityBuilder() {
putExtra(POSTAL_TYPE, it)
}
- putExtra(POSTAL_ISPRIMARY, postalIsPrimary)
+ postalIsPrimary?.let {
+ putExtra(POSTAL_ISPRIMARY, it)
+ }
}
}
diff --git a/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java b/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java
index e5a78eb..a2a4b4d 100644
--- a/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java
+++ b/examples/src/main/java/com/omega_r/omegaintentbuilder/MainActivity.java
@@ -257,21 +257,21 @@ private void onInsertContactClicked() {
.notes("notes")
.phone("88000000008")
.phoneType(PhoneType.TYPE_HOME)
- .phoneIsPrimary()
+ .phoneIsPrimary(true)
.secondaryPhone("88000001008")
.secondaryPhoneType("YOUR_CUSTOM_TYPE")
.tertiaryPhone("888888888")
.tertiaryPhoneType(PhoneType.TYPE_WORK_MOBILE)
.email("develop@omega-r.com")
.emailType(EmailAddressType.TYPE_HOME)
- .emailIsPrimary()
+ .emailIsPrimary(false)
.secondaryEmail("secondaryEmail")
.secondaryEmailType(EmailAddressType.TYPE_WORK)
.tertiaryEmail("tertiaryEmail")
.tertiaryEmailType("YOUR_CUSTOM_EMAIL_TYPE")
.postal("postal")
.postalType("Home")
- .postalIsPrimary()
+ .postalIsPrimary(true)
.createIntentHandler(this)
.startActivity();
}