Merge branch 'dev' into zephyr

This commit is contained in:
ibo
2024-03-29 00:22:03 +01:00
committed by GitHub
9 changed files with 231 additions and 118 deletions

View File

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

View File

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

View File

@@ -113,10 +113,8 @@ class ProfileStatsWidget : AppWidgetProvider() {
launchIO {
val userPref = PrefManager.getVal(PrefName.AnilistUserId, "")
val userId = if (userPref.isNotEmpty()) userPref.toInt() else Anilist.userid
?: if (Anilist.query.getUserData()) Anilist.userid else null
userId?.let {
val respond = Anilist.query.getUserProfile(it)
if (userPref.isNotEmpty()) {
val respond = Anilist.query.getUserProfile(userPref.toInt())
respond?.data?.user?.let { user ->
withContext(Dispatchers.Main) {
val views = RemoteViews(context.packageName, R.layout.statistics_widget).apply {
@@ -195,7 +193,7 @@ class ProfileStatsWidget : AppWidgetProvider() {
)
val intent = Intent(context, ProfileActivity::class.java)
.putExtra("userId", it)
.putExtra("userId", userPref.toInt())
val pendingIntent = PendingIntent.getActivity(
context, 0, intent, PendingIntent.FLAG_IMMUTABLE
)
@@ -205,7 +203,7 @@ class ProfileStatsWidget : AppWidgetProvider() {
appWidgetManager.updateAppWidget(appWidgetId, views)
}
} ?: 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:bottom="-50dp">
<shape>
<stroke android:width="2dp" android:color="@color/bg_white" />
<stroke android:width="2dp" android:color="@color/bg_black" />
<corners
android:topLeftRadius="28dp"
android:topRightRadius="28dp"

View File

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

View File

@@ -5,9 +5,8 @@
android:id="@+id/mediaInfoQuelContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:layout_marginHorizontal="24dp"
android:layout_marginBottom="16dp">
<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

@@ -9,13 +9,12 @@
<string name="login">Login</string>
<string name="logout">Logout</string>
<string name="dantotsu" translatable="false">https://dantotsu.app/</string>
<string name="discord" translatable="false">https://discord.gg/4HPZ5nAWwM</string>
<string name="github" translatable="false">https://github.com/rebelonion/Dantotsu</string>
<string name="dantotsu" translatable="false">https://dantotsu.app/</string>
<string name="telegram" tools:ignore="Typos" translatable="false">https://t.me/+gzBCQExtLQo1YTNh </string>
<string name="telegram" translatable="false" tools:ignore="Typos">https://t.me/+gzBCQExtLQo1YTNh </string>
<string name="coffee" translatable="false">https://www.buymeacoffee.com/rebelonion</string>
<string name="anilist_link">https://anilist.co/user/%1$s/</string>
<string name="home">Home</string>
<string name="anime">Anime</string>
@@ -52,10 +51,10 @@
<string name="popular_manga">Popular Manga</string>
<string name="username">Username</string>
<string name="chapters_read">"Chapters Read "</string>
<string name="chapters_read_n">"Chapters\nRead "</string>
<string name="episodes_watched">"Episodes Watched "</string>
<string name="episodes_watched_n">"Episodes\nWatched "</string>
<string name="chapters_read">Chapters Read</string>
<string name="chapters_read_n">Chapters\nRead</string>
<string name="episodes_watched">Episodes Watched</string>
<string name="episodes_watched_n">Episodes\nWatched</string>
<string name="continue_reading">Continue Reading</string>
<string name="continue_watching">Continue Watching</string>
<string name="recommended">Recommended</string>
@@ -413,6 +412,16 @@
<string name="sort_by_release_date">Sort by Release Date</string>
<string name="crop_borders">Crop Borders</string>
<string name="note">NOTE</string>
<string name="discord_dantotsu_button">Display dantotsu in the second button</string>
<string name="discord_anilist_button">Display your AniList profile</string>
<string name="discord_custom_button">Set up your own custom button</string>
<string name="discord_rich_presence">Discord Rich Presence</string>
<string name="stream_on_dantotsu">Stream on Dantotsu</string>
<string name="view_my_anilist">View My AniList</string>
<string name="button_text">Button Text</string>
<string name="button_link">Button Link</string>
<string name="discord_custom_sample">Sample</string>
<string name="installing_extension">Installing extension</string>
<string name="installation_failed">Installation failed: %1$s</string>
@@ -665,15 +674,6 @@
<string name="discord_try_again">Try logging-in again</string>
<string name="error_loading_discord_user_data">Error loading Discord User Data</string>
<string name="discord_warning"><![CDATA[By logging in, your discord will now show what you are watching & reading on Dantotsu\n\nIf you are on invisible mode, logging in will make you online, when you open Dantotsu.\n\nThis does break the Discord TOS. \nAlthough Discord has never banned anyone for using Custom Rich Presence(what Dantotsu uses), You have still been warned.\n\nDantotsu is not responsible for anything that happens to your account.]]></string>
<string name="discord_dantotsu_button">Display dantotsu in the second button</string>
<string name="discord_anilist_button">Display your AniList profile</string>
<string name="discord_custom_button">Set up your own custom button</string>
<string name="discord_rich_presence">Discord Rich Presence</string>
<string name="stream_on_dantotsu">Stream on Dantotsu</string>
<string name="view_my_anilist">View My AniList</string>
<string name="button_text">Button Text</string>
<string name="button_link">Button Link</string>
<string name="discord_custom_sample">Sample</string>
<string name="warning">Warning</string>
<string name="view_anime">View Anime</string>
<string name="view_manga">View Manga</string>
@@ -834,6 +834,9 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="donate">donate :)</string>
<string name="do_it">Do it!</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="anime_watched">Anime\nWatched</string>
<string name="manga_read">Manga\nRead</string>
@@ -850,4 +853,4 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="title_color">Title Color</string>
<string name="stat_text_color">Stats Text Color</string>
<string name="placeholder">Placeholder</string>
</resources>
</resources>