From 7ab920d94321d92e6887ed55ac41eabd45bc6453 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sun, 9 Jun 2024 08:40:45 +0200 Subject: [PATCH] fix: disable GroupDivider on Honor's MagicOS They have the same invisibility bug as EMUI. --- .../org/joinmastodon/android/fragments/ComposeFragment.java | 2 +- .../org/joinmastodon/android/fragments/HomeTabFragment.java | 2 +- .../android/ui/displayitems/HeaderStatusDisplayItem.java | 2 +- .../main/java/org/joinmastodon/android/ui/utils/UiUtils.java | 4 ++++ .../android/ui/viewholders/AccountViewHolder.java | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 16ddd10bd0..abab4c7cf6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -1663,7 +1663,7 @@ private void buildVisibilityPopup(View v){ } } UiUtils.enablePopupMenuIcons(getActivity(), visibilityPopup); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI()) m.setGroupDividerEnabled(true); + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI() && !UiUtils.isMagic()) m.setGroupDividerEnabled(true); visibilityPopup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){ @Override public boolean onMenuItemClick(MenuItem item){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java index 802aae4bc1..2af83c5a24 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java @@ -408,7 +408,7 @@ private void updateOverflowMenu() { addListsToOverflowMenu(); addHashtagsToOverflowMenu(); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI()) + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI() && !UiUtils.isMagic()) m.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 d5f5cf9a0f..7e05968bac 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 @@ -179,7 +179,7 @@ protected Holder(Activity activity, @LayoutRes int layout, ViewGroup parent){ 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 63dca6f227..c8473bf608 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 @@ -1530,6 +1530,10 @@ public static boolean isEMUI() { 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); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java index 8b52a3ed2e..355d9f7cd7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewholders/AccountViewHolder.java @@ -113,7 +113,7 @@ public AccountViewHolder(Fragment fragment, ViewGroup list, HashMapshowMenuFromButton()); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI()) + if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P && !UiUtils.isEMUI() && !UiUtils.isMagic()) contextMenu.getMenu().setGroupDividerEnabled(true); UiUtils.enablePopupMenuIcons(fragment.getContext(), contextMenu);