Skip to content

Commit

Permalink
Merge pull request #157 from salemove/prelive
Browse files Browse the repository at this point in the history
Prelive
  • Loading branch information
dukhovnyi authored Dec 17, 2021
2 parents d14daa4 + fae6a94 commit 9760341
Show file tree
Hide file tree
Showing 27 changed files with 132 additions and 543 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/glia/exampleapp/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static UiTheme getUiThemeByPrefs(SharedPreferences sharedPreferences, Res
Integer baseShadeColor = getColorValueFromPrefs(R.string.pref_base_shade_color, sharedPreferences, resources);
Integer brandPrimaryColor = getColorValueFromPrefs(R.string.pref_brand_primary_color, sharedPreferences, resources);
Integer systemAgentBubbleColor = getColorValueFromPrefs(R.string.pref_system_agent_bubble_color, sharedPreferences, resources);
Integer chatSendMessageButtonTintColor = getColorValueFromPrefs(R.string.pref_send_message_button_tint_color, sharedPreferences, resources);
Integer chatHeaderTitleTintColor = getColorValueFromPrefs(R.string.pref_chat_header_title_tint_color, sharedPreferences, resources);
Integer chatHeaderHomeButtonTintColor = getColorValueFromPrefs(R.string.pref_chat_header_home_button_tint_color, sharedPreferences, resources);
Integer chatHeaderExitQueueButtonTintColor = getColorValueFromPrefs(R.string.pref_chat_header_exit_queue_button_tint_color, sharedPreferences, resources);
Expand Down Expand Up @@ -85,6 +86,8 @@ public static UiTheme getUiThemeByPrefs(SharedPreferences sharedPreferences, Res
builder.setNegativeButtonConfiguration(null);
builder.setNeutralButtonConfiguration(null);

builder.setSendMessageButtonTintColor(chatSendMessageButtonTintColor);

builder.setGliaChatHeaderTitleTintColor(chatHeaderTitleTintColor);
builder.setGliaChatHeaderHomeButtonTintColor(chatHeaderHomeButtonTintColor);
builder.setGliaChatHeaderExitQueueButtonTintColor(chatHeaderExitQueueButtonTintColor);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<string name="pref_chat_starting_caption_text_color">chat_starting_caption_text_color</string>
<string name="pref_chat_started_heading_text_color">chat_started_heading_text_color</string>
<string name="pref_chat_started_caption_text_color">chat_started_caption_text_color</string>
<string name="pref_send_message_button_tint_color">send_message_button_tint_color</string>
<string name="default_value">default</string>
<string name="color_blue_value">blue</string>
<string name="color_grey_value">grey</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string name="settings_chat_starting_caption_text_color">Operator Layout Connecting Caption Color</string>
<string name="settings_chat_started_heading_text_color">Operator Layout Connected Heading Color</string>
<string name="settings_chat_started_caption_text_color">Operator Layout Connected Caption Color</string>
<string name="settings_send_message_button_tint_color">Send message button tint color</string>
<string name="settings_colors_title">Colors</string>
<string name="settings_sdk_title">Sdk settings</string>
<string name="settings_typography">Typography</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</style>

<style name="ThemeOverlay.GliaAndroidSDKWidgetsExample.Chat" parent="ThemeOverlay.Glia.Chat">
<item name="gliaSendMessageButtonTintColor">@color/color_pure_yellow</item>
<item name="gliaIconAppBarBack">@drawable/ic_baseline_volume_off</item>
<item name="gliaIconCallMinimize">@drawable/ic_person</item>
<item name="gliaHeaderEndButtonStyle">
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@
android:key="@string/pref_bot_action_button_selected_txt_color"
android:title="@string/settings_chat_bot_action_button_selected_txt_color"
app:useSimpleSummaryProvider="true" />

<ListPreference
android:defaultValue="@string/default_value"
android:entries="@array/colors"
android:entryValues="@array/color_values"
android:key="@string/pref_send_message_button_tint_color"
android:title="@string/settings_send_message_button_tint_color"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>

<PreferenceCategory app:title="@string/settings_operator_layout_styling">
Expand Down
9 changes: 4 additions & 5 deletions widgetssdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 24
targetSdkVersion 30
versionCode 21
versionName "1.6.16"
versionCode 22
versionName "1.6.17"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down Expand Up @@ -57,7 +57,6 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:$androidXTestVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso"
implementation "com.squareup.picasso:picasso:$picassoVersion"
implementation "androidx.browser:browser:1.3.0"

// Used for audio and video permissions by CallActivity
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
Expand All @@ -68,7 +67,7 @@ dependencies {
// debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"

// Replaced with a local AAR file
implementation "com.glia:android-sdk:$gliaSdkVersion"
api "com.glia:android-sdk:$gliaSdkVersion"
// Glia sdk aar
// implementation(name: "glia-core-sdk-$gliaSdkVersion", ext: 'aar')

Expand All @@ -87,4 +86,4 @@ ext {
PUBLISH_ORGANISATION_URL = 'https://www.glia.com/'
}

apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
16 changes: 0 additions & 16 deletions widgetssdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
android:maxSdkVersion="28" />

<application>
<activity
android:name=".urlwebview.OperatorLinksActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/Application.Glia.Chat.Activity" />
<activity
android:name=".chat.ChatActivity"
android:launchMode="singleTask"
Expand Down Expand Up @@ -61,15 +56,4 @@
android:resource="@xml/file_provider" />
</provider>
</application>

<queries>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="*" />
</intent>
</queries>

</manifest>
6 changes: 0 additions & 6 deletions widgetssdk/src/main/java/com/glia/widgets/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ public class Constants {
* Used by the sdk to differentiate between CHAT and CALL and IMAGE_PREVIEW activities.
*/
public static final String IMAGE_PREVIEW_ACTIVITY = "image_preview_activity";
/**
* Used by the sdk to differentiate between CHAT and CALL and URL_WEB_VIEW_ACTIVITY activities.
*/
public static final String URL_WEB_VIEW_ACTIVITY = "url_web_view";
/**
* Global media timer delay value
*/
Expand All @@ -25,6 +21,4 @@ public class Constants {
* Global media timer interval value
*/
public static final int CALL_TIMER_INTERVAL_VALUE = 1000;

public static final String PHONE_NUMBER_REGEX = "^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\./0-9]*$";
}
31 changes: 31 additions & 0 deletions widgetssdk/src/main/java/com/glia/widgets/UiTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public class UiTheme implements Parcelable {
*/
private @ColorRes
final Integer botActionButtonSelectedTextColor;
/**
* Color for Chat Send message Button
*/
private @ColorRes
final Integer sendMessageButtonTintColor;
/**
* Color for Chat Header title
*/
Expand Down Expand Up @@ -250,6 +255,7 @@ private UiTheme(UiThemeBuilder builder) {
this.botActionButtonTextColor = builder.botActionButtonTextColor;
this.botActionButtonSelectedBackgroundColor = builder.botActionButtonSelectedBackgroundColor;
this.botActionButtonSelectedTextColor = builder.botActionButtonSelectedTextColor;
this.sendMessageButtonTintColor = builder.sendMessageButtonTintColor;
this.gliaChatHeaderTitleTintColor = builder.gliaChatHeaderTitleTintColor;
this.gliaChatHeaderHomeButtonTintColor = builder.gliaChatHomeButtonTintColor;
this.gliaChatHeaderExitQueueButtonTintColor = builder.gliaChatHeaderExitQueueButtonTintColor;
Expand Down Expand Up @@ -364,6 +370,11 @@ public static class UiThemeBuilder {
*/
private @ColorRes
Integer botActionButtonSelectedTextColor;
/**
* Color for Send message Button
*/
private @ColorRes
Integer sendMessageButtonTintColor;
/**
* Color for Chat Header Title
*/
Expand Down Expand Up @@ -679,6 +690,10 @@ public void setNeutralButtonConfiguration(ButtonConfiguration configuration) {
this.neutralButtonConfiguration = configuration;
}

public void setSendMessageButtonTintColor(Integer color) {
this.sendMessageButtonTintColor = color;
}

public void setGliaChatHeaderTitleTintColor(Integer color) {
this.gliaChatHeaderTitleTintColor = color;
}
Expand Down Expand Up @@ -751,6 +766,7 @@ public void setTheme(UiTheme theme) {
this.positiveButtonConfiguration = theme.positiveButtonConfiguration;
this.negativeButtonConfiguration = theme.negativeButtonConfiguration;
this.neutralButtonConfiguration = theme.neutralButtonConfiguration;
this.sendMessageButtonTintColor = theme.sendMessageButtonTintColor;
this.gliaChatHeaderTitleTintColor = theme.gliaChatHeaderTitleTintColor;
this.gliaChatHomeButtonTintColor = theme.gliaChatHeaderHomeButtonTintColor;
this.gliaChatHeaderExitQueueButtonTintColor = theme.gliaChatHeaderExitQueueButtonTintColor;
Expand Down Expand Up @@ -843,6 +859,11 @@ protected UiTheme(Parcel in) {
} else {
botActionButtonSelectedTextColor = in.readInt();
}
if (in.readByte() == 0) {
sendMessageButtonTintColor = null;
} else {
sendMessageButtonTintColor = in.readInt();
}
if (in.readByte() == 0) {
gliaChatHeaderTitleTintColor = null;
} else {
Expand Down Expand Up @@ -1072,6 +1093,12 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeByte((byte) 1);
dest.writeInt(botActionButtonSelectedTextColor);
}
if (sendMessageButtonTintColor == null) {
dest.writeByte((byte) 0);
} else {
dest.writeByte((byte) 1);
dest.writeInt(sendMessageButtonTintColor);
}
if (gliaChatHeaderTitleTintColor == null) {
dest.writeByte((byte) 0);
} else {
Expand Down Expand Up @@ -1316,6 +1343,10 @@ public Integer getBotActionButtonSelectedTextColor() {
return botActionButtonSelectedTextColor;
}

public Integer getSendMessageButtonTintColor() {
return sendMessageButtonTintColor;
}

public Integer getGliaChatHeaderTitleTintColor() {
return gliaChatHeaderTitleTintColor;
}
Expand Down
61 changes: 4 additions & 57 deletions widgetssdk/src/main/java/com/glia/widgets/chat/ChatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.Cursor;
Expand All @@ -24,7 +25,6 @@
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Patterns;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
Expand All @@ -48,13 +48,11 @@
import com.airbnb.lottie.LottieProperty;
import com.airbnb.lottie.model.KeyPath;
import com.glia.androidsdk.chat.AttachmentFile;
import com.glia.widgets.Constants;
import com.glia.widgets.R;
import com.glia.widgets.UiTheme;
import com.glia.widgets.chat.adapter.ChatAdapter;
import com.glia.widgets.chat.adapter.UploadAttachmentAdapter;
import com.glia.widgets.chat.controller.ChatController;
import com.glia.widgets.chat.helper.CustomTabActivityHelper;
import com.glia.widgets.chat.helper.FileHelper;
import com.glia.widgets.chat.model.ChatInputMode;
import com.glia.widgets.chat.model.ChatState;
Expand All @@ -70,15 +68,14 @@
import com.glia.widgets.filepreview.ui.FilePreviewActivity;
import com.glia.widgets.helper.Logger;
import com.glia.widgets.helper.Utils;
import com.glia.widgets.urlwebview.OperatorLinksActivity;
import com.glia.widgets.view.header.AppBarView;
import com.glia.widgets.view.DialogOfferType;
import com.glia.widgets.view.Dialogs;
import com.glia.widgets.view.OperatorStatusView;
import com.glia.widgets.view.SingleChoiceCardView;
import com.glia.widgets.view.head.ChatHeadService;
import com.glia.widgets.view.head.ChatHeadsController;
import com.glia.widgets.view.head.model.ChatHeadInput;
import com.glia.widgets.view.header.AppBarView;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.shape.MarkerEdgeTreatment;
import com.google.android.material.shape.ShapeAppearanceModel;
Expand All @@ -87,18 +84,16 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class ChatView extends ConstraintLayout implements ChatAdapter.OnFileItemClickListener, ChatAdapter.OnImageItemClickListener, ChatAdapter.OnTextClickListener {
public class ChatView extends ConstraintLayout implements ChatAdapter.OnFileItemClickListener, ChatAdapter.OnImageItemClickListener {

private final static String TAG = "ChatView";
private AlertDialog alertDialog;

private ChatViewCallback callback;
private ChatController controller;
private ChatHeadsController chatHeadsController;
private CustomTabActivityHelper customTabActivityHelper;

private DialogController.Callback dialogCallback;
private DialogController dialogController;
Expand Down Expand Up @@ -401,13 +396,8 @@ public void onDestroyView() {
}
}

public void onStart() {
customTabActivityHelper.bindCustomTabsService((Utils.getActivity(this.getContext())));
}

public void onStop() {
controller.onStop();
customTabActivityHelper.unbindCustomTabsService((Utils.getActivity(this.getContext())));
}

/**
Expand Down Expand Up @@ -634,10 +624,6 @@ public void fileDownloadSuccess(AttachmentFile attachmentFile) {
screenSharingController = Dependencies
.getControllerFactory()
.getScreenSharingController(screenSharingCallback);

if (customTabActivityHelper == null) {
customTabActivityHelper = new CustomTabActivityHelper();
}
}

private void updateChatEditText(ChatState chatState) {
Expand Down Expand Up @@ -811,7 +797,6 @@ private void setupViewAppearance() {
this.onImageLoadedListener,
this,
this,
this,
Dependencies.getUseCaseFactory().createGetImageFileFromCacheUseCase(),
Dependencies.getUseCaseFactory().createGetImageFileFromDownloadsUseCase(),
Dependencies.getUseCaseFactory().createGetImageFileFromNetworkUseCase()
Expand Down Expand Up @@ -864,7 +849,7 @@ public void onItemRangeInserted(int positionStart, int itemCount) {
sendButton.setImageTintList(
ContextCompat.getColorStateList(
this.getContext(),
this.theme.getBrandPrimaryColor()));
this.theme.getSendMessageButtonTintColor()));
chatEditText.setTextColor(ContextCompat.getColor(
this.getContext(), this.theme.getBaseDarkColor()));
chatEditText.setHintTextColor(ContextCompat.getColor(
Expand Down Expand Up @@ -1384,44 +1369,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
}
}

@Override
public void onTextClick(String text) {
Activity activity = Utils.getActivity(this.getContext());

if (Patterns.WEB_URL.matcher(text).matches()) {
if (CustomTabActivityHelper.hasSupportedBrowser(activity)) {
int primaryColor = ContextCompat.getColor(this.getContext(), theme.getBrandPrimaryColor());
int baseLightColor = ContextCompat.getColor(this.getContext(), theme.getBaseLightColor());

CustomTabActivityHelper.openCustomTab(activity, text, primaryColor, baseLightColor);
} else {
activity.startActivity(OperatorLinksActivity.intent(activity, text, theme));
}
} else if (Patterns.EMAIL_ADDRESS.matcher(text).matches()) {
composeEmail(text, activity);
} else if (Pattern.matches(Constants.PHONE_NUMBER_REGEX, text)) {
composeCall(text, activity);
}
}

public void composeEmail(String email, Activity activity) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email.trim()});
intent.setData(Uri.parse("mailto:"));

if (intent.resolveActivity(activity.getPackageManager()) != null) {
activity.startActivity(intent);
} else {
Toast.makeText(activity, activity.getString(R.string.glia_chat_no_email_app_msg), Toast.LENGTH_SHORT).show();
}
}

public void composeCall(String phoneNumber, Activity activity) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + phoneNumber));
activity.startActivity(intent);
}

public interface OnBackClickedListener {
/**
* Callback which is used to notify the enclosing activity or fragment when the user
Expand Down
Loading

0 comments on commit 9760341

Please sign in to comment.