-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added call_started_message.xml - added CallStartedViewHolder.kt - added CallStartedMessageInterface.kt - Both join audio and join video buttons - Gets destroyed if call ends, persists despite state changes Signed-off-by: Julius Linus <[email protected]>
- Loading branch information
1 parent
7e4a3dc
commit 63ed6e8
Showing
6 changed files
with
272 additions
and
7 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/nextcloud/talk/adapters/messages/CallStartedMessageInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Nextcloud Talk application | ||
* | ||
* @author Julius Linus | ||
* Copyright (C) 2023 Julius Linus <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.nextcloud.talk.adapters.messages | ||
|
||
interface CallStartedMessageInterface { | ||
fun joinAudioCall() | ||
fun joinVideoCall() | ||
} |
95 changes: 95 additions & 0 deletions
95
app/src/main/java/com/nextcloud/talk/adapters/messages/CallStartedViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Nextcloud Talk application | ||
* | ||
* @author Julius Linus | ||
* Copyright (C) 2023 Julius Linus <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.nextcloud.talk.adapters.messages | ||
|
||
import android.content.Context | ||
import android.text.Spannable | ||
import android.text.SpannableString | ||
import android.view.View | ||
import autodagger.AutoInjector | ||
import com.nextcloud.talk.R | ||
import com.nextcloud.talk.application.NextcloudTalkApplication | ||
import com.nextcloud.talk.databinding.CallStartedMessageBinding | ||
import com.nextcloud.talk.models.json.chat.ChatMessage | ||
import com.nextcloud.talk.ui.theme.ViewThemeUtils | ||
import com.nextcloud.talk.users.UserManager | ||
import com.nextcloud.talk.utils.DisplayUtils | ||
import com.stfalcon.chatkit.messages.MessageHolders | ||
import javax.inject.Inject | ||
|
||
@AutoInjector(NextcloudTalkApplication::class) | ||
class CallStartedViewHolder(incomingView: View, payload: Any) : | ||
MessageHolders.BaseIncomingMessageViewHolder<ChatMessage>(incomingView, payload) { | ||
private val binding: CallStartedMessageBinding = CallStartedMessageBinding.bind(incomingView) | ||
|
||
@Inject | ||
lateinit var context: Context | ||
|
||
@Inject | ||
lateinit var userManager: UserManager | ||
|
||
@Inject | ||
lateinit var viewThemeUtils: ViewThemeUtils | ||
|
||
private lateinit var messageInterface: CallStartedMessageInterface | ||
|
||
override fun onBind(message: ChatMessage?) { | ||
super.onBind(message) | ||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this) | ||
themeBackground() | ||
val name = "@" + message!!.actorDisplayName | ||
val text = name + " " + context.resources.getString(R.string.started_a_call) | ||
var spannable: Spannable = SpannableString(text) | ||
// TODO figure out a way to replace with mentioned chip | ||
val mentionColor: Int = context.resources.getColor(R.color.textColorMaxContrast) | ||
spannable = DisplayUtils.searchAndColor(spannable, name, mentionColor) | ||
|
||
binding.callAuthorTextview.text = spannable | ||
binding.joinVideoCall.setOnClickListener { messageInterface.joinVideoCall() } | ||
binding.joinAudioCall.setOnClickListener { messageInterface.joinAudioCall() } | ||
} | ||
|
||
private fun themeBackground() { | ||
binding.callStartedBackground.apply { | ||
viewThemeUtils.talk.themeOutgoingMessageBubble(this, grouped = true, false) | ||
} | ||
} | ||
|
||
fun assignCallStartedMessageInterface(inf: CallStartedMessageInterface) { | ||
messageInterface = inf | ||
} | ||
|
||
companion object { | ||
var TAG: String? = CallStartedViewHolder::class.simpleName | ||
} | ||
|
||
override fun viewDetached() { | ||
// unused atm | ||
} | ||
|
||
override fun viewAttached() { | ||
// unused atm | ||
} | ||
|
||
override fun viewRecycled() { | ||
// unused atm | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ Nextcloud Talk application | ||
~ | ||
~ @author Julius Linus | ||
~ Copyright (C) 2023 Julius Linus <[email protected]> | ||
~ | ||
~ This program is free software: you can redistribute it and/or modify | ||
~ it under the terms of the GNU General Public License as published by | ||
~ the Free Software Foundation, either version 3 of the License, or | ||
~ at your option) any later version. | ||
~ | ||
~ This program is distributed in the hope that it will be useful, | ||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
~ GNU General Public License for more details. | ||
~ | ||
~ You should have received a copy of the GNU General Public License | ||
~ along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/call_started_background" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/standard_double_margin" | ||
android:padding="@dimen/standard_padding" | ||
tools:background="@drawable/shape_grouped_outcoming_message" | ||
tools:backgroundTint="@color/colorPrimaryDark"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/standard_margin" | ||
android:orientation="horizontal" | ||
android:gravity="center"> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/call_author_textview" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
tools:text="(( ) Ariel Fox) started a call" /> | ||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:gravity="center"> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/join_video_call" | ||
style="@style/Widget.Material3.Button.Icon" | ||
android:backgroundTint="@color/nc_darkGreen" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/standard_half_margin" | ||
app:icon="@drawable/ic_videocam_grey_600_24dp" | ||
app:iconTint="@color/hwSecurityGreen" | ||
android:alpha="0.8" | ||
android:text="@string/video_call" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/join_audio_call" | ||
style="@style/Widget.Material3.Button.Icon" | ||
android:backgroundTint="@color/nc_darkGreen" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="@dimen/standard_half_margin" | ||
android:alpha="0.8" | ||
app:icon="@drawable/ic_phone" | ||
app:iconTint="@color/hwSecurityGreen" | ||
android:text="@string/audio_call" /> | ||
</LinearLayout> | ||
|
||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters