Fixed submenu icons (2)

pull/194/merge
M66B 3 years ago
parent bc2af68449
commit aa849d6e56

@ -1537,7 +1537,7 @@ public class FragmentCompose extends FragmentBase {
inflater.inflate(R.menu.menu_compose, menu);
final Context context = getContext();
PopupMenuLifecycle.insertIcons(context, menu);
PopupMenuLifecycle.insertIcons(context, menu, false);
LayoutInflater infl = LayoutInflater.from(context);
@ -1618,10 +1618,8 @@ public class FragmentCompose extends FragmentBase {
ssbZoom.append(' ');
for (int i = 0; i <= zoom; i++)
ssbZoom.append('+');
menu.findItem(R.id.menu_zoom)
.setTitle(ssbZoom)
.setIcon(R.drawable.twotone_format_size_24);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_zoom));
menu.findItem(R.id.menu_zoom).setTitle(ssbZoom);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_zoom), false);
int colorEncrypt = Helper.resolveColor(context, R.attr.colorEncrypt);
int colorActionForeground = Helper.resolveColor(context, R.attr.colorActionForeground);

@ -4385,7 +4385,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
inflater.inflate(R.menu.menu_messages, menu);
final Context context = getContext();
PopupMenuLifecycle.insertIcons(context, menu);
PopupMenuLifecycle.insertIcons(context, menu, false);
LayoutInflater infl = LayoutInflater.from(context);
ImageButton ib = (ImageButton) infl.inflate(R.layout.action_button, null);
@ -4537,16 +4537,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
menu.findItem(R.id.menu_compact).setChecked(compact);
menu.findItem(R.id.menu_zoom)
.setTitle(ssbZoom)
.setIcon(R.drawable.twotone_format_size_24);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_zoom));
menu.findItem(R.id.menu_zoom).setTitle(ssbZoom);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_zoom), false);
menu.findItem(R.id.menu_padding)
.setTitle(ssbPadding)
.setIcon(R.drawable.twotone_fullscreen_24);
menu.findItem(R.id.menu_padding).setTitle(ssbPadding);
menu.findItem(R.id.menu_padding).setVisible(cards);
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_padding));
PopupMenuLifecycle.insertIcon(context, menu.findItem(R.id.menu_padding), false);
menu.findItem(R.id.menu_theme).setVisible(viewType == AdapterMessage.ViewType.UNIFIED);

@ -59,7 +59,7 @@ public class PopupMenuLifecycle extends PopupMenu {
}
public void insertIcons(Context context) {
insertIcons(new ContextThemeWrapper(context, R.style.popupMenuStyle), getMenu());
insertIcons(new ContextThemeWrapper(context, R.style.popupMenuStyle), getMenu(), false);
}
@Override
@ -95,18 +95,18 @@ public class PopupMenuLifecycle extends PopupMenu {
});
}
static void insertIcons(Context context, Menu menu) {
static void insertIcons(Context context, Menu menu, boolean submenu) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
CharSequence title = item.getTitle();
insertIcon(context, item);
insertIcon(context, item, submenu);
if (item.hasSubMenu()) {
SubMenu sub = item.getSubMenu();
boolean has = false;
for (int j = 0; j < sub.size(); j++)
if (sub.getItem(j).getIcon() != null) {
has = true;
insertIcons(context, sub);
insertIcons(context, sub, true);
break;
}
if (has)
@ -115,7 +115,7 @@ public class PopupMenuLifecycle extends PopupMenu {
}
}
static void insertIcon(Context context, MenuItem menuItem) {
static void insertIcon(Context context, MenuItem menuItem, boolean submenu) {
Drawable icon = menuItem.getIcon();
if (icon == null)
@ -136,7 +136,8 @@ public class PopupMenuLifecycle extends PopupMenu {
ssb.insert(0, "\uFFFC\u2002"); // object replacement character, en space
ssb.setSpan(imageSpan, 0, 1, 0);
menuItem.setTitle(ssb);
menuItem.setIcon(null);
if (submenu)
menuItem.setIcon(null);
menuItem.setTitleCondensed("");
}
}

Loading…
Cancel
Save