aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java23
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java18
2 files changed, 19 insertions, 22 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 8175d10bc..e8d61d1df 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -18,7 +18,6 @@ import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
@@ -29,8 +28,6 @@ import android.provider.MediaStore;
import android.provider.Settings;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
-import android.text.SpannableStringBuilder;
-import android.text.style.ImageSpan;
import android.util.Log;
import android.util.Pair;
import android.view.Gravity;
@@ -914,24 +911,6 @@ public class ConversationActivity extends XmppActivity
builder.create().show();
}
- /**
- * Moves icons from the PopupMenu's MenuItems' icon fields into the menu title as a Spannable with the icon and title text.
- */
- public static void insertMenuItemIcons(Context context, PopupMenu popupMenu) {
- Menu menu = popupMenu.getMenu();
- for (int i = 0; i < menu.size(); i++) {
- MenuItem menuItem = menu.getItem(i);
- Drawable icon = menuItem.getIcon();
- int iconSize = context.getResources().getDimensionPixelSize(R.dimen.menu_item_icon_size);
- icon.setBounds(0, 0, iconSize, iconSize);
- ImageSpan imageSpan = new ImageSpan(icon);
- SpannableStringBuilder ssb = new SpannableStringBuilder(" " + menuItem.getTitle());
- ssb.setSpan(imageSpan, 0, 1, 0);
- menuItem.setTitle(ssb);
- menuItem.setIcon(null);
- }
- }
-
protected void attachFileDialog() {
View menuAttachFile = findViewById(R.id.action_attach_file);
if (menuAttachFile == null) {
@@ -972,7 +951,7 @@ public class ConversationActivity extends XmppActivity
return false;
}
});
- insertMenuItemIcons(getApplicationContext(), attachFilePopup);
+ UIHelper.showIconsInPopup(attachFilePopup);
attachFilePopup.show();
}
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index 12cd708f1..caa466b04 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -4,7 +4,10 @@ import android.content.Context;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.util.Pair;
+import android.widget.PopupMenu;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@@ -371,4 +374,19 @@ public class UIHelper {
return type;
}
}
+
+ public static boolean showIconsInPopup(PopupMenu attachFilePopup) {
+ try {
+ Field field = attachFilePopup.getClass().getDeclaredField("mPopup");
+ field.setAccessible(true);
+ Object menuPopupHelper = field.get(attachFilePopup);
+ Class<?> cls = Class.forName("com.android.internal.view.menu.MenuPopupHelper");
+ Method method = cls.getDeclaredMethod("setForceShowIcon", new Class[]{boolean.class});
+ method.setAccessible(true);
+ method.invoke(menuPopupHelper, new Object[]{true});
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
}