<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/readaloud_expanded_player"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <!-- Drag handlebar. -->
    <ImageView
        android:id="@+id/drag_handlebar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/readaloud_sheet_drag_bar_margin"
        android:layout_marginBottom="@dimen/readaloud_sheet_drag_bar_margin"
        android:layout_gravity="center_horizontal|top"
        android:importantForAccessibility="no"
        android:src="@drawable/drag_handlebar" />

    <!-- Scroll view in case the player is taller than the screen. -->
    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <!-- Container for scrolling. -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <!-- Error layout. -->
            <LinearLayout
                android:id="@+id/error_layout"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="@dimen/error_layour_portrait_height"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="289dp"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:paddingBottom="24dp">
                    <ImageView
                        android:layout_width="24dp"
                        android:layout_height="24dp"
                        android:layout_gravity="center"
                        android:src="@drawable/error_24"
                        android:clickable="false"
                        android:focusable="false"
                        android:importantForAccessibility="no"/>

                    <!-- Error message -->
                    <TextView
                        android:id="@+id/error_message"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:paddingVertical="4dp"
                        android:text="@string/readaloud_expanded_playback_error"
                        android:textAppearance="@style/TextAppearance.Headline2.Primary"
                        android:textAlignment="center"
                        android:clickable="false"
                        android:focusable="false"
                        android:ellipsize="none"/>
                    <TextView
                        android:id="@+id/error_message"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/readaloud_expanded_playback_error_description"
                        android:textAppearance="@style/TextAppearance.TextMedium.Primary"
                        android:paddingVertical="4dp"
                        android:textAlignment="center"
                        android:clickable="false"
                        android:focusable="false"
                        android:ellipsize="none"/>
                </LinearLayout>
            </LinearLayout>
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
            <!-- Normal layout. -->
            <LinearLayout
                android:id="@+id/normal_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginHorizontal="@dimen/readaloud_expanded_player_margin_horizontal"
                android:layout_marginBottom="@dimen/readaloud_expanded_player_margin_bottom"
                android:orientation="vertical">
                <TextView
                    android:id="@+id/chrome_now_playing_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginTop="@dimen/readaloud_now_playing_spacing_portrait"
                    android:text="@string/readaloud_chrome_now_playing"
                    android:textAppearance="@style/TextAppearance.TextMedium.Secondary"/>
                <!-- Title. -->
                <TextView
                    android:id="@+id/readaloud_expanded_player_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginVertical="@dimen/readaloud_expanded_player_title_margin_vertical"
                    android:layout_gravity="center_horizontal"
                    android:textAppearance="@style/TextAppearance.Headline2Thick.Primary"
                    android:ellipsize="end"
                    android:maxLines="1"/>

                <FrameLayout
                  android:id="@+id/readaloud_player_publisher_container"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center_horizontal"
                  android:minWidth="48dp"
                  android:minHeight="48dp"
                  android:clickable="true"
                  android:focusable="true">
                  <!-- Publisher button. -->
                  <LinearLayout
                      android:id="@+id/readaloud_player_publisher_button"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"
                      android:layout_gravity="center_horizontal"
                      android:background="@drawable/secondary_gray_rounded"
                      android:clickable="false"
                      android:focusable="false">
                      <TextView
                          android:id="@+id/readaloud_expanded_player_publisher"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_marginStart="@dimen/readaloud_expanded_player_publisher_margin_left"
                          android:layout_marginVertical="@dimen/readaloud_expanded_player_publisher_margin_vertical"
                          android:textAppearance="@style/TextAppearance.TextMedium.Primary"
                          android:ellipsize="end"
                          android:maxLines="1"/>
                      <ImageView
                          android:layout_width="@dimen/readaloud_expanded_player_publisher_chevron_width"
                          android:layout_height="@dimen/readaloud_expanded_player_publisher_chevron_height"
                          android:layout_marginHorizontal="@dimen/readaloud_expanded_player_publisher_chevron_margin_horizontal"
                          android:layout_marginVertical="@dimen/readaloud_expanded_player_publisher_chevron_margin_vertical"
                          android:src="@drawable/chevron_right"
                          android:importantForAccessibility="no"/>
                  </LinearLayout>
                </FrameLayout>

                <!-- Seek bar and times. -->
                <SeekBar
                    android:id="@+id/readaloud_expanded_player_seek_bar"
                    android:layout_marginTop="@dimen/readaloud_expanded_player_seek_bar_margin_top"
                    android:paddingTop="@dimen/readaloud_expanded_player_seek_bar_vertical_padding"
                    android:paddingBottom="@dimen/readaloud_expanded_player_seek_bar_vertical_padding"
                    android:paddingEnd="2dp"
                    android:paddingStart="2dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:max="1000"
                    android:progress="0"
                    android:maxHeight="@dimen/readaloud_expanded_player_seek_bar_height"
                    android:progressDrawable="@drawable/seekbar_style"
                    android:thumb="@drawable/scrubber_select_handle"
                    android:splitTrack="false"/>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">
                    <TextView
                        android:id="@+id/readaloud_player_time"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="0"
                        android:textAppearance="@style/TextAppearance.TextSmall.Primary"
                        android:importantForAccessibility="no"/>
                    <View
                        android:layout_width="fill_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"/>
                    <TextView
                        android:id="@+id/readaloud_player_duration"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="0"
                        android:textAppearance="@style/TextAppearance.TextSmall.Primary"
                        android:importantForAccessibility="no"/>
                </LinearLayout>

                <!-- Speed menu, playback controls and overflow menu. -->
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <LinearLayout
                        android:id="@+id/readaloud_playback_controls"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:paddingBottom="60dp"
                        android:layout_gravity="center_horizontal">
                           <ImageView
                              android:id="@+id/readaloud_seek_back_button"
                              android:layout_width="@dimen/readaloud_control_button_diameter"
                              android:layout_height="@dimen/readaloud_control_button_diameter"
                              android:src="@drawable/replay_10_button"
                              android:background="@drawable/rounded_ripple"
                              android:contentDescription="@string/readaloud_replay"
                              android:accessibilityTraversalAfter="@+id/readaloud_expanded_player_seek_bar"/>
                          <ImageView
                              android:id="@+id/readaloud_play_pause_button"
                              android:layout_width="@dimen/readaloud_play_button_width"
                              android:layout_height="@dimen/readaloud_control_button_diameter"
                              android:layout_marginHorizontal="@dimen/readaloud_control_button_spacing"
                              android:src="@drawable/play_button"
                              android:background="@drawable/rounded_ripple"
                              android:contentDescription="@string/readaloud_play"
                              android:accessibilityTraversalAfter="@+id/readaloud_seek_back_button"/>
                          <ImageView
                              android:id="@+id/readaloud_seek_forward_button"
                              android:layout_width="@dimen/readaloud_control_button_diameter"
                              android:layout_height="@dimen/readaloud_control_button_diameter"
                              android:src="@drawable/forward_10_button"
                              android:background="@drawable/rounded_ripple"
                              android:contentDescription="@string/readaloud_forward"
                              android:accessibilityTraversalAfter="@+id/readaloud_play_pause_button"/>
                    </LinearLayout>
                    <LinearLayout
                        android:id="@+id/bottom_controls_container"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:layout_alignParentBottom="true"
                        android:accessibilityTraversalAfter="@+id/readaloud_playback_controls">
                        <ImageView
                            android:id="@+id/readaloud_mode_selector"
                            android:layout_width="@dimen/readaloud_playback_mode_selector_diameter"
                            android:layout_height="@dimen/readaloud_playback_mode_selector_diameter"
                            android:padding="8dp"
                            android:src="@drawable/mode_selector_stateful"
                            android:foreground="@drawable/rounded_ripple"
                            android:layout_gravity="center_vertical"
                            android:layout_marginRight="10dp"
                            android:clickable="true"
                            android:visibility="gone"
                            android:accessibilityTraversalAfter="@+id/readaloud_seek_forward_button"/>
                            <FrameLayout
                                android:id="@+id/readaloud_playback_speed_container"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:minWidth="48dp"
                                android:minHeight="48dp">
                              <TextView
                                  android:id="@+id/readaloud_playback_speed"
                                  android:layout_width="wrap_content"
                                  android:maxLines="1"
                                  android:layout_height="@dimen/readaloud_menu_buttons_width"
                                  android:layout_gravity="center_vertical"
                                  android:gravity="center_vertical"
                                  android:textAppearance="@style/TextAppearance.TextAccentMediumThick.Primary"
                                  tools:ignore="ContentDescription"
                                  android:accessibilityTraversalAfter="@+id/readaloud_mode_selector"/>
                            </FrameLayout>
                        <!-- Note: contentDescription for playback speed button above is set in ExpandedPlayerSheetContent.java. -->
                         <View
                            android:layout_width="0dp"
                            android:layout_height="0dp"
                            android:layout_weight="1" />
                        <ImageView
                            android:id="@+id/readaloud_more_button"
                            android:layout_width="@dimen/button_size"
                            android:layout_height="@dimen/button_size"
                            android:padding="12dp"
                            android:src="@drawable/baseline_more_horiz_24"
                            android:layout_gravity="center_vertical"
                            android:contentDescription="@string/readaloud_options_menu_button"/>
                        <ImageView
                            android:id="@+id/readaloud_thumb_up_button"
                            android:layout_width="@dimen/readaloud_playback_thumb_up_down_dimen"
                            android:layout_height="@dimen/readaloud_playback_thumb_up_down_dimen"
                            android:src="@drawable/feedback_thumb_up_selector"
                            android:padding="12dp"
                            android:background="?attr/selectableItemBackgroundBorderless"
                            android:clickable="true"
                            android:focusable="true"
                            android:layout_gravity="center_vertical"
                            android:layout_marginStart="8dp"
                            android:contentDescription="@string/readaloud_feedback_thumb_up"
                            android:visibility="gone" />
                        <ImageView
                            android:id="@+id/readaloud_thumb_down_button"
                            android:layout_width="@dimen/readaloud_playback_thumb_up_down_dimen"
                            android:layout_height="@dimen/readaloud_playback_thumb_up_down_dimen"
                            android:src="@drawable/feedback_thumb_down_selector"
                            android:padding="12dp"
                            android:background="?attr/selectableItemBackgroundBorderless"
                            android:clickable="true"
                            android:focusable="true"
                            android:layout_gravity="center_vertical"
                            android:contentDescription="@string/readaloud_feedback_thumb_down"
                            android:visibility="gone" />
                    </LinearLayout>
                </RelativeLayout>
            </LinearLayout>

            <TextView
                android:id="@+id/readaloud_loading_text"
                android:layout_width="wrap_content"
                android:maxLines="1"
                android:layout_gravity="bottom|start"
                android:layout_marginStart="@dimen/readaloud_expanded_player_loading_text_margin_start"
                android:layout_marginBottom="@dimen/readaloud_expanded_player_loading_text_margin_bottom"
                android:gravity="center_vertical"
                android:layout_height="@dimen/readaloud_menu_buttons_width"
                android:text="@string/readaloud_playback_loading"
                android:textAppearance="@style/TextAppearance.TextAccentMediumThick.Primary" />

            <!-- Loading layout -->
            <LinearLayout
                android:id="@+id/readaloud_loading_overlay"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center"
                android:layout_gravity="center">
                <ProgressBar
                    android:id="@+id/readaloud_loading_progress_bar"
                    style="?android:attr/progressBarStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="8dp"/>
                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>