Skip to content

Commit a2b8b13

Browse files
Merge pull request #57 from cometchat-pro/dev
v1.0.1
2 parents 826ee4f + e636db8 commit a2b8b13

14 files changed

Lines changed: 521 additions & 5 deletions

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ android {
99
applicationId "com.cometchat.javasampleapp"
1010
minSdk 21
1111
targetSdk 33
12-
versionCode 1
13-
versionName "1.0.0"
12+
versionCode 2
13+
versionName "1.0.1"
1414

1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
manifestPlaceholders = [file_provider: "com.cometchat.javasampleapp"]

app/src/main/java/com/cometchat/javasampleapp/activity/ComponentLaunchActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
import com.cometchat.javasampleapp.fragments.shared.views.AudioBubbleFragment;
3737
import com.cometchat.javasampleapp.fragments.shared.views.AvatarFragment;
3838
import com.cometchat.javasampleapp.fragments.shared.views.BadgeCountFragment;
39+
import com.cometchat.javasampleapp.fragments.shared.views.CardBubbleFragment;
3940
import com.cometchat.javasampleapp.fragments.shared.views.FileBubbleFragment;
41+
import com.cometchat.javasampleapp.fragments.shared.views.FormBubbleFragment;
4042
import com.cometchat.javasampleapp.fragments.shared.views.ImageBubbleFragment;
4143
import com.cometchat.javasampleapp.fragments.shared.views.ListItemFragment;
4244
import com.cometchat.javasampleapp.fragments.shared.views.MediaRecorderFragment;
@@ -121,6 +123,10 @@ protected void onCreate(Bundle savedInstanceState) {
121123
loadFragment(new AudioBubbleFragment());
122124
} else if (id == R.id.files_bubble) {
123125
loadFragment(new FileBubbleFragment());
126+
}else if (id == R.id.form_bubble) {
127+
loadFragment(new FormBubbleFragment());
128+
}else if (id == R.id.card_bubble) {
129+
loadFragment(new CardBubbleFragment());
124130
} else if (id == R.id.media_recorder) {
125131
loadFragment(new MediaRecorderFragment());
126132
} else if (id == R.id.contacts) {

app/src/main/java/com/cometchat/javasampleapp/activity/ComponentListActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ protected void onCreate(Bundle savedInstanceState) {
8787
findViewById(R.id.video_bubble).setOnClickListener(view -> handleIntent(R.id.video_bubble));
8888
findViewById(R.id.audio_bubble).setOnClickListener(view -> handleIntent(R.id.audio_bubble));
8989
findViewById(R.id.files_bubble).setOnClickListener(view -> handleIntent(R.id.files_bubble));
90+
findViewById(R.id.form_bubble).setOnClickListener(view -> handleIntent(R.id.form_bubble));
91+
findViewById(R.id.card_bubble).setOnClickListener(view -> handleIntent(R.id.card_bubble));
9092
findViewById(R.id.media_recorder).setOnClickListener(view -> handleIntent(R.id.media_recorder));
9193

9294
//resources
@@ -130,6 +132,8 @@ private void setUpUI() {
130132
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_video_bubble));
131133
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_audio_bubble));
132134
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_file_bubble));
135+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_form_bubble));
136+
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_card_bubble));
133137
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_mic));
134138
AppUtils.changeIconTintToWhite(this,findViewById(R.id.image_list_item));
135139
Utils.setStatusBarColor(this, ContextCompat.getColor(this,R.color.app_background_dark));
@@ -168,6 +172,8 @@ private void setUpUI() {
168172
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_video_bubble));
169173
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_audio_bubble));
170174
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_file_bubble));
175+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_form_bubble));
176+
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_card_bubble));
171177
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_mic));
172178
AppUtils.changeIconTintToBlack(this,findViewById(R.id.image_list_item));
173179
Utils.setStatusBarColor(this, getResources().getColor(R.color.app_background));
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package com.cometchat.javasampleapp.fragments.shared.views;
2+
3+
import android.os.Bundle;
4+
5+
import androidx.fragment.app.Fragment;
6+
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
import android.widget.LinearLayout;
11+
import android.widget.ScrollView;
12+
13+
import com.cometchat.chatuikit.shared.cometchatuikit.CometChatUIKit;
14+
import com.cometchat.chatuikit.shared.constants.UIKitConstants;
15+
import com.cometchat.chatuikit.shared.models.interactiveactions.APIAction;
16+
import com.cometchat.chatuikit.shared.models.interactiveactions.URLNavigationAction;
17+
import com.cometchat.chatuikit.shared.models.interactiveelements.BaseInteractiveElement;
18+
import com.cometchat.chatuikit.shared.models.interactiveelements.ButtonElement;
19+
import com.cometchat.chatuikit.shared.models.interactivemessage.CardMessage;
20+
import com.cometchat.chatuikit.shared.resources.theme.CometChatTheme;
21+
import com.cometchat.chatuikit.shared.views.CometChatCardBubble.CardBubbleStyle;
22+
import com.cometchat.chatuikit.shared.views.CometChatCardBubble.CometChatCardBubble;
23+
import com.cometchat.chatuikit.shared.views.CometChatImageBubble.ImageBubbleStyle;
24+
import com.cometchat.javasampleapp.AppConstants;
25+
import com.cometchat.javasampleapp.AppUtils;
26+
import com.cometchat.javasampleapp.R;
27+
28+
import org.json.JSONObject;
29+
30+
import java.util.ArrayList;
31+
import java.util.List;
32+
33+
public class CardBubbleFragment extends Fragment {
34+
35+
private LinearLayout parentLayout;
36+
private CometChatCardBubble cardBubble;
37+
private ScrollView scrollView;
38+
@Override
39+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
40+
Bundle savedInstanceState) {
41+
// Inflate the layout for this fragment
42+
View view = inflater.inflate(R.layout.fragment_card_bubble, container, false);
43+
parentLayout = view.findViewById(R.id.parent_layout);
44+
cardBubble = view.findViewById(R.id.card_bubble);
45+
scrollView = view.findViewById(R.id.scroll_view);
46+
scrollView.setVerticalScrollBarEnabled(false);
47+
CometChatTheme theme = CometChatTheme.getInstance(getContext());
48+
49+
//create style object for card bubble
50+
CardBubbleStyle cardBubbleStyle = new CardBubbleStyle()
51+
.setTextAppearance(theme.getTypography().getText1())
52+
.setTextColor(theme.getPalette().getAccent())
53+
.setContentBackgroundColor(theme.getPalette().getBackground())
54+
.setCornerRadius(16)
55+
.setProgressBarTintColor(theme.getPalette().getPrimary())
56+
.setButtonSeparatorColor(theme.getPalette().getAccent100())
57+
.setButtonBackgroundColor(theme.getPalette().getBackground())
58+
.setButtonTextColor(theme.getPalette().getPrimary())
59+
.setButtonDisableTextColor(theme.getPalette().getAccent500())
60+
.setButtonTextAppearance(theme.getTypography().getSubtitle1())
61+
.setBackground(theme.getPalette().getBackground())
62+
.setBackground(theme.getPalette().getGradientBackground())
63+
.setImageBubbleStyle(new ImageBubbleStyle()
64+
.setCornerRadius(16)
65+
);
66+
67+
cardBubble.setStyle(cardBubbleStyle);
68+
69+
//create list of interactive elements
70+
List<BaseInteractiveElement> elementEntities = new ArrayList<>();
71+
72+
URLNavigationAction urlNavigationAction = new URLNavigationAction("https://www.cometchat.com/");
73+
74+
ButtonElement buttonElement1 = new ButtonElement("element1", "Navigate", urlNavigationAction);
75+
buttonElement1.setDisableAfterInteracted(true);
76+
elementEntities.add(buttonElement1);
77+
78+
CardMessage cardMessage = new CardMessage(AppUtils.getDefaultUser() != null ? AppUtils.getDefaultUser().getUid() : AppUtils.getDefaultGroup() != null ? AppUtils.getDefaultGroup().getGuid() : null, AppUtils.getDefaultUser() != null ? UIKitConstants.ReceiverType.USER : UIKitConstants.ReceiverType.GROUP, null, elementEntities);
79+
cardMessage.setText("\uD83C\uDF1F Introducing our New Personalized Card Messages! \uD83C\uDF1F\n" + "\n" + "Want to make your gifts more special? Now it's easy with our personalized card messages! \uD83D\uDCAC✍️\n" + "\n" + "Our new feature lets you add a custom message on a beautifully designed card, making your gift-giving extra personal and memorable. Whether it's for a birthday \uD83C\uDF82, anniversary \uD83D\uDC8D, or just because \uD83C\uDF81, our card messages will express your feelings perfectly.\n" + "\n" + "To start creating your own card message:\n 1️⃣ Choose the gift \n2️⃣ Write your heartfelt message \n3️⃣ We'll print it on a high-quality card and include it with your gift\n" + "\n" + "\uD83D\uDCAB Add a touch of your own sentiments with our personalized card messages. Make every gift unforgettable. Start creating your card message today!\n" + "\n" + "Visit our website [Website Link] or download our app [App Link].\n" + "\n" + "Express more than just words with our Personalized Card Messages. Because it's not just a gift, it's your feelings. ❤️");
80+
cardMessage.setImageUrl("https://images.unsplash.com/photo-1608755728617-aefab37d2edd?q=80&w=3270&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D");
81+
cardMessage.setAllowSenderInteraction(true); // sender can interact with the card message
82+
83+
cardMessage.setSender(CometChatUIKit.getLoggedInUser());
84+
cardMessage.setSentAt(System.currentTimeMillis() / 1000);
85+
cardMessage.setReceiver(AppUtils.getDefaultUser() != null ? AppUtils.getDefaultUser() : AppUtils.getDefaultGroup() != null ? AppUtils.getDefaultGroup() : null);
86+
87+
cardBubble.setCardMessage(cardMessage);
88+
89+
return view;
90+
}
91+
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
package com.cometchat.javasampleapp.fragments.shared.views;
2+
3+
import android.os.Bundle;
4+
5+
import androidx.fragment.app.Fragment;
6+
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
import android.widget.LinearLayout;
11+
12+
import com.cometchat.chat.constants.CometChatConstants;
13+
import com.cometchat.chat.models.InteractionGoal;
14+
import com.cometchat.chatuikit.shared.cometchatuikit.CometChatUIKit;
15+
import com.cometchat.chatuikit.shared.constants.UIKitConstants;
16+
import com.cometchat.chatuikit.shared.models.interactiveactions.APIAction;
17+
import com.cometchat.chatuikit.shared.models.interactiveactions.URLNavigationAction;
18+
import com.cometchat.chatuikit.shared.models.interactiveelements.ButtonElement;
19+
import com.cometchat.chatuikit.shared.models.interactiveelements.CheckboxElement;
20+
import com.cometchat.chatuikit.shared.models.interactiveelements.ElementEntity;
21+
import com.cometchat.chatuikit.shared.models.interactiveelements.OptionElement;
22+
import com.cometchat.chatuikit.shared.models.interactiveelements.PlaceHolder;
23+
import com.cometchat.chatuikit.shared.models.interactiveelements.RadioButtonElement;
24+
import com.cometchat.chatuikit.shared.models.interactiveelements.SingleSelectElement;
25+
import com.cometchat.chatuikit.shared.models.interactiveelements.SpinnerElement;
26+
import com.cometchat.chatuikit.shared.models.interactiveelements.TextInputElement;
27+
import com.cometchat.chatuikit.shared.models.interactivemessage.FormMessage;
28+
import com.cometchat.chatuikit.shared.resources.theme.CometChatTheme;
29+
import com.cometchat.chatuikit.shared.views.CometChatFormbubble.CometChatFormBubble;
30+
import com.cometchat.chatuikit.shared.views.CometChatFormbubble.FormBubbleStyle;
31+
import com.cometchat.chatuikit.shared.views.CometChatSingleSelect.SingleSelectStyle;
32+
import com.cometchat.javasampleapp.AppConstants;
33+
import com.cometchat.javasampleapp.AppUtils;
34+
import com.cometchat.javasampleapp.R;
35+
36+
import org.json.JSONException;
37+
import org.json.JSONObject;
38+
39+
import java.util.ArrayList;
40+
import java.util.Arrays;
41+
import java.util.List;
42+
43+
public class FormBubbleFragment extends Fragment {
44+
private LinearLayout parentLayout;
45+
private CometChatFormBubble formBubble;
46+
47+
@Override
48+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
49+
Bundle savedInstanceState) {
50+
View view = inflater.inflate(R.layout.fragment_form_bubble, container, false);
51+
52+
parentLayout = view.findViewById(R.id.parent_layout);
53+
formBubble = view.findViewById(R.id.form_bubble);
54+
55+
56+
CometChatTheme theme = CometChatTheme.getInstance(getContext());
57+
//create style object for Form bubble
58+
FormBubbleStyle formBubbleStyle = new FormBubbleStyle()
59+
.setTitleAppearance(theme.getTypography().getHeading())
60+
.setTitleColor(theme.getPalette().getAccent())
61+
62+
.setLabelAppearance(theme.getTypography().getSubtitle1())
63+
.setLabelColor(theme.getPalette().getAccent())
64+
65+
.setInputTextAppearance(theme.getTypography().getSubtitle1())
66+
.setInputTextColor(theme.getPalette().getAccent())
67+
.setInputHintColor(theme.getPalette().getAccent500())
68+
.setErrorColor(theme.getPalette().getError())
69+
.setInputStrokeColor(theme.getPalette().getAccent600())
70+
.setActiveInputStrokeColor(theme.getPalette().getAccent())
71+
72+
.setDefaultCheckboxButtonTint(theme.getPalette().getAccent500())
73+
.setSelectedCheckboxButtonTint(theme.getPalette().getPrimary())
74+
.setErrorCheckboxButtonTint(theme.getPalette().getError())
75+
.setCheckboxTextColor(theme.getPalette().getAccent())
76+
.setCheckboxTextAppearance(theme.getTypography().getSubtitle1())
77+
78+
.setButtonBackgroundColor(theme.getPalette().getPrimary())
79+
.setButtonTextColor(theme.getPalette().getAccent900())
80+
.setButtonTextAppearance(theme.getTypography().getSubtitle1())
81+
.setProgressBarTintColor(theme.getPalette().getAccent900())
82+
.setRadioButtonTint(theme.getPalette().getAccent500())
83+
.setRadioButtonTextColor(theme.getPalette().getAccent())
84+
.setRadioButtonTextAppearance(theme.getTypography().getSubtitle1())
85+
.setSelectedRadioButtonTint(theme.getPalette().getPrimary())
86+
87+
.setSpinnerTextColor(theme.getPalette().getAccent())
88+
.setSpinnerTextAppearance(theme.getTypography().getSubtitle1())
89+
.setSpinnerBackgroundColor(theme.getPalette().getAccent500())
90+
91+
.setBackground(theme.getPalette().getBackground())
92+
.setBackground(theme.getPalette().getGradientBackground())
93+
94+
.setSingleSelectStyle(new SingleSelectStyle()
95+
.setOptionTextAppearance(theme.getTypography().getSubtitle1())
96+
.setOptionTextColor(theme.getPalette().getAccent500())
97+
.setSelectedOptionTextAppearance(theme.getTypography().getSubtitle1())
98+
.setSelectedOptionTextColor(theme.getPalette().getAccent())
99+
.setButtonStrokeColor(theme.getPalette().getAccent600())
100+
.setTitleColor(theme.getPalette().getAccent())
101+
.setTitleAppearance(theme.getTypography().getSubtitle1())
102+
);
103+
formBubble.setStyle(formBubbleStyle);
104+
105+
//create elements for form bubble
106+
List<ElementEntity> elementEntities = new ArrayList<>();
107+
TextInputElement textInputElement1 = new TextInputElement("element1", "Name");
108+
textInputElement1.setPlaceHolder(new PlaceHolder("write your name here"));
109+
110+
TextInputElement textInputElement2 = new TextInputElement("element2", "Last Name");
111+
TextInputElement textInputElement3 = new TextInputElement("element3", "Address");
112+
textInputElement3.setMaxLines(5);
113+
textInputElement1.setDefaultValue("vivek");
114+
elementEntities.add(textInputElement1);
115+
elementEntities.add(textInputElement2);
116+
elementEntities.add(textInputElement3);
117+
118+
List<OptionElement> optionElementList = new ArrayList<>();
119+
optionElementList.add(new OptionElement("option1", "INDIA"));
120+
optionElementList.add(new OptionElement("option2", "AUSTRALIA"));
121+
optionElementList.add(new OptionElement("option3", "RUSSIA"));
122+
optionElementList.add(new OptionElement("option4", "AMERICA"));
123+
SpinnerElement spinnerElement = new SpinnerElement("element4", "Country", optionElementList, "option1");
124+
elementEntities.add(spinnerElement);
125+
126+
127+
List<OptionElement> checkBox = new ArrayList<>();
128+
checkBox.add(new OptionElement("option1", "Garbage"));
129+
checkBox.add(new OptionElement("option2", "Electricity Bill"));
130+
checkBox.add(new OptionElement("option3", "Lift"));
131+
CheckboxElement checkboxElement = new CheckboxElement("element5", "Services", checkBox, new ArrayList<>(Arrays.asList("option1", "option2")));
132+
elementEntities.add(checkboxElement);
133+
134+
List<OptionElement> optionElementList2 = new ArrayList<>();
135+
optionElementList2.add(new OptionElement("option1", "A"));
136+
optionElementList2.add(new OptionElement("option2", "B"));
137+
138+
SingleSelectElement singleSelectElement = new SingleSelectElement("element6", "Wing", optionElementList2, "option1");
139+
elementEntities.add(singleSelectElement);
140+
141+
RadioButtonElement radioButtonElement = new RadioButtonElement("element7", "Country", optionElementList, "option1");
142+
elementEntities.add(radioButtonElement);
143+
144+
URLNavigationAction urlNavigationAction = new URLNavigationAction("https://www.cometchat.com/");
145+
ButtonElement submitButton = new ButtonElement("element9", "About us", urlNavigationAction);
146+
submitButton.setDisableAfterInteracted(true);
147+
elementEntities.add(submitButton);
148+
149+
FormMessage formMessage = new FormMessage(AppUtils.getDefaultUser() != null ? AppUtils.getDefaultUser().getUid() : AppUtils.getDefaultGroup() != null ? AppUtils.getDefaultGroup().getGuid() : null, AppUtils.getDefaultUser() != null ? UIKitConstants.ReceiverType.USER : UIKitConstants.ReceiverType.GROUP, elementEntities, submitButton);
150+
formMessage.setTitle("Society Survey");
151+
formMessage.setAllowSenderInteraction(true);
152+
formMessage.setSender(CometChatUIKit.getLoggedInUser());
153+
formMessage.setSentAt(System.currentTimeMillis() / 1000);
154+
formMessage.setReceiver(AppUtils.getDefaultUser() != null ? AppUtils.getDefaultUser() : AppUtils.getDefaultGroup() != null ? AppUtils.getDefaultGroup() : null);
155+
formMessage.setInteractionGoal(new InteractionGoal(CometChatConstants.INTERACTION_TYPE_All_OF, Arrays.asList("element8", "element9")));
156+
157+
formBubble.setFormMessage(formMessage);
158+
return view;
159+
}
160+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:pathData="M2.859,1.456h18.281s1.406,0 1.406,1.406v18.281s0,1.406 -1.406,1.406L2.859,22.55s-1.406,0 -1.406,-1.406v-18.281s0,-1.406 1.406,-1.406"
8+
android:strokeLineJoin="round"
9+
android:strokeWidth="1.5"
10+
android:fillColor="#00000000"
11+
android:strokeColor="#000000"
12+
android:strokeLineCap="round"/>
13+
<path
14+
android:pathData="m7.078,7.784 l9.844,0"
15+
android:strokeLineJoin="round"
16+
android:strokeWidth="1.5"
17+
android:fillColor="#00000000"
18+
android:strokeColor="#000000"
19+
android:strokeLineCap="round"/>
20+
<path
21+
android:pathData="m7.078,12.003 l9.844,0"
22+
android:strokeLineJoin="round"
23+
android:strokeWidth="1.5"
24+
android:fillColor="#00000000"
25+
android:strokeColor="#000000"
26+
android:strokeLineCap="round"/>
27+
<path
28+
android:pathData="m7.078,16.222 l9.844,0"
29+
android:strokeLineJoin="round"
30+
android:strokeWidth="1.5"
31+
android:fillColor="#00000000"
32+
android:strokeColor="#000000"
33+
android:strokeLineCap="round"/>
34+
</vector>

0 commit comments

Comments
 (0)