From 90a6297c8fa39d014f8739f123d02207784baa51 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 1 Apr 2025 09:43:53 +0200 Subject: [PATCH 1/4] Fix status bar icons not visible in light theme with custom accent color --- .../android/mastodon/activities/BaseActivity.java | 15 +++++++++++++++ .../mastodon/activities/BaseBarActivity.java | 11 +++++++++++ app/src/main/res/values-night/themes.xml | 12 ++++++++++++ 3 files changed, 38 insertions(+) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/BaseActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/BaseActivity.java index 8507bda9..7c71a738 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/BaseActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/BaseActivity.java @@ -15,7 +15,9 @@ package app.fedilab.android.mastodon.activities; * see . */ +import static app.fedilab.android.BaseMainActivity.currentInstance; import static app.fedilab.android.BaseMainActivity.currentNightMode; +import static app.fedilab.android.BaseMainActivity.currentUserID; import android.annotation.SuppressLint; import android.content.Context; @@ -24,6 +26,7 @@ import android.content.res.Configuration; import android.graphics.Color; import android.os.Build; import android.os.Bundle; +import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -72,8 +75,20 @@ public class BaseActivity extends AppCompatActivity { } String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME)); + boolean customAccentEnabled = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_ACCENT) + currentUserID + currentInstance, false); + //Default automatic switch currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + + + if(customAccentEnabled && currentNightMode == Configuration.UI_MODE_NIGHT_NO) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR|View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + } + if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { switch (currentNightMode) { case Configuration.UI_MODE_NIGHT_NO -> { diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/BaseBarActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/BaseBarActivity.java index e606020b..94912f04 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/BaseBarActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/BaseBarActivity.java @@ -15,7 +15,9 @@ package app.fedilab.android.mastodon.activities; * see . */ +import static app.fedilab.android.BaseMainActivity.currentInstance; import static app.fedilab.android.BaseMainActivity.currentNightMode; +import static app.fedilab.android.BaseMainActivity.currentUserID; import android.annotation.SuppressLint; import android.content.Context; @@ -24,6 +26,7 @@ import android.content.res.Configuration; import android.graphics.Color; import android.os.Build; import android.os.Bundle; +import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -67,8 +70,16 @@ public class BaseBarActivity extends AppCompatActivity { } } String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME)); + boolean customAccentEnabled = sharedpreferences.getBoolean(getString(R.string.SET_CUSTOM_ACCENT) + currentUserID + currentInstance, false); //Default automatic switch currentNightMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + if(customAccentEnabled && currentNightMode == Configuration.UI_MODE_NIGHT_NO) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR|View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + } if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) { switch (currentNightMode) { case Configuration.UI_MODE_NIGHT_NO -> { diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 8344bd2c..0afe1d32 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -26,6 +26,7 @@ @color/md_theme_dark_background @color/md_theme_dark_onBackground @color/md_theme_dark_surface + @color/md_theme_dark_surface @color/md_theme_dark_onSurface @color/md_theme_dark_surfaceVariant @color/md_theme_dark_onSurfaceVariant @@ -72,6 +73,7 @@ @color/md_theme_dark_background @color/md_theme_dark_onBackground @color/md_theme_dark_surface + @color/md_theme_dark_surface @color/md_theme_dark_onSurface @color/md_theme_dark_surfaceVariant @color/md_theme_dark_onSurfaceVariant @@ -126,6 +128,7 @@ @color/md_theme_dark_background @color/md_theme_dark_onBackground @color/md_theme_dark_surface + @color/md_theme_dark_surface @color/md_theme_dark_onSurface @color/md_theme_dark_surfaceVariant @color/md_theme_dark_onSurfaceVariant @@ -164,6 +167,7 @@ @color/solarized_md_theme_dark_background @color/solarized_md_theme_dark_onBackground @color/solarized_md_theme_dark_surface + @color/solarized_md_theme_dark_surface @color/solarized_md_theme_dark_onSurface @color/solarized_md_theme_dark_surfaceVariant @color/solarized_md_theme_dark_onSurfaceVariant @@ -200,6 +204,7 @@ @color/solarized_md_theme_dark_background @color/solarized_md_theme_dark_onBackground @color/solarized_md_theme_dark_surface + @color/solarized_md_theme_dark_surface @color/solarized_md_theme_dark_onSurface @color/solarized_md_theme_dark_surfaceVariant @color/solarized_md_theme_dark_onSurfaceVariant @@ -255,6 +260,7 @@ @color/solarized_md_theme_dark_background @color/solarized_md_theme_dark_onBackground @color/solarized_md_theme_dark_surface + @color/solarized_md_theme_dark_surface @color/solarized_md_theme_dark_onSurface @color/solarized_md_theme_dark_surfaceVariant @color/solarized_md_theme_dark_onSurfaceVariant @@ -288,6 +294,7 @@ @color/black @color/white @color/black + @color/black @color/white @color/black @color/white @@ -320,6 +327,7 @@ @color/black @color/white @color/black + @color/black @color/white @color/black @color/white @@ -370,6 +378,7 @@ @color/black @color/white @color/black + @color/black @color/white @color/black @color/white @@ -404,6 +413,7 @@ @color/dracula_background @color/dracula_foreground @color/dracula_background + @color/dracula_background @color/dracula_foreground @color/dracula_current_Line @color/dracula_foreground @@ -437,6 +447,7 @@ @color/dracula_background @color/dracula_foreground @color/dracula_background + @color/dracula_background @color/dracula_foreground @color/dracula_current_Line @color/dracula_foreground @@ -488,6 +499,7 @@ @color/dracula_background @color/dracula_foreground @color/dracula_background + @color/dracula_background @color/dracula_foreground @color/dracula_current_Line @color/dracula_foreground From 98a8ac0df3a2fef248e0064aca7e2a56f031b635 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 1 Apr 2025 10:11:11 +0200 Subject: [PATCH 2/4] Make logout/proxy button more visible in main menu --- .../mastodon/layout/nav_header_main.xml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/res/layouts/mastodon/layout/nav_header_main.xml b/app/src/main/res/layouts/mastodon/layout/nav_header_main.xml index 96a78728..61b6daae 100644 --- a/app/src/main/res/layouts/mastodon/layout/nav_header_main.xml +++ b/app/src/main/res/layouts/mastodon/layout/nav_header_main.xml @@ -13,18 +13,20 @@ android:minHeight="@dimen/nav_header_height" android:scaleType="centerCrop" tools:src="@tools:sample/backgrounds/scenic" /> - - + app:icon="@drawable/ic_baseline_more_vert_24" /> + Date: Tue, 1 Apr 2025 15:38:30 +0200 Subject: [PATCH 3/4] Improve a little more media layout with translations --- .../mastodon/activities/MediaActivity.java | 2 ++ .../mastodon/layout/activity_media_pager.xml | 26 +++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java index 1d81b61e..aca57088 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java @@ -199,6 +199,7 @@ public class MediaActivity extends BaseBarActivity implements OnDownloadInterfac if (mCurrentFragment != null) { mCurrentFragment.toggleController(false); } + binding.translate.setVisibility(View.GONE); } else { Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); } @@ -248,6 +249,7 @@ public class MediaActivity extends BaseBarActivity implements OnDownloadInterfac if (mCurrentFragment != null) { mCurrentFragment.toggleController(true); } + binding.translate.setVisibility(View.GONE); } else { Toasty.error(MediaActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/res/layouts/mastodon/layout/activity_media_pager.xml b/app/src/main/res/layouts/mastodon/layout/activity_media_pager.xml index 7f7e799f..2b541a9d 100644 --- a/app/src/main/res/layouts/mastodon/layout/activity_media_pager.xml +++ b/app/src/main/res/layouts/mastodon/layout/activity_media_pager.xml @@ -20,10 +20,10 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true" + android:fitsSystemWindows="true" android:background="@android:color/transparent"> - From e7b9fd9f1d3b4072943add5c0b260f6a12535c38 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 1 Apr 2025 18:16:31 +0200 Subject: [PATCH 4/4] Display reaction buttons only if instance --- .../mastodon/ui/drawer/StatusAdapter.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index 23d3db65..694e600e 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -631,15 +631,17 @@ public class StatusAdapter extends RecyclerView.Adapter holder.binding.quotedMessage.cardviewContainer.setVisibility(View.GONE); } - if (Helper.getCurrentAccount(context) != null && Helper.getCurrentAccount(context).api == Account.API.PLEROMA || status.reactions != null) { - if (status.pleroma != null && status.pleroma.emoji_reactions != null && status.pleroma.emoji_reactions.size() > 0) { + if (extraFeatures && displayReactions) { + holder.binding.statusAddCustomEmoji.setVisibility(View.VISIBLE); + holder.binding.statusEmoji.setVisibility(View.VISIBLE); + if (status.pleroma != null && status.pleroma.emoji_reactions != null && !status.pleroma.emoji_reactions.isEmpty()) { holder.binding.layoutReactions.getRoot().setVisibility(View.VISIBLE); ReactionAdapter reactionAdapter = new ReactionAdapter(status.id, status.pleroma.emoji_reactions, true); holder.binding.layoutReactions.reactionsView.setAdapter(reactionAdapter); LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false); holder.binding.layoutReactions.reactionsView.setLayoutManager(layoutManager); - } else if (status.reactions != null && status.reactions.size() > 0) { + } else if (status.reactions != null && !status.reactions.isEmpty()) { holder.binding.layoutReactions.getRoot().setVisibility(View.VISIBLE); ReactionAdapter reactionAdapter = new ReactionAdapter(status.id, status.reactions, true, false); holder.binding.layoutReactions.reactionsView.setAdapter(reactionAdapter); @@ -801,6 +803,9 @@ public class StatusAdapter extends RecyclerView.Adapter } builder.show(); }); + } else { + holder.binding.statusAddCustomEmoji.setVisibility(View.GONE); + holder.binding.statusEmoji.setVisibility(View.GONE); } int truncate_toots_size = sharedpreferences.getInt(context.getString(R.string.SET_TRUNCATE_TOOTS_SIZE), 0); @@ -811,15 +816,6 @@ public class StatusAdapter extends RecyclerView.Adapter } else { holder.binding.actionButtonQuote.setVisibility(View.GONE); } - if (displayReactions) { - holder.binding.statusAddCustomEmoji.setVisibility(View.VISIBLE); - holder.binding.statusEmoji.setVisibility(View.VISIBLE); - } else { - holder.binding.statusAddCustomEmoji.setVisibility(View.GONE); - holder.binding.statusEmoji.setVisibility(View.GONE); - } - - } if (status.isMaths == null) {