Copy app version when tapped

This commit is contained in:
Grishka 2023-11-16 18:15:59 +03:00
parent e5506d952c
commit 2063dbd0b0
2 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,9 @@
package org.joinmastodon.android.fragments.settings; package org.joinmastodon.android.fragments.settings;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity; import android.view.Gravity;
import android.view.ViewGroup; 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.AccountSession;
import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.model.viewmodel.ListItem; import org.joinmastodon.android.model.viewmodel.ListItem;
import org.joinmastodon.android.ui.Snackbar;
import org.joinmastodon.android.ui.utils.UiUtils; import org.joinmastodon.android.ui.utils.UiUtils;
import java.util.List; import java.util.List;
@ -57,6 +61,14 @@ public class SettingsAboutAppFragment extends BaseSettingsFragment<Void>{
versionInfo.setTextColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Outline)); versionInfo.setTextColor(UiUtils.getThemeColor(getActivity(), R.attr.colorM3Outline));
versionInfo.setGravity(Gravity.CENTER); versionInfo.setGravity(Gravity.CENTER);
versionInfo.setText(getString(R.string.settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)); 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)); adapter.addAdapter(new SingleViewRecyclerAdapter(versionInfo));
return adapter; return adapter;

View File

@ -663,4 +663,5 @@
<string name="make_profile_discoverable">Make my profile discoverable</string> <string name="make_profile_discoverable">Make my profile discoverable</string>
<string name="discoverability">Discoverability</string> <string name="discoverability">Discoverability</string>
<string name="discoverability_help">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.</string> <string name="discoverability_help">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.</string>
<string name="app_version_copied">Version number copied to clipboard</string>
</resources> </resources>