Update 'Release notes' dialog

- Some UI changes
- Add an accessibility action to translate release notes
- Re-use drawer_account_list for account
This commit is contained in:
0xd9a 2025-09-26 15:04:51 +05:30
parent 5997481319
commit b65b5887a5
6 changed files with 184 additions and 177 deletions

View file

@ -1994,23 +1994,13 @@ public class Helper {
} catch (Exception ignored) {
}
if (BuildConfig.DONATIONS) {
binding.aboutSupport.setVisibility(View.VISIBLE);
binding.aboutSupportPaypal.setVisibility(View.VISIBLE);
binding.donationsMethods.setVisibility(View.VISIBLE);
binding.donateLiberapay.setOnClickListener(v -> Helper.openBrowser(activity, "https://liberapay.com/tom79"));
binding.donatePaypal.setOnClickListener(v -> Helper.openBrowser(activity, "https://www.paypal.me/Mastalab"));
binding.donateOpencollective.setOnClickListener(v -> Helper.openBrowser(activity, "https://opencollective.com/fedilab"));
} else {
binding.aboutSupport.setVisibility(View.GONE);
binding.aboutSupportPaypal.setVisibility(View.GONE);
binding.donationsMethods.setVisibility(View.GONE);
}
binding.accountFollow.setIconResource(R.drawable.ic_baseline_person_add_24);
binding.aboutSupport.setOnClickListener(v -> {
Intent intentLiberapay = new Intent(Intent.ACTION_VIEW);
intentLiberapay.setData(Uri.parse("https://liberapay.com/tom79"));
try {
activity.startActivity(intentLiberapay);
} catch (Exception e) {
Helper.openBrowser(activity, "https://liberapay.com/tom79");
}
});
binding.aboutSupportPaypal.setOnClickListener(v -> Helper.openBrowser(activity, "https://www.paypal.me/Mastalab"));
CrossActionHelper.fetchRemoteAccount(activity, "@apps@toot.fedilab.app", new CrossActionHelper.Callback() {
@Override
public void federatedStatus(Status status) {
@ -2021,10 +2011,10 @@ public class Helper {
public void federatedAccount(app.fedilab.android.mastodon.client.entities.api.Account account) {
if (account != null && account.username.equalsIgnoreCase("apps")) {
MastodonHelper.loadPPMastodon(binding.accountPp, account);
binding.accountDn.setText(account.display_name);
binding.accountUn.setText(account.acct);
binding.accountPp.setOnClickListener(v -> {
MastodonHelper.loadPPMastodon(binding.accountContainer.avatar, account);
binding.accountContainer.displayName.setText(account.display_name);
binding.accountContainer.username.setText(account.acct);
binding.accountContainer.avatar.setOnClickListener(v -> {
Intent intent = new Intent(activity, ProfileActivity.class);
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_ACCOUNT, account);
@ -2043,10 +2033,9 @@ public class Helper {
.observe((LifecycleOwner) activity, relationShips -> {
if (relationShips != null && relationShips.size() > 0) {
if (!relationShips.get(0).following) {
binding.acccountContainer.setVisibility(View.VISIBLE);
binding.accountFollow.setVisibility(View.VISIBLE);
binding.accountFollow.setOnClickListener(v -> accountsVM.follow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id, true, false, null)
.observe((LifecycleOwner) activity, relationShip -> binding.accountFollow.setVisibility(View.GONE)));
binding.accountContainer.getRoot().setVisibility(View.VISIBLE);
binding.accountContainer.listAction.setOnClickListener(v -> accountsVM.follow(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, account.id, true, false, null)
.observe((LifecycleOwner) activity, relationShip -> binding.accountContainer.listAction.setVisibility(View.GONE)));
}
}
});

View file

@ -22,6 +22,7 @@ import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
@ -68,23 +69,32 @@ public class ReleaseNoteAdapter extends RecyclerView.Adapter<ReleaseNoteAdapter.
holder.binding.version.setText(String.format(Locale.getDefault(), "%s (%s)", note.version, note.code));
if (note.noteTranslated != null) {
holder.binding.noteTranslated.setText(note.noteTranslated);
holder.binding.containerTrans.setContentDescription(context.getString(R.string.cd_release_note, note.noteTranslated));
holder.binding.containerTrans.setVisibility(View.VISIBLE);
holder.binding.translate.setVisibility(View.GONE);
} else {
holder.binding.containerTrans.setVisibility(View.GONE);
holder.binding.translate.setVisibility(View.VISIBLE);
}
holder.binding.translate.setOnClickListener(v -> TranslateHelper.translate(context, note.note, "en", translated -> {
holder.binding.translate.setOnClickListener(v -> onTranslatePressed(note, holder.getBindingAdapterPosition()));
ViewCompat.addAccessibilityAction(holder.binding.note, context.getString(R.string.translate), (view, arguments) -> {
onTranslatePressed(note, holder.getBindingAdapterPosition());
return true;
});
holder.binding.translate.setOnClickListener(v -> onTranslatePressed(note, holder.getBindingAdapterPosition()));
}
private void onTranslatePressed(ReleaseNote.Note note, int bindingAdapterPosition) {
TranslateHelper.translate(context, note.note, "en", translated -> {
if (translated != null) {
note.noteTranslated = translated;
notifyItemChanged(holder.getBindingAdapterPosition());
notifyItemChanged(bindingAdapterPosition);
} else {
Toasty.error(context, context.getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
}
}));
});
}
public static class ReleaseNoteViewHolder extends RecyclerView.ViewHolder {
DrawerReleaseNoteBinding binding;

View file

@ -46,13 +46,13 @@
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_person" />
tools:src="@tools:sample/avatars" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/display_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginHorizontal="6dp"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
app:layout_constraintBottom_toTopOf="@id/username"
app:layout_constraintEnd_toStartOf="@+id/list_action"
@ -65,7 +65,7 @@
android:id="@+id/username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginHorizontal="6dp"
android:ellipsize="end"
android:singleLine="true"
app:layout_constraintBottom_toBottomOf="@id/avatar"
@ -74,18 +74,13 @@
app:layout_constraintTop_toBottomOf="@id/display_name"
tools:text="\@username@instance.test" />
<com.google.android.material.button.MaterialButton
android:id="@+id/list_action"
style="@style/Widget.Material3.Button.Icon"
android:layout_width="36dp"
android:layout_height="36dp"
style="@style/Widget.Material3.Button.IconButton.Filled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:padding="0dp"
app:icon="@drawable/ic_baseline_person_add_alt_1_24"
app:iconGravity="textStart"
app:iconPadding="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

View file

@ -1,85 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_margin="6dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/version"
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:padding="2dp"
android:textSize="18sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="16sp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/translate"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:contentDescription="@string/translate"
app:icon="@drawable/ic_baseline_translate_24"
app:iconPadding="0dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container_trans"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:orientation="vertical"
android:visibility="gone">
android:padding="6dp">
<View
android:id="@+id/translation_border_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/translation_border"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/translation_border_top" />
<androidx.constraintlayout.widget.Placeholder
android:id="@+id/translation_border_top"
android:layout_width="wrap_content"
android:layout_height="1dp"
app:layout_constraintBottom_toBottomOf="@id/translation_label"
app:layout_constraintEnd_toEndOf="@id/translation_label"
app:layout_constraintTop_toTopOf="@id/translation_label" />
<TextView
android:id="@+id/translation_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text="@string/translation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/note_translated"
<com.google.android.material.textview.MaterialTextView
android:id="@+id/version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/translation_label"
app:layout_goneMarginBottom="8dp" />
android:ellipsize="end"
android:focusable="true"
android:lines="1"
android:padding="6dp"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
tools:text="1.0.0 (100)" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:padding="6dp"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
tools:maxLines="5"
tools:text="@tools:sample/lorem/random" />
<com.google.android.material.button.MaterialButton
android:id="@+id/translate"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:contentDescription="@string/translate"
android:importantForAccessibility="no"
app:icon="@drawable/ic_baseline_translate_24" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container_trans"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:focusable="true"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<View
android:id="@+id/translation_border_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/translation_border"
android:importantForAccessibility="no"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/translation_border_top" />
<androidx.constraintlayout.widget.Placeholder
android:id="@+id/translation_border_top"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:importantForAccessibility="no"
app:layout_constraintBottom_toBottomOf="@id/translation_label"
app:layout_constraintEnd_toEndOf="@id/translation_label"
app:layout_constraintTop_toTopOf="@id/translation_label" />
<TextView
android:id="@+id/translation_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:background="?colorSurface"
android:importantForAccessibility="no"
android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text="@string/translation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/note_translated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:importantForAccessibility="no"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/translation_label"
app:layout_goneMarginBottom="8dp"
tools:maxLines="5"
tools:text="@tools:sample/lorem/random" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.google.android.material.card.MaterialCardView>

View file

@ -20,88 +20,77 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:padding="6dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/releasenotes"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:layout_margin="6dp"
android:layout_weight="1" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/acccount_container"
<include
android:id="@+id/account_container"
layout="@layout/drawer_account_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/about_support"
tools:visibility="visible">
android:layout_marginTop="12dp" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/account_pp"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="10dp"
android:contentDescription="@string/profile_picture" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/about_donate"
android:textAppearance="@style/TextAppearance.Material3.LabelLarge" />
<androidx.appcompat.widget.LinearLayoutCompat
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/donations_methods"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/donate_liberapay"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:padding="10dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/account_dn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="16sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/account_un"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="14sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
android:ellipsize="end"
android:maxLines="1"
android:text="Liberapay"
app:cornerRadius="0dp"
app:icon="@drawable/ic_liberapay"
app:iconGravity="top"
tools:ignore="HardcodedText" />
<com.google.android.material.button.MaterialButton
android:id="@+id/account_follow"
style="@style/Widget.Material3.Button.Icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:contentDescription="@string/make_an_action"
android:scaleType="fitCenter"
android:visibility="gone"
tools:icon="@drawable/ic_baseline_person_add_24"
tools:visibility="visible" />
android:id="@+id/donate_opencollective"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="OpenCollective"
app:cornerRadius="0dp"
app:icon="@drawable/ic_opencollective"
app:iconGravity="top"
tools:ignore="HardcodedText" />
<com.google.android.material.button.MaterialButton
android:id="@+id/donate_paypal"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="PayPal"
app:cornerRadius="0dp"
app:icon="@drawable/ic_paypal"
app:iconGravity="top"
tools:ignore="HardcodedText" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.button.MaterialButton
android:id="@+id/about_support"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:text="@string/support_the_app_on_liberapay" />
<com.google.android.material.button.MaterialButton
android:id="@+id/about_support_paypal"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PayPal"
tools:ignore="HardcodedText" />
</androidx.appcompat.widget.LinearLayoutCompat>

View file

@ -86,6 +86,7 @@
<string name="cd_translated_content">Translated content: %s</string>
<string name="cd_list_timeline">%s. List timeline</string>
<string name="cd_hash_tag_timeline">%s. Hash tag timeline</string>
<string name="cd_release_note">Translated release note: %s</string>
<!-- Status -->
<string name="no_status">No message to display</string>