Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. Qiscus.getChatConfig()
  2. .setEnableFcmPushNotification(true)
  3. .setOnlyEnablePushNotificationOutsideChatRoom(true)
  4. .setNotificationBigIcon(R.mipmap.ic_launcher)
  5. .setNotificationSmallIcon(R.mipmap.ic_launcher)
  6. .setNotificationClickListener((context, qiscusComment) -> {
  7.  
  8. if (SystemEventUtil.isSystemEvent(qiscusComment) &&
  9. SystemEventUtil.getExtraPayloadType(qiscusComment)
  10. .equals(RealTimeChatroomHandler.SystemEvent.REMOVE_MEMBER)) {
  11. return;
  12. } else {
  13. ChatRoomNavigator
  14. .openChatRoom(context, qiscusComment)
  15. .withParentClass(MainActivity.class)
  16. .start();
  17. }
  18. })
  19. .setSwipeRefreshColorScheme(R.color.colorPrimary, R.color.colorAccent)
  20. .setLeftBubbleColor(R.color.leftBubble)
  21. .setLeftBubbleTextColor(R.color.qiscus_primary_text)
  22. .setLeftBubbleTimeColor(R.color.qiscus_secondary_text)
  23. .setLeftLinkTextColor(R.color.qiscus_primary_text)
  24. .setLeftProgressFinishedColor(R.color.colorPrimary)
  25. .setRightBubbleColor(R.color.colorPrimaryLight)
  26. .setRightProgressFinishedColor(R.color.colorPrimaryLight)
  27. .setSelectedBubbleBackgroundColor(R.color.colorPrimary)
  28. .setReadIconColor(R.color.colorPrimary)
  29. .setAppBarColor(R.color.colorPrimary)
  30. .setStatusBarColor(R.color.colorPrimaryDark)
  31. .setAccentColor(R.color.colorAccent)
  32. .setAccountLinkingTextColor(R.color.colorPrimary)
  33. .setAccountLinkingBackground(R.color.accountLinkingBackground)
  34. .setButtonBubbleTextColor(R.color.colorPrimary)
  35. .setButtonBubbleBackBackground(R.color.accountLinkingBackground)
  36. .setReplyBarColor(R.color.colorPrimary)
  37. .setReplySenderColor(R.color.colorPrimary)
  38. .setSendButtonIcon(R.drawable.ic_default_send)
  39. .setStopRecordIcon(R.drawable.ic_send_on)
  40. .setCancelRecordIcon(R.drawable.ic_cancel_record)
  41. .setEmptyRoomImageResource(R.drawable.ic_empty_chat_room)
  42. .setEmptyRoomTitle("It's so quiet over here")
  43. .setEmptyRoomSubtitle("Start by sending message, file or even a voice ")
  44. .setQiscusImageCompressionConfig(new QiscusImageCompressionConfig()
  45. .setMaxHeight(1920.0f)
  46. .setMaxWidth(1080.0f)
  47. .setQuality(100)
  48. )
  49. .setNotificationBuilderInterceptor((notificationBuilder, qiscusComment) -> {
  50.  
  51. if (SystemEventUtil.isSystemEvent(qiscusComment)) {
  52. JsonObject extraPayload = SystemEventUtil.getExtraPayload(qiscusComment);
  53. JsonObject payload = extraPayload.get("payload").getAsJsonObject();
  54. String payloadAgoraCall = extraPayload.get("object_username").toString();
  55. payloadAgoraCall.substring(1, payloadAgoraCall.length() - 1);
  56. String typeExtra = extraPayload.get("type").toString();
  57. String checkTypeFirst = typeExtra.substring(1);
  58. String checkTypeLast = checkTypeFirst.substring(0, checkTypeFirst.length() - 1);
  59. if (payload.get("system_event_type") != null) {
  60. String checkadmin = payload.get("system_event_type").toString();
  61. String checkadminFirst = checkadmin.substring(1);
  62. String checkadminLast = checkadminFirst.substring(0, checkadminFirst.length() - 1);
  63. if (checkadminLast.equals("remove_group_admin") || checkadminLast.equals("add_group_admin")) {
  64. return true;
  65. }
  66. }
  67. if (checkTypeLast.equals("create_room") || checkTypeLast.equals("left_room")) {
  68. return true;
  69. }
  70. if (payload.has("system_event_type")) {
  71. if (payload.get("system_event_type").getAsString().equals("call"))
  72. return false;
  73. }
  74. if (payloadAgoraCall.substring(1, payloadAgoraCall.length() - 1).equals("System")) {
  75. return false;
  76. }
  77. }
  78.  
  79. NotifBadgeUtil.updateCount(getApplicationContext());
  80.  
  81. if (!ChatPreferencesHelper.getInstance().isEnableNotification()
  82. || !ChatPreferencesHelper.getInstance().isEnableNotification(qiscusComment.getRoomId())) {
  83. return false;
  84. }
  85.  
  86. Uri sound = Uri.parse(ChatPreferencesHelper.getInstance().getRingtone(qiscusComment.getRoomId()));
  87. boolean vibrate = ChatPreferencesHelper.getInstance().isEnableVibration(qiscusComment.getRoomId());
  88. @ColorInt int ledColor = ChatPreferencesHelper.getInstance().getLedColor(qiscusComment.getRoomId());
  89.  
  90. notificationBuilder.setSound(sound).setLights(ledColor, 3000, 2000);
  91. if (vibrate) {
  92. notificationBuilder.setVibrate(new long[]{100, 300, 600, 300, 100});
  93. }
  94.  
  95. return true;
  96. })
  97. .setEnableForwardComment(true)
  98. .setForwardCommentHandler(comments -> startActivity(ForwardActivity.generateIntent(this, comments)
  99. .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)))
  100. .getDeleteCommentConfig()
  101. .setEnableDeleteComment(true)
  102. .setEnableHardDelete(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement