Move manga info summary more/less button toggle

This commit is contained in:
arkon 2020-09-22 22:20:29 -04:00
parent 01ad405dd2
commit a9bed90d02
4 changed files with 117 additions and 96 deletions

View File

@ -1,7 +1,5 @@
package eu.kanade.tachiyomi.ui.manga.info package eu.kanade.tachiyomi.ui.manga.info
import android.content.Context
import android.text.TextUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -302,21 +300,23 @@ class MangaInfoHeaderAdapter(
controller::performSearch controller::performSearch
) )
} else { } else {
binding.mangaGenresTagsWrapper.isVisible = false binding.mangaGenresTagsCompactChips.isVisible = false
binding.mangaGenresTagsFullChips.isVisible = false
} }
// Handle showing more or less info // Handle showing more or less info
merge( merge(
binding.mangaSummarySection.clicks(), binding.mangaSummarySection.clicks(),
binding.mangaSummaryText.clicks(), binding.mangaSummaryText.clicks(),
binding.mangaInfoToggle.clicks() binding.mangaInfoToggleMore.clicks(),
binding.mangaInfoToggleLess.clicks()
) )
.onEach { toggleMangaInfo(view.context) } .onEach { toggleMangaInfo() }
.launchIn(scope) .launchIn(scope)
// Expand manga info if navigated from source listing // Expand manga info if navigated from source listing
if (initialLoad && fromSource) { if (initialLoad && fromSource) {
toggleMangaInfo(view.context) toggleMangaInfo()
initialLoad = false initialLoad = false
} }
} }
@ -326,44 +326,21 @@ class MangaInfoHeaderAdapter(
binding.mangaSummarySection.isVisible = visible binding.mangaSummarySection.isVisible = visible
} }
private fun toggleMangaInfo(context: Context) { private fun toggleMangaInfo() {
val isExpanded = val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != 2
binding.mangaInfoToggle.contentDescription == context.getString(R.string.manga_info_collapse)
with(binding.mangaInfoToggle) { binding.mangaInfoToggleMoreScrim.isVisible = isCurrentlyExpanded
contentDescription = if (isExpanded) { binding.mangaInfoToggleMore.isVisible = isCurrentlyExpanded
context.getString(R.string.manga_info_expand) binding.mangaInfoToggleLess.isVisible = !isCurrentlyExpanded
} else {
context.getString(R.string.manga_info_collapse)
}
setImageDrawable( binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) {
if (isExpanded) { 2
context.getDrawable(R.drawable.ic_baseline_expand_more_24dp) } else {
} else { Int.MAX_VALUE
context.getDrawable(R.drawable.ic_baseline_expand_less_24dp)
}
)
} }
with(binding.mangaSummaryText) { binding.mangaGenresTagsCompact.isVisible = isCurrentlyExpanded
maxLines = binding.mangaGenresTagsFullChips.isVisible = !isCurrentlyExpanded
if (isExpanded) {
2
} else {
Int.MAX_VALUE
}
ellipsize =
if (isExpanded) {
TextUtils.TruncateAt.END
} else {
null
}
}
binding.mangaGenresTagsCompact.isVisible = isExpanded
binding.mangaGenresTagsFullChips.isVisible = !isExpanded
} }
/** /**

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="180"
android:centerColor="#ff000000"
android:endColor="#00000000"
android:startColor="#ff000000" />
<corners android:radius="0dp" />
</shape>

View File

@ -38,7 +38,7 @@
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="64dp" android:paddingTop="64dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:paddingBottom="16dp" android:paddingBottom="8dp"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<eu.kanade.tachiyomi.ui.manga.info.MangaCoverImageView <eu.kanade.tachiyomi.ui.manga.info.MangaCoverImageView
@ -178,34 +178,12 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/manga_summary_section" android:id="@+id/manga_summary_section"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground">
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<ImageButton
android:id="@+id/manga_info_toggle"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentEnd="true"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/manga_info_expand"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_baseline_expand_more_24dp"
app:tint="?attr/colorOnPrimary" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView <TextView
android:id="@+id/manga_summary_text" android:id="@+id/manga_summary_text"
@ -215,49 +193,85 @@
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:clickable="true" android:clickable="true"
android:ellipsize="end"
android:focusable="true" android:focusable="true"
android:maxLines="2" android:maxLines="2"
android:textIsSelectable="false" android:textIsSelectable="false"
tools:text="Summary" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Collapsed summary content Collapsed summary content Collapsed summary content Collapsed summary content Collapsed summary content Collapsed summary content" />
<FrameLayout <View
android:id="@+id/manga_genres_tags_wrapper" android:id="@+id/manga_info_toggle_more_scrim"
android:layout_width="20dp"
android:layout_height="0dp"
android:background="@drawable/manga_info_more_gradient"
android:backgroundTint="?android:attr/colorBackground"
app:layout_constraintBottom_toBottomOf="@+id/manga_summary_text"
app:layout_constraintEnd_toStartOf="@id/manga_info_toggle_more"
app:layout_constraintTop_toTopOf="@+id/manga_info_toggle_more" />
<com.google.android.material.button.MaterialButton
android:id="@+id/manga_info_toggle_more"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="16dp"
android:text="@string/manga_info_expand"
android:textAlignment="viewEnd"
app:layout_constraintBottom_toBottomOf="@+id/manga_summary_text"
app:layout_constraintEnd_toEndOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/manga_info_toggle_less"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="16dp"
android:text="@string/manga_info_collapse"
android:textAlignment="viewEnd"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/manga_summary_text" />
<HorizontalScrollView
android:id="@+id/manga_genres_tags_compact"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:requiresFadingEdge="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/manga_summary_text">
<com.google.android.material.chip.ChipGroup <com.google.android.material.chip.ChipGroup
android:id="@+id/manga_genres_tags_full_chips" android:id="@+id/manga_genres_tags_compact_chips"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:paddingStart="16dp"
android:layout_marginEnd="16dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:visibility="gone" app:chipSpacingHorizontal="4dp"
app:chipSpacingHorizontal="4dp" /> app:singleLine="true" />
<HorizontalScrollView </HorizontalScrollView>
android:id="@+id/manga_genres_tags_compact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:requiresFadingEdge="horizontal">
<com.google.android.material.chip.ChipGroup <com.google.android.material.chip.ChipGroup
android:id="@+id/manga_genres_tags_compact_chips" android:id="@+id/manga_genres_tags_full_chips"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="16dp" android:layout_marginStart="16dp"
android:paddingTop="8dp" android:layout_marginEnd="16dp"
android:paddingEnd="16dp" android:paddingTop="8dp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
app:chipSpacingHorizontal="4dp" android:visibility="gone"
app:singleLine="true" /> app:chipSpacingHorizontal="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/manga_info_toggle_less" />
</HorizontalScrollView> </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -265,6 +265,23 @@
<item name="backgroundTint">@color/outlined_button_bg</item> <item name="backgroundTint">@color/outlined_button_bg</item>
</style> </style>
<style name="Theme.Widget.Button.TextButton" parent="Widget.MaterialComponents.Button.TextButton">
<item name="android:letterSpacing">0.0</item>
<item name="android:textColor">?attr/colorAccent</item>
<item name="android:textAllCaps">false</item>
<item name="android:minHeight">0dp</item>
<item name="android:minWidth">0dp</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:insetBottom">0dp</item>
<item name="android:background">?android:attr/colorBackground</item>
<item name="backgroundTint">@null</item>
<item name="rippleColor">@null</item>
</style>
<!--=================--> <!--=================-->
<!--Widgets.TabLayout--> <!--Widgets.TabLayout-->