Added padding to IconicsDrawables measured from original drawables

This commit is contained in:
str4d
2015-06-03 11:54:27 +00:00
parent 31e8e35749
commit 1604e4d04d
4 changed files with 48 additions and 23 deletions

View File

@@ -130,7 +130,7 @@ public class EmailListActivity extends BoteActivityBase implements
.withIconTintingEnabled(true)
.withSelectedIconColorRes(R.color.primary);
IDrawerItem networkStatus = getNetStatusItem(
R.string.network_status, GoogleMaterial.Icon.gmd_cloud_off, R.color.md_grey_600);
R.string.network_status, GoogleMaterial.Icon.gmd_cloud_off, R.color.md_grey_600, 0);
// Set the drawer width per Material design spec
// http://www.google.com/design/spec/layout/structure.html#structure-side-nav-1
@@ -333,11 +333,11 @@ public class EmailListActivity extends BoteActivityBase implements
.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, IIcon icon, int iconColorRes) {
private IDrawerItem getNetStatusItem(int nameRes, IIcon icon, int iconColorRes, int padding) {
return new PrimaryDrawerItem()
.withIdentifier(ID_NET_STATUS)
.withName(nameRes)
.withIcon(new IconicsDrawable(this, icon).colorRes(iconColorRes).sizeDp(24))
.withIcon(new IconicsDrawable(this, icon).colorRes(iconColorRes).sizeDp(24).paddingDp(padding))
.withIconTintingEnabled(true)
.withSelectedIconColorRes(R.color.primary);
}
@@ -556,7 +556,7 @@ public class EmailListActivity extends BoteActivityBase implements
.withTag(folder)
.withIconTintingEnabled(true)
.withSelectedIconColorRes(R.color.primary)
.withIcon(new IconicsDrawable(getContext(), BoteHelper.getFolderIcon(folder)).colorRes(R.color.md_grey_600).sizeDp(24))
.withIcon(BoteHelper.getFolderIcon(getContext(), folder))
.withName(BoteHelper.getFolderDisplayName(getContext(), folder));
try {
@@ -665,36 +665,45 @@ public class EmailListActivity extends BoteActivityBase implements
// Update network status
final int statusText;
final IIcon statusIcon;
int colorRes = R.color.md_grey_600;
final int colorRes;
final int padding;
switch (I2PBote.getInstance().getNetworkStatus()) {
case DELAY:
statusText = R.string.connect_delay;
statusIcon = GoogleMaterial.Icon.gmd_av_timer;
colorRes = R.color.md_grey_600;
padding = 3;
break;
case CONNECTING:
statusText = R.string.connecting;
statusIcon = GoogleMaterial.Icon.gmd_cloud_queue;
colorRes = R.color.md_grey_600;
padding = 0;
break;
case CONNECTED:
statusText = R.string.connected;
statusIcon = GoogleMaterial.Icon.gmd_cloud_done;
colorRes = R.color.md_grey_600;
padding = 0;
break;
case ERROR:
statusText = R.string.error;
statusIcon = GoogleMaterial.Icon.gmd_error;
colorRes = R.color.red;
padding = 2;
break;
case NOT_STARTED:
default:
statusText = R.string.not_started;
statusIcon = GoogleMaterial.Icon.gmd_cloud_off;
colorRes = R.color.md_grey_600;
padding = 0;
}
final int statusIconColorRes = colorRes;
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO change this when #378 is resolved
mDrawer.updateItem(getNetStatusItem(statusText, statusIcon, statusIconColorRes));
mDrawer.updateItem(getNetStatusItem(statusText, statusIcon, colorRes, padding));
}
});
}

View File

@@ -213,7 +213,7 @@ 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.setImageDrawable(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_unfold_more).colorRes(R.color.md_grey_600).sizeDp(24).paddingDp(3));
mMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -222,7 +222,8 @@ public class NewEmailFragment extends Fragment {
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));
.sizeDp(24)
.paddingDp(mMoreVisible ? 3 : 4));
mMoreVisible = !mMoreVisible;
}
});
@@ -461,7 +462,7 @@ public class NewEmailFragment extends Fragment {
((TextView) v.findViewById(R.id.filename)).setText(attachment.getFileName());
((TextView) v.findViewById(R.id.size)).setText(attachment.getHumanReadableSize());
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.setImageDrawable(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_clear).colorRes(R.color.md_grey_600).sizeDp(24).paddingDp(5));
attachmentAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View File

@@ -184,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(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_more_vert).colorRes(R.color.md_grey_600).sizeDp(16));
action.setImageDrawable(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_more_vert).colorRes(R.color.md_grey_600).sizeDp(24).paddingDp(4));
action.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View File

@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.support.v7.app.AlertDialog;
@@ -22,6 +23,7 @@ import android.widget.TextView;
import com.lambdaworks.codec.Base64;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.typeface.IIcon;
import java.io.ByteArrayOutputStream;
@@ -122,18 +124,31 @@ public class BoteHelper extends GeneralHelper {
return displayName;
}
public static IIcon getFolderIcon(EmailFolder folder) {
String name = folder.getName();
if ("inbox".equals(name))
return GoogleMaterial.Icon.gmd_inbox;
else if ("outbox".equals(name))
return GoogleMaterial.Icon.gmd_cloud_upload;
else if ("sent".equals(name))
return GoogleMaterial.Icon.gmd_send;
else if ("trash".equals(name))
return GoogleMaterial.Icon.gmd_delete;
else
return null;
public static Drawable getFolderIcon(Context ctx, EmailFolder folder) {
IIcon icon;
int padding;
switch (folder.getName()) {
case "inbox":
icon = GoogleMaterial.Icon.gmd_inbox;
padding = 3;
break;
case "outbox":
icon = GoogleMaterial.Icon.gmd_cloud_upload;
padding = 0;
break;
case "sent":
icon = GoogleMaterial.Icon.gmd_send;
padding = 1;
break;
case "trash":
icon = GoogleMaterial.Icon.gmd_delete;
padding = 3;
break;
default:
icon = null;
padding = 0;
}
return new IconicsDrawable(ctx, icon).colorRes(R.color.md_grey_600).sizeDp(24).paddingDp(padding);
}
public static String getDisplayAddress(String address) throws PasswordException, IOException, GeneralSecurityException, MessagingException {