From cf07dd3df8a82d14aa3c9b11b1bf16220d2e64ec Mon Sep 17 00:00:00 2001 From: TwistedUmbrellaX Date: Wed, 20 Mar 2024 17:03:02 -0400 Subject: [PATCH] chore: resolve profile SetTextI18n --- .../dantotsu/media/comments/CommentItem.kt | 4 +-- .../ani/dantotsu/profile/ProfileActivity.kt | 32 ++++++++++++------- .../dantotsu/profile/activity/ActivityItem.kt | 9 +++--- .../profile/activity/NotificationActivity.kt | 5 +-- app/src/main/res/values/strings.xml | 12 +++++-- 5 files changed, 41 insertions(+), 21 deletions(-) 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 6f2c794c..c45c274a 100644 --- a/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt +++ b/app/src/main/java/ani/dantotsu/media/comments/CommentItem.kt @@ -83,7 +83,7 @@ class CommentItem(val comment: Comment, if (comment.replyCount == 1) getString(R.string.view_reply) else - getString(R.string.view_replies, comment.replyCount) + getString(R.string.view_replies_count, comment.replyCount) } } else { viewBinding.commentTotalReplies.visibility = View.GONE @@ -98,7 +98,7 @@ class CommentItem(val comment: Comment, viewBinding.commentTotalReplies.text = if (comment.replyCount == 1) getString(R.string.view_reply) else - getString(R.string.view_replies, comment.replyCount) + getString(R.string.view_replies_count, comment.replyCount) } repliesVisible = false } else { diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt index 78867e37..25b02e72 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt @@ -47,7 +47,6 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene private var selected: Int = 0 private lateinit var navBar: AnimatedBottomBar - @SuppressLint("SetTextI18n") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ThemeManager(this).applyTheme() @@ -105,20 +104,30 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene val userLevel = intent.getStringExtra("userLVL") ?: "" binding.followButton.visibility = if (user.id == Anilist.userid || Anilist.userid == null) View.GONE else View.VISIBLE - binding.followButton.text = - if (user.isFollowing) "Unfollow" else if (user.isFollower) "Follows you" else "Follow" - if (user.isFollowing && user.isFollower) binding.followButton.text = "Mutual" + binding.followButton.text = getString( + when { + user.isFollowing -> R.string.unfollow + user.isFollower -> R.string.follows_you + else -> R.string.follow + } + ) + if (user.isFollowing && user.isFollower) binding.followButton.text = getString(R.string.mutual) binding.followButton.setOnClickListener { lifecycleScope.launch(Dispatchers.IO) { val res = Anilist.query.toggleFollow(user.id) if (res?.data?.toggleFollow != null) { withContext(Dispatchers.Main) { - snackString("Success") + snackString(R.string.success) user.isFollowing = res.data.toggleFollow.isFollowing - binding.followButton.text = - if (user.isFollowing) "Unfollow" else if (user.isFollower) "Follows you" else "Follow" - if (user.isFollowing && user.isFollower) binding.followButton.text = - "Mutual" + binding.followButton.text = getString( + when { + user.isFollowing -> R.string.unfollow + user.isFollower -> R.string.follows_you + else -> R.string.follow + } + ) + if (user.isFollowing && user.isFollower) + binding.followButton.text = getString(R.string.mutual) } } } @@ -172,7 +181,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene ) } - binding.profileUserName.text = "${user.name} $userLevel" + val userLevelText = "${user.name} $userLevel" + binding.profileUserName.text = userLevelText if (!(PrefManager.getVal(PrefName.BannerAnimations) as Boolean)) binding.profileBannerImage.pause() blurImage(binding.profileBannerImage, user.bannerImage ?: user.avatar?.medium) binding.profileBannerImage.updateLayoutParams { height += statusBarHeight } @@ -196,7 +206,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene ContextCompat.startActivity( this@ProfileActivity, Intent(this@ProfileActivity, FollowActivity::class.java) - .putExtra("title", "Followers") + .putExtra("title", getString(R.string.followers)) .putExtra("userId", user.id), null ) diff --git a/app/src/main/java/ani/dantotsu/profile/activity/ActivityItem.kt b/app/src/main/java/ani/dantotsu/profile/activity/ActivityItem.kt index c55e6a82..59316e2b 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/ActivityItem.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/ActivityItem.kt @@ -38,7 +38,6 @@ class ActivityItem( private lateinit var binding: ItemActivityBinding private lateinit var repliesAdapter: GroupieAdapter - @SuppressLint("SetTextI18n") override fun bind(viewBinding: ItemActivityBinding, position: Int) { binding = viewBinding setAnimation(binding.root.context, binding.root) @@ -73,13 +72,13 @@ class ActivityItem( } ?: emptyList() repliesAdapter.addAll(replyItems) binding.activityReplies.visibility = View.VISIBLE - binding.commentTotalReplies.text = "Hide replies" + binding.commentTotalReplies.setText(R.string.hide_replies) } else -> { repliesAdapter.clear() binding.activityReplies.visibility = View.GONE - binding.commentTotalReplies.text = "View replies" + binding.commentTotalReplies.setText(R.string.view_replies) } } @@ -127,7 +126,9 @@ class ActivityItem( binding.activityContent.visibility = View.GONE binding.activityBannerContainer.visibility = View.VISIBLE binding.activityMediaName.text = activity.media?.title?.userPreferred - binding.activityText.text = "${activity.user!!.name} ${activity.status} ${activity.progress ?: activity.media?.title?.userPreferred}" + val activityText = "${activity.user!!.name} ${activity.status} ${activity.progress + ?: activity.media?.title?.userPreferred}" + binding.activityText.text = activityText binding.activityCover.loadImage(cover) blurImage(binding.activityBannerImage, banner ?: cover) binding.activityAvatarContainer.setOnClickListener { diff --git a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt index 9b68f377..c8f5141c 100644 --- a/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/activity/NotificationActivity.kt @@ -11,6 +11,7 @@ import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager +import ani.dantotsu.R import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.connections.anilist.api.Notification import ani.dantotsu.databinding.ActivityFollowBinding @@ -37,14 +38,14 @@ class NotificationActivity : AppCompatActivity() { private var currentPage: Int = 1 private var hasNextPage: Boolean = true - @SuppressLint("SetTextI18n", "ClickableViewAccessibility") + @SuppressLint("ClickableViewAccessibility") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) ThemeManager(this).applyTheme() initActivity(this) binding = ActivityFollowBinding.inflate(layoutInflater) setContentView(binding.root) - binding.listTitle.text = "Notifications" + binding.listTitle.text = getString(R.string.notifications) binding.listToolbar.updateLayoutParams { topMargin = statusBarHeight } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dce799f6..442d36a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,6 +72,9 @@ All + No more notifications + Followers + STATUS PLANNING @@ -693,6 +696,10 @@ Manga Mean Score About me Follow + Unfollow + Follows you + Mutual + Success Lorem ipsum dolor sit amet. Est consectetur sint qui internos optio nam Quis excepturi qui voluptatem animi. Qui labore quasi vel suscipit deleniti et doloremque omnis in velit suscipit et quasi eaque. Et doloribus recusandae id laudantium Quis qui natus velit in voluptatem voluptatem! @@ -718,9 +725,10 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc Failed to delete because of… %1$s - Hide Replies + Hide replies View reply - View %1$d replies + View replies + View %1$d replies Replying to %1$s Delete Comment