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