11package com.goodwy.contacts.activities
22
33import android.app.Activity
4+ import android.content.Context
45import android.content.Intent
56import android.graphics.Bitmap
67import android.graphics.Canvas
@@ -178,95 +179,7 @@ abstract class ContactActivity : SimpleActivity() {
178179 }
179180 }
180181
181- fun getEmailTypeText (type : Int , label : String ): String {
182- return if (type == BaseTypes .TYPE_CUSTOM ) {
183- label
184- } else {
185- getString(
186- when (type) {
187- Email .TYPE_HOME -> com.goodwy.commons.R .string.home
188- Email .TYPE_WORK -> com.goodwy.commons.R .string.work
189- Email .TYPE_MOBILE -> com.goodwy.commons.R .string.mobile
190- else -> com.goodwy.commons.R .string.other
191- }
192- )
193- }
194- }
195-
196- fun getRelationTypeText (type : Int , label : String ): String {
197- return if (type == BaseTypes .TYPE_CUSTOM ) {
198- label
199- } else {
200- getString(
201- when (type) {
202- // Relation.TYPE_CUSTOM -> com.goodwy.strings.R.string.custom
203- Relation .TYPE_ASSISTANT -> com.goodwy.strings.R .string.relation_assistant_g
204- Relation .TYPE_BROTHER -> com.goodwy.strings.R .string.relation_brother_g
205- Relation .TYPE_CHILD -> com.goodwy.strings.R .string.relation_child_g
206- Relation .TYPE_DOMESTIC_PARTNER -> com.goodwy.strings.R .string.relation_domestic_partner_g
207- Relation .TYPE_FATHER -> com.goodwy.strings.R .string.relation_father_g
208- Relation .TYPE_FRIEND -> com.goodwy.strings.R .string.relation_friend_g
209- Relation .TYPE_MANAGER -> com.goodwy.strings.R .string.relation_manager_g
210- Relation .TYPE_MOTHER -> com.goodwy.strings.R .string.relation_mother_g
211- Relation .TYPE_PARENT -> com.goodwy.strings.R .string.relation_parent_g
212- Relation .TYPE_PARTNER -> com.goodwy.strings.R .string.relation_partner_g
213- Relation .TYPE_REFERRED_BY -> com.goodwy.strings.R .string.relation_referred_by_g
214- Relation .TYPE_RELATIVE -> com.goodwy.strings.R .string.relation_relative_g
215- Relation .TYPE_SISTER -> com.goodwy.strings.R .string.relation_sister_g
216- Relation .TYPE_SPOUSE -> com.goodwy.strings.R .string.relation_spouse_g
217-
218- // Relation types defined in vCard 4.0
219- ContactRelation .TYPE_CONTACT -> com.goodwy.strings.R .string.relation_contact_g
220- ContactRelation .TYPE_ACQUAINTANCE -> com.goodwy.strings.R .string.relation_acquaintance_g
221- // ContactRelation.TYPE_FRIEND -> com.goodwy.strings.R.string.relation_friend
222- ContactRelation .TYPE_MET -> com.goodwy.strings.R .string.relation_met_g
223- ContactRelation .TYPE_CO_WORKER -> com.goodwy.strings.R .string.relation_co_worker_g
224- ContactRelation .TYPE_COLLEAGUE -> com.goodwy.strings.R .string.relation_colleague_g
225- ContactRelation .TYPE_CO_RESIDENT -> com.goodwy.strings.R .string.relation_co_resident_g
226- ContactRelation .TYPE_NEIGHBOR -> com.goodwy.strings.R .string.relation_neighbor_g
227- // ContactRelation.TYPE_CHILD -> com.goodwy.strings.R.string.relation_child
228- // ContactRelation.TYPE_PARENT -> com.goodwy.strings.R.string.relation_parent
229- ContactRelation .TYPE_SIBLING -> com.goodwy.strings.R .string.relation_sibling_g
230- // ContactRelation.TYPE_SPOUSE -> com.goodwy.strings.R.string.relation_spouse
231- ContactRelation .TYPE_KIN -> com.goodwy.strings.R .string.relation_kin_g
232- ContactRelation .TYPE_MUSE -> com.goodwy.strings.R .string.relation_muse_g
233- ContactRelation .TYPE_CRUSH -> com.goodwy.strings.R .string.relation_crush_g
234- ContactRelation .TYPE_DATE -> com.goodwy.strings.R .string.relation_date_g
235- ContactRelation .TYPE_SWEETHEART -> com.goodwy.strings.R .string.relation_sweetheart_g
236- ContactRelation .TYPE_ME -> com.goodwy.strings.R .string.relation_me_g
237- ContactRelation .TYPE_AGENT -> com.goodwy.strings.R .string.relation_agent_g
238- ContactRelation .TYPE_EMERGENCY -> com.goodwy.strings.R .string.relation_emergency_g
239-
240- ContactRelation .TYPE_SUPERIOR -> com.goodwy.strings.R .string.relation_superior_g
241- ContactRelation .TYPE_SUBORDINATE -> com.goodwy.strings.R .string.relation_subordinate_g
242- ContactRelation .TYPE_HUSBAND -> com.goodwy.strings.R .string.relation_husband_g
243- ContactRelation .TYPE_WIFE -> com.goodwy.strings.R .string.relation_wife_g
244- ContactRelation .TYPE_SON -> com.goodwy.strings.R .string.relation_son_g
245- ContactRelation .TYPE_DAUGHTER -> com.goodwy.strings.R .string.relation_daughter_g
246- ContactRelation .TYPE_GRANDPARENT -> com.goodwy.strings.R .string.relation_grandparent_g
247- ContactRelation .TYPE_GRANDFATHER -> com.goodwy.strings.R .string.relation_grandfather_g
248- ContactRelation .TYPE_GRANDMOTHER -> com.goodwy.strings.R .string.relation_grandmother_g
249- ContactRelation .TYPE_GRANDCHILD -> com.goodwy.strings.R .string.relation_grandchild_g
250- ContactRelation .TYPE_GRANDSON -> com.goodwy.strings.R .string.relation_grandson_g
251- ContactRelation .TYPE_GRANDDAUGHTER -> com.goodwy.strings.R .string.relation_granddaughter_g
252- ContactRelation .TYPE_UNCLE -> com.goodwy.strings.R .string.relation_uncle_g
253- ContactRelation .TYPE_AUNT -> com.goodwy.strings.R .string.relation_aunt_g
254- ContactRelation .TYPE_NEPHEW -> com.goodwy.strings.R .string.relation_nephew_g
255- ContactRelation .TYPE_NIECE -> com.goodwy.strings.R .string.relation_niece_g
256- ContactRelation .TYPE_FATHER_IN_LAW -> com.goodwy.strings.R .string.relation_father_in_law_g
257- ContactRelation .TYPE_MOTHER_IN_LAW -> com.goodwy.strings.R .string.relation_mother_in_law_g
258- ContactRelation .TYPE_SON_IN_LAW -> com.goodwy.strings.R .string.relation_son_in_law_g
259- ContactRelation .TYPE_DAUGHTER_IN_LAW -> com.goodwy.strings.R .string.relation_daughter_in_law_g
260- ContactRelation .TYPE_BROTHER_IN_LAW -> com.goodwy.strings.R .string.relation_brother_in_law_g
261- ContactRelation .TYPE_SISTER_IN_LAW -> com.goodwy.strings.R .string.relation_sister_in_law_g
262-
263- else -> com.goodwy.commons.R .string.other
264- }
265- )
266- }
267- }
268-
269- fun getAddressTypeText (type : Int , label : String ): String {
182+ fun Context.getAddressTypeText (type : Int , label : String ): String {
270183 return if (type == BaseTypes .TYPE_CUSTOM ) {
271184 label
272185 } else {
@@ -280,7 +193,7 @@ abstract class ContactActivity : SimpleActivity() {
280193 }
281194 }
282195
283- fun getIMTypeText (type : Int , label : String ): String {
196+ fun Context. getIMTypeText (type : Int , label : String ): String {
284197 return if (type == Im .PROTOCOL_CUSTOM ) {
285198 label
286199 } else {
@@ -299,12 +212,6 @@ abstract class ContactActivity : SimpleActivity() {
299212 }
300213 }
301214
302- fun getEventTextId (type : Int ) = when (type) {
303- Event .TYPE_ANNIVERSARY -> com.goodwy.commons.R .string.anniversary
304- Event .TYPE_BIRTHDAY -> com.goodwy.commons.R .string.birthday
305- else -> com.goodwy.commons.R .string.other
306- }
307-
308215 protected fun getDefaultRingtoneUri () = RingtoneManager .getDefaultUri(RingtoneManager .TYPE_RINGTONE )
309216
310217 protected fun getRingtonePickerIntent (): Intent {
0 commit comments