From 15ce78b85a2bc2cb9d21c703c5a2713f6e188a05 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 4 Dec 2022 15:00:28 +0100 Subject: [PATCH 1/2] Fix a crash --- .../ui/fragment/settings/FragmentThemingSettings.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java index 50e05c84..72f63533 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentThemingSettings.java @@ -23,7 +23,6 @@ import androidx.preference.PreferenceFragmentCompat; import app.fedilab.android.R; import app.fedilab.android.helper.Helper; -import app.fedilab.android.helper.ThemeHelper; import es.dmoral.toasty.Toasty; public class FragmentThemingSettings extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -61,9 +60,8 @@ public class FragmentThemingSettings extends PreferenceFragmentCompat implements if (key.compareTo(getString(R.string.SET_THEME_BASE)) == 0) { ListPreference SET_THEME_BASE = findPreference(getString(R.string.SET_THEME_BASE)); if (SET_THEME_BASE != null) { - ThemeHelper.switchTo(SET_THEME_BASE.getValue()); - requireActivity().recreate(); - Helper.recreateMainActivity(requireActivity()); + requireActivity().finish(); + startActivity(requireActivity().getIntent()); } } //TODO: check if can be removed From 468f825dc061ce6ea68701d91dfc24536f0f8957 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 4 Dec 2022 15:49:38 +0100 Subject: [PATCH 2/2] Release 3.9.4 --- app/build.gradle | 4 +- app/src/main/assets/release_notes/notes.json | 5 +++ .../app/fedilab/android/BaseMainActivity.java | 10 +++-- .../android/client/entities/api/Account.java | 8 ++++ .../android/helper/SpannableHelper.java | 37 +++++++++++++++++++ app/src/main/res/layout/drawer_account.xml | 13 ++++--- .../main/res/layout/drawer_account_list.xml | 14 ++++--- .../main/res/layout/drawer_admin_account.xml | 14 ++++--- .../main/res/layout/drawer_announcement.xml | 13 ++++--- .../main/res/layout/drawer_conversation.xml | 13 ++++--- .../main/res/layout/drawer_domain_block.xml | 12 +++--- app/src/main/res/layout/drawer_follow.xml | 13 ++++--- .../main/res/layout/drawer_instance_reg.xml | 12 +++--- app/src/main/res/layout/drawer_status.xml | 14 ++++--- .../main/res/layout/drawer_status_draft.xml | 12 +++--- .../res/layout/drawer_status_filtered.xml | 12 +++--- .../layout/drawer_status_filtered_hide.xml | 12 +++--- .../main/res/layout/drawer_status_history.xml | 13 ++++--- .../res/layout/drawer_status_scheduled.xml | 12 +++--- .../main/res/layout/drawer_status_simple.xml | 15 ++++---- app/src/main/res/layout/drawer_suggestion.xml | 12 +++--- app/src/main/res/layout/drawer_tag.xml | 13 ++++--- app/src/main/res/values-night/themes.xml | 14 +++---- .../metadata/android/en/changelogs/439.txt | 6 +++ 24 files changed, 198 insertions(+), 105 deletions(-) create mode 100644 src/fdroid/fastlane/metadata/android/en/changelogs/439.txt diff --git a/app/build.gradle b/app/build.gradle index 6d80864f..4ab8912d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { defaultConfig { minSdk 21 targetSdk 32 - versionCode 438 - versionName "3.9.3" + versionCode 439 + versionName "3.9.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } flavorDimensions "default" diff --git a/app/src/main/assets/release_notes/notes.json b/app/src/main/assets/release_notes/notes.json index 7f6aff91..3a01fdff 100644 --- a/app/src/main/assets/release_notes/notes.json +++ b/app/src/main/assets/release_notes/notes.json @@ -1,4 +1,9 @@ [ + { + "version": "3.9.4", + "code": "439", + "note": "Changed:\n- Remove card presentation\n- Link color for black theme\n\nFixed:\n- Crash when changing the theme" + }, { "version": "3.9.3", "code": "438", diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index bf1cf1f0..1f28b8be 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -646,10 +646,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) { currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct; } - headerMainBinding.accountName.setText( - currentAccount.mastodon_account.getSpanDisplayName(BaseMainActivity.this, - new WeakReference<>(headerMainBinding.accountName)), - TextView.BufferType.SPANNABLE); + if (!isFinishing()) { + headerMainBinding.accountName.setText( + currentAccount.mastodon_account.getSpanDisplayName(BaseMainActivity.this, + new WeakReference<>(headerMainBinding.accountName)), + TextView.BufferType.SPANNABLE); + } float scale = sharedpreferences.getFloat(getString(R.string.SET_FONT_SCALE), 1.1f); headerMainBinding.accountName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); diff --git a/app/src/main/java/app/fedilab/android/client/entities/api/Account.java b/app/src/main/java/app/fedilab/android/client/entities/api/Account.java index 36fb7a74..9ece8182 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/api/Account.java +++ b/app/src/main/java/app/fedilab/android/client/entities/api/Account.java @@ -14,6 +14,7 @@ package app.fedilab.android.client.entities.api; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ +import android.app.Activity; import android.content.Context; import android.text.Spannable; import android.view.View; @@ -87,6 +88,13 @@ public class Account implements Serializable { return SpannableHelper.convert(context, display_name, null, this, null, false, viewWeakReference); } + public synchronized Spannable getSpanDisplayName(Activity activity, WeakReference viewWeakReference) { + if (display_name == null || display_name.isEmpty()) { + display_name = username; + } + return SpannableHelper.convertEmoji(activity, display_name, this, viewWeakReference); + } + public synchronized Spannable getSpanDisplayNameTitle(Context context, WeakReference viewWeakReference, String title) { return SpannableHelper.convert(context, title, null, this, null, false, viewWeakReference); } diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index 1987da18..455614b3 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -18,6 +18,7 @@ package app.fedilab.android.helper; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction; +import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -1037,4 +1038,40 @@ public class SpannableHelper { } return spannableString; } + + + public static Spannable convertEmoji(Activity activity, String text, Account account, WeakReference viewWeakReference) { + + SpannableString initialContent; + if (text == null) { + return null; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) + initialContent = new SpannableString(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)); + else + initialContent = new SpannableString(Html.fromHtml(text)); + + SpannableStringBuilder content = new SpannableStringBuilder(initialContent); + List emojiList = account.emojis; + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity); + boolean animate = !sharedpreferences.getBoolean(activity.getString(R.string.SET_DISABLE_ANIMATED_EMOJI), false); + if (emojiList != null && emojiList.size() > 0) { + for (Emoji emoji : emojiList) { + Matcher matcher = Pattern.compile(":" + emoji.shortcode + ":", Pattern.LITERAL) + .matcher(content); + while (matcher.find()) { + CustomEmoji customEmoji = new CustomEmoji(new WeakReference<>(viewWeakReference.get())); + content.setSpan(customEmoji, matcher.start(), matcher.end(), 0); + if (Helper.isValidContextForGlide(activity)) { + Glide.with(viewWeakReference.get()) + .asDrawable() + .load(animate ? emoji.url : emoji.static_url) + .into(customEmoji.getTarget(animate)); + } + } + } + } + + return trimSpannable(new SpannableStringBuilder(content)); + } } diff --git a/app/src/main/res/layout/drawer_account.xml b/app/src/main/res/layout/drawer_account.xml index 25b46fc5..75a4731a 100644 --- a/app/src/main/res/layout/drawer_account.xml +++ b/app/src/main/res/layout/drawer_account.xml @@ -14,16 +14,19 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:layout_marginTop="6dp"> + + - + diff --git a/app/src/main/res/layout/drawer_account_list.xml b/app/src/main/res/layout/drawer_account_list.xml index 32c86a30..06c94694 100644 --- a/app/src/main/res/layout/drawer_account_list.xml +++ b/app/src/main/res/layout/drawer_account_list.xml @@ -14,16 +14,18 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:layout_marginTop="12dp"> + + - + diff --git a/app/src/main/res/layout/drawer_admin_account.xml b/app/src/main/res/layout/drawer_admin_account.xml index 7faf4ef5..11be1312 100644 --- a/app/src/main/res/layout/drawer_admin_account.xml +++ b/app/src/main/res/layout/drawer_admin_account.xml @@ -1,13 +1,15 @@ - + android:layout_marginTop="6dp"> + + - + diff --git a/app/src/main/res/layout/drawer_announcement.xml b/app/src/main/res/layout/drawer_announcement.xml index 2ba338a1..b7fe3621 100644 --- a/app/src/main/res/layout/drawer_announcement.xml +++ b/app/src/main/res/layout/drawer_announcement.xml @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:clipToPadding="false"> + + - + diff --git a/app/src/main/res/layout/drawer_conversation.xml b/app/src/main/res/layout/drawer_conversation.xml index 41e0f0d3..3fa599d2 100644 --- a/app/src/main/res/layout/drawer_conversation.xml +++ b/app/src/main/res/layout/drawer_conversation.xml @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:layout_marginTop="6dp"> + + - + diff --git a/app/src/main/res/layout/drawer_domain_block.xml b/app/src/main/res/layout/drawer_domain_block.xml index 0de61977..81edbc78 100644 --- a/app/src/main/res/layout/drawer_domain_block.xml +++ b/app/src/main/res/layout/drawer_domain_block.xml @@ -14,14 +14,16 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see . --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_follow.xml b/app/src/main/res/layout/drawer_follow.xml index 22d6f8bf..0fcc8e74 100644 --- a/app/src/main/res/layout/drawer_follow.xml +++ b/app/src/main/res/layout/drawer_follow.xml @@ -14,15 +14,18 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:layout_marginTop="@dimen/card_margin"> + + - + diff --git a/app/src/main/res/layout/drawer_instance_reg.xml b/app/src/main/res/layout/drawer_instance_reg.xml index 430c1dd0..0f97003a 100644 --- a/app/src/main/res/layout/drawer_instance_reg.xml +++ b/app/src/main/res/layout/drawer_instance_reg.xml @@ -14,15 +14,17 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see . --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index 9c22561f..3a741fe3 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -14,19 +14,21 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:clipChildren="false"> + + - + diff --git a/app/src/main/res/layout/drawer_status_draft.xml b/app/src/main/res/layout/drawer_status_draft.xml index a51911c4..1eb24ce4 100644 --- a/app/src/main/res/layout/drawer_status_draft.xml +++ b/app/src/main/res/layout/drawer_status_draft.xml @@ -14,16 +14,18 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - + diff --git a/app/src/main/res/layout/drawer_status_filtered.xml b/app/src/main/res/layout/drawer_status_filtered.xml index 7eee092e..69154e28 100644 --- a/app/src/main/res/layout/drawer_status_filtered.xml +++ b/app/src/main/res/layout/drawer_status_filtered.xml @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - - android:clipToPadding="false" - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_status_filtered_hide.xml b/app/src/main/res/layout/drawer_status_filtered_hide.xml index 19385238..4b7b3223 100644 --- a/app/src/main/res/layout/drawer_status_filtered_hide.xml +++ b/app/src/main/res/layout/drawer_status_filtered_hide.xml @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - - android:clipToPadding="false" - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_status_history.xml b/app/src/main/res/layout/drawer_status_history.xml index 4507a628..0522d2c6 100644 --- a/app/src/main/res/layout/drawer_status_history.xml +++ b/app/src/main/res/layout/drawer_status_history.xml @@ -14,8 +14,7 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_status_scheduled.xml b/app/src/main/res/layout/drawer_status_scheduled.xml index c55ba39b..b22296a2 100644 --- a/app/src/main/res/layout/drawer_status_scheduled.xml +++ b/app/src/main/res/layout/drawer_status_scheduled.xml @@ -14,16 +14,18 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - + diff --git a/app/src/main/res/layout/drawer_status_simple.xml b/app/src/main/res/layout/drawer_status_simple.xml index 50d0e314..f7412709 100644 --- a/app/src/main/res/layout/drawer_status_simple.xml +++ b/app/src/main/res/layout/drawer_status_simple.xml @@ -14,19 +14,20 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - + android:clipToPadding="false"> + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/drawer_suggestion.xml b/app/src/main/res/layout/drawer_suggestion.xml index 966c2eea..8ed647a5 100644 --- a/app/src/main/res/layout/drawer_suggestion.xml +++ b/app/src/main/res/layout/drawer_suggestion.xml @@ -14,16 +14,18 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - + diff --git a/app/src/main/res/layout/drawer_tag.xml b/app/src/main/res/layout/drawer_tag.xml index bcc24c41..96667104 100644 --- a/app/src/main/res/layout/drawer_tag.xml +++ b/app/src/main/res/layout/drawer_tag.xml @@ -14,14 +14,15 @@ You should have received a copy of the GNU General Public License along with Fedilab; if not, see . --> - - app:cardElevation="5dp" - app:strokeWidth="0dp"> + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 159f0a79..031cb493 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -218,9 +218,9 @@