Swapped rating and state fields on details screen
This commit is contained in:
@@ -104,20 +104,11 @@ class DetailsFragment :
|
|||||||
textViewTitle.text = manga.title
|
textViewTitle.text = manga.title
|
||||||
textViewSubtitle.textAndVisible = manga.altTitle
|
textViewSubtitle.textAndVisible = manga.altTitle
|
||||||
textViewAuthor.textAndVisible = manga.author
|
textViewAuthor.textAndVisible = manga.author
|
||||||
when (manga.state) {
|
if (manga.hasRating) {
|
||||||
MangaState.FINISHED -> {
|
ratingBar.rating = manga.rating * ratingBar.numStars
|
||||||
textViewState.apply {
|
ratingBar.isVisible = true
|
||||||
textAndVisible = resources.getString(R.string.state_finished)
|
} else {
|
||||||
drawableStart = ContextCompat.getDrawable(context, R.drawable.ic_state_finished)
|
ratingBar.isVisible = false
|
||||||
}
|
|
||||||
}
|
|
||||||
MangaState.ONGOING -> {
|
|
||||||
textViewState.apply {
|
|
||||||
textAndVisible = resources.getString(R.string.state_ongoing)
|
|
||||||
drawableStart = ContextCompat.getDrawable(context, R.drawable.ic_state_ongoing)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> textViewState.isVisible = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info containers
|
// Info containers
|
||||||
@@ -132,11 +123,20 @@ class DetailsFragment :
|
|||||||
chapters.size,
|
chapters.size,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (manga.hasRating) {
|
when (manga.state) {
|
||||||
infoLayout.textViewRating.text = String.format("%.1f", manga.rating * 5)
|
MangaState.FINISHED -> {
|
||||||
infoLayout.ratingContainer.isVisible = true
|
infoLayout.textViewState.apply {
|
||||||
} else {
|
textAndVisible = resources.getString(R.string.state_finished)
|
||||||
infoLayout.ratingContainer.isVisible = false
|
drawableTop = ContextCompat.getDrawable(context, R.drawable.ic_state_finished)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MangaState.ONGOING -> {
|
||||||
|
infoLayout.textViewState.apply {
|
||||||
|
textAndVisible = resources.getString(R.string.state_ongoing)
|
||||||
|
drawableTop = ContextCompat.getDrawable(context, R.drawable.ic_state_ongoing)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> infoLayout.textViewState.isVisible = false
|
||||||
}
|
}
|
||||||
if (manga.source == MangaSource.LOCAL) {
|
if (manga.source == MangaSource.LOCAL) {
|
||||||
infoLayout.textViewSource.isVisible = false
|
infoLayout.textViewSource.isVisible = false
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ var TextView.drawableEnd: Drawable?
|
|||||||
setCompoundDrawablesRelativeWithIntrinsicBounds(dr[0], dr[1], value, dr[3])
|
setCompoundDrawablesRelativeWithIntrinsicBounds(dr[0], dr[1], value, dr[3])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var TextView.drawableTop: Drawable?
|
||||||
|
inline get() = compoundDrawablesRelative[1]
|
||||||
|
set(value) {
|
||||||
|
val dr = compoundDrawablesRelative
|
||||||
|
setCompoundDrawablesRelativeWithIntrinsicBounds(dr[0], value, dr[2], dr[3])
|
||||||
|
}
|
||||||
|
|
||||||
fun TextView.setTextAndVisible(@StringRes textResId: Int) {
|
fun TextView.setTextAndVisible(@StringRes textResId: Int) {
|
||||||
if (textResId == 0) {
|
if (textResId == 0) {
|
||||||
text = null
|
text = null
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<vector
|
<vector
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="16dp"
|
android:width="24dp"
|
||||||
android:height="16dp"
|
android:height="24dp"
|
||||||
android:tint="?attr/colorControlNormal"
|
android:tint="?attr/colorControlNormal"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<vector
|
<vector
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:width="16dp"
|
android:width="24dp"
|
||||||
android:height="16dp"
|
android:height="24dp"
|
||||||
android:tint="?attr/colorControlNormal"
|
android:tint="?attr/colorControlNormal"
|
||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
|
|||||||
@@ -84,17 +84,18 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:text="@tools:sample/full_names" />
|
tools:text="@tools:sample/full_names" />
|
||||||
|
|
||||||
<TextView
|
<RatingBar
|
||||||
android:id="@+id/textView_state"
|
android:id="@+id/rating_bar"
|
||||||
android:layout_width="match_parent"
|
style="@style/Widget.AppCompat.RatingBar.Small"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:drawablePadding="4dp"
|
android:isIndicator="true"
|
||||||
android:singleLine="true"
|
android:max="1"
|
||||||
android:textAppearance="?attr/textAppearanceBodySmall"
|
android:numStars="5"
|
||||||
tools:drawableStart="@drawable/ic_state_finished"
|
android:stepSize="0.5"
|
||||||
tools:text="Finished" />
|
tools:rating="4" />
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -88,21 +88,23 @@
|
|||||||
app:layout_constraintWidth_default="wrap"
|
app:layout_constraintWidth_default="wrap"
|
||||||
tools:text="@tools:sample/full_names" />
|
tools:text="@tools:sample/full_names" />
|
||||||
|
|
||||||
<TextView
|
<RatingBar
|
||||||
android:id="@+id/textView_state"
|
android:id="@+id/rating_bar"
|
||||||
android:layout_width="0dp"
|
style="@style/Widget.AppCompat.RatingBar.Small"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:drawablePadding="4dp"
|
android:isIndicator="true"
|
||||||
android:singleLine="true"
|
android:max="1"
|
||||||
android:textAppearance="?attr/textAppearanceBodySmall"
|
android:numStars="5"
|
||||||
|
android:stepSize="0.5"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toEndOf="@id/imageView_cover"
|
app:layout_constraintStart_toEndOf="@id/imageView_cover"
|
||||||
app:layout_constraintTop_toBottomOf="@id/textView_author"
|
app:layout_constraintTop_toBottomOf="@id/textView_author"
|
||||||
tools:drawableStart="@drawable/ic_state_finished"
|
tools:rating="4" />
|
||||||
tools:text="Finished" />
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Barrier
|
<androidx.constraintlayout.widget.Barrier
|
||||||
android:id="@+id/barrier_header"
|
android:id="@+id/barrier_header"
|
||||||
@@ -110,7 +112,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:barrierDirection="bottom"
|
app:barrierDirection="bottom"
|
||||||
app:barrierMargin="8dp"
|
app:barrierMargin="8dp"
|
||||||
app:constraint_referenced_ids="imageView_cover,textView_state" />
|
app:constraint_referenced_ids="imageView_cover,rating_bar" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/info_layout"
|
android:id="@+id/info_layout"
|
||||||
|
|||||||
@@ -15,26 +15,19 @@
|
|||||||
android:paddingEnd="8dp"
|
android:paddingEnd="8dp"
|
||||||
android:showDividers="middle">
|
android:showDividers="middle">
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
android:id="@+id/rating_container"
|
android:id="@+id/textView_state"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView_rating"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:drawablePadding="4dp"
|
android:drawablePadding="4dp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
android:textSize="20sp"
|
android:textSize="12sp"
|
||||||
app:drawableEndCompat="@drawable/ic_star_manga_info"
|
android:visibility="gone"
|
||||||
tools:text="4.8" />
|
tools:drawableTopCompat="@drawable/ic_state_finished"
|
||||||
|
tools:text="Completed"
|
||||||
</FrameLayout>
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView_chapters"
|
android:id="@+id/textView_chapters"
|
||||||
|
|||||||
Reference in New Issue
Block a user