diff --git a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt index 9fe7e9d7bc..e2beffdcf8 100644 --- a/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt +++ b/app/src/main/java/ani/dantotsu/connections/anilist/AnilistQueries.kt @@ -54,7 +54,7 @@ class AnilistQueries { suspend fun getUserProfile(id: Int): Query.UserProfileResponse? { return executeQuery( - """{user:User(id:$id){id,name,about(asHtml:true)avatar{medium,large},bannerImage,isFollowing,isFollower,isBlocked,favourites{anime{nodes{coverImage{extraLarge,large,medium,color}}}manga{nodes{id,coverImage{extraLarge,large,medium,color}}}characters{nodes{id,image{large,medium}}}staff{nodes{id,image{large,medium}}}studios{nodes{id,name}}}statistics{anime{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}manga{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}}siteUrl}}""", + """{user:User(id:$id){id,name,about(asHtml:false)avatar{medium,large},bannerImage,isFollowing,isFollower,isBlocked,favourites{anime{nodes{coverImage{extraLarge,large,medium,color}}}manga{nodes{id,coverImage{extraLarge,large,medium,color}}}characters{nodes{id,image{large,medium}}}staff{nodes{id,image{large,medium}}}studios{nodes{id,name}}}statistics{anime{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}manga{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}}siteUrl}}""", force = true ) } diff --git a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt index 90419d877a..b5d2f883bd 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt @@ -12,6 +12,7 @@ import ani.dantotsu.connections.comments.CommentsAPI import ani.dantotsu.copyToClipboard import ani.dantotsu.databinding.ItemCommentsBinding import ani.dantotsu.loadImage +import ani.dantotsu.others.ImageViewDialog import ani.dantotsu.profile.ProfileActivity import ani.dantotsu.snackString import com.xwray.groupie.GroupieAdapter @@ -101,7 +102,13 @@ class CommentItem(val comment: Comment, .putExtra("userId", comment.userId.toInt()) .putExtra("username","[${levelColor.second}]"), null ) - + } + viewBinding.commentUserAvatar.setOnClickListener { + ContextCompat.startActivity( + commentsFragment.activity, Intent(commentsFragment.activity, ProfileActivity::class.java) + .putExtra("userId", comment.userId.toInt()) + .putExtra("username","[${levelColor.second}]"), null + ) } viewBinding.commentText.setOnLongClickListener { copyToClipboard(comment.content) @@ -193,10 +200,15 @@ class CommentItem(val comment: Comment, } } viewBinding.commentTotalVotes.text = (comment.upvotes - comment.downvotes).toString() - viewBinding.commentUserAvatar + viewBinding.commentUserAvatar.setOnLongClickListener { + ImageViewDialog.newInstance( + commentsFragment.activity, + "${comment.username}'s [Cover]", + comment.profilePictureUrl + ) + } comment.profilePictureUrl?.let { viewBinding.commentUserAvatar.loadImage(it) } viewBinding.commentUserName.text = comment.username - viewBinding.commentUserLevel.text = "[${levelColor.second}]" viewBinding.commentUserLevel.setTextColor(levelColor.first) viewBinding.commentUserTime.text = formatTimestamp(comment.timestamp) diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt index 5c77d40fa6..b85175234a 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt @@ -4,8 +4,10 @@ import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle import android.view.View +import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat +import androidx.core.view.updateLayoutParams import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.Lifecycle @@ -20,8 +22,12 @@ import ani.dantotsu.loadImage import ani.dantotsu.media.Media import ani.dantotsu.media.MediaDetailsActivity import ani.dantotsu.media.user.ListActivity +import ani.dantotsu.navBarHeight import ani.dantotsu.others.ImageViewDialog +import ani.dantotsu.settings.saving.PrefManager +import ani.dantotsu.settings.saving.PrefName import ani.dantotsu.snackString +import ani.dantotsu.statusBarHeight import ani.dantotsu.themes.ThemeManager import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -32,7 +38,7 @@ import nl.joery.animatedbottombar.AnimatedBottomBar class ProfileActivity : AppCompatActivity(){ private lateinit var binding: ActivityProfileBinding private var selected: Int = 0 - private lateinit var tabLayout: AnimatedBottomBar + private lateinit var navBar: AnimatedBottomBar @SuppressLint("SetTextI18n") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -40,15 +46,14 @@ class ProfileActivity : AppCompatActivity(){ initActivity(this) binding = ActivityProfileBinding.inflate(layoutInflater) setContentView(binding.root) - tabLayout = binding.typeTab - val profileTab = tabLayout.createTab(R.drawable.ic_round_person_24, "Profile") - val statsTab = tabLayout.createTab(R.drawable.ic_stats_24, "Stats") - tabLayout.addTab(profileTab) - tabLayout.addTab(statsTab) - tabLayout.visibility = View.GONE + navBar = binding.profileNavBar + navBar.updateLayoutParams { bottomMargin = navBarHeight } + val profileTab = navBar.createTab(R.drawable.ic_round_person_24, "Profile") + val statsTab = navBar.createTab(R.drawable.ic_stats_24, "Stats") + navBar.addTab(profileTab) + navBar.addTab(statsTab) + navBar.visibility = View.GONE binding.mediaViewPager.isUserInputEnabled = false - - lifecycleScope.launch(Dispatchers.IO) { val userid = intent.getIntExtra("userId", 0) val respond = Anilist.query.getUserProfile(userid) @@ -60,9 +65,9 @@ class ProfileActivity : AppCompatActivity(){ } withContext(Dispatchers.Main) { binding.mediaViewPager.adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, user, this@ProfileActivity) - tabLayout.visibility = View.VISIBLE - tabLayout.selectTabAt(selected) - tabLayout.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener { + navBar.visibility = View.VISIBLE + navBar.selectTabAt(selected) + navBar.setOnTabSelectListener(object : AnimatedBottomBar.OnTabSelectListener { override fun onTabSelected( lastIndex: Int, lastTab: AnimatedBottomBar.Tab?, @@ -76,13 +81,27 @@ class ProfileActivity : AppCompatActivity(){ val userLevel = intent.getStringExtra("username")?: "" binding.profileProgressBar.visibility = View.GONE + binding.profileTopContainer.visibility = View.VISIBLE binding.profileBannerImage.loadImage(user.bannerImage) + binding.profileBannerImage.setOnLongClickListener { + ImageViewDialog.newInstance( + this@ProfileActivity, + "${user.name}'s [Banner]", + user.bannerImage + ) + } binding.profileUserAvatar.loadImage(user.avatar?.medium) + binding.profileUserAvatar.setOnLongClickListener { + ImageViewDialog.newInstance( + this@ProfileActivity, + "${user.name}'s [Avatar]", + user.avatar?.medium + ) + } binding.profileUserName.text = "${user.name} $userLevel" - binding.profileUserEpisodesWatched.text = user.statistics.anime.episodesWatched.toString() - binding.profileUserChaptersRead.text = user.statistics.manga.chaptersRead.toString() - + if (!(PrefManager.getVal(PrefName.BannerAnimations) as Boolean)) binding.profileBannerImage.pause() binding.profileBannerImage.loadImage(user.bannerImage) + binding.profileBannerImage.updateLayoutParams { height += statusBarHeight } binding.profileBannerImage.setOnLongClickListener { ImageViewDialog.newInstance( this@ProfileActivity, @@ -104,8 +123,8 @@ class ProfileActivity : AppCompatActivity(){ } override fun onResume() { - if (this::tabLayout.isInitialized) { - tabLayout.selectTabAt(selected) + if (this::navBar.isInitialized) { + navBar.selectTabAt(selected) } super.onResume() } diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileFragment.kt b/app/src/main/java/ani/dantotsu/profile/ProfileFragment.kt index 504bce577b..2fa98c9c09 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileFragment.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileFragment.kt @@ -27,7 +27,9 @@ class ProfileFragment(private val user: Query.UserProfile, private val activity: override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val markwon = buildMarkwon(activity, false) - markwon.setMarkdown(binding.profileUserInfo, user.about?:"") + markwon.setMarkdown(binding.profileUserBio, user.about?:"") + binding.userInfoContainer.visibility = if (user.about != null) View.VISIBLE else View.GONE + binding.profileAnimeList.setOnClickListener { ContextCompat.startActivity( activity, Intent(activity, ListActivity::class.java) @@ -46,5 +48,15 @@ class ProfileFragment(private val user: Query.UserProfile, private val activity: } binding.profileAnimeListImage.loadImage("https://bit.ly/31bsIHq") binding.profileMangaListImage.loadImage("https://bit.ly/2ZGfcuG") + binding.statsEpisodesWatched.text = user.statistics.anime.episodesWatched.toString() + binding.statsDaysWatched.text = (user.statistics.anime.minutesWatched / (24 * 60)).toString() + binding.statsTotalAnime.text = user.statistics.anime.count.toString() + binding.statsAnimeMeanScore.text = user.statistics.anime.meanScore.toString() + binding.statsChaptersRead.text = user.statistics.manga.chaptersRead.toString() + binding.statsVolumeRead.text = (user.statistics.manga.volumesRead).toString() + binding.statsTotalManga.text = user.statistics.manga.count.toString() + binding.statsMangaMeanScore.text = user.statistics.manga.meanScore.toString() + + } } \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt b/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt index d2ce739fef..6eb76728d4 100644 --- a/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt +++ b/app/src/main/java/ani/dantotsu/profile/StatsFragment.kt @@ -135,7 +135,7 @@ class StatsFragment(private val user: Query.UserProfile, private val activity: P val names: List = if (anime) { stats?.data?.user?.statistics?.anime?.formats?.map { it.format } ?: emptyList() } else { - stats?.data?.user?.statistics?.manga?.formats?.map { it.format } ?: emptyList() + stats?.data?.user?.statistics?.manga?.countries?.map { it.country } ?: emptyList() } val values: List = if (anime) { when (statType) { diff --git a/app/src/main/res/layout/activity_profile.xml b/app/src/main/res/layout/activity_profile.xml index 36aa8560fc..9249a4de8a 100644 --- a/app/src/main/res/layout/activity_profile.xml +++ b/app/src/main/res/layout/activity_profile.xml @@ -28,98 +28,63 @@ android:id="@+id/profileTopContainer" android:layout_width="match_parent" android:layout_height="wrap_content" + android:visibility="gone" + tools:visibility="visible" android:orientation="vertical"> - - + tools:ignore="ContentDescription" + tools:src="@tools:sample/backgrounds/scenic" /> - - - + - + + + + + + - - - - - - - - - - - - - - @@ -141,7 +106,7 @@ - - - + android:orientation="vertical"> - - - + android:layout_height="wrap_content" + android:clipToPadding="false" + android:paddingStart="24dp" + android:paddingEnd="24dp"> - + android:layout_height="72dp" + android:layout_margin="8dp" + app:boxStrokeColor="@color/text_input_layout_stroke_color" + app:cardCornerRadius="16dp" + app:layout_constrainedWidth="true" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@+id/profileMangaList" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintWidth_max="256dp" + tools:visibility="visible"> - + - + + + android:orientation="vertical"> + + + + + + + + + + + + - - + android:orientation="vertical"> + + + + + + + + + + + + + - - - + + + android:layout_height="24dp" + android:orientation="horizontal"> - + + + + + + + android:layout_height="24dp" + android:orientation="horizontal"> + + + + + - + + + + android:textAlignment="textEnd" /> + - - + + + - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:orientation="vertical"> + + + + + \ No newline at end of file