Skip to content

Commit

Permalink
Merge pull request #3863 from vector-im/feature/fga/new_voip_design
Browse files Browse the repository at this point in the history
Feature/fga/new voip design
  • Loading branch information
bmarty authored Aug 27, 2021
2 parents 1815acf + fd25813 commit 5b908c4
Show file tree
Hide file tree
Showing 96 changed files with 2,271 additions and 1,448 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ allprojects {
includeGroupByRegex 'com\\.github\\.chrisbanes'
// PFLockScreen-Android
includeGroupByRegex 'com\\.github\\.vector-im'
// DraggableView
includeGroupByRegex 'com\\.github\\.hyuwah'

// Chat effects
includeGroupByRegex 'com\\.github\\.jetradarmobile'
Expand Down
1 change: 1 addition & 0 deletions changelog.d/3599.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New call designs
1 change: 1 addition & 0 deletions library/ui-styles/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<!-- Other useful color -->
<!-- Emoji text has to use a black text color -->
<color name="emoji_color">@android:color/black</color>
<color name="join_conference_animated_color">#0BAC7E</color>

<color name="half_transparent_status_bar">#80000000</color>

Expand Down
4 changes: 4 additions & 0 deletions library/ui-styles/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<dimen name="pill_min_height">20dp</dimen>
<dimen name="pill_text_padding">4dp</dimen>

<dimen name="call_pip_height">128dp</dimen>
<dimen name="call_pip_width">88dp</dimen>
<dimen name="call_pip_radius">8dp</dimen>


<dimen name="item_form_min_height">76dp</dimen>

Expand Down
1 change: 1 addition & 0 deletions vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ dependencies {
implementation "androidx.autofill:autofill:$autofill_version"
implementation 'jp.wasabeef:glide-transformations:4.3.0'
implementation 'com.github.vector-im:PFLockScreen-Android:1.0.0-beta12'
implementation 'com.github.hyuwah:DraggableView:1.0.0'
implementation 'com.github.Armen101:AudioRecordView:1.0.5'

// Custom Tab
Expand Down
4 changes: 4 additions & 0 deletions vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@
android:name=".features.attachments.preview.AttachmentsPreviewActivity"
android:theme="@style/Theme.Vector.Black.AttachmentsPreview" />
<activity
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:name=".features.call.VectorCallActivity"
android:launchMode="singleTask"
android:taskAffinity=".features.call.VectorCallActivity"
android:excludeFromRecents="true" />
<!-- PIP Support https://developer.android.com/guide/topics/ui/picture-in-picture -->
<activity
Expand Down
31 changes: 31 additions & 0 deletions vector/src/main/assets/open_source_licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,37 @@

</pre>

<ul>
<li>
<b>hyuwah/DraggableView</b>
<br/>
hyuwah/DraggableView is licensed under the MIT License
Copyright (c) 2018 Muhammad Wahyudin
</li>
</ul>
<pre>

Copyright (c) 2018 Muhammad Wahyudin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</pre>

<ul>
<li>
<b>com.github.piasy:BigImageViewer</b>
Expand Down
4 changes: 2 additions & 2 deletions vector/src/main/java/im/vector/app/core/di/VectorComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import im.vector.app.core.network.WifiDetector
import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.utils.AssetReader
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.call.conference.JitsiActiveConferenceHolder
import im.vector.app.features.call.webrtc.WebRtcCallManager
import im.vector.app.features.configuration.VectorConfiguration
import im.vector.app.features.crypto.keysrequest.KeyRequestHandler
Expand All @@ -39,7 +40,6 @@ import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.CurrentSpaceSuggestedRoomListDataSource
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummariesHolder
import im.vector.app.features.html.EventHtmlRenderer
import im.vector.app.features.html.VectorHtmlCompressor
import im.vector.app.features.invite.AutoAcceptInvites
Expand Down Expand Up @@ -165,7 +165,7 @@ interface VectorComponent {

fun webRtcCallManager(): WebRtcCallManager

fun roomSummaryHolder(): RoomSummariesHolder
fun jitsiActiveConferenceHolder(): JitsiActiveConferenceHolder

@Component.Factory
interface Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,10 @@ class CallRingPlayerOutgoing(
private var player: MediaPlayer? = null

fun start() {
val audioManager: AudioManager? = applicationContext.getSystemService()
applicationContext.getSystemService<AudioManager>()?.mode = AudioManager.MODE_IN_COMMUNICATION
player?.release()
player = createPlayer()

// Check if sound is enabled
val ringerMode = audioManager?.ringerMode
if (player != null && ringerMode == AudioManager.RINGER_MODE_NORMAL) {
if (player != null) {
try {
if (player?.isPlaying == false) {
player?.start()
Expand All @@ -116,8 +113,6 @@ class CallRingPlayerOutgoing(
Timber.e(failure, "## VOIP Failed to start ringing outgoing")
player = null
}
} else {
Timber.v("## VOIP Can't play $player ode $ringerMode")
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package im.vector.app.core.ui.views

import android.content.Context
import android.util.AttributeSet
import android.widget.RelativeLayout
import android.util.TypedValue
import android.widget.FrameLayout
import androidx.appcompat.content.res.AppCompatResources
import im.vector.app.R
import im.vector.app.databinding.ViewCurrentCallsBinding
import im.vector.app.features.call.webrtc.WebRtcCall
Expand All @@ -29,7 +31,7 @@ class CurrentCallsView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr) {
) : FrameLayout(context, attrs, defStyleAttr) {

interface Callback {
fun onTapToReturnToCall()
Expand All @@ -42,25 +44,33 @@ class CurrentCallsView @JvmOverloads constructor(
inflate(context, R.layout.view_current_calls, this)
views = ViewCurrentCallsBinding.bind(this)
setBackgroundColor(ThemeUtils.getColor(context, R.attr.colorPrimary))
val outValue = TypedValue().also {
context.theme.resolveAttribute(android.R.attr.selectableItemBackground, it, true)
}
foreground = AppCompatResources.getDrawable(context, outValue.resourceId)
setOnClickListener { callback?.onTapToReturnToCall() }
}

fun render(calls: List<WebRtcCall>, formattedDuration: String) {
val connectedCalls = calls.filter {
it.mxCall.state is CallState.Connected
}
val heldCalls = connectedCalls.filter {
it.isLocalOnHold || it.remoteOnHold
}
if (connectedCalls.isEmpty()) return
views.currentCallsInfo.text = if (connectedCalls.size == heldCalls.size) {
resources.getQuantityString(R.plurals.call_only_paused, heldCalls.size, heldCalls.size)
} else {
if (heldCalls.isEmpty()) {
resources.getString(R.string.call_only_active, formattedDuration)
} else {
resources.getQuantityString(R.plurals.call_one_active_and_other_paused, heldCalls.size, formattedDuration, heldCalls.size)
val tapToReturnFormat = if (calls.size == 1) {
val firstCall = calls.first()
when (firstCall.mxCall.state) {
is CallState.Idle,
is CallState.CreateOffer,
is CallState.LocalRinging,
is CallState.Dialing -> {
resources.getString(R.string.call_ringing)
}
is CallState.Answering -> {
resources.getString(R.string.call_connecting)
}
else -> {
resources.getString(R.string.call_one_active, formattedDuration)
}
}
} else {
resources.getQuantityString(R.plurals.call_active_status, calls.size, calls.size)
}
views.currentCallsInfo.text = resources.getString(R.string.call_tap_to_return, tapToReturnFormat)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package im.vector.app.core.ui.views

import androidx.core.view.isVisible
import im.vector.app.features.call.webrtc.WebRtcCall

class CurrentCallsViewPresenter {

private var currentCallsView: CurrentCallsView? = null
private var currentCall: WebRtcCall? = null
private var calls: List<WebRtcCall> = emptyList()

private val tickListener = object : WebRtcCall.Listener {
override fun onTick(formattedDuration: String) {
currentCallsView?.render(calls, formattedDuration)
}
}

fun updateCall(currentCall: WebRtcCall?, calls: List<WebRtcCall>) {
this.currentCall?.removeListener(tickListener)
this.currentCall = currentCall
this.currentCall?.addListener(tickListener)
this.calls = calls
val hasActiveCall = currentCall != null
currentCallsView?.isVisible = hasActiveCall
currentCallsView?.render(calls, currentCall?.formattedDuration() ?: "")
}

fun bind(activeCallView: CurrentCallsView, interactionListener: CurrentCallsView.Callback) {
this.currentCallsView = activeCallView
this.currentCallsView?.callback = interactionListener
this.currentCall?.addListener(tickListener)
}

fun unBind() {
this.currentCallsView?.callback = null
this.currentCall?.removeListener(tickListener)
currentCallsView = null
}
}
Loading

0 comments on commit 5b908c4

Please sign in to comment.