fixes #1200 : Added icons for the attach options according to material design guidlines

This commit is contained in:
vikiCoder 2017-03-03 16:01:44 +05:30
parent 8cce653a1f
commit 51ef096e01
64 changed files with 64 additions and 5 deletions

View file

@ -7,11 +7,13 @@ import android.app.FragmentTransaction;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -20,6 +22,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;
@ -775,6 +779,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) {
@ -812,6 +834,7 @@ public class ConversationActivity extends XmppActivity
return false;
}
});
insertMenuItemIcons(getApplicationContext(), attachFilePopup);
attachFilePopup.show();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

View file

@ -3,22 +3,27 @@
<item
android:id="@+id/attach_location"
android:title="@string/send_location"/>
android:title="@string/send_location"
android:icon="?attr/ic_attach_location"/>
<item
android:id="@+id/attach_record_voice"
android:title="@string/attach_record_voice"/>
android:title="@string/attach_record_voice"
android:icon="?attr/ic_attach_record"/>
<item
android:id="@+id/attach_take_picture"
android:title="@string/attach_take_picture"/>
android:title="@string/attach_take_picture"
android:icon="?attr/ic_attach_camera"/>
<item
android:id="@+id/attach_choose_picture"
android:title="@string/attach_choose_picture"/>
android:title="@string/attach_choose_picture"
android:icon="?attr/ic_attach_photo"/>
<item
android:id="@+id/attach_choose_file"
android:title="@string/choose_file"/>
android:title="@string/choose_file"
android:icon="?attr/ic_attach_document"/>
</menu>

View file

@ -29,6 +29,12 @@
<item name="attr/ic_send_text_offline">@drawable/ic_send_text_offline</item>
<item name="attr/ic_send_voice_offline">@drawable/ic_send_voice_offline</item>
<item name="attr/ic_attach_camera">@drawable/ic_attach_camera</item>
<item name="attr/ic_attach_document">@drawable/ic_attach_document</item>
<item name="attr/ic_attach_location">@drawable/ic_attach_location</item>
<item name="attr/ic_attach_photo">@drawable/ic_attach_photo</item>
<item name="attr/ic_attach_record">@drawable/ic_attach_record</item>
<item name="attr/message_bubble_received_monochrome">@drawable/message_bubble_received_white</item>
<item name="attr/message_bubble_sent">@drawable/message_bubble_sent</item>
<item name="attr/message_bubble_received_green">@drawable/message_bubble_received</item>
@ -97,6 +103,12 @@
<item name="attr/ic_send_text_offline">@drawable/ic_send_text_offline_white</item>
<item name="attr/ic_send_voice_offline">@drawable/ic_send_voice_offline_white</item>
<item name="attr/ic_attach_camera">@drawable/ic_attach_camera_white</item>
<item name="attr/ic_attach_document">@drawable/ic_attach_document_white</item>
<item name="attr/ic_attach_location">@drawable/ic_attach_location_white</item>
<item name="attr/ic_attach_photo">@drawable/ic_attach_photo_white</item>
<item name="attr/ic_attach_record">@drawable/ic_attach_record_white</item>
<item name="attr/message_bubble_received_monochrome">@drawable/message_bubble_received_grey</item>
<item name="attr/message_bubble_sent">@drawable/message_bubble_sent_grey</item>
<item name="attr/message_bubble_received_green">@drawable/message_bubble_received_dark</item>

View file

@ -19,6 +19,12 @@
<attr name="ic_send_text_offline" format="reference"/>
<attr name="ic_send_voice_offline" format="reference"/>
<attr name="ic_attach_camera" format="reference"/>
<attr name="ic_attach_document" format="reference"/>
<attr name="ic_attach_location" format="reference"/>
<attr name="ic_attach_photo" format="reference"/>
<attr name="ic_attach_record" format="reference"/>
<attr name="message_bubble_received_monochrome" format="reference"/>
<attr name="message_bubble_sent" format="reference"/>
<attr name="message_bubble_received_green" format="reference"/>

View file

@ -6,4 +6,5 @@
<dimen name="conversations_overview_width">288dp</dimen>
<dimen name="image_button_padding">8dp</dimen>
<dimen name="fineprint_size">11sp</dimen>
<dimen name="menu_item_icon_size">24dp</dimen>
</resources>

View file

@ -25,6 +25,12 @@
<item name="attr/ic_send_text_offline">@drawable/ic_send_text_offline</item>
<item name="attr/ic_send_voice_offline">@drawable/ic_send_voice_offline</item>
<item name="attr/ic_attach_camera">@drawable/ic_attach_camera</item>
<item name="attr/ic_attach_document">@drawable/ic_attach_document</item>
<item name="attr/ic_attach_location">@drawable/ic_attach_location</item>
<item name="attr/ic_attach_photo">@drawable/ic_attach_photo</item>
<item name="attr/ic_attach_record">@drawable/ic_attach_record</item>
<item name="attr/icon_add_group">@drawable/ic_action_add_group</item>
<item name="attr/icon_add_person">@drawable/ic_action_add_person</item>
<item name="attr/icon_cancel">@drawable/ic_action_cancel</item>
@ -90,6 +96,12 @@
<item name="attr/ic_send_text_offline">@drawable/ic_send_text_offline_white</item>
<item name="attr/ic_send_voice_offline">@drawable/ic_send_voice_offline_white</item>
<item name="attr/ic_attach_camera">@drawable/ic_attach_camera_white</item>
<item name="attr/ic_attach_document">@drawable/ic_attach_document_white</item>
<item name="attr/ic_attach_location">@drawable/ic_attach_location_white</item>
<item name="attr/ic_attach_photo">@drawable/ic_attach_photo_white</item>
<item name="attr/ic_attach_record">@drawable/ic_attach_record_white</item>
<item name="attr/message_bubble_received_monochrome">@drawable/message_bubble_received_grey</item>
<item name="attr/message_bubble_sent">@drawable/message_bubble_sent_grey</item>
<item name="attr/message_bubble_received_green">@drawable/message_bubble_received_dark</item>