Skip to content

Commit

Permalink
Android Push Notification v3.0.0-1
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Aug 30, 2021
1 parent 34326b6 commit 25e6d1f
Show file tree
Hide file tree
Showing 22 changed files with 745 additions and 204 deletions.
2 changes: 1 addition & 1 deletion ConnectionService + Firebase/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ dependencies {
implementation 'com.google.android.material:material:1.2.0-alpha01'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
//
implementation 'com.cometchat:pro-android-chat-sdk:2.4.1'
implementation 'com.cometchat:pro-android-chat-sdk:3.0.0'
implementation 'com.cometchat:pro-android-calls-sdk:2.1.0'
}
2 changes: 1 addition & 1 deletion ConnectionService + Firebase/uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//cometchat
compileOnly 'com.cometchat:pro-android-chat-sdk:2.4.1'
compileOnly 'com.cometchat:pro-android-chat-sdk:3.0.0'
compileOnly 'com.cometchat:pro-android-calls-sdk:2.1.0'

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
Expand Down
14 changes: 8 additions & 6 deletions ConnectionService + Firebase/uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
android:usesCleartextTraffic="true"
tools:node="merge"
tools:targetApi="m">
<activity android:name=".ui_components.messages.extensions.Collaborative.CometChatWebViewActivity"/>
<activity
android:name=".ui_components.messages.extensions.Reactions.CometChatReactionInfoActivity"/>
<activity android:name=".ui_components.chats.CometChatStartConversation"/>
<activity android:name=".ui_components.messages.extensions.Collaborative.CometChatWebViewActivity" />
<activity android:name=".ui_components.messages.extensions.Reactions.CometChatReactionInfoActivity" />
<activity android:name=".ui_components.messages.media_view.CometChatMediaViewActivity" />
<activity android:name=".ui_components.messages.message_information.CometChatMessageInfoScreenActivity" />
<activity android:name=".ui_components.calls.call_manager.CometChatStartCallActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui_components.calls.call_manager.CometChatStartCallActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<activity
android:name=".ui_components.messages.thread_message_list.CometChatThreadMessageListActivity"
android:windowSoftInputMode="adjustResize" />
Expand All @@ -55,7 +57,7 @@
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/pdf" />
<data android:mimeType="application/*" />
</intent-filter>
</activity>
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ private void addConversationListener() {
CometChat.addMessageListener(TAG, new CometChat.MessageListener() {
@Override
public void onTextMessageReceived(TextMessage message) {
if (!message.getSender().getUid().equalsIgnoreCase(CometChat.getLoggedInUser().getUid()))
CometChat.markAsDelivered(message);
if (rvConversationList!=null) {
rvConversationList.refreshConversation(message);
checkNoConverstaion();
Expand All @@ -415,6 +417,8 @@ public void onTextMessageReceived(TextMessage message) {

@Override
public void onMediaMessageReceived(MediaMessage message) {
if (!message.getSender().getUid().equalsIgnoreCase(CometChat.getLoggedInUser().getUid()))
CometChat.markAsDelivered(message);
if (rvConversationList != null) {
rvConversationList.refreshConversation(message);
checkNoConverstaion();
Expand All @@ -423,6 +427,8 @@ public void onMediaMessageReceived(MediaMessage message) {

@Override
public void onCustomMessageReceived(CustomMessage message) {
if (!message.getSender().getUid().equalsIgnoreCase(CometChat.getLoggedInUser().getUid()))
CometChat.markAsDelivered(message);
if (rvConversationList != null) {
rvConversationList.refreshConversation(message);
checkNoConverstaion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import com.cometchat.pro.models.MediaMessage;
import com.cometchat.pro.models.MessageReceipt;
import com.cometchat.pro.models.TextMessage;
import com.cometchat.pro.models.TransientMessage;
import com.cometchat.pro.models.TypingIndicator;
import com.cometchat.pro.models.User;
import com.cometchat.pro.uikit.R;
Expand Down Expand Up @@ -327,6 +328,7 @@ public class CometChatMessageList extends Fragment implements View.OnClickListen
private ImageView backIcon;
private BaseMessage repliedMessage;

private boolean isLiveReactionEnded = true;
public CometChatMessageList() {
// Required empty public constructor
}
Expand Down Expand Up @@ -430,50 +432,13 @@ public void onSuccess(Boolean booleanVal) {
}

container = view.findViewById(R.id.reactions_container);
composeBox.liveReactionBtn.setOnTouchListener(new LiveReactionListener(700, 1000, new ReactionClickListener() {
composeBox.liveReactionBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View var1) {
container.setAlpha(1.0f);
sendLiveReaction();
}

@Override
public void onCancel(View var1) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (imageView != null && animation != null && animation.isRunning()) {
ObjectAnimator animator = ObjectAnimator.ofFloat(container, "alpha", 0.2f);
animator.setDuration(700);
animator.start();
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (imageView != null)
imageView.clearAnimation();
container.removeAllViews();
if (typingTimer != null)
typingTimer.schedule(new TimerTask() {
@Override
public void run() {
JSONObject metaData = new JSONObject();
try {
metaData.put("reaction", "heart");
} catch (JSONException e) {
e.printStackTrace();
}
TypingIndicator typingIndicator = new TypingIndicator(Id, type, metaData);
CometChat.endTyping(typingIndicator);
}
}, 2000);
}
});
}
}
}, 1400);
public void onClick(View v) {
if (isLiveReactionEnded)
sendLiveReaction();
}
}));
});


newMessageLayout = view.findViewById(R.id.new_message_layout);
Expand Down Expand Up @@ -635,8 +600,7 @@ public void OnItemClick(String var, int position) {
}

private void checkOnGoingCall(String callType) {
if (CometChat.getActiveCall() != null &&
CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId() != null) {
if (CometChat.getActiveCall() != null && CometChat.getActiveCall().getCallStatus().equals(CometChatConstants.CALL_STATUS_ONGOING) && CometChat.getActiveCall().getSessionId() != null) {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle(getResources().getString(R.string.ongoing_call))
.setMessage(getResources().getString(R.string.ongoing_call_message))
Expand Down Expand Up @@ -2056,13 +2020,8 @@ public void onUserOffline(User user) {
* @param baseMessage is object of BaseMessage.class. It is message which is been marked as read.
*/
private void markMessageAsRead(BaseMessage baseMessage) {
// CometChat.markAsRead(baseMessage); //Used for v3
if (type.equals(CometChatConstants.RECEIVER_TYPE_USER))
CometChat.markAsRead(baseMessage.getId(), baseMessage.getSender().getUid(),
baseMessage.getReceiverType());
else
CometChat.markAsRead(baseMessage.getId(), baseMessage.getReceiverUid(),
baseMessage.getReceiverType());
CometChat.markAsDelivered(baseMessage);
CometChat.markAsRead(baseMessage);
}


Expand Down Expand Up @@ -2134,6 +2093,12 @@ public void onMessageDeleted(BaseMessage message) {
updateMessage(message);
}
}
@Override
public void onTransientMessageReceived(TransientMessage transientMessage) {
if (transientMessage.getData()!=null) {
setLiveReaction();
}
}
});
}

Expand Down Expand Up @@ -2260,8 +2225,7 @@ public void onSuccess(Boolean booleanVal) {
}
});
}
else
setLiveReaction();

} else {
if (typingIndicator.getMetadata() == null) {
FeatureRestriction.isTypingIndicatorsEnabled(new FeatureRestriction.OnSuccessListener() {
Expand All @@ -2272,44 +2236,14 @@ public void onSuccess(Boolean booleanVal) {
}
});
}
else
setLiveReaction();
}
} else {
if (typingIndicator.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
if (typingIndicator.getMetadata() == null)
tvStatus.setText(status);
else {
ObjectAnimator animator = ObjectAnimator.ofFloat(container,"alpha",0.2f);
animator.setDuration(700);
animator.start();
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (imageView!=null)
imageView.clearAnimation();
container.removeAllViews();
}
});
}
} else{
if (typingIndicator.getMetadata() == null)
tvStatus.setText(memberNames);
else {
ObjectAnimator animator = ObjectAnimator.ofFloat(container,"alpha",0.2f);
animator.setDuration(700);
animator.start();
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (imageView!=null)
imageView.clearAnimation();
container.removeAllViews();
}
});
}
}
}

Expand Down Expand Up @@ -3400,20 +3334,43 @@ private void sendLiveReaction() {
try {
JSONObject metaData = new JSONObject();
metaData.put("reaction", "heart");
TypingIndicator typingIndicator = new TypingIndicator(Id, type, metaData);
CometChat.startTyping(typingIndicator);
metaData.put("type","live_reaction");
TransientMessage transientMessage = new TransientMessage(Id, type, metaData);
CometChat.sendTransientMessage(transientMessage);
setLiveReaction();
} catch (Exception e) {
Log.e(TAG, "sendLiveReaction: "+e.getMessage());
}
}

private void stopLiveReaction() {
ObjectAnimator animator = ObjectAnimator.ofFloat(container,"alpha",0.2f);
animator.setDuration(700);
animator.start();
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (imageView!=null)
imageView.clearAnimation();
container.removeAllViews();
isLiveReactionEnded = true;
}
});
}
private void setLiveReaction() {
container.setAlpha(1.0f);
flyEmoji(R.drawable.heart_reaction);
isLiveReactionEnded = false;
animateLiveReaction(R.drawable.heart_reaction);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
stopLiveReaction();
}
},1500);
}

private void flyEmoji(final int resId) {
private void animateLiveReaction(final int resId) {
imageView = new ImageView(getContext());

FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1725,11 +1725,7 @@ private void scrollToBottom() {
* @param baseMessage is object of BaseMessage.class. It is message which is been marked as read.
*/
private void markMessageAsRead(BaseMessage baseMessage) {
// CometChat.markAsRead(baseMessage);
if (type.equals(CometChatConstants.RECEIVER_TYPE_USER))
CometChat.markAsRead(baseMessage.getId(), baseMessage.getSender().getUid(), baseMessage.getReceiverType());
else
CometChat.markAsRead(baseMessage.getId(), baseMessage.getReceiverUid(), baseMessage.getReceiverType());
CometChat.markAsRead(baseMessage);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ public static class IntentStrings {
public static final String INTENT_MEDIA_AUDIO_MESSAGE = "intent_media_audio_message";

public static final String INTENT_MEDIA_FILE_MESSAGE = "intent_media_file_message";

public static final String LINK = "link";

public static final String IS_TITLE_VISIBLE = "IS_TITLE_VISIBLE";

public static final String CREATE_GROUP_VISIBLE = "IS_CREATE_GROUP_VISIBLE";
public static final String CALL_TYPE = "CALL_TYPE";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public static void richMedia(boolean isEnable) {


public static void sendStickers(boolean isEnable) {
sendStickers = isEnable;
sendStickers = isEnable;
}

public static void unreadCount(boolean isEnable) { unreadCount = isEnable; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,5 @@
<string name="search_users">Search Users</string>
<string name="search_groups">Search Groups</string>
<string name="background_location_permission_title">Allow Background Location Permisssion</string>
<string name="allow_connection_service">Please enable VoIP for this app</string>
<string name="allow_connection_service">Please enable VoIP from Call Accounts Settings</string>
</resources>
2 changes: 1 addition & 1 deletion Firebase/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ dependencies {
implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
//
implementation 'com.cometchat:pro-android-chat-sdk:2.4.1'
implementation 'com.cometchat:pro-android-chat-sdk:3.0.0'
implementation 'com.cometchat:pro-android-calls-sdk:2.1.0'
}
2 changes: 1 addition & 1 deletion Firebase/uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//cometchat
compileOnly 'com.cometchat:pro-android-chat-sdk:2.4.1'
compileOnly 'com.cometchat:pro-android-chat-sdk:3.0.0'
compileOnly 'com.cometchat:pro-android-calls-sdk:2.1.0'

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
Expand Down
21 changes: 15 additions & 6 deletions Firebase/uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
android:usesCleartextTraffic="true"
tools:node="merge"
tools:targetApi="m">
<activity android:name=".ui_components.messages.extensions.Collaborative.CometChatWebViewActivity"/>
<activity
android:name=".ui_components.messages.extensions.Reactions.CometChatReactionInfoActivity"/>
<activity android:name=".ui_components.chats.CometChatStartConversation"/>
<activity android:name=".ui_components.messages.extensions.Collaborative.CometChatWebViewActivity" />
<activity android:name=".ui_components.messages.extensions.Reactions.CometChatReactionInfoActivity" />
<activity android:name=".ui_components.messages.media_view.CometChatMediaViewActivity" />
<activity android:name=".ui_components.messages.message_information.CometChatMessageInfoScreenActivity" />
<activity android:name=".ui_components.calls.call_manager.CometChatStartCallActivity"
android:launchMode="singleTask" />
<activity
android:name=".ui_components.calls.call_manager.CometChatStartCallActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<activity
android:name=".ui_components.messages.thread_message_list.CometChatThreadMessageListActivity"
android:windowSoftInputMode="adjustResize" />
Expand All @@ -55,7 +57,7 @@
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/pdf" />
<data android:mimeType="application/*" />
</intent-filter>
</activity>
<meta-data
Expand Down Expand Up @@ -106,6 +108,12 @@
android:resource="@xml/provider_path" />
</provider>

<service android:name=".ui_components.calls.callconnection.MyConnectionService"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>
<service android:name=".ui_components.calls.call_manager.ongoing_call.OngoingCallService"
android:enabled="true"/>
<receiver android:name=".ui_components.calls.call_manager.ongoing_call.OngoingCallBroadcast"
Expand All @@ -115,6 +123,7 @@
<action android:name="restartService"/>
</intent-filter>
</receiver>
<receiver android:name=".ui_components.calls.callconnection.CallNotificationAction" />
</application>

</manifest>
Loading

0 comments on commit 25e6d1f

Please sign in to comment.