Skip to content

Commit 471db97

Browse files
committed
Rebase + resolving merge conflicts
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
1 parent a344e39 commit 471db97

8 files changed

Lines changed: 117 additions & 10 deletions

File tree

244 KB
Binary file not shown.

app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ import com.nextcloud.talk.call.ReactionAnimator
7373
import com.nextcloud.talk.call.components.ParticipantGrid
7474
import com.nextcloud.talk.call.components.SelfVideoView
7575
import com.nextcloud.talk.call.components.screenshare.ScreenShareComponent
76+
import com.nextcloud.talk.camera.BackgroundBlurFrameProcessor
77+
import com.nextcloud.talk.camera.BlurBackgroundViewModel
78+
import com.nextcloud.talk.camera.BlurBackgroundViewModel.BackgroundBlurOn
7679
import com.nextcloud.talk.chat.ChatActivity
7780
import com.nextcloud.talk.data.user.model.User
7881
import com.nextcloud.talk.databinding.CallActivityBinding
@@ -185,7 +188,6 @@ import java.util.Objects
185188
import java.util.concurrent.TimeUnit
186189
import java.util.concurrent.atomic.AtomicInteger
187190
import javax.inject.Inject
188-
import kotlin.String
189191
import kotlin.math.abs
190192

191193
@AutoInjector(NextcloudTalkApplication::class)
@@ -214,6 +216,7 @@ class CallActivity : CallBaseActivity() {
214216
var audioManager: WebRtcAudioManager? = null
215217
var callRecordingViewModel: CallRecordingViewModel? = null
216218
var raiseHandViewModel: RaiseHandViewModel? = null
219+
val blurBackgroundViewModel: BlurBackgroundViewModel = BlurBackgroundViewModel()
217220
private var mReceiver: BroadcastReceiver? = null
218221
private var peerConnectionFactory: PeerConnectionFactory? = null
219222
private var screenSharePeerConnectionFactory: PeerConnectionFactory? = null
@@ -447,7 +450,6 @@ class CallActivity : CallBaseActivity() {
447450

448451
initRaiseHandViewModel()
449452
initCallRecordingViewModel(extras.getInt(KEY_RECORDING_STATE, 0))
450-
initBackgroundBlurViewModel()
451453

452454
initClickListeners(isModerator, isOneToOneConversation)
453455
binding!!.microphoneButton.setOnTouchListener(MicrophoneButtonTouchListener())
@@ -542,12 +544,6 @@ class CallActivity : CallBaseActivity() {
542544

543545
private fun initBackgroundBlurViewModel(surfaceTextureHelper: SurfaceTextureHelper) {
544546
blurBackgroundViewModel.viewState.observe(this) { state ->
545-
val frontFacing = isCameraFrontFacing(cameraEnumerator)
546-
if (frontFacing == null) {
547-
Log.e(TAG, "Camera not found")
548-
return@observe
549-
}
550-
551547
val isOn = state == BackgroundBlurOn
552548

553549
val processor = if (isOn) {
@@ -1272,6 +1268,7 @@ class CallActivity : CallBaseActivity() {
12721268
binding!!.cameraButton.setImageResource(R.drawable.ic_videocam_white_24px)
12731269
} else {
12741270
binding!!.cameraButton.setImageResource(R.drawable.ic_videocam_off_white_24px)
1271+
blurBackgroundViewModel.turnOffBlur()
12751272
}
12761273
toggleMedia(videoOn, true)
12771274
} else if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
@@ -1348,6 +1345,10 @@ class CallActivity : CallBaseActivity() {
13481345
raiseHandViewModel!!.clickHandButton()
13491346
}
13501347

1348+
fun toggleBackgroundBlur() {
1349+
blurBackgroundViewModel.toggleBackgroundBlur()
1350+
}
1351+
13511352
public override fun onDestroy() {
13521353
if (signalingMessageReceiver != null) {
13531354
signalingMessageReceiver!!.removeListener(localParticipantMessageListener)

app/src/main/java/com/nextcloud/talk/camera/BackgroundBlurFrameProcessor.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ class BackgroundBlurFrameProcessor(val context: Context, val surfaceTextureHelpe
8080

8181
// This should run on the CaptureThread
8282
surfaceTextureHelper.handler.post {
83-
// Send final frame to sink
84-
Log.d("Julius", "Sent VideoFrame to sink on :${Thread.currentThread().name}")
83+
Log.d(TAG, "Sent VideoFrame to sink on :${Thread.currentThread().name}")
8584
sink?.onFrame(videoFrame)
8685

8786
// webRTCBuffer usually needs release() if it's not a JavaI420Buffer wrapper that auto-GCs,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Nextcloud Talk - Android Client
3+
*
4+
* SPDX-FileCopyrightText: 2025 Julius Linus <juliuslinus1@gmail.com>
5+
* SPDX-License-Identifier: GPL-3.0-or-later
6+
*/
7+
8+
package com.nextcloud.talk.camera
9+
10+
import androidx.lifecycle.LiveData
11+
import androidx.lifecycle.MutableLiveData
12+
import androidx.lifecycle.ViewModel
13+
14+
class BlurBackgroundViewModel : ViewModel() {
15+
16+
sealed interface ViewState
17+
18+
object BackgroundBlurOn : ViewState
19+
object BackgroundBlurOff : ViewState
20+
21+
private val _viewState: MutableLiveData<ViewState> = MutableLiveData(BackgroundBlurOff)
22+
val viewState: LiveData<ViewState>
23+
get() = _viewState
24+
25+
fun toggleBackgroundBlur() {
26+
val isOn = _viewState.value == BackgroundBlurOn
27+
28+
if (isOn) {
29+
_viewState.value = BackgroundBlurOff
30+
} else {
31+
_viewState.value = BackgroundBlurOn
32+
}
33+
}
34+
35+
fun turnOffBlur() {
36+
_viewState.value = BackgroundBlurOff
37+
}
38+
}

app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
1818
import com.nextcloud.talk.R
1919
import com.nextcloud.talk.activities.CallActivity
2020
import com.nextcloud.talk.application.NextcloudTalkApplication
21+
import com.nextcloud.talk.camera.BlurBackgroundViewModel
2122
import com.nextcloud.talk.databinding.DialogMoreCallActionsBinding
2223
import com.nextcloud.talk.raisehand.viewmodel.RaiseHandViewModel
2324
import com.nextcloud.talk.ui.theme.ViewThemeUtils
@@ -86,6 +87,10 @@ class MoreCallActionsDialog(private val callActivity: CallActivity) : BottomShee
8687
binding.raiseHand.setOnClickListener {
8788
callActivity.clickRaiseOrLowerHandButton()
8889
}
90+
91+
binding.backgroundBlur.setOnClickListener {
92+
callActivity.toggleBackgroundBlur()
93+
}
8994
}
9095

9196
private fun initEmojiBar() {
@@ -181,6 +186,18 @@ class MoreCallActionsDialog(private val callActivity: CallActivity) : BottomShee
181186
else -> {}
182187
}
183188
}
189+
190+
callActivity.blurBackgroundViewModel.viewState.observe(this) { state ->
191+
when (state) {
192+
BlurBackgroundViewModel.BackgroundBlurOff -> {
193+
binding.backgroundBlurText.text = context.getText(R.string.turn_on_background_blur)
194+
}
195+
196+
BlurBackgroundViewModel.BackgroundBlurOn -> {
197+
binding.backgroundBlurText.text = context.getText(R.string.turn_off_background_blur)
198+
}
199+
}
200+
}
184201
}
185202

186203
companion object {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!--
2+
~ Nextcloud Talk - Android Client
3+
~
4+
~ SPDX-FileCopyrightText: 2025 Google LLC
5+
~ SPDX-License-Identifier: Apache-2.0
6+
-->
7+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
8+
android:width="24dp"
9+
android:height="24dp"
10+
android:viewportWidth="960"
11+
android:viewportHeight="960"
12+
android:tint="?attr/colorControlNormal">
13+
<path
14+
android:fillColor="@android:color/white"
15+
android:pathData="M120,386L120,301L301,120L386,120L120,386ZM120,190L120,120L120,120L190,120L120,190ZM647,257Q637,246 625.5,235.5Q614,225 602,217L699,120L784,120L784,120L647,257ZM220,599L297,522Q304,533 311.5,542Q319,551 328,559L328,559Q300,566 271.5,576.5Q243,587 220,599ZM700,402Q700,401 700,401Q700,401 700,400Q700,381 697,363Q694,345 688,328L840,176L840,262L700,402ZM436,184L501,120L586,120L522,184Q511,182 501,181Q491,180 480,180Q469,180 458,181Q447,182 436,184ZM120,585L120,500L264,356Q262,367 261,378Q260,389 260,400Q260,411 261,421Q262,431 264,441L120,585ZM829,668Q821,656 810.5,645Q800,634 788,625L840,573L840,658L829,668ZM713,586Q706,583 699,580.5Q692,578 685,576Q676,573 667.5,570Q659,567 650,565L840,374L840,460L713,586ZM480,560Q414,560 367,513Q320,466 320,400Q320,334 367,287Q414,240 480,240Q546,240 593,287Q640,334 640,400Q640,466 593,513Q546,560 480,560ZM480,480Q513,480 536.5,456.5Q560,433 560,400Q560,367 536.5,343.5Q513,320 480,320Q447,320 423.5,343.5Q400,367 400,400Q400,433 423.5,456.5Q447,480 480,480ZM160,840L160,769Q160,735 177,706Q194,677 224,662Q275,636 339.5,618Q404,600 480,600Q556,600 620.5,618Q685,636 736,662Q766,677 783,706Q800,735 800,769L800,840L160,840ZM241,760L719,760Q717,751 712,744.5Q707,738 699,734Q663,716 607.5,698Q552,680 480,680Q408,680 352.5,698Q297,716 261,734Q253,738 248,745Q243,752 241,760ZM480,760Q480,760 480,760Q480,760 480,760Q480,760 480,760Q480,760 480,760Q480,760 480,760Q480,760 480,760Q480,760 480,760Q480,760 480,760ZM480,400Q480,400 480,400Q480,400 480,400Q480,400 480,400Q480,400 480,400Q480,400 480,400Q480,400 480,400Q480,400 480,400Q480,400 480,400Z"/>
16+
</vector>

app/src/main/res/layout/dialog_more_call_actions.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,38 @@
117117

118118
</LinearLayout>
119119

120+
<LinearLayout
121+
android:id="@+id/background_blur"
122+
android:layout_width="match_parent"
123+
android:layout_height="@dimen/bottom_sheet_item_height"
124+
android:background="?android:attr/selectableItemBackground"
125+
android:gravity="center_vertical"
126+
android:orientation="horizontal"
127+
android:paddingStart="@dimen/standard_padding"
128+
android:paddingEnd="@dimen/standard_padding"
129+
tools:ignore="UseCompoundDrawables">
130+
131+
<ImageView
132+
android:id="@+id/background_blur_icon"
133+
android:layout_width="wrap_content"
134+
android:layout_height="wrap_content"
135+
android:contentDescription="@null"
136+
android:src="@drawable/background_replace_24px"
137+
app:tint="@color/high_emphasis_menu_icon_inverse" />
138+
139+
<androidx.appcompat.widget.AppCompatTextView
140+
android:id="@+id/background_blur_text"
141+
android:layout_width="match_parent"
142+
android:layout_height="wrap_content"
143+
android:layout_gravity="start|center_vertical"
144+
android:paddingStart="@dimen/standard_double_padding"
145+
android:paddingEnd="@dimen/zero"
146+
android:text="@string/turn_on_background_blur"
147+
android:textAlignment="viewStart"
148+
android:textColor="@color/high_emphasis_text_dark_background"
149+
android:textSize="@dimen/bottom_sheet_text_size" />
150+
151+
</LinearLayout>
152+
153+
120154
</LinearLayout>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,4 +941,6 @@ How to translate with transifex:
941941
<string name="no_scheduled_messages_offline">No connection to server - Scheduled messages could not be loaded</string>
942942
<string name="nc_show_ecosystem_title">Show app switcher</string>
943943
<string name="nc_show_ecosystem_description">Nextcloud app suggestions in account chooser dialog</string>
944+
<string name="turn_on_background_blur">Turn on background blur</string>
945+
<string name="turn_off_background_blur">Turn off background blur</string>
944946
</resources>

0 commit comments

Comments
 (0)