<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Nextcloud Talk application
  ~
  ~ @author Andy Scherzinger
  ~ @author Mario Danic
  ~ @author Marcel Hibbe
  ~ @author Tim Krüger
  ~ Copyright (C) 2023 Andy Scherzinger <
  ~ Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
  ~ Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
  ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
  ~
  ~ 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/>.
  -->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/callLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    tools:context=".activities.CallActivity">

    <LinearLayout
        android:id="@+id/linearWrapperLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/conversationRelativeLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@color/grey950"
            android:visibility="visible"
            tools:visibility="visible">

            <GridView
                android:id="@+id/gridview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center"
                android:numColumns="2"
                android:scrollbars="vertical"
                android:stretchMode="columnWidth"
                tools:listitem="@layout/call_item" />

            <FrameLayout
                android:id="@+id/selfVideoViewWrapper"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <org.webrtc.SurfaceViewRenderer
                    android:id="@+id/selfVideoRenderer"
                    android:layout_width="@dimen/call_self_video_short_side_length"
                    android:layout_height="@dimen/call_self_video_long_side_length"
                    android:layout_gravity="center"
                    android:layout_margin="16dp"
                    android:clickable="false"
                    android:visibility="invisible"
                    tools:visibility="visible" />

                <ImageView
                    android:id="@+id/switchSelfVideoButton"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:layout_gravity="center_horizontal|bottom"
                    android:layout_marginBottom="20dp"
                    android:contentDescription="@string/nc_call_button_content_description_switch_to_self_vide"
                    app:srcCompat="@drawable/ic_switch_video_white_24px" />

                <ProgressBar
                    android:id="@+id/selfVideoViewProgressBar"
                    style="?android:attr/progressBarStyle"
                    android:layout_width="@dimen/call_self_participant_progress_bar_size"
                    android:layout_height="@dimen/call_self_participant_progress_bar_size"
                    android:layout_gravity="center"
                    android:visibility="gone" />
            </FrameLayout>

            <LinearLayout
                android:id="@+id/call_indicator_controls"
                android:layout_width="match_parent"
                android:layout_height="20dp"
                android:layout_margin="20dp"
                android:animateLayoutChanges="true"
                android:background="@android:color/transparent"
                android:orientation="horizontal"
                android:weightSum="1">

                <ImageView
                    android:id="@+id/call_recording_indicator"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@null"
                    android:src="@drawable/record_stop"
                    android:translationZ="2dp"
                    android:visibility="gone"
                    tools:visibility="visible"></ImageView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/callInfosLinearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:animateLayoutChanges="true"
                android:gravity="center"
                android:orientation="vertical"
                android:paddingTop="20dp">

                <TextView
                    android:id="@+id/callModeTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:textColor="@color/call_incomingCallTextView"
                    android:textSize="16sp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:text="Voice Call" />

                <TextView
                    android:id="@+id/call_duration"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:textColor="@color/white"
                    android:textSize="16sp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:text="00:22" />

                <TextView
                    android:id="@+id/callConversationNameTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:layout_marginBottom="15dp"
                    android:ellipsize="marquee"
                    android:textAlignment="center"
                    android:textColor="@color/white"
                    android:textSize="22sp"
                    android:textStyle="bold"
                    tools:text="Marsellus Wallace" />
            </LinearLayout>

            <View
                android:id="@+id/verticalCenter"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true" />

            <include
                android:id="@+id/callStates"
                layout="@layout/call_states"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignTop="@id/verticalCenter"
                android:layout_marginTop="-50dp" />

        </RelativeLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@id/linearWrapperLayout"
        android:gravity="center_vertical"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="300dp">

            <RelativeLayout
                android:id="@+id/reaction_animation_wrapper"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginStart="50dp"
                android:layout_marginBottom="50dp">
            </RelativeLayout>

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/lower_hand_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentBottom="true"
                android:layout_marginEnd="@dimen/standard_margin"
                android:layout_marginBottom="@dimen/standard_half_margin"
                android:contentDescription="@string/lower_hand"
                android:visibility="gone"
                app:backgroundTint="@color/call_buttons_background"
                app:borderWidth="0dp"
                app:fabCustomSize="40dp"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_baseline_do_not_touch_24"
                app:tint="@color/white"
                tools:visibility="visible" />

        </RelativeLayout>

        <com.google.android.flexbox.FlexboxLayout
            android:id="@+id/callControls"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:animateLayoutChanges="true"
            android:background="@android:color/transparent"
            android:gravity="center"
            android:minHeight="@dimen/call_controls_height"
            android:orientation="horizontal"
            android:paddingStart="@dimen/standard_half_padding"
            android:paddingEnd="@dimen/standard_half_padding"
            app:alignItems="center"
            app:flexWrap="wrap"
            app:justifyContent="center">

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/pictureInPictureButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/standard_quarter_margin"
                android:contentDescription="@string/nc_call_button_content_description_pip"
                app:backgroundTint="@color/call_buttons_background"
                app:borderWidth="0dp"
                app:fabCustomSize="@dimen/fab_small"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_baseline_picture_in_picture_alt_24"
                app:tint="@color/white" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/audioOutputButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/standard_quarter_margin"
                android:contentDescription="@string/nc_call_button_content_description_audio_output"
                app:backgroundTint="@color/call_buttons_background"
                app:borderWidth="0dp"
                app:fabCustomSize="40dp"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_volume_mute_white_24dp"
                app:tint="@color/white" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/cameraButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/standard_quarter_margin"
                android:alpha="0.7"
                android:contentDescription="@string/nc_call_button_content_description_camera"
                app:backgroundTint="@color/call_buttons_background"
                app:borderWidth="0dp"
                app:fabCustomSize="40dp"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_videocam_white_24px"
                app:tint="@color/white" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/microphoneButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/standard_quarter_margin"
                android:alpha="0.7"
                android:contentDescription="@string/nc_call_button_content_description_microphone"
                app:backgroundTint="@color/call_buttons_background"
                app:borderWidth="0dp"
                app:fabCustomSize="40dp"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_mic_off_white_24px"
                app:tint="@color/white" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/more_call_actions"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/standard_quarter_margin"
                android:contentDescription="@string/nc_call_button_content_description_microphone"
                app:backgroundTint="@color/call_buttons_background"
                app:borderWidth="0dp"
                app:fabCustomSize="40dp"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_dots_horizontal_white"
                app:tint="@color/white" />

            <com.google.android.material.floatingactionbutton.FloatingActionButton
                android:id="@+id/hangupButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="@dimen/standard_quarter_margin"
                android:contentDescription="@string/nc_call_button_content_description_microphone"
                app:backgroundTint="@color/nc_darkRed"
                app:borderWidth="0dp"
                app:fabCustomSize="40dp"
                app:shapeAppearance="@style/fab_3_rounded"
                app:srcCompat="@drawable/ic_call_end_white_24px"
                app:tint="@color/white" />
        </com.google.android.flexbox.FlexboxLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/pipGroupCallOverlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/black"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="gone">

        <TextView
            android:id="@+id/pipCallConversationNameTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:layout_marginTop="-30dp"
            android:layout_marginEnd="5dp"
            android:layout_marginBottom="15dp"
            android:ellipsize="end"
            android:maxLines="3"
            android:textAlignment="center"
            android:textColor="@color/white"
            android:textSize="16sp"
            tools:text="our group call" />

        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            app:srcCompat="@drawable/ic_circular_group"
            tools:ignore="ContentDescription" />

    </LinearLayout>

</RelativeLayout>
