From 7366aa1bf2b48a4300665073916dcde8aeff31e3 Mon Sep 17 00:00:00 2001 From: ibo <41344259+sneazy-ibo@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:56:34 +0200 Subject: [PATCH] [skip ci] feat: copy username and better profile dropdown menu (#429) --- .../ani/dantotsu/profile/ProfileActivity.kt | 19 ++++++++++++++++--- app/src/main/res/menu/menu_profile.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt index 856dc0b8..88b814af 100644 --- a/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt +++ b/app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt @@ -22,6 +22,7 @@ import ani.dantotsu.R import ani.dantotsu.blurImage import ani.dantotsu.connections.anilist.Anilist import ani.dantotsu.connections.anilist.api.Query +import ani.dantotsu.copyToClipboard import ani.dantotsu.databinding.ActivityProfileBinding import ani.dantotsu.databinding.ItemProfileAppBarBinding import ani.dantotsu.initActivity @@ -152,11 +153,20 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene popup.setOnMenuItemClickListener { item -> when (item.itemId) { R.id.action_view_on_anilist -> { - openLinkInBrowser("https://anilist.co/user/${user.name}") + openLinkInBrowser(getString(R.string.anilist_link, user.name)) + true + } + R.id.action_share_profile -> { + val shareIntent = Intent(Intent.ACTION_SEND) + shareIntent.type = "text/plain" + shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.anilist_link, user.name)) + startActivity(Intent.createChooser(shareIntent, "Share Profile")) + true + } + R.id.action_copy_user_id -> { + copyToClipboard(user.id.toString(), true) true } - - else -> false } } @@ -169,6 +179,9 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene user.avatar?.medium ?: "" ) profileUserName.text = user.name + profileUserName.setOnClickListener { + copyToClipboard(profileUserName.text.toString(), true) + } val bannerAnimations: ImageView = if (PrefManager.getVal(PrefName.BannerAnimations)) profileBannerImage else profileBannerImageNoKen diff --git a/app/src/main/res/menu/menu_profile.xml b/app/src/main/res/menu/menu_profile.xml index 9cb03021..c1351e8e 100644 --- a/app/src/main/res/menu/menu_profile.xml +++ b/app/src/main/res/menu/menu_profile.xml @@ -7,4 +7,14 @@ android:title="@string/view_on_anilist" app:showAsAction="never" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f47309a0..a4d5a027 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -802,6 +802,8 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc Blur Hide Scroll Bar View on AniList + Share Profile + Copy user ID Filter Notifications Anilist notifications update frequency : %1$s Comment notifications update frequency : %1$s