Use Android-Iconics for most icons

Some icon sizes increase slightly. Fix waiting on
https://github.com/mikepenz/Android-Iconics/issues/36
https://github.com/mikepenz/MaterialDrawer/issues/384
This commit is contained in:
str4d
2015-06-02 23:28:01 +00:00
parent 919b45d602
commit 89d2c7aac5
10 changed files with 67 additions and 43 deletions

View File

@@ -7,6 +7,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
@@ -21,6 +22,9 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.typeface.IIcon;
import com.mikepenz.materialdrawer.Drawer;
import com.mikepenz.materialdrawer.DrawerBuilder;
import com.mikepenz.materialdrawer.accountswitcher.AccountHeader;
@@ -122,11 +126,11 @@ public class EmailListActivity extends BoteActivityBase implements
IDrawerItem addressBook = new PrimaryDrawerItem()
.withIdentifier(ID_ADDRESS_BOOK)
.withName(R.string.address_book)
.withIcon(R.drawable.ic_contacts_grey600_24dp)
.withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_contacts).colorRes(R.color.md_grey_600).sizeDp(24))
.withIconTintingEnabled(true)
.withSelectedIconColorRes(R.color.primary);
IDrawerItem networkStatus = getNetStatusItem(
R.string.network_status, R.drawable.ic_cloud_off_grey600_24dp);
R.string.network_status, GoogleMaterial.Icon.gmd_cloud_off, R.color.md_grey_600);
// Set the drawer width per Material design spec
// http://www.google.com/design/spec/layout/structure.html#structure-side-nav-1
@@ -326,14 +330,14 @@ public class EmailListActivity extends BoteActivityBase implements
return new ProfileDrawerItem()
.withIdentifier(ID_LOCKED)
.withEmail(getString(R.string.touch_lock_to_log_in))
.withIcon(getResources().getDrawable(R.drawable.ic_lock_white_24dp));
.withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_lock).color(Color.WHITE).sizeRes(com.mikepenz.materialdrawer.R.dimen.material_drawer_item_profile_icon));
}
private IDrawerItem getNetStatusItem(int nameRes, int icRes) {
private IDrawerItem getNetStatusItem(int nameRes, IIcon icon, int iconColorRes) {
return new PrimaryDrawerItem()
.withIdentifier(ID_NET_STATUS)
.withName(nameRes)
.withIcon(icRes)
.withIcon(new IconicsDrawable(this, icon).colorRes(iconColorRes).sizeDp(24))
.withIconTintingEnabled(true)
.withSelectedIconColorRes(R.color.primary);
}
@@ -552,7 +556,7 @@ public class EmailListActivity extends BoteActivityBase implements
.withTag(folder)
.withIconTintingEnabled(true)
.withSelectedIconColorRes(R.color.primary)
.withIcon(BoteHelper.getFolderIcon(folder))
.withIcon(new IconicsDrawable(getContext(), BoteHelper.getFolderIcon(folder)).colorRes(R.color.md_grey_600).sizeDp(24))
.withName(BoteHelper.getFolderDisplayName(getContext(), folder));
try {
@@ -660,34 +664,37 @@ public class EmailListActivity extends BoteActivityBase implements
public void networkStatusChanged() {
// Update network status
final int statusText;
final int statusIcon;
final IIcon statusIcon;
int colorRes = R.color.md_grey_600;
switch (I2PBote.getInstance().getNetworkStatus()) {
case DELAY:
statusText = R.string.connect_delay;
statusIcon = R.drawable.ic_av_timer_grey600_24dp;
statusIcon = GoogleMaterial.Icon.gmd_av_timer;
break;
case CONNECTING:
statusText = R.string.connecting;
statusIcon = R.drawable.ic_cloud_queue_grey600_24dp;
statusIcon = GoogleMaterial.Icon.gmd_cloud_queue;
break;
case CONNECTED:
statusText = R.string.connected;
statusIcon = R.drawable.ic_cloud_done_grey600_24dp;
statusIcon = GoogleMaterial.Icon.gmd_cloud_done;
break;
case ERROR:
statusText = R.string.error;
statusIcon = R.drawable.ic_error_red_24dp;
statusIcon = GoogleMaterial.Icon.gmd_error;
colorRes = R.color.red;
break;
case NOT_STARTED:
default:
statusText = R.string.not_started;
statusIcon = R.drawable.ic_cloud_off_grey600_24dp;
statusIcon = GoogleMaterial.Icon.gmd_cloud_off;
}
final int statusIconColorRes = colorRes;
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO change this when #378 is resolved
mDrawer.updateItem(getNetStatusItem(statusText, statusIcon));
mDrawer.updateItem(getNetStatusItem(statusText, statusIcon, statusIconColorRes));
}
});
}

View File

@@ -28,6 +28,8 @@ import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.tokenautocomplete.FilteredArrayAdapter;
import net.i2p.data.DataFormatException;
@@ -211,14 +213,16 @@ public class NewEmailFragment extends Fragment {
mSpinner.setSelection(mDefaultPos);
// Set up Cc/Bcc button
mMore.setImageDrawable(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_unfold_more).colorRes(R.color.md_grey_600).sizeDp(20));
mMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mCc.setVisibility(mMoreVisible ? View.GONE : View.VISIBLE);
mBcc.setVisibility(mMoreVisible ? View.GONE : View.VISIBLE);
mMore.setImageResource(mMoreVisible ?
R.drawable.ic_unfold_more_grey600_24dp :
R.drawable.ic_unfold_less_grey600_24dp);
mMore.setImageDrawable(new IconicsDrawable(getActivity(), mMoreVisible ?
GoogleMaterial.Icon.gmd_unfold_more : GoogleMaterial.Icon.gmd_unfold_less)
.colorRes(R.color.md_grey_600)
.sizeDp(mMoreVisible ? 20 : 18));
mMoreVisible = !mMoreVisible;
}
});
@@ -456,7 +460,9 @@ public class NewEmailFragment extends Fragment {
v.setTag(attachment);
((TextView) v.findViewById(R.id.filename)).setText(attachment.getFileName());
((TextView) v.findViewById(R.id.size)).setText(attachment.getHumanReadableSize());
v.findViewById(R.id.attachment_action).setOnClickListener(new View.OnClickListener() {
ImageView attachmentAction = (ImageView) v.findViewById(R.id.attachment_action);
attachmentAction.setImageDrawable(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_clear).colorRes(R.color.md_grey_600).sizeDp(14));
attachmentAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateAttachmentSizeCount(attachment.getSize(), false);

View File

@@ -19,6 +19,9 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -181,7 +184,7 @@ public class ViewEmailFragment extends Fragment {
((TextView) a.findViewById(R.id.size)).setText(attachment.getHumanReadableSize());
final ImageView action = (ImageView) a.findViewById(R.id.attachment_action);
action.setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_more_vert_grey600_24dp));
action.setImageDrawable(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_more_vert).colorRes(R.color.md_grey_600).sizeDp(16));
action.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View File

@@ -21,6 +21,8 @@ import android.widget.EditText;
import android.widget.TextView;
import com.lambdaworks.codec.Base64;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.typeface.IIcon;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -120,18 +122,18 @@ public class BoteHelper extends GeneralHelper {
return displayName;
}
public static int getFolderIcon(EmailFolder folder) {
public static IIcon getFolderIcon(EmailFolder folder) {
String name = folder.getName();
if ("inbox".equals(name))
return R.drawable.ic_inbox_grey600_24dp;
return GoogleMaterial.Icon.gmd_inbox;
else if ("outbox".equals(name))
return R.drawable.ic_cloud_upload_grey600_24dp;
return GoogleMaterial.Icon.gmd_cloud_upload;
else if ("sent".equals(name))
return R.drawable.ic_send_grey600_24dp;
return GoogleMaterial.Icon.gmd_send;
else if ("trash".equals(name))
return R.drawable.ic_delete_grey600_24dp;
return GoogleMaterial.Icon.gmd_delete;
else
return 0;
return null;
}
public static String getDisplayAddress(String address) throws PasswordException, IOException, GeneralSecurityException, MessagingException {

View File

@@ -38,8 +38,7 @@
android:layout_width="@dimen/listitem_icon_size"
android:layout_height="@dimen/listitem_picture_size"
android:layout_gravity="center_vertical"
android:scaleType="center"
android:src="@drawable/ic_unfold_more_grey600_24dp"/>
android:scaleType="center"/>
</LinearLayout>
<i2p.bote.android.widget.ContactsCompletionView

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -22,7 +23,7 @@
android:orientation="horizontal"
android:padding="@dimen/listitem_horizontal_margin">
<ImageView
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/signature_invalid"
android:layout_width="@dimen/listitem_icon_size"
android:layout_height="@dimen/listitem_icon_size"
@@ -30,8 +31,9 @@
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_error_red_24dp"
android:visibility="gone"/>
android:visibility="visible"
app:iiv_color="@color/error_red"
app:iiv_icon="gmd-error"/>
<TextView
android:id="@+id/email_subject"

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
@@ -9,10 +10,11 @@
android:orientation="horizontal"
android:padding="8dp">
<ImageView
<com.mikepenz.iconics.view.IconicsImageView
android:layout_width="@dimen/listitem_icon_size"
android:layout_height="@dimen/listitem_icon_size"
android:src="@drawable/ic_attachment_grey600_24dp"/>
app:iiv_color="@color/md_grey_600"
app:iiv_icon="gmd-attachment"/>
<LinearLayout
android:layout_width="0dp"
@@ -41,6 +43,5 @@
android:id="@+id/attachment_action"
android:layout_width="@dimen/listitem_picture_size"
android:layout_height="@dimen/listitem_picture_size"
android:scaleType="center"
android:src="@drawable/ic_clear_grey600_24dp"/>
android:scaleType="center"/>
</LinearLayout>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
@@ -9,10 +10,11 @@
android:orientation="horizontal"
android:padding="8dp">
<ImageView
<com.mikepenz.iconics.view.IconicsImageView
android:layout_width="@dimen/listitem_icon_size"
android:layout_height="@dimen/listitem_icon_size"
android:src="@drawable/ic_error_red_24dp"/>
app:iiv_color="@color/error_red"
app:iiv_icon="gmd-error"/>
<TextView
android:id="@+id/attachment_warning_text"

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/listitem_height_three_lines"
android:background="@drawable/listitem_background">
@@ -105,21 +106,23 @@
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
android:layout_marginRight="@dimen/listitem_horizontal_margin">
<ImageView
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/email_attachment"
android:layout_width="@dimen/listitem_icon_size"
android:layout_height="match_parent"
android:scaleType="fitEnd"
android:src="@drawable/ic_attachment_grey600_24dp"
android:visibility="gone"/>
android:visibility="gone"
app:iiv_color="@color/md_grey_600"
app:iiv_icon="gmd-attachment"/>
<ImageView
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/email_delivered"
android:layout_width="@dimen/listitem_icon_size"
android:layout_height="match_parent"
android:scaleType="fitEnd"
android:src="@drawable/ic_beenhere_grey600_24dp"
android:visibility="gone"/>
android:visibility="gone"
app:iiv_color="@color/md_grey_600"
app:iiv_icon="gmd-beenhere"/>
</LinearLayout>
</RelativeLayout>

View File

@@ -10,8 +10,7 @@
<color name="listitem_pressed">#bdbdbd</color><!-- Grey 400 -->
<color name="uva_color">#c31756</color>
<color name="error_color">#f00</color>
<color name="grey_600">#757575</color>
<color name="error_red">#e51e25</color>
<color name="green">#4caf50</color>
<color name="red">#f44336</color>