mirror of
https://github.com/videolan/vlc-android
synced 2024-11-23 09:56:36 +08:00
Improve the subtitle download UI
This commit is contained in:
parent
4412753cb3
commit
937b94d25d
@ -6,7 +6,7 @@
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?attr/colorControlNormal"
|
||||
android:fillColor="@color/standard_selection_control_normal"
|
||||
tools:fillColor="@color/white"
|
||||
android:pathData="M14.06,9.02l0.92,0.92L5.92,19L5,19v-0.92l9.06,-9.06M17.66,3c-0.25,0 -0.51,0.1 -0.7,0.29l-1.83,1.83 3.75,3.75 1.83,-1.83c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.2,-0.2 -0.45,-0.29 -0.71,-0.29zM14.06,6.19L3,17.25L3,21h3.75L17.81,9.94l-3.75,-3.75z" />
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/orange700" />
|
||||
|
||||
</shape>
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ *************************************************************************
|
||||
~ rounded_corners_line.xml
|
||||
~ **************************************************************************
|
||||
~ Copyright © 2020 VLC authors and VideoLAN
|
||||
~ Author: Nicolas POMEPUY
|
||||
~ 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 2 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, write to the Free Software
|
||||
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
||||
~ ***************************************************************************
|
||||
~
|
||||
~
|
||||
-->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="?attr/colorControlNormal" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
@ -716,6 +716,7 @@
|
||||
<string name="popup_playback">Playing in a Pop-Up window</string>
|
||||
<string name="popup_expand">Expand video</string>
|
||||
<string name="download_subtitles">Download subtitles</string>
|
||||
<string name="powered_opensubtitles">Powered by OpenSubtitles. Remaining downloads : %s</string>
|
||||
<string name="open_subtitles_login_title">Open subtitles login</string>
|
||||
<string name="open_subtitles_not_logged_in">You are not logged in</string>
|
||||
<string name="open_subtitles_logged_in">Welcome %1$s</string>
|
||||
@ -987,7 +988,7 @@
|
||||
<string name="sub_result_by_name">Results for %s</string>
|
||||
<string name="sub_result_by_name_season">Season %s</string>
|
||||
<string name="sub_result_by_name_episode">Episode %s</string>
|
||||
<string name="sub_result_by_name_hearing_impaired">only hearing impaired</string>
|
||||
<string name="sub_result_by_name_hearing_impaired">Only hearing impaired</string>
|
||||
|
||||
<string name="sub_result_by_file">Results for your file</string>
|
||||
<string name="donate">Help VLC</string>
|
||||
|
@ -23,33 +23,38 @@
|
||||
~
|
||||
-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout 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:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/language_text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_language" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/badge"
|
||||
android:layout_width="0dp"
|
||||
android:id="@+id/language_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/round_orange"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="10sp"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="?attr/font_default"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:text="3" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="EN - FR" />
|
||||
</LinearLayout>
|
@ -57,11 +57,11 @@
|
||||
android:id="@+id/language"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@{subtitleItem.subLanguageID.trim()}"
|
||||
android:text="@{subtitleItem.subLanguageID.trim().toUpperCase()}"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/font_default"
|
||||
android:textSize="12sp"
|
||||
|
@ -40,108 +40,256 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:singleLine="true"
|
||||
android:text="@string/download_subtitles"
|
||||
android:textAppearance="@style/Theme.VLC.BottomSheetTitle"
|
||||
app:layout_constraintEnd_toStartOf="@+id/language_list_spinner"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sub_download_history"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Game of Thrones - S01e01" />
|
||||
app:layout_constraintTop_toTopOf="@+id/sub_download_history" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/limit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{viewmodel.observableLimit.get().getRemainingText()}"
|
||||
app:layout_constraintStart_toStartOf="@+id/movieName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/movieName" />
|
||||
|
||||
<org.videolan.vlc.gui.view.LanguageSelector
|
||||
android:id="@+id/language_list_spinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:focusable="true"
|
||||
android:padding="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/movieName"
|
||||
app:layout_constraintEnd_toStartOf="@+id/sub_download_search"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/movieName"
|
||||
app:layout_constraintTop_toTopOf="@+id/movieName" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sub_download_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:focusable="true"
|
||||
android:padding="4dp"
|
||||
android:contentDescription="@string/search"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/movieName"
|
||||
app:layout_constraintEnd_toStartOf="@+id/sub_download_history"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/language_list_spinner"
|
||||
app:layout_constraintTop_toTopOf="@+id/movieName"
|
||||
app:srcCompat="@drawable/ic_search" />
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@{@string/powered_opensubtitles(viewmodel.observableLimit.get().getRemainingText())}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sub_download_history"
|
||||
tools:text="@string/powered_opensubtitles" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sub_download_history"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:focusable="true"
|
||||
android:padding="4dp"
|
||||
android:contentDescription="@string/talkback_subtitle_history"
|
||||
android:focusable="true"
|
||||
android:padding="8dp"
|
||||
android:selected="@{state == state.History}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/movieName"
|
||||
app:layout_constraintEnd_toStartOf="@+id/sub_login"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/sub_download_search"
|
||||
app:layout_constraintTop_toTopOf="@+id/movieName"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_history" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sub_login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/login"
|
||||
android:focusable="true"
|
||||
android:padding="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/movieName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:padding="8dp"
|
||||
android:selected="@{state == state.Login}"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/sub_download_history"
|
||||
app:layout_constraintTop_toTopOf="@+id/movieName"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_account" />
|
||||
|
||||
|
||||
<TextView
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/result_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@{viewmodel.observableResultDescription}"
|
||||
android:textColor="?attr/font_default"
|
||||
android:textSize="11sp"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/rounded_corners_line"
|
||||
android:visibility="@{state == state.Download ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/movieName"
|
||||
tools:text="Results for your file" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/limit">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView38"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:text="@{viewmodel.observableResultDescription}"
|
||||
android:textColor="?attr/font_default"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/nameContainer"
|
||||
app:layout_constraintEnd_toStartOf="@+id/open_sub_edit"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_goneMarginBottom="16dp"
|
||||
tools:text="Results for your file" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/open_sub_edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:padding="8dp"
|
||||
android:selected="@{viewmodel.observableInEditMode.get()}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView38"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView38"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView38"
|
||||
app:srcCompat="@drawable/ic_edit" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/nameContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/seasonContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView38">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:focusable="true"
|
||||
android:hint="@string/subtitle_search_name_hint"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:nextFocusDown="@id/season"
|
||||
android:text="@={viewmodel.observableSearchName}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/seasonContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/episodeContainer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameContainer">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/season"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:focusable="true"
|
||||
android:hint="@string/subtitle_search_season_hint"
|
||||
android:inputType="textPersonName|number"
|
||||
android:nextFocusRight="@+id/episode"
|
||||
android:nextFocusDown="@+id/episode"
|
||||
android:nextFocusForward="@+id/episode"
|
||||
android:text="@={viewmodel.observableSearchSeason}"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/episodeContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/language_list_spinner"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seasonContainer">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/episode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:focusable="true"
|
||||
android:hint="@string/subtitle_search_episode_hint"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPersonName|number"
|
||||
android:nextFocusRight="@+id/search_button"
|
||||
android:nextFocusDown="@+id/search_button"
|
||||
android:nextFocusForward="@+id/search_button"
|
||||
android:text="@={viewmodel.observableSearchEpisode}"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.checkbox.MaterialCheckBox
|
||||
android:id="@+id/checkBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:checked="@={viewmodel.observableSearchHearingImpaired.get()}"
|
||||
android:paddingStart="4dp"
|
||||
android:text="@string/sub_result_by_name_hearing_impaired"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/search_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/language_list_spinner" />
|
||||
|
||||
<org.videolan.vlc.gui.view.LanguageSelector
|
||||
android:id="@+id/language_list_spinner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:focusable="true"
|
||||
android:padding="4dp"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/checkBox"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/episodeContainer" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:focusable="true"
|
||||
android:text="@string/cancel"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/search_button"
|
||||
app:layout_constraintTop_toTopOf="@+id/search_button" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/search_button"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:enabled="@{!TextUtils.isEmpty(viewmodel.observableSearchName.get().trim())}"
|
||||
android:focusable="true"
|
||||
android:text="@android:string/search_go"
|
||||
android:visibility="@{viewmodel.observableInEditMode.get() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/checkBox" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/subs_download_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:defaultFocusHighlightEnabled="false"
|
||||
android:minHeight="160dp"
|
||||
android:visibility="@{state == state.Download ? View.VISIBLE : View.GONE}"
|
||||
@ -182,6 +330,7 @@
|
||||
android:id="@+id/subs_history_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:minHeight="160dp"
|
||||
android:visibility="@{state == state.History ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -199,115 +348,12 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/subs_download_list" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/nameContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/subs_download_list">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:focusable="true"
|
||||
android:hint="@string/subtitle_search_name_hint"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:nextFocusDown="@id/season"
|
||||
android:text="@={viewmodel.observableSearchName}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/seasonContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintStart_toStartOf="@+id/nameContainer"
|
||||
app:layout_constraintTop_toBottomOf="@+id/nameContainer">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/season"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:focusable="true"
|
||||
android:hint="@string/subtitle_search_season_hint"
|
||||
android:inputType="textPersonName|number"
|
||||
android:nextFocusRight="@+id/episode"
|
||||
android:nextFocusDown="@+id/episode"
|
||||
android:nextFocusForward="@+id/episode"
|
||||
android:text="@={viewmodel.observableSearchSeason}"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/episodeContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/seasonContainer"
|
||||
app:layout_constraintStart_toEndOf="@+id/seasonContainer"
|
||||
app:layout_constraintTop_toTopOf="@+id/seasonContainer">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/episode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:focusable="true"
|
||||
android:hint="@string/subtitle_search_episode_hint"
|
||||
android:inputType="textPersonName|number"
|
||||
android:nextFocusDown="@+id/search_button"
|
||||
android:nextFocusRight="@+id/search_button"
|
||||
android:nextFocusForward="@+id/search_button"
|
||||
android:imeOptions="actionDone"
|
||||
android:text="@={viewmodel.observableSearchEpisode}"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:focusable="true"
|
||||
android:text="@string/cancel"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toStartOf="@+id/search_button"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seasonContainer" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/search_button"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:enabled="@{!TextUtils.isEmpty(viewmodel.observableSearchName.get().trim())}"
|
||||
android:focusable="true"
|
||||
android:text="@android:string/search_go"
|
||||
android:visibility="@{state == state.Search ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/seasonContainer" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView37"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/open_subtitles_login_title"
|
||||
android:textColor="?attr/font_default"
|
||||
@ -315,7 +361,7 @@
|
||||
android:visibility="@{state == state.Login ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cancel_button" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/subs_download_list" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loginDescription"
|
||||
|
@ -133,7 +133,10 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
|
||||
if (!token.isNullOrEmpty()) viewModel.checkUserInfos(settings)
|
||||
|
||||
binding.subLogin.setOnClickListener {
|
||||
state = SubDownloadDialogState.Login
|
||||
state = if (state == SubDownloadDialogState.Login)
|
||||
SubDownloadDialogState.Download
|
||||
else
|
||||
SubDownloadDialogState.Login
|
||||
}
|
||||
|
||||
binding.loginButton.setOnClickListener {
|
||||
@ -148,7 +151,6 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
binding.movieName.text = names ?: uris.lastPathSegment
|
||||
state = SubDownloadDialogState.Download
|
||||
|
||||
downloadAdapter = SubtitlesAdapter(listEventActor)
|
||||
@ -167,17 +169,27 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
|
||||
viewModel.search(false)
|
||||
focusOnView(binding.scrollView)
|
||||
state = SubDownloadDialogState.Download
|
||||
viewModel.observableInEditMode.set(false)
|
||||
|
||||
}
|
||||
binding.cancelButton.setOnClickListener {
|
||||
state = SubDownloadDialogState.Download
|
||||
viewModel.observableInEditMode.set(false)
|
||||
}
|
||||
|
||||
binding.subDownloadSearch.setOnClickListener {
|
||||
UiTools.setKeyboardVisibility(binding.name, true)
|
||||
binding.name.requestFocus()
|
||||
state = SubDownloadDialogState.Search
|
||||
}
|
||||
binding.openSubEdit.setOnClickListener {
|
||||
if (viewModel.observableInEditMode.get() == false) {
|
||||
//fill form
|
||||
val name = when {
|
||||
viewModel.observableSearchName.get().isNullOrBlank() -> names
|
||||
else -> viewModel.observableSearchName.get()
|
||||
}
|
||||
binding.name.setText(name)
|
||||
binding.season.setText(viewModel.observableSearchSeason.get())
|
||||
binding.episode.setText(viewModel.observableSearchEpisode.get())
|
||||
binding.checkBox.isChecked = viewModel.observableSearchHearingImpaired.get() == true
|
||||
}
|
||||
viewModel.observableInEditMode.set(viewModel.observableInEditMode.get()?.not())
|
||||
}
|
||||
|
||||
binding.subDownloadHistory.setOnClickListener {
|
||||
state = if (state == SubDownloadDialogState.History) SubDownloadDialogState.Download else SubDownloadDialogState.History
|
||||
@ -190,7 +202,7 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
|
||||
viewModel.observableSearchLanguage.set(selectedLanguages)
|
||||
}
|
||||
})
|
||||
//todo
|
||||
viewModel.observableInEditMode.set(false)
|
||||
viewModel.observableSearchHearingImpaired.set(false)
|
||||
viewModel.observableUser.set(user)
|
||||
viewModel.observableLimit.set(OpenSubtitlesUtils.getLimit(settings))
|
||||
@ -253,6 +265,5 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
|
||||
enum class SubDownloadDialogState {
|
||||
Download,
|
||||
History,
|
||||
Search,
|
||||
Login
|
||||
}
|
||||
|
@ -24,13 +24,13 @@
|
||||
|
||||
package org.videolan.vlc.gui.view
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.videolan.vlc.R
|
||||
|
||||
class LanguageSelector: ConstraintLayout, DialogInterface.OnDismissListener, DialogInterface.OnMultiChoiceClickListener {
|
||||
@ -43,8 +43,8 @@ class LanguageSelector: ConstraintLayout, DialogInterface.OnDismissListener, Dia
|
||||
return selection.mapIndexed { index, b -> Pair(index, b) }.filter { it.second }.map { it.first }
|
||||
}
|
||||
|
||||
val badge: TextView by lazy {
|
||||
findViewById<TextView>(R.id.badge)
|
||||
val languageText: TextView by lazy {
|
||||
findViewById(R.id.language_text)
|
||||
}
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
@ -65,7 +65,7 @@ class LanguageSelector: ConstraintLayout, DialogInterface.OnDismissListener, Dia
|
||||
LayoutInflater.from(context).inflate(R.layout.language_spinner, this, true)
|
||||
selection.addAll(allEntriesOfLanguages.map { false })
|
||||
setOnClickListener {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
val builder = MaterialAlertDialogBuilder(context)
|
||||
builder.setOnDismissListener(this)
|
||||
builder.setMultiChoiceItems(allEntriesOfLanguages, selection.toBooleanArray(), this)
|
||||
.setPositiveButton(R.string.done) { dialogInterface: DialogInterface, _: Int ->
|
||||
@ -98,7 +98,8 @@ class LanguageSelector: ConstraintLayout, DialogInterface.OnDismissListener, Dia
|
||||
}
|
||||
|
||||
private fun updateBadge() {
|
||||
badge.text = if (selectedIndices.isNotEmpty()) selectedIndices.size.toString() else "+"
|
||||
languageText.text =
|
||||
selectedIndices.joinToString(", ") { allValuesOfLanguages[it].uppercase() }
|
||||
}
|
||||
|
||||
fun setOnItemsSelectListener(onItemSelectListener: OnItemSelectListener) {
|
||||
|
@ -70,6 +70,7 @@ class SubtitlesModel(private val context: Context, private val mediaUri: Uri, pr
|
||||
val observableSearchSeason = ObservableField<String>()
|
||||
val observableSearchLanguage = ObservableField<List<String>>()
|
||||
val observableSearchHearingImpaired = ObservableField<Boolean>()
|
||||
val observableInEditMode = ObservableField<Boolean>()
|
||||
val observableUser = ObservableField<OpenSubtitlesUser>()
|
||||
val observableLimit = ObservableField<OpenSubtitlesLimit>()
|
||||
private var previousSearchLanguage: List<String>? = null
|
||||
@ -182,7 +183,7 @@ class SubtitlesModel(private val context: Context, private val mediaUri: Uri, pr
|
||||
val builder = StringBuilder(context.getString(R.string.sub_result_by_name, "<i>$name</i>"))
|
||||
season?.let { builder.append(" ${TextUtils.SEPARATOR} ").append(context.getString(R.string.sub_result_by_name_season, "<i>$it</i>")) }
|
||||
episode?.let { builder.append(" ${TextUtils.SEPARATOR} ").append(context.getString(R.string.sub_result_by_name_episode, "<i>$it</i>")) }
|
||||
languageIds?.let { if (languageIds.isNotEmpty()) builder.append(" ${TextUtils.SEPARATOR} ").append("<i>${it.joinToString(", ")}</i>") }
|
||||
languageIds?.let { languages -> if (languageIds.isNotEmpty()) builder.append(" ${TextUtils.SEPARATOR} ").append("<i>${languages.joinToString(", "){ it.uppercase()} }</i>") }
|
||||
if (hearingImpaired) builder.append(" ${TextUtils.SEPARATOR} ").append(context.getString(R.string.sub_result_by_name_hearing_impaired))
|
||||
observableResultDescription.set(Html.fromHtml(builder.toString()))
|
||||
manualSearchEnabled.set(true)
|
||||
@ -229,7 +230,17 @@ class SubtitlesModel(private val context: Context, private val mediaUri: Uri, pr
|
||||
}
|
||||
} else {
|
||||
observableSearchName.get()?.let {
|
||||
getSubtitleByName(it, observableSearchEpisode.get()?.toInt(), observableSearchSeason.get()?.toInt(), observableSearchLanguage.get(), observableSearchHearingImpaired.get() ?: false).data
|
||||
val episode = try {
|
||||
observableSearchEpisode.get()?.toIntOrNull()
|
||||
} catch (e: NumberFormatException) {
|
||||
null
|
||||
}
|
||||
val season = try {
|
||||
observableSearchSeason.get()?.toIntOrNull()
|
||||
} catch (e: NumberFormatException) {
|
||||
null
|
||||
}
|
||||
getSubtitleByName(it, episode, season, observableSearchLanguage.get(), observableSearchHearingImpaired.get() ?: false).data
|
||||
} ?: listOf()
|
||||
}
|
||||
if (isActive) apiResultLiveData.postValue(subs)
|
||||
|
Loading…
Reference in New Issue
Block a user