Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Permalink
Browse files

[android] enable context menu icons in player

  • Loading branch information
aldenml committed Apr 17, 2017
1 parent 2837a6b commit 46f2ab824f250cfd4ee3eda9f56d224ad5989816
@@ -59,6 +59,7 @@
import com.devspark.appmsg.AppMsg;
import com.frostwire.android.R;
import com.frostwire.android.core.Constants;
import com.frostwire.android.gui.util.UIUtils;
import com.frostwire.android.gui.util.WriteSettingsPermissionActivityHelper;
import com.viewpagerindicator.TitlePageIndicator;

@@ -184,6 +185,7 @@ public T getAdapter() {
public void onCreateContextMenu(final ContextMenu menu, final View v,
final ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
UIUtils.setOptionalIconsVisible(menu, true);

// Get the position of the selected item
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
@@ -231,7 +233,8 @@ public void onCreateContextMenu(final ContextMenu menu, final View v,
}

// Play the selected songs
menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection));
menu.add(GROUP_ID, FragmentMenuItems.PLAY_SELECTION, Menu.NONE, getString(R.string.context_menu_play_selection))
.setIcon(R.drawable.app_icon);

// Play the next song
menu.add(GROUP_ID, FragmentMenuItems.PLAY_NEXT, Menu.NONE, getString(R.string.context_menu_play_next));
@@ -62,6 +62,7 @@
import org.apache.commons.io.FilenameUtils;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.NumberFormat;
import java.util.List;
@@ -584,5 +585,17 @@ public static void setOptionalIconsVisible(Menu menu, boolean visible) {
LOG.warn("unable to set icons for overflow menu", e);
}
}

if (menu != null && menuClass.getSimpleName().equals("ContextMenuBuilder")) {
try {
Field f = menuClass.getSuperclass().getDeclaredField("mOptionalIconsVisible");
if (f != null) {
f.setAccessible(true);
f.set(menu, visible);
}
} catch (Throwable e) {
LOG.warn("unable to set icons for context menu", e);
}
}
}
}

1 comment on commit 46f2ab8

@gubatron

This comment has been minimized.

Copy link
Collaborator

gubatron commented on 46f2ab8 Apr 17, 2017

so I guess the reflection hack is still the only way to enable the icons.
weird android sdk.

Please sign in to comment.
You can’t perform that action at this time.