From 2063dbd0b0760c4d8d547ac614e63abdd973627b Mon Sep 17 00:00:00 2001 From: Grishka Date: Thu, 16 Nov 2023 18:15:59 +0300 Subject: [PATCH] Copy app version when tapped --- .../fragments/settings/SettingsAboutAppFragment.java | 12 ++++++++++++ mastodon/src/main/res/values/strings.xml | 1 + 2 files changed, 13 insertions(+) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java index 7174a340..1143f670 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsAboutAppFragment.java @@ -1,6 +1,9 @@ package org.joinmastodon.android.fragments.settings; import android.app.Activity; +import android.content.ClipData; +import android.content.ClipboardManager; +import android.os.Build; import android.os.Bundle; import android.view.Gravity; import android.view.ViewGroup; @@ -13,6 +16,7 @@ import org.joinmastodon.android.api.MastodonAPIController; import org.joinmastodon.android.api.session.AccountSession; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.model.viewmodel.ListItem; +import org.joinmastodon.android.ui.Snackbar; import org.joinmastodon.android.ui.utils.UiUtils; import java.util.List; @@ -57,6 +61,14 @@ public class SettingsAboutAppFragment extends BaseSettingsFragment{ versionInfo.setTextColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Outline)); versionInfo.setGravity(Gravity.CENTER); versionInfo.setText(getString(R.string.settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); + versionInfo.setOnClickListener(v->{ + getActivity().getSystemService(ClipboardManager.class).setPrimaryClip(ClipData.newPlainText("", BuildConfig.VERSION_NAME+" ("+BuildConfig.VERSION_CODE+")")); + if(Build.VERSION.SDK_INT<=Build.VERSION_CODES.S_V2){ + new Snackbar.Builder(getActivity()) + .setText(R.string.app_version_copied) + .show(); + } + }); adapter.addAdapter(new SingleViewRecyclerAdapter(versionInfo)); return adapter; diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index deeb066f..0b51afff 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -663,4 +663,5 @@ Make my profile discoverable Discoverability When you opt into discoverability on Mastodon, your posts may appear in search results and trending.\n\nYour profile may be suggested to people with similar interests to you.\n\nOpting out does not hide your profile if someone searches for you by name. + Version number copied to clipboard \ No newline at end of file