File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
WooCommerce/src/main/kotlin/com/woocommerce/android/util Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.woocommerce.android.util
2
+
3
+ import android.content.Context
4
+ import androidx.annotation.StringRes
5
+ import com.woocommerce.android.R
6
+
7
+ private const val WHATSAPP_PACKAGE_NAME = " com.whatsapp"
8
+ private const val TELEGRAM_PACKAGE_NAME = " org.telegram.messenger"
9
+
10
+ fun Context.getAvailablePhoneContactOptions (): List <PhoneContactOption > {
11
+ return buildList {
12
+ add(PhoneContactOption .CALL )
13
+ add(PhoneContactOption .SMS )
14
+ if (ActivityUtils .isAppInstalled(this @getAvailablePhoneContactOptions, WHATSAPP_PACKAGE_NAME )) {
15
+ add(PhoneContactOption .WHATSAPP )
16
+ }
17
+ if (ActivityUtils .isAppInstalled(this @getAvailablePhoneContactOptions, TELEGRAM_PACKAGE_NAME )) {
18
+ add(PhoneContactOption .TELEGRAM )
19
+ }
20
+ }
21
+ }
22
+
23
+ enum class PhoneContactOption {
24
+ CALL , SMS , WHATSAPP , TELEGRAM
25
+ }
26
+
27
+ val PhoneContactOption .stringRes: Int
28
+ @StringRes get() = when (this ) {
29
+ PhoneContactOption .CALL -> R .string.orderdetail_call_customer
30
+ PhoneContactOption .SMS -> R .string.orderdetail_message_customer
31
+ PhoneContactOption .WHATSAPP -> R .string.orderdetail_message_customer_using_whatsapp
32
+ PhoneContactOption .TELEGRAM -> R .string.orderdetail_message_customer_using_telegram
33
+ }
You can’t perform that action at this time.
0 commit comments