Move menus to Iconics
This commit is contained in:
@@ -22,6 +22,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
import com.pnikosis.materialishprogress.ProgressWheel;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@@ -345,14 +346,23 @@ public class EmailListFragment extends AuthenticatedFragment implements
|
||||
// Inflate the menu for the CAB
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.email_list_context, menu);
|
||||
MenuItem markRead = menu.findItem(R.id.action_mark_read);
|
||||
MenuItem markUnread = menu.findItem(R.id.action_mark_unread);
|
||||
MenuItem moveTo = menu.findItem(R.id.action_move_to);
|
||||
|
||||
menu.findItem(R.id.action_delete).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_delete));
|
||||
markRead.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_drafts));
|
||||
markUnread.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_markunread));
|
||||
moveTo.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_folder));
|
||||
|
||||
if (BoteHelper.isOutbox(mFolder)) {
|
||||
menu.findItem(R.id.action_mark_read).setVisible(false);
|
||||
menu.findItem(R.id.action_mark_unread).setVisible(false);
|
||||
markRead.setVisible(false);
|
||||
markUnread.setVisible(false);
|
||||
}
|
||||
// Only allow moving from the trash
|
||||
// TODO change this when user folders are implemented
|
||||
if (!BoteHelper.isTrash(mFolder))
|
||||
menu.findItem(R.id.action_move_to).setVisible(false);
|
||||
moveTo.setVisible(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -374,6 +374,8 @@ public class NewEmailFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.new_email, menu);
|
||||
menu.findItem(R.id.action_attach_file).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_attach_file));
|
||||
menu.findItem(R.id.action_send_email).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_send));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -283,8 +283,14 @@ public class ViewEmailFragment extends Fragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.view_email, menu);
|
||||
MenuItem reply = menu.findItem(R.id.action_reply);
|
||||
|
||||
reply.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_reply));
|
||||
menu.findItem(R.id.action_reply_all).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_reply_all));
|
||||
menu.findItem(R.id.action_forward).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_forward));
|
||||
|
||||
if (mIsAnonymous)
|
||||
menu.findItem(R.id.action_reply).setVisible(false);
|
||||
reply.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,8 @@ import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -150,6 +152,7 @@ public class EditContactFragment extends EditPictureFragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.edit_contact, menu);
|
||||
menu.findItem(R.id.action_save_contact).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_save));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,9 +15,12 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
|
||||
import i2p.bote.I2PBote;
|
||||
import i2p.bote.StatusListener;
|
||||
import i2p.bote.android.R;
|
||||
import i2p.bote.android.util.BoteHelper;
|
||||
import i2p.bote.android.util.RobustAsyncTask;
|
||||
import i2p.bote.android.util.TaskFragment;
|
||||
|
||||
@@ -93,6 +96,8 @@ public class SetPasswordFragment extends Fragment {
|
||||
inflater.inflate(R.menu.set_password, menu);
|
||||
mSave = menu.findItem(R.id.action_set_password);
|
||||
|
||||
mSave.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_save));
|
||||
|
||||
// If task is running, disable the save button.
|
||||
PasswordWaiterFrag f = (PasswordWaiterFrag) getFragmentManager().findFragmentByTag(PASSWORD_WAITER_TAG);
|
||||
if (f != null)
|
||||
|
||||
@@ -17,6 +17,8 @@ import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.List;
|
||||
@@ -170,6 +172,8 @@ public class EditIdentityFragment extends EditPictureFragment {
|
||||
inflater.inflate(R.menu.edit_identity, menu);
|
||||
mSave = menu.findItem(R.id.action_save_identity);
|
||||
|
||||
mSave.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_save));
|
||||
|
||||
IdentityWaiterFrag f = (IdentityWaiterFrag) getFragmentManager().findFragmentByTag(IDENTITY_WAITER_TAG);
|
||||
if (f != null)
|
||||
setInterfaceEnabled(false);
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
|
||||
import i2p.bote.I2PBote;
|
||||
import i2p.bote.android.R;
|
||||
|
||||
@@ -58,6 +60,9 @@ public abstract class AuthenticatedFragment extends Fragment {
|
||||
inflater.inflate(R.menu.authenticated_fragment, menu);
|
||||
mLogIn = menu.findItem(R.id.action_log_in);
|
||||
mClearPassword = menu.findItem(R.id.action_log_out);
|
||||
|
||||
mLogIn.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_lock));
|
||||
mClearPassword.setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_lock_open));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
@@ -151,6 +152,41 @@ public class BoteHelper extends GeneralHelper {
|
||||
return new IconicsDrawable(ctx, icon).colorRes(R.color.md_grey_600).sizeDp(24).paddingDp(padding);
|
||||
}
|
||||
|
||||
public static Drawable getMenuIcon(Context ctx, GoogleMaterial.Icon icon) {
|
||||
IconicsDrawable iconic = new IconicsDrawable(ctx, icon).color(Color.WHITE).sizeDp(24);
|
||||
switch (icon) {
|
||||
case gmd_attach_file:
|
||||
case gmd_lock:
|
||||
case gmd_lock_open:
|
||||
case gmd_person_add:
|
||||
case gmd_send:
|
||||
iconic.paddingDp(1);
|
||||
break;
|
||||
|
||||
case gmd_drafts:
|
||||
case gmd_folder:
|
||||
case gmd_markunread:
|
||||
iconic.paddingDp(2);
|
||||
break;
|
||||
|
||||
case gmd_create:
|
||||
case gmd_delete:
|
||||
case gmd_reply:
|
||||
case gmd_save:
|
||||
iconic.paddingDp(3);
|
||||
break;
|
||||
|
||||
case gmd_forward:
|
||||
iconic.paddingDp(4);
|
||||
break;
|
||||
|
||||
case gmd_reply_all:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return iconic;
|
||||
}
|
||||
|
||||
public static String getDisplayAddress(String address) throws PasswordException, IOException, GeneralSecurityException, MessagingException {
|
||||
String fullAdr = getNameAndDestination(address);
|
||||
String emailDest = extractEmailDestination(fullAdr);
|
||||
@@ -260,6 +296,7 @@ public class BoteHelper extends GeneralHelper {
|
||||
}
|
||||
|
||||
private static final String PROPERTY_SENT = "sent";
|
||||
|
||||
public static void setEmailSent(Email email, boolean isSent) {
|
||||
email.getMetadata().setProperty(PROPERTY_SENT, isSent ? "true" : "false");
|
||||
}
|
||||
@@ -562,9 +599,14 @@ public class BoteHelper extends GeneralHelper {
|
||||
double value = (double) size / (1 << (10 * unit));
|
||||
int formatStr;
|
||||
switch (unit) {
|
||||
case 0: formatStr = R.string.n_bytes; break;
|
||||
case 1: formatStr = R.string.n_kilobytes; break;
|
||||
default: formatStr = R.string.n_megabytes;
|
||||
case 0:
|
||||
formatStr = R.string.n_bytes;
|
||||
break;
|
||||
case 1:
|
||||
formatStr = R.string.n_kilobytes;
|
||||
break;
|
||||
default:
|
||||
formatStr = R.string.n_megabytes;
|
||||
}
|
||||
NumberFormat formatter = NumberFormat.getInstance(Locale.getDefault());
|
||||
if (value < 100)
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
import com.nineoldandroids.animation.AnimatorListenerAdapter;
|
||||
import com.nineoldandroids.animation.AnimatorSet;
|
||||
@@ -163,17 +164,18 @@ public abstract class ViewAddressFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.view_identity, menu);
|
||||
inflater.inflate(R.menu.view_address, menu);
|
||||
menu.findItem(R.id.action_edit_address).setIcon(BoteHelper.getMenuIcon(getActivity(), GoogleMaterial.Icon.gmd_create));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_edit_identity:
|
||||
case R.id.action_edit_address:
|
||||
onEditAddress();
|
||||
return true;
|
||||
|
||||
case R.id.action_delete_identity:
|
||||
case R.id.action_delete_address:
|
||||
DialogFragment df = new DialogFragment() {
|
||||
@Override
|
||||
@NonNull
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_log_in"
|
||||
android:icon="@drawable/ic_lock_white_24dp"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/log_in"
|
||||
android:visible="false"
|
||||
@@ -12,7 +11,6 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_log_out"
|
||||
android:icon="@drawable/ic_lock_open_white_24dp"
|
||||
android:orderInCategory="1"
|
||||
android:title="@string/log_out"
|
||||
android:visible="false"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_save_contact"
|
||||
android:icon="@drawable/ic_save_white_24dp"
|
||||
android:title="@string/save_contact"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_save_identity"
|
||||
android:icon="@drawable/ic_save_white_24dp"
|
||||
android:title="@string/save_identity"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_delete"
|
||||
android:icon="@drawable/ic_delete_white_24dp"
|
||||
android:title="@string/action_delete"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_mark_read"
|
||||
android:icon="@drawable/ic_drafts_white_24dp"
|
||||
android:title="@string/action_mark_read"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_mark_unread"
|
||||
android:icon="@drawable/ic_markunread_white_24dp"
|
||||
android:title="@string/action_mark_unread"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/action_move_to"
|
||||
android:icon="@drawable/ic_folder_white_24dp"
|
||||
android:title="@string/action_move_to"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_attach_file"
|
||||
android:icon="@drawable/ic_attach_file_white_24dp"
|
||||
android:title="@string/action_attach_file"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_send_email"
|
||||
android:icon="@drawable/ic_send_white_24dp"
|
||||
android:title="@string/action_send_email"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_set_password"
|
||||
android:icon="@drawable/ic_save_white_24dp"
|
||||
android:title="@string/pref_title_change_password"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit_identity"
|
||||
android:icon="@drawable/ic_create_white_24dp"
|
||||
android:id="@+id/action_edit_address"
|
||||
android:title="@string/edit_identity"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_delete_identity"
|
||||
android:id="@+id/action_delete_address"
|
||||
android:title="@string/action_delete"
|
||||
i2pandroid:showAsAction="never"/>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit_contact"
|
||||
android:icon="@drawable/ic_create_white_24dp"
|
||||
android:title="@string/edit_contact"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_delete_contact"
|
||||
android:title="@string/action_delete"
|
||||
i2pandroid:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
@@ -4,19 +4,16 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reply"
|
||||
android:icon="@drawable/ic_reply_white_24dp"
|
||||
android:title="@string/reply"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reply_all"
|
||||
android:icon="@drawable/ic_reply_all_white_24dp"
|
||||
android:title="@string/reply_all"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_forward"
|
||||
android:icon="@drawable/ic_forward_white_24dp"
|
||||
android:title="@string/forward"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user