Debug: save EML to junk

pull/194/merge
M66B 3 years ago
parent 7a702db3ec
commit 9f47d1a28b

@ -102,6 +102,7 @@ public class ActivityEML extends ActivityBase {
private ContentLoadingProgressBar pbWait; private ContentLoadingProgressBar pbWait;
private Group grpReady; private Group grpReady;
private boolean junk;
private Uri uri; private Uri uri;
private MessageHelper.AttachmentPart apart; private MessageHelper.AttachmentPart apart;
private static final int REQUEST_ATTACHMENT = 1; private static final int REQUEST_ATTACHMENT = 1;
@ -110,6 +111,9 @@ public class ActivityEML extends ActivityBase {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null)
junk = savedInstanceState.getBoolean("fair:junk");
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle("EML"); getSupportActionBar().setSubtitle("EML");
@ -225,6 +229,12 @@ public class ActivityEML extends ActivityBase {
load(); load();
} }
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putBoolean("fair:junk", junk);
super.onSaveInstanceState(outState);
}
private void load() { private void load() {
uri = getIntent().getData(); uri = getIntent().getData();
Log.i("EML uri=" + uri); Log.i("EML uri=" + uri);
@ -566,11 +576,25 @@ public class ActivityEML extends ActivityBase {
return true; return true;
} }
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.menu_junk).setVisible(BuildConfig.DEBUG);
menu.findItem(R.id.menu_save).setIcon(junk
? R.drawable.twotone_report_24
: R.drawable.twotone_move_to_inbox_24);
return super.onPrepareOptionsMenu(menu);
}
@Override @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) { public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.menu_save) { int itemId = item.getItemId();
if (itemId == R.id.menu_save) {
onMenuSave(); onMenuSave();
return true; return true;
} else if (itemId == R.id.menu_junk) {
junk = !junk;
item.setChecked(junk);
invalidateOptionsMenu();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -601,6 +625,7 @@ public class ActivityEML extends ActivityBase {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable("uri", uri); args.putParcelable("uri", uri);
args.putLong("account", account.id); args.putLong("account", account.id);
args.putBoolean("junk", junk);
new SimpleTask<String>() { new SimpleTask<String>() {
@Override @Override
@ -617,8 +642,9 @@ public class ActivityEML extends ActivityBase {
EntityAccount account = db.account().getAccount(aid); EntityAccount account = db.account().getAccount(aid);
if (account == null) if (account == null)
return null; return null;
EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX); EntityFolder folder = db.folder().getFolderByType(account.id,
if (inbox == null) junk ? EntityFolder.JUNK : EntityFolder.INBOX);
if (folder == null)
throw new IllegalArgumentException(context.getString(R.string.title_no_folder)); throw new IllegalArgumentException(context.getString(R.string.title_no_folder));
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
@ -634,7 +660,7 @@ public class ActivityEML extends ActivityBase {
iservice.setIgnoreBodyStructureSize(account.ignore_size); iservice.setIgnoreBodyStructureSize(account.ignore_size);
iservice.connect(account); iservice.connect(account);
IMAPFolder ifolder = (IMAPFolder) iservice.getStore().getFolder(inbox.name); IMAPFolder ifolder = (IMAPFolder) iservice.getStore().getFolder(folder.name);
ifolder.open(Folder.READ_WRITE); ifolder.open(Folder.READ_WRITE);
if (ifolder.getPermanentFlags().contains(Flags.Flag.DRAFT)) if (ifolder.getPermanentFlags().contains(Flags.Flag.DRAFT))
@ -644,10 +670,10 @@ public class ActivityEML extends ActivityBase {
} }
} }
EntityOperation.sync(context, inbox.id, true); EntityOperation.sync(context, folder.id, true);
ServiceSynchronize.eval(context, "EML"); ServiceSynchronize.eval(context, "EML");
return account.name + "/" + inbox.name; return account.name + "/" + folder.name;
} }
@Override @Override

@ -6,4 +6,9 @@
android:icon="@drawable/twotone_move_to_inbox_24" android:icon="@drawable/twotone_move_to_inbox_24"
android:title="@string/title_save" android:title="@string/title_save"
app:showAsAction="always" /> app:showAsAction="always" />
<item
android:id="@+id/menu_junk"
android:checkable="true"
android:title="@string/title_folder_junk"
app:showAsAction="never" />
</menu> </menu>

Loading…
Cancel
Save