mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Call UI: add toolbar
This commit is contained in:
parent
e888f2b15a
commit
7c033b4090
6 changed files with 83 additions and 64 deletions
|
@ -24,9 +24,9 @@ import android.graphics.Color
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContentProviderCompat.requireContext
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.view.isInvisible
|
||||
|
@ -38,13 +38,13 @@ import com.airbnb.mvrx.withState
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.core.utils.PERMISSIONS_FOR_AUDIO_IP_CALL
|
||||
import im.vector.app.core.utils.PERMISSIONS_FOR_VIDEO_IP_CALL
|
||||
import im.vector.app.core.utils.allGranted
|
||||
import im.vector.app.core.utils.checkPermissions
|
||||
import im.vector.app.databinding.ActivityCallBinding
|
||||
import im.vector.app.features.call.audio.CallAudioManager
|
||||
import im.vector.app.features.call.dialpad.CallDialPadBottomSheet
|
||||
import im.vector.app.features.call.dialpad.DialPadFragment
|
||||
import im.vector.app.features.call.utils.EglUtils
|
||||
|
@ -55,7 +55,6 @@ import im.vector.app.features.home.room.detail.RoomDetailActivity
|
|||
import im.vector.app.features.home.room.detail.RoomDetailArgs
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import me.gujun.android.span.span
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.call.CallState
|
||||
import org.matrix.android.sdk.api.session.call.MxPeerConnectionState
|
||||
|
@ -127,6 +126,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
if (savedInstanceState != null) {
|
||||
(supportFragmentManager.findFragmentByTag(FRAGMENT_DIAL_PAD_TAG) as? CallDialPadBottomSheet)?.callback = dialPadCallback
|
||||
}
|
||||
setSupportActionBar(views.callToolbar)
|
||||
configureCallViews()
|
||||
|
||||
callViewModel.subscribe(this) {
|
||||
|
@ -152,6 +152,16 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
}
|
||||
}
|
||||
|
||||
override fun getMenuRes() = R.menu.vector_call
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.menu_call_open_chat) {
|
||||
returnToChat()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
callManager.getCallById(callArgs.callId)?.detachRenderers(listOf(views.pipRenderer, views.fullscreenRenderer))
|
||||
if (surfaceRenderersAreInitialized) {
|
||||
|
@ -171,35 +181,27 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
|
||||
views.callControlsView.updateForState(state)
|
||||
val callState = state.callState.invoke()
|
||||
views.callConnectingProgress.isVisible = false
|
||||
views.callActionText.setOnClickListener(null)
|
||||
views.callActionText.isVisible = false
|
||||
views.smallIsHeldIcon.isVisible = false
|
||||
when (callState) {
|
||||
is CallState.Idle,
|
||||
is CallState.CreateOffer,
|
||||
is CallState.LocalRinging,
|
||||
is CallState.Dialing -> {
|
||||
views.callVideoGroup.isInvisible = true
|
||||
views.callInfoGroup.isVisible = true
|
||||
views.callStatusText.setText(R.string.call_ring)
|
||||
views.callToolbar.setSubtitle(R.string.call_ring)
|
||||
configureCallInfo(state)
|
||||
}
|
||||
|
||||
is CallState.LocalRinging -> {
|
||||
views.callVideoGroup.isInvisible = true
|
||||
views.callInfoGroup.isVisible = true
|
||||
views.callStatusText.text = null
|
||||
configureCallInfo(state)
|
||||
}
|
||||
|
||||
is CallState.Answering -> {
|
||||
views.callVideoGroup.isInvisible = true
|
||||
views.callInfoGroup.isVisible = true
|
||||
views.callStatusText.setText(R.string.call_connecting)
|
||||
views.callConnectingProgress.isVisible = true
|
||||
views.callToolbar.setSubtitle(R.string.call_connecting)
|
||||
configureCallInfo(state)
|
||||
}
|
||||
is CallState.Connected -> {
|
||||
views.callToolbar.subtitle = state.formattedDuration
|
||||
if (callState.iceConnectionState == MxPeerConnectionState.CONNECTED) {
|
||||
if (state.isLocalOnHold || state.isRemoteOnHold) {
|
||||
views.smallIsHeldIcon.isVisible = true
|
||||
|
@ -210,11 +212,11 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
views.callActionText.setText(R.string.call_resume_action)
|
||||
views.callActionText.isVisible = true
|
||||
views.callActionText.setOnClickListener { callViewModel.handle(VectorCallViewActions.ToggleHoldResume) }
|
||||
views.callStatusText.setText(R.string.call_held_by_you)
|
||||
views.callToolbar.setSubtitle(R.string.call_held_by_you)
|
||||
} else {
|
||||
views.callActionText.isInvisible = true
|
||||
state.callInfo?.opponentUserItem?.let {
|
||||
views.callStatusText.text = getString(R.string.call_held_by_user, it.getBestName())
|
||||
views.callToolbar.subtitle = getString(R.string.call_held_by_user, it.getBestName())
|
||||
}
|
||||
}
|
||||
} else if (state.transferee !is VectorCallViewState.TransfereeState.NoTransferee) {
|
||||
|
@ -226,10 +228,8 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
views.callActionText.text = getString(R.string.call_transfer_transfer_to_title, transfereeName)
|
||||
views.callActionText.isVisible = true
|
||||
views.callActionText.setOnClickListener { callViewModel.handle(VectorCallViewActions.TransferCall) }
|
||||
views.callStatusText.text = state.formattedDuration
|
||||
configureCallInfo(state)
|
||||
} else {
|
||||
views.callStatusText.text = state.formattedDuration
|
||||
configureCallInfo(state)
|
||||
if (callArgs.isVideoCall) {
|
||||
views.callVideoGroup.isVisible = true
|
||||
|
@ -245,8 +245,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
views.callVideoGroup.isInvisible = true
|
||||
views.callInfoGroup.isVisible = true
|
||||
configureCallInfo(state)
|
||||
views.callStatusText.setText(R.string.call_connecting)
|
||||
views.callConnectingProgress.isVisible = true
|
||||
views.callToolbar.setSubtitle(R.string.call_connecting)
|
||||
}
|
||||
}
|
||||
is CallState.Terminated -> {
|
||||
|
@ -262,9 +261,14 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
val colorFilter = ContextCompat.getColor(this, R.color.bg_call_screen_blur)
|
||||
avatarRenderer.renderBlur(it, views.bgCallView, sampling = 20, rounded = false, colorFilter = colorFilter, addPlaceholder = false)
|
||||
if (state.transferee is VectorCallViewState.TransfereeState.NoTransferee) {
|
||||
views.participantNameText.text = it.getBestName()
|
||||
views.participantNameText.setTextOrHide(null)
|
||||
views.callToolbar.title = if (state.isVideoCall) {
|
||||
getString(R.string.video_call_with_participant, it.getBestName())
|
||||
} else {
|
||||
getString(R.string.audio_call_with_participant, it.getBestName())
|
||||
}
|
||||
} else {
|
||||
views.participantNameText.text = getString(R.string.call_transfer_consulting_with, it.getBestName())
|
||||
views.participantNameText.setTextOrHide(getString(R.string.call_transfer_consulting_with, it.getBestName()))
|
||||
}
|
||||
if (blurAvatar) {
|
||||
avatarRenderer.renderBlur(it, views.otherMemberAvatar, sampling = 2, rounded = true, colorFilter = colorFilter, addPlaceholder = true)
|
||||
|
|
10
vector/src/main/res/drawable/ic_call_back_to_chat.xml
Normal file
10
vector/src/main/res/drawable/ic_call_back_to_chat.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M22.8,12C22.8,17.9646 17.9647,22.8 12,22.8C10.0252,22.8 8.1742,22.2699 6.5815,21.3444L2.4145,22.6302C1.6455,22.8675 0.9255,22.1455 1.1649,21.3772L2.4903,17.1235C1.6672,15.599 1.2,13.854 1.2,12C1.2,6.0353 6.0353,1.1999 12,1.1999C17.9647,1.1999 22.8,6.0353 22.8,12ZM8.4,12C8.4,12.6627 7.8628,13.2 7.2,13.2C6.5373,13.2 6,12.6627 6,12C6,11.3372 6.5373,10.8 7.2,10.8C7.8628,10.8 8.4,11.3372 8.4,12ZM12,13.2C12.6628,13.2 13.2,12.6627 13.2,12C13.2,11.3372 12.6628,10.8 12,10.8C11.3373,10.8 10.8,11.3372 10.8,12C10.8,12.6627 11.3373,13.2 12,13.2ZM18,12C18,12.6627 17.4628,13.2 16.8,13.2C16.1373,13.2 15.6,12.6627 15.6,12C15.6,11.3372 16.1373,10.8 16.8,10.8C17.4628,10.8 18,11.3372 18,12Z"
|
||||
android:fillColor="#ffffff"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
|
@ -22,9 +22,11 @@
|
|||
|
||||
<org.webrtc.SurfaceViewRenderer
|
||||
android:id="@+id/fullscreenRenderer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<org.webrtc.SurfaceViewRenderer
|
||||
|
@ -37,6 +39,25 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/callToolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:fitsSystemWindows="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="@drawable/ic_back_24dp"
|
||||
app:navigationIconTint="@color/element_background_light"
|
||||
app:subtitle="3:10"
|
||||
app:subtitleTextAppearance="@style/TextAppearance.Vector.Caption"
|
||||
app:subtitleTextColor="@color/element_background_light"
|
||||
app:title="Video call"
|
||||
app:titleMarginTop="16dp"
|
||||
app:titleTextAppearance="@style/TextAppearance.Vector.Body.Medium"
|
||||
app:titleTextColor="@color/element_background_light" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/otherKnownCallLayout"
|
||||
android:layout_width="80dp"
|
||||
|
@ -112,22 +133,6 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/otherMemberAvatar"
|
||||
tools:text="@sample/users.json/data/displayName" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/callStatusText"
|
||||
style="@style/Widget.Vector.TextView.Body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="@dimen/layout_horizontal_margin"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/participantNameText"
|
||||
tools:text="@string/call_connecting" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/callActionText"
|
||||
style="@style/Widget.Vector.Button.Text"
|
||||
|
@ -138,27 +143,16 @@
|
|||
android:textColor="?colorSecondary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/callStatusText"
|
||||
app:layout_constraintTop_toBottomOf="@id/participantNameText"
|
||||
tools:text="@string/call_resume_action" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/callConnectingProgress"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_margin="8dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/callStatusText"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/callInfoGroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="visible"
|
||||
app:constraint_referenced_ids="participantNameText, otherMemberAvatar,callStatusText" />
|
||||
app:constraint_referenced_ids="participantNameText, otherMemberAvatar" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/callVideoGroup"
|
||||
|
|
|
@ -58,8 +58,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:visibility="gone"
|
||||
tools:background="@color/password_strength_bar_low"
|
||||
tools:layout_marginTop="120dp"
|
||||
|
@ -74,9 +74,9 @@
|
|||
android:contentDescription="@string/call_select_sound_device"
|
||||
android:focusable="true"
|
||||
android:scaleType="center"
|
||||
app:tint="?vctr_content_primary"
|
||||
app:backgroundTint="?android:colorBackground"
|
||||
android:src="@drawable/ic_call_audio_settings"
|
||||
app:backgroundTint="?android:colorBackground"
|
||||
app:tint="?vctr_content_primary"
|
||||
tools:ignore="MissingConstraints,MissingPrefix" />
|
||||
|
||||
<ImageView
|
||||
|
@ -126,25 +126,23 @@
|
|||
android:id="@+id/moreIcon"
|
||||
android:layout_width="@dimen/layout_touch_size"
|
||||
android:layout_height="@dimen/layout_touch_size"
|
||||
android:background="@drawable/bg_rounded_button"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/endCallIcon"
|
||||
android:background="@drawable/bg_rounded_button"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/settings"
|
||||
android:focusable="true"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_more_horizontal"
|
||||
app:tint="@android:color/white"
|
||||
/>
|
||||
tools:ignore="MissingConstraints,MissingPrefix" />
|
||||
|
||||
<androidx.constraintlayout.helper.widget.Flow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="audioSettingsIcon,videoToggleIcon, muteIcon, endCallIcon"
|
||||
app:constraint_referenced_ids="audioSettingsIcon,videoToggleIcon, muteIcon, endCallIcon, moreIcon"
|
||||
app:flow_horizontalGap="16dp"
|
||||
app:flow_horizontalStyle="packed"
|
||||
app:flow_wrapMode="chain"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
11
vector/src/main/res/menu/vector_call.xml
Normal file
11
vector/src/main/res/menu/vector_call.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_call_open_chat"
|
||||
app:showAsAction="always"
|
||||
android:icon="@drawable/ic_call_back_to_chat"
|
||||
android:title="@string/a11y_open_chat" />
|
||||
|
||||
</menu>
|
|
@ -728,6 +728,8 @@
|
|||
<string name="incoming_voice_call">Incoming Voice Call</string>
|
||||
<string name="call_in_progress">Call In Progress…</string>
|
||||
<string name="video_call_in_progress">Video Call In Progress…</string>
|
||||
<string name="video_call_with_participant">Video call with %s</string>
|
||||
<string name="audio_call_with_participant">Audio call with %s</string>
|
||||
<string name="active_call_with_duration">Active Call (%s)</string>
|
||||
<string name="return_to_call">Return to call</string>
|
||||
<string name="call_resume_action">Resume</string>
|
||||
|
|
Loading…
Reference in a new issue