Hide the score display on the tracksheet if not supported (#5169)

* hide the score display on the tracksheet if not supported

* Convert track item to use LinearLayout

Co-authored-by: Andreas E <andreas.everos@gmail.com>
This commit is contained in:
Gauthier 2021-05-25 21:03:56 +08:00 committed by GitHub
parent 4af13e3536
commit 9a801cfdfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 60 deletions

View File

@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.manga.track
import android.annotation.SuppressLint import android.annotation.SuppressLint
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import eu.kanade.tachiyomi.R.string
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.TrackItemBinding import eu.kanade.tachiyomi.databinding.TrackItemBinding
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
@ -43,18 +42,22 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
binding.trackSet.isVisible = track == null binding.trackSet.isVisible = track == null
binding.trackTitle.isVisible = track != null binding.trackTitle.isVisible = track != null
binding.trackDetails.isVisible = track != null binding.topDivider.isVisible = track != null
binding.middleRow.isVisible = track != null
binding.bottomDivider.isVisible = track != null
binding.bottomRow.isVisible = track != null
if (track != null) { if (track != null) {
binding.trackTitle.text = track.title binding.trackTitle.text = track.title
binding.trackChapters.text = "${track.last_chapter_read}/" + binding.trackChapters.text = "${track.last_chapter_read}/" +
if (track.total_chapters > 0) track.total_chapters else "-" if (track.total_chapters > 0) track.total_chapters else "-"
binding.trackStatus.text = item.service.getStatus(track.status) binding.trackStatus.text = item.service.getStatus(track.status)
binding.trackScore.text = if (track.score == 0f) "-" else item.service.displayScore(track)
if (item.service.getScoreList().isEmpty()) { if (item.service.getScoreList().isEmpty()) {
with(binding.trackScore) { binding.trackScore.isVisible = false
text = context.getString(string.score_unsupported) binding.vertDivider2.isVisible = false
isEnabled = false } else {
} binding.trackScore.text = if (track.score == 0f) "-" else item.service.displayScore(track)
} }
if (item.service.supportsReadingDates) { if (item.service.supportsReadingDates) {
@ -64,9 +67,7 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter)
if (track.finished_reading_date != 0L) dateFormat.format(track.finished_reading_date) else "-" if (track.finished_reading_date != 0L) dateFormat.format(track.finished_reading_date) else "-"
} else { } else {
binding.bottomDivider.isVisible = false binding.bottomDivider.isVisible = false
binding.vertDivider3.isVisible = false binding.bottomRow.isVisible = false
binding.trackStartDate.isVisible = false
binding.trackFinishDate.isVisible = false
} }
} }
} }

View File

@ -67,24 +67,22 @@
</LinearLayout> </LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/track_details"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View <View
android:id="@+id/top_divider" android:id="@+id/top_divider"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:alpha="0.25" android:alpha="0.25"
android:background="?android:attr/textColorHint" android:background="?android:attr/textColorHint" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" <LinearLayout
app:layout_constraintTop_toTopOf="parent" /> android:id="@+id/middle_row"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/track_status" android:id="@+id/track_status"
style="@style/TextAppearance.Regular.Body1.Secondary" style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_selector" android:background="@drawable/list_item_selector"
@ -92,27 +90,22 @@
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:padding="16dp" android:padding="16dp"
app:layout_constraintEnd_toStartOf="@+id/vert_divider_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_divider"
tools:text="Reading" /> tools:text="Reading" />
<View <View
android:id="@+id/vert_divider_1" android:id="@+id/vert_divider_1"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:alpha="0.25" android:alpha="0.25"
android:background="?android:attr/textColorHint" android:background="?android:attr/textColorHint"
app:layout_constraintBottom_toTopOf="@+id/bottom_divider"
app:layout_constraintEnd_toStartOf="@+id/track_chapters"
app:layout_constraintStart_toEndOf="@+id/track_status"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/track_chapters" android:id="@+id/track_chapters"
style="@style/TextAppearance.Regular.Body1.Secondary" style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_selector" android:background="@drawable/list_item_selector"
@ -120,27 +113,21 @@
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:padding="16dp" android:padding="16dp"
app:layout_constraintEnd_toStartOf="@+id/vert_divider_2"
app:layout_constraintStart_toEndOf="@+id/vert_divider_1"
app:layout_constraintTop_toBottomOf="@+id/top_divider"
tools:text="12/24" /> tools:text="12/24" />
<View <View
android:id="@+id/vert_divider_2" android:id="@+id/vert_divider_2"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:alpha="0.25" android:alpha="0.25"
android:background="?android:attr/textColorHint" android:background="?android:attr/textColorHint"/>
app:layout_constraintBottom_toTopOf="@+id/bottom_divider"
app:layout_constraintEnd_toStartOf="@+id/track_score"
app:layout_constraintStart_toEndOf="@+id/track_chapters"
app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
android:id="@+id/track_score" android:id="@+id/track_score"
style="@style/TextAppearance.Regular.Body1.Secondary" style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_selector" android:background="@drawable/list_item_selector"
@ -148,24 +135,26 @@
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:padding="16dp" android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/vert_divider_2"
app:layout_constraintTop_toBottomOf="@+id/top_divider"
tools:text="10" /> tools:text="10" />
</LinearLayout>
<View <View
android:id="@+id/bottom_divider" android:id="@+id/bottom_divider"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:alpha="0.25" android:alpha="0.25"
android:background="?android:attr/textColorHint" android:background="?android:attr/textColorHint" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" <LinearLayout
app:layout_constraintTop_toBottomOf="@+id/track_score" /> android:id="@+id/bottom_row"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/track_start_date" android:id="@+id/track_start_date"
style="@style/TextAppearance.Regular.Body1.Secondary" style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_selector" android:background="@drawable/list_item_selector"
@ -173,27 +162,22 @@
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:padding="16dp" android:padding="16dp"
app:layout_constraintEnd_toStartOf="@+id/vert_divider_3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bottom_divider"
tools:text="4/16/2020" /> tools:text="4/16/2020" />
<View <View
android:id="@+id/vert_divider_3" android:id="@+id/vert_divider_3"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="0dp" android:layout_height="match_parent"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:alpha="0.25" android:alpha="0.25"
android:background="?android:attr/textColorHint" android:background="?android:attr/textColorHint"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintEnd_toStartOf="@+id/track_finish_date"
app:layout_constraintStart_toEndOf="@+id/track_start_date"
app:layout_constraintTop_toTopOf="@+id/bottom_divider" />
<TextView <TextView
android:id="@+id/track_finish_date" android:id="@+id/track_finish_date"
style="@style/TextAppearance.Regular.Body1.Secondary" style="@style/TextAppearance.Regular.Body1.Secondary"
android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_selector" android:background="@drawable/list_item_selector"
@ -206,7 +190,7 @@
app:layout_constraintTop_toBottomOf="@+id/bottom_divider" app:layout_constraintTop_toBottomOf="@+id/bottom_divider"
tools:text="4/16/2020" /> tools:text="4/16/2020" />
</androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -623,7 +623,6 @@
<string name="error_invalid_date_supplied">Invalid date supplied</string> <string name="error_invalid_date_supplied">Invalid date supplied</string>
<string name="myanimelist_creds_missing">MAL login credentials not found</string> <string name="myanimelist_creds_missing">MAL login credentials not found</string>
<string name="myanimelist_relogin">Please login to MAL again</string> <string name="myanimelist_relogin">Please login to MAL again</string>
<string name="score_unsupported">Not supported</string>
<string name="source_unsupported">Source is not supported</string> <string name="source_unsupported">Source is not supported</string>
<string name="error_no_match">No match found</string> <string name="error_no_match">No match found</string>