From 7e1f63348a1f066d9dcf2a98268c62bcc66c6fe8 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 9 Jun 2024 08:46:05 +0200 Subject: [PATCH] fix: disable GroupDivider on Honor's MagicOS When enabled on MagicOS, GroupDivider are not displayed and causes other menu items to be invisble. Similar bug to https://github.com/mastodon/mastodon-android/pull/732. --- .../org/joinmastodon/android/fragments/ProfileFragment.java | 2 +- .../android/ui/displayitems/HeaderStatusDisplayItem.java | 2 +- .../main/java/org/joinmastodon/android/ui/utils/UiUtils.java | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index deb45ae7..2662d4f5 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -687,7 +687,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList notifications.setTitle(getString(relationship.notifying ? R.string.disable_new_post_notifications : R.string.enable_new_post_notifications, account.getDisplayUsername())); } - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI()){ + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI() && !UiUtils.isMagic()){ menu.setGroupDividerEnabled(true); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index c998434e..b5034f57 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -140,7 +140,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ optionsMenu=new PopupMenu(activity, more); optionsMenu.inflate(R.menu.post); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI()) + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI() && !UiUtils.isMagic()) optionsMenu.getMenu().setGroupDividerEnabled(true); optionsMenu.setOnMenuItemClickListener(menuItem->{ Account account=item.user; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 2c2d6eee..c9a7e110 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -809,6 +809,10 @@ public class UiUtils{ return !TextUtils.isEmpty(getSystemProperty("ro.build.version.emui")); } + public static boolean isMagic() { + return !TextUtils.isEmpty(getSystemProperty("ro.build.version.magic")); + } + public static int alphaBlendColors(int color1, int color2, float alpha){ float alpha0=1f-alpha; int r=Math.round(((color1 >> 16) & 0xFF)*alpha0+((color2 >> 16) & 0xFF)*alpha);