Improve details ui
This commit is contained in:
@@ -5,8 +5,13 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.transition.Slide
|
||||||
|
import android.transition.TransitionManager
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.animation.AccelerateDecelerateInterpolator
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
@@ -18,6 +23,7 @@ import com.google.android.material.badge.BadgeDrawable
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.base.domain.MangaIntent
|
import org.koitharu.kotatsu.base.domain.MangaIntent
|
||||||
@@ -36,7 +42,6 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
||||||
import org.koitharu.kotatsu.reader.ui.ReaderState
|
import org.koitharu.kotatsu.reader.ui.ReaderState
|
||||||
import org.koitharu.kotatsu.utils.ext.*
|
import org.koitharu.kotatsu.utils.ext.*
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DetailsActivity :
|
class DetailsActivity :
|
||||||
@@ -159,8 +164,11 @@ class DetailsActivity :
|
|||||||
|
|
||||||
private fun onMangaUpdated(manga: Manga) {
|
private fun onMangaUpdated(manga: Manga) {
|
||||||
title = manga.title
|
title = manga.title
|
||||||
binding.buttonRead.isEnabled = !manga.chapters.isNullOrEmpty()
|
val hasChapters = !manga.chapters.isNullOrEmpty()
|
||||||
|
binding.buttonRead.isEnabled = hasChapters
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
showBottomSheet(hasChapters)
|
||||||
|
binding.groupHeader?.isVisible = hasChapters
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onMangaRemoved(manga: Manga) {
|
private fun onMangaRemoved(manga: Manga) {
|
||||||
@@ -192,7 +200,9 @@ class DetailsActivity :
|
|||||||
Snackbar.LENGTH_LONG
|
Snackbar.LENGTH_LONG
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
snackbar.anchorView = binding.headerChapters
|
if (binding.layoutBottom?.isVisible == true) {
|
||||||
|
snackbar.anchorView = binding.headerChapters
|
||||||
|
}
|
||||||
if (e.isReportable()) {
|
if (e.isReportable()) {
|
||||||
snackbar.setAction(R.string.details) {
|
snackbar.setAction(R.string.details) {
|
||||||
MangaErrorDialog.show(supportFragmentManager, manga, e)
|
MangaErrorDialog.show(supportFragmentManager, manga, e)
|
||||||
@@ -293,6 +303,16 @@ class DetailsActivity :
|
|||||||
|
|
||||||
private fun isTabletLayout() = binding.layoutBottom == null
|
private fun isTabletLayout() = binding.layoutBottom == null
|
||||||
|
|
||||||
|
private fun showBottomSheet(isVisible: Boolean) {
|
||||||
|
val view = binding.layoutBottom ?: return
|
||||||
|
if (view.isVisible == isVisible) return
|
||||||
|
val transition = Slide(Gravity.BOTTOM)
|
||||||
|
transition.addTarget(view)
|
||||||
|
transition.interpolator = AccelerateDecelerateInterpolator()
|
||||||
|
TransitionManager.beginDelayedTransition(binding.root as ViewGroup, transition)
|
||||||
|
view.isVisible = isVisible
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun newIntent(context: Context, manga: Manga): Intent {
|
fun newIntent(context: Context, manga: Manga): Intent {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class DetailsFragment :
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.textViewAuthor.setOnClickListener(this)
|
binding.textViewAuthor.setOnClickListener(this)
|
||||||
binding.imageViewCover.setOnClickListener(this)
|
binding.imageViewCover.setOnClickListener(this)
|
||||||
|
binding.infoLayout.textViewSource.setOnClickListener(this)
|
||||||
binding.textViewDescription.movementMethod = LinkMovementMethod.getInstance()
|
binding.textViewDescription.movementMethod = LinkMovementMethod.getInstance()
|
||||||
binding.chipsTags.onChipClickListener = this
|
binding.chipsTags.onChipClickListener = this
|
||||||
viewModel.manga.observe(viewLifecycleOwner, ::onMangaUpdated)
|
viewModel.manga.observe(viewLifecycleOwner, ::onMangaUpdated)
|
||||||
@@ -228,6 +229,14 @@ class DetailsFragment :
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
R.id.textView_source -> {
|
||||||
|
startActivity(
|
||||||
|
MangaListActivity.newIntent(
|
||||||
|
context = v.context,
|
||||||
|
source = manga.source,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
R.id.imageView_cover -> {
|
R.id.imageView_cover -> {
|
||||||
startActivity(
|
startActivity(
|
||||||
ImageActivity.newIntent(v.context, manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl }),
|
ImageActivity.newIntent(v.context, manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl }),
|
||||||
|
|||||||
@@ -181,11 +181,11 @@
|
|||||||
android:id="@+id/textView_description"
|
android:id="@+id/textView_description"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="@dimen/margin_normal"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="@dimen/margin_small"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="@dimen/margin_normal"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:lineSpacingMultiplier="1.2"
|
android:lineSpacingMultiplier="1.2"
|
||||||
|
android:paddingBottom="@dimen/margin_normal"
|
||||||
android:textAppearance="?attr/textAppearanceBodyMedium"
|
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
@@ -63,56 +63,66 @@
|
|||||||
app:layout_constraintWidth_percent="0.5"
|
app:layout_constraintWidth_percent="0.5"
|
||||||
tools:layout="@layout/fragment_details" />
|
tools:layout="@layout/fragment_details" />
|
||||||
|
|
||||||
<ImageView
|
<RelativeLayout
|
||||||
android:id="@+id/button_dropdown"
|
android:id="@+id/group_header"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
|
||||||
android:padding="@dimen/margin_small"
|
|
||||||
android:src="@drawable/ic_expand_more"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/divider"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/appbar" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView_title"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingHorizontal="@dimen/margin_normal"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:textAppearance="?textAppearanceTitleMedium"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/textView_subtitle"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/button_dropdown"
|
|
||||||
app:layout_constraintStart_toStartOf="@id/container_chapters"
|
app:layout_constraintStart_toStartOf="@id/container_chapters"
|
||||||
app:layout_constraintTop_toBottomOf="@id/appbar"
|
app:layout_constraintTop_toBottomOf="@id/appbar">
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
|
||||||
tools:text="@string/chapter_d_of_d" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView_subtitle"
|
android:id="@+id/textView_title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="@dimen/margin_normal"
|
android:layout_alignWithParentIfMissing="true"
|
||||||
android:singleLine="true"
|
android:layout_alignParentStart="true"
|
||||||
android:textAppearance="?textAppearanceTitleSmall"
|
android:layout_alignParentTop="true"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:layout_marginTop="4dp"
|
||||||
android:visibility="gone"
|
android:layout_toStartOf="@id/button_dropdown"
|
||||||
app:layout_constraintBottom_toTopOf="@id/divider"
|
android:paddingHorizontal="@dimen/margin_normal"
|
||||||
app:layout_constraintEnd_toStartOf="@id/button_dropdown"
|
android:singleLine="true"
|
||||||
app:layout_constraintStart_toStartOf="@id/container_chapters"
|
android:textAppearance="?textAppearanceTitleMedium"
|
||||||
app:layout_constraintTop_toBottomOf="@id/textView_title"
|
tools:text="@string/chapter_d_of_d" />
|
||||||
tools:text="English"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<View
|
<TextView
|
||||||
android:id="@+id/divider"
|
android:id="@+id/textView_subtitle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="1dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="48dp"
|
android:layout_alignWithParentIfMissing="true"
|
||||||
android:background="?colorSecondaryContainer"
|
android:layout_below="@id/textView_title"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_alignParentStart="true"
|
||||||
app:layout_constraintStart_toEndOf="@id/container_details"
|
android:layout_toStartOf="@id/button_dropdown"
|
||||||
app:layout_constraintTop_toBottomOf="@id/appbar" />
|
android:paddingHorizontal="@dimen/margin_normal"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?textAppearanceTitleSmall"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:text="English"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/button_dropdown"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginBottom="1dp"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/margin_small"
|
||||||
|
android:src="@drawable/ic_expand_more" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/divider"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_below="@id/textView_subtitle"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:background="?colorSecondaryContainer" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/container_chapters"
|
android:id="@+id/container_chapters"
|
||||||
@@ -122,7 +132,7 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/container_details"
|
app:layout_constraintStart_toEndOf="@id/container_details"
|
||||||
app:layout_constraintTop_toBottomOf="@id/divider"
|
app:layout_constraintTop_toBottomOf="@id/group_header"
|
||||||
tools:layout="@layout/fragment_chapters" />
|
tools:layout="@layout/fragment_chapters" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -42,9 +42,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
app:behavior_hideable="false"
|
app:behavior_hideable="false"
|
||||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
|
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
|
||||||
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Kotatsu.BottomSheet">
|
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Kotatsu.BottomSheet"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<org.koitharu.kotatsu.base.ui.widgets.BottomSheetHeaderBar
|
<org.koitharu.kotatsu.base.ui.widgets.BottomSheetHeaderBar
|
||||||
android:id="@+id/header_chapters"
|
android:id="@+id/header_chapters"
|
||||||
|
|||||||
@@ -193,11 +193,11 @@
|
|||||||
android:id="@+id/textView_description"
|
android:id="@+id/textView_description"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="@dimen/margin_normal"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="@dimen/margin_small"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="@dimen/margin_normal"
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:lineSpacingMultiplier="1.2"
|
android:lineSpacingMultiplier="1.2"
|
||||||
|
android:paddingBottom="@dimen/margin_normal"
|
||||||
android:textAppearance="?attr/textAppearanceBodyMedium"
|
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
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:background="?selectableItemBackgroundBorderless"
|
||||||
android:drawablePadding="4dp"
|
android:drawablePadding="4dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user