diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-03-04 18:05:37 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-03-04 18:05:37 +0100 |
commit | 382b741adfa29104223dfed32799b5883db9110a (patch) | |
tree | adada3fe3603fcfd28411a4ef780d4fb7c66d118 /src/main/java/de/pixart/messenger | |
parent | 777cba79a72201c7b85bc6725c8bf88943796d9a (diff) |
Added icons for the attach options according to material design guidlines
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationActivity.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index a1e2a344b..7864c9e12 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -18,6 +18,7 @@ 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; @@ -28,6 +29,8 @@ 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; @@ -911,6 +914,24 @@ 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) { @@ -951,6 +972,7 @@ public class ConversationActivity extends XmppActivity return false; } }); + insertMenuItemIcons(getApplicationContext(), attachFilePopup); attachFilePopup.show(); } |