Fix #1008 -Allow to copy app version from the about page

custom_intent
Thomas 11 months ago
parent 4ce92e67b1
commit b6cbd8ea74

@ -15,12 +15,16 @@ package app.fedilab.android.activities;
* see <http://www.gnu.org/licenses>. */
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.core.app.ActivityOptionsCompat;
import androidx.lifecycle.ViewModelProvider;
@ -40,6 +44,7 @@ import app.fedilab.android.mastodon.helper.CrossActionHelper;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.helper.MastodonHelper;
import app.fedilab.android.mastodon.viewmodel.mastodon.AccountsVM;
import es.dmoral.toasty.Toasty;
public class AboutActivity extends BaseBarActivity {
@ -58,10 +63,10 @@ public class AboutActivity extends BaseBarActivity {
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
String version = "";
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;
version = pInfo.versionName;
binding.aboutVersion.setText(getResources().getString(R.string.about_vesrion, version));
} catch (PackageManager.NameNotFoundException ignored) {
}
@ -77,6 +82,20 @@ public class AboutActivity extends BaseBarActivity {
}
binding.aboutSupportPaypal.setOnClickListener(v -> Helper.openBrowser(AboutActivity.this, "https://www.paypal.me/Mastalab"));
String finalVersion = version;
binding.aboutVersionCopy.setOnClickListener(v->{
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
String content = "Fedilab v" + finalVersion + " for " + (BuildConfig.DONATIONS?"FDroid":"Google");
ClipData clip = ClipData.newPlainText(Helper.CLIP_BOARD, content);
if (clipboard != null) {
clipboard.setPrimaryClip(clip);
Toasty.info(AboutActivity.this, getString(R.string.clipboard_version), Toast.LENGTH_LONG).show();
}
});
if (BuildConfig.DONATIONS) {
binding.aboutSupportPaypal.setVisibility(View.VISIBLE);
} else {

@ -35,14 +35,32 @@
android:text="@string/app_name"
android:textSize="20sp" />
<!-- About version -->
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/about_version"
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/about_version"
tools:text="x.y.z"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:textSize="16sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/about_version_copy"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="36dp"
android:layout_height="36dp"
app:iconGravity="textStart"
app:iconPadding="0dp"
android:layout_marginStart="10dp"
android:contentDescription="@string/copy_version"
app:icon="@drawable/ic_copy_link"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<!-- About developer -->
<androidx.appcompat.widget.AppCompatTextView

@ -27,6 +27,7 @@
<string name="add_account">Add an account</string>
<string name="clipboard">The content of the message has been copied to the clipboard</string>
<string name="clipboard_url">The URL of the message has been copied to the clipboard</string>
<string name="clipboard_version">Information have been copied to the clipboard</string>
<string name="camera">Camera</string>
<string name="delete_all">Delete all</string>
<string name="schedule">Schedule</string>
@ -407,6 +408,7 @@
<string name="action_logout_account">Logout account</string>
<string name="all">All</string>
<string name="copy_link">Copy link</string>
<string name="copy_version">Copy information</string>
<string name="calls_blocked">http calls blocked by the application</string>
<string name="list_of_blocked_domains">List of blocked calls</string>
<string name="submit">Submit</string>

Loading…
Cancel
Save