Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
aayush262 2024-03-30 02:40:04 +05:30
commit eff0a34c54
9 changed files with 216 additions and 104 deletions

View file

@ -35,6 +35,7 @@ import ani.dantotsu.databinding.ItemChipBinding
import ani.dantotsu.databinding.ItemQuelsBinding import ani.dantotsu.databinding.ItemQuelsBinding
import ani.dantotsu.databinding.ItemTitleChipgroupBinding import ani.dantotsu.databinding.ItemTitleChipgroupBinding
import ani.dantotsu.databinding.ItemTitleRecyclerBinding import ani.dantotsu.databinding.ItemTitleRecyclerBinding
import ani.dantotsu.databinding.ItemTitleSearchBinding
import ani.dantotsu.databinding.ItemTitleTextBinding import ani.dantotsu.databinding.ItemTitleTextBinding
import ani.dantotsu.databinding.ItemTitleTrailerBinding import ani.dantotsu.databinding.ItemTitleTrailerBinding
import ani.dantotsu.loadImage import ani.dantotsu.loadImage
@ -91,7 +92,6 @@ class MediaInfoFragment : Fragment() {
if (media != null && !loaded) { if (media != null && !loaded) {
loaded = true loaded = true
binding.mediaInfoProgressBar.visibility = View.GONE binding.mediaInfoProgressBar.visibility = View.GONE
binding.mediaInfoContainer.visibility = View.VISIBLE binding.mediaInfoContainer.visibility = View.VISIBLE
val infoName = tripleTab + (media.name ?: media.nameRomaji) val infoName = tripleTab + (media.name ?: media.nameRomaji)
@ -438,113 +438,138 @@ class MediaInfoFragment : Fragment() {
if (!media.relations.isNullOrEmpty() && !offline) { if (!media.relations.isNullOrEmpty() && !offline) {
if (media.sequel != null || media.prequel != null) { if (media.sequel != null || media.prequel != null) {
val bind = ItemQuelsBinding.inflate( ItemQuelsBinding.inflate(
LayoutInflater.from(context), LayoutInflater.from(context),
parent, parent,
false false
) ).apply {
if (media.sequel != null) { if (media.sequel != null) {
bind.mediaInfoSequel.visibility = View.VISIBLE mediaInfoSequel.visibility = View.VISIBLE
bind.mediaInfoSequelImage.loadImage( mediaInfoSequelImage.loadImage(
media.sequel!!.banner ?: media.sequel!!.cover media.sequel!!.banner ?: media.sequel!!.cover
)
bind.mediaInfoSequel.setSafeOnClickListener {
ContextCompat.startActivity(
requireContext(),
Intent(
requireContext(),
MediaDetailsActivity::class.java
).putExtra(
"media",
media.sequel as Serializable
), null
) )
} mediaInfoSequel.setSafeOnClickListener {
} ContextCompat.startActivity(
if (media.prequel != null) {
bind.mediaInfoPrequel.visibility = View.VISIBLE
bind.mediaInfoPrequelImage.loadImage(
media.prequel!!.banner ?: media.prequel!!.cover
)
bind.mediaInfoPrequel.setSafeOnClickListener {
ContextCompat.startActivity(
requireContext(),
Intent(
requireContext(), requireContext(),
MediaDetailsActivity::class.java Intent(
).putExtra( requireContext(),
"media", MediaDetailsActivity::class.java
media.prequel as Serializable ).putExtra(
), null "media",
) media.sequel as Serializable
), null
)
}
} }
if (media.prequel != null) {
mediaInfoPrequel.visibility = View.VISIBLE
mediaInfoPrequelImage.loadImage(
media.prequel!!.banner ?: media.prequel!!.cover
)
mediaInfoPrequel.setSafeOnClickListener {
ContextCompat.startActivity(
requireContext(),
Intent(
requireContext(),
MediaDetailsActivity::class.java
).putExtra(
"media",
media.prequel as Serializable
), null
)
}
}
parent.addView(root)
}
ItemTitleSearchBinding.inflate(
LayoutInflater.from(context),
parent,
false
).apply {
titleSearchImage.loadImage(media.banner ?: media.cover)
titleSearchText.text =
getString(R.string.search_title, media.mainName())
titleSearchCard.setSafeOnClickListener {
val query = Intent(requireContext(), SearchActivity::class.java)
.putExtra("type", "ANIME")
.putExtra("query", media.mainName())
.putExtra("search", true)
ContextCompat.startActivity(requireContext(), query, null)
}
parent.addView(root)
} }
parent.addView(bind.root)
} }
val bindi = ItemTitleRecyclerBinding.inflate( ItemTitleRecyclerBinding.inflate(
LayoutInflater.from(context), LayoutInflater.from(context),
parent, parent,
false false
) ).apply {
bindi.itemRecycler.adapter = itemRecycler.adapter =
MediaAdaptor(0, media.relations!!, requireActivity()) MediaAdaptor(0, media.relations!!, requireActivity())
bindi.itemRecycler.layoutManager = LinearLayoutManager( itemRecycler.layoutManager = LinearLayoutManager(
requireContext(), requireContext(),
LinearLayoutManager.HORIZONTAL, LinearLayoutManager.HORIZONTAL,
false false
) )
parent.addView(bindi.root) parent.addView(root)
}
} }
if (!media.characters.isNullOrEmpty() && !offline) { if (!media.characters.isNullOrEmpty() && !offline) {
val bind = ItemTitleRecyclerBinding.inflate( ItemTitleRecyclerBinding.inflate(
LayoutInflater.from(context), LayoutInflater.from(context),
parent, parent,
false false
) ).apply {
bind.itemTitle.setText(R.string.characters) itemTitle.setText(R.string.characters)
bind.itemRecycler.adapter = itemRecycler.adapter =
CharacterAdapter(media.characters!!) CharacterAdapter(media.characters!!)
bind.itemRecycler.layoutManager = LinearLayoutManager( itemRecycler.layoutManager = LinearLayoutManager(
requireContext(), requireContext(),
LinearLayoutManager.HORIZONTAL, LinearLayoutManager.HORIZONTAL,
false false
) )
parent.addView(bind.root) parent.addView(root)
}
} }
if (!media.staff.isNullOrEmpty() && !offline) { if (!media.staff.isNullOrEmpty() && !offline) {
val bind = ItemTitleRecyclerBinding.inflate( ItemTitleRecyclerBinding.inflate(
LayoutInflater.from(context), LayoutInflater.from(context),
parent, parent,
false false
) ).apply {
bind.itemTitle.setText(R.string.staff) itemTitle.setText(R.string.staff)
bind.itemRecycler.adapter = itemRecycler.adapter =
AuthorAdapter(media.staff!!) AuthorAdapter(media.staff!!)
bind.itemRecycler.layoutManager = LinearLayoutManager( itemRecycler.layoutManager = LinearLayoutManager(
requireContext(), requireContext(),
LinearLayoutManager.HORIZONTAL, LinearLayoutManager.HORIZONTAL,
false false
) )
parent.addView(bind.root) parent.addView(root)
}
} }
if (!media.recommendations.isNullOrEmpty() && !offline) { if (!media.recommendations.isNullOrEmpty() && !offline) {
val bind = ItemTitleRecyclerBinding.inflate( ItemTitleRecyclerBinding.inflate(
LayoutInflater.from(context), LayoutInflater.from(context),
parent, parent,
false false
) ).apply {
bind.itemTitle.setText(R.string.recommended) itemTitle.setText(R.string.recommended)
bind.itemRecycler.adapter = itemRecycler.adapter =
MediaAdaptor(0, media.recommendations!!, requireActivity()) MediaAdaptor(0, media.recommendations!!, requireActivity())
bind.itemRecycler.layoutManager = LinearLayoutManager( itemRecycler.layoutManager = LinearLayoutManager(
requireContext(), requireContext(),
LinearLayoutManager.HORIZONTAL, LinearLayoutManager.HORIZONTAL,
false false
) )
parent.addView(bind.root) parent.addView(root)
}
} }
} }
} }
@ -569,6 +594,7 @@ class MediaInfoFragment : Fragment() {
} }
} }
} }
super.onViewCreated(view, null) super.onViewCreated(view, null)
} }

View file

@ -70,6 +70,7 @@ class SearchActivity : AppCompatActivity() {
intent.getStringExtra("type") ?: "ANIME", intent.getStringExtra("type") ?: "ANIME",
isAdult = if (Anilist.adult) intent.getBooleanExtra("hentai", false) else false, isAdult = if (Anilist.adult) intent.getBooleanExtra("hentai", false) else false,
onList = listOnly, onList = listOnly,
search = intent.getStringExtra("query"),
genres = intent.getStringExtra("genre")?.let { mutableListOf(it) }, genres = intent.getStringExtra("genre")?.let { mutableListOf(it) },
tags = intent.getStringExtra("tag")?.let { mutableListOf(it) }, tags = intent.getStringExtra("tag")?.let { mutableListOf(it) },
sort = intent.getStringExtra("sortBy"), sort = intent.getStringExtra("sortBy"),

View file

@ -113,10 +113,8 @@ class ProfileStatsWidget : AppWidgetProvider() {
launchIO { launchIO {
val userPref = PrefManager.getVal(PrefName.AnilistUserId, "") val userPref = PrefManager.getVal(PrefName.AnilistUserId, "")
val userId = if (userPref.isNotEmpty()) userPref.toInt() else Anilist.userid if (userPref.isNotEmpty()) {
?: if (Anilist.query.getUserData()) Anilist.userid else null val respond = Anilist.query.getUserProfile(userPref.toInt())
userId?.let {
val respond = Anilist.query.getUserProfile(it)
respond?.data?.user?.let { user -> respond?.data?.user?.let { user ->
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
val views = RemoteViews(context.packageName, R.layout.statistics_widget).apply { val views = RemoteViews(context.packageName, R.layout.statistics_widget).apply {
@ -195,7 +193,7 @@ class ProfileStatsWidget : AppWidgetProvider() {
) )
val intent = Intent(context, ProfileActivity::class.java) val intent = Intent(context, ProfileActivity::class.java)
.putExtra("userId", it) .putExtra("userId", userPref.toInt())
val pendingIntent = PendingIntent.getActivity( val pendingIntent = PendingIntent.getActivity(
context, 0, intent, PendingIntent.FLAG_IMMUTABLE context, 0, intent, PendingIntent.FLAG_IMMUTABLE
) )
@ -205,7 +203,7 @@ class ProfileStatsWidget : AppWidgetProvider() {
appWidgetManager.updateAppWidget(appWidgetId, views) appWidgetManager.updateAppWidget(appWidgetId, views)
} }
} ?: showLoginCascade(context, appWidgetManager, appWidgetId) } ?: showLoginCascade(context, appWidgetManager, appWidgetId)
} ?: showLoginCascade(context, appWidgetManager, appWidgetId) } else showLoginCascade(context, appWidgetManager, appWidgetId)
} }
} }

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<corners
android:topLeftRadius="28dp"
android:topRightRadius="28dp"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"/>
</shape>
</item>
<item
android:left="-3dp"
android:right="-3dp"
android:bottom="-50dp">
<shape>
<stroke android:width="2dp" android:color="@color/bg_white" />
<corners
android:topLeftRadius="28dp"
android:topRightRadius="28dp"
android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"/>
</shape>
</item>
</layer-list>

View file

@ -14,7 +14,7 @@
android:right="-3dp" android:right="-3dp"
android:bottom="-50dp"> android:bottom="-50dp">
<shape> <shape>
<stroke android:width="2dp" android:color="@color/bg_white" /> <stroke android:width="2dp" android:color="@color/bg_black" />
<corners <corners
android:topLeftRadius="28dp" android:topLeftRadius="28dp"
android:topRightRadius="28dp" android:topRightRadius="28dp"

View file

@ -26,10 +26,7 @@
style="?android:attr/progressBarStyle" style="?android:attr/progressBarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_margin="32dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:indeterminate="true" android:indeterminate="true"
android:visibility="gone" android:visibility="gone"
tools:visibility="gone" /> tools:visibility="gone" />
@ -42,15 +39,12 @@
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">
<TableLayout <TableLayout
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:paddingStart="32dp" android:paddingHorizontal="32dp"
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"> android:paddingBottom="16dp">
<TableRow <TableRow
@ -397,8 +391,7 @@
android:id="@+id/mediaInfoDescriptionText" android:id="@+id/mediaInfoDescriptionText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="32dp" android:layout_marginHorizontal="32dp"
android:layout_marginEnd="32dp"
android:fontFamily="@font/poppins_bold" android:fontFamily="@font/poppins_bold"
android:text="@string/description" android:text="@string/description"
android:textSize="16sp" /> android:textSize="16sp" />
@ -407,8 +400,7 @@
android:id="@+id/mediaInfoDescription" android:id="@+id/mediaInfoDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginHorizontal="16dp"
android:layout_marginEnd="16dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="5" android:maxLines="5"
android:padding="16dp" android:padding="16dp"

View file

@ -5,9 +5,8 @@
android:id="@+id/mediaInfoQuelContainer" android:id="@+id/mediaInfoQuelContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginEnd="24dp" android:layout_marginHorizontal="24dp"
android:layout_marginBottom="16dp"> android:layout_marginBottom="16dp">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView

View file

@ -0,0 +1,67 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/titleSearchContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="16dp">
<com.google.android.material.card.MaterialCardView
android:id="@+id/titleSearchCard"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_margin="8dp"
app:cardCornerRadius="16dp"
app:layout_constrainedWidth="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:id="@+id/titleSearchImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:ignore="ContentDescription"
tools:src="@tools:sample/backgrounds/scenic" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.75"
android:background="@color/bg_black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/titleSearchText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:layout_gravity="center"
android:gravity="center"
android:maxLines="2"
android:ellipsize="end"
android:fontFamily="@font/poppins_bold"
android:text="@string/search"
android:textAllCaps="true"
android:textColor="@color/bg_white"
android:textSize="14sp" />
<View
android:layout_width="64dp"
android:layout_height="2dp"
android:layout_gravity="center"
android:background="?attr/colorSecondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -49,10 +49,10 @@
<string name="popular_manga">Popular Manga</string> <string name="popular_manga">Popular Manga</string>
<string name="username">Username</string> <string name="username">Username</string>
<string name="chapters_read">"Chapters Read "</string> <string name="chapters_read">Chapters Read</string>
<string name="chapters_read_n">"Chapters\nRead "</string> <string name="chapters_read_n">Chapters\nRead</string>
<string name="episodes_watched">"Episodes Watched "</string> <string name="episodes_watched">Episodes Watched</string>
<string name="episodes_watched_n">"Episodes\nWatched "</string> <string name="episodes_watched_n">Episodes\nWatched</string>
<string name="continue_reading">Continue Reading</string> <string name="continue_reading">Continue Reading</string>
<string name="continue_watching">Continue Watching</string> <string name="continue_watching">Continue Watching</string>
<string name="recommended">Recommended</string> <string name="recommended">Recommended</string>
@ -823,6 +823,8 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="do_it">Do it!</string> <string name="do_it">Do it!</string>
<string name="password">Password</string> <string name="password">Password</string>
<string name="search_title">Search %1$s</string>
<string name="profile_stats_widget">Track progress directly from your home screen</string> <string name="profile_stats_widget">Track progress directly from your home screen</string>
<string name="anime_watched">Anime\nWatched</string> <string name="anime_watched">Anime\nWatched</string>
<string name="manga_read">Manga\nRead</string> <string name="manga_read">Manga\nRead</string>