mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +03:00
Merge pull request #302 from vector-im/feature/invitation
Quick action in invitation and composer input type
This commit is contained in:
commit
2800d86a57
5 changed files with 46 additions and 17 deletions
|
@ -55,12 +55,38 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
NotificationUtils.MARK_ROOM_READ_ACTION ->
|
||||
intent.getStringExtra(KEY_ROOM_ID)?.let {
|
||||
notificationDrawerManager.clearMessageEventOfRoom(it)
|
||||
handleMarkAsRead(context, it)
|
||||
handleMarkAsRead(it)
|
||||
}
|
||||
NotificationUtils.JOIN_ACTION -> {
|
||||
intent.getStringExtra(KEY_ROOM_ID)?.let {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(it)
|
||||
handleJoinRoom(it)
|
||||
}
|
||||
}
|
||||
NotificationUtils.REJECT_ACTION -> {
|
||||
intent.getStringExtra(KEY_ROOM_ID)?.let {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(it)
|
||||
handleRejectRoom(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleMarkAsRead(context: Context, roomId: String) {
|
||||
private fun handleJoinRoom(roomId: String) {
|
||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||
session.getRoom(roomId)
|
||||
?.join(object : MatrixCallback<Unit> {})
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleRejectRoom(roomId: String) {
|
||||
activeSessionHolder.getSafeActiveSession()?.let { session ->
|
||||
session.getRoom(roomId)
|
||||
?.leave(object : MatrixCallback<Unit> {})
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleMarkAsRead(roomId: String) {
|
||||
activeSessionHolder.getActiveSession().let { session ->
|
||||
session.getRoom(roomId)
|
||||
?.markAllAsRead(object : MatrixCallback<Unit> {})
|
||||
|
@ -96,7 +122,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
false,
|
||||
System.currentTimeMillis(),
|
||||
session.getUser(session.sessionParams.credentials.userId)?.displayName
|
||||
?: context?.getString(R.string.notification_sender_me),
|
||||
?: context?.getString(R.string.notification_sender_me),
|
||||
session.sessionParams.credentials.userId,
|
||||
message,
|
||||
room.roomId,
|
||||
|
@ -165,7 +191,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
|
||||
private fun getReplyMessage(intent: Intent?): String? {
|
||||
if (intent != null) {
|
||||
val remoteInput = RemoteInput.getResultsFromIntent(intent);
|
||||
val remoteInput = RemoteInput.getResultsFromIntent(intent)
|
||||
if (remoteInput != null) {
|
||||
return remoteInput.getCharSequence(KEY_TEXT_REPLY)?.toString()
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ object NotificationUtils {
|
|||
* IDs for actions
|
||||
* ========================================================================================== */
|
||||
|
||||
private const val JOIN_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.JOIN_ACTION"
|
||||
private const val REJECT_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.REJECT_ACTION"
|
||||
const val JOIN_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.JOIN_ACTION"
|
||||
const val REJECT_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.REJECT_ACTION"
|
||||
private const val QUICK_LAUNCH_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.QUICK_LAUNCH_ACTION"
|
||||
const val MARK_ROOM_READ_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.MARK_ROOM_READ_ACTION"
|
||||
const val SMART_REPLY_ACTION = "${BuildConfig.APPLICATION_ID}.NotificationActions.SMART_REPLY_ACTION"
|
||||
|
@ -492,31 +492,31 @@ object NotificationUtils {
|
|||
.setColor(accentColor)
|
||||
.apply {
|
||||
if (simpleNotifiableEvent is InviteNotifiableEvent) {
|
||||
/*
|
||||
TODO
|
||||
val roomId = simpleNotifiableEvent.roomId
|
||||
// offer to type a quick reject button
|
||||
val rejectIntent = JoinRoomActivity.getRejectRoomIntent(context, roomId, matrixId)
|
||||
|
||||
// the action must be unique else the parameters are ignored
|
||||
val rejectIntent = Intent(context, NotificationBroadcastReceiver::class.java)
|
||||
rejectIntent.action = REJECT_ACTION
|
||||
rejectIntent.data = Uri.parse("foobar://$roomId&$matrixId")
|
||||
rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId)
|
||||
val rejectIntentPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), rejectIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
|
||||
addAction(
|
||||
R.drawable.vector_notification_reject_invitation,
|
||||
context.getString(R.string.reject),
|
||||
PendingIntent.getActivity(context, System.currentTimeMillis().toInt(), rejectIntent, 0))
|
||||
rejectIntentPendingIntent)
|
||||
|
||||
// offer to type a quick accept button
|
||||
val joinIntent = JoinRoomActivity.getJoinRoomIntent(context, roomId, matrixId)
|
||||
|
||||
// the action must be unique else the parameters are ignored
|
||||
val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java)
|
||||
joinIntent.action = JOIN_ACTION
|
||||
joinIntent.data = Uri.parse("foobar://$roomId&$matrixId")
|
||||
rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId)
|
||||
val joinIntentPendingIntent = PendingIntent.getBroadcast(context, System.currentTimeMillis().toInt(), joinIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
addAction(
|
||||
R.drawable.vector_notification_accept_invitation,
|
||||
context.getString(R.string.join),
|
||||
PendingIntent.getActivity(context, 0, joinIntent, 0))
|
||||
*/
|
||||
joinIntentPendingIntent)
|
||||
} else {
|
||||
setAutoCancel(true)
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:hint="@string/room_message_placeholder_not_encrypted"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:maxHeight="200dp"
|
||||
android:minHeight="48dp"
|
||||
android:nextFocusLeft="@id/composerEditText"
|
||||
|
|
|
@ -159,6 +159,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:hint="@string/room_message_placeholder_not_encrypted"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:minHeight="48dp"
|
||||
android:nextFocusLeft="@id/composerEditText"
|
||||
android:nextFocusUp="@id/composerEditText"
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:nextFocusLeft="@id/composerEditText"
|
||||
android:nextFocusUp="@id/composerEditText"
|
||||
android:padding="8dp"
|
||||
|
|
Loading…
Reference in a new issue