Added manual expunge

pull/194/head
M66B 4 years ago
parent d00d790941
commit adab903e32

@ -52,6 +52,7 @@ import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -474,6 +475,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
return false;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean debug = prefs.getBoolean("debug", false);
int order = 1;
@ -502,6 +504,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_local, order++, R.string.title_delete_local);
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_browsed, order++, R.string.title_delete_browsed);
if (!perform_expunge || BuildConfig.DEBUG)
popupMenu.getMenu().add(Menu.NONE, R.string.title_advanced_expunge, order++, R.string.title_advanced_expunge);
}
if (EntityFolder.TRASH.equals(folder.type))
@ -615,6 +619,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
} else if (itemId == R.string.title_delete_browsed) {
OnActionDeleteLocal(true);
return true;
} else if (itemId == R.string.title_advanced_expunge) {
onActionExpunge();
return true;
} else if (itemId == R.string.title_empty_trash) {
onActionEmpty(EntityFolder.TRASH);
return true;
@ -789,6 +796,36 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ask.show(parentFragment.getParentFragmentManager(), "folder:delete_local");
}
private void onActionExpunge() {
Bundle args = new Bundle();
args.putLong("id", folder.id);
new SimpleTask<Void>() {
@Override
protected void onPreExecute(Bundle args) {
ToastEx.makeText(context, R.string.title_executing, Toast.LENGTH_LONG).show();
}
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(id);
if (folder == null)
return null;
EntityOperation.queue(context, folder, EntityOperation.EXPUNGE);
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "folder:expunge");
}
private void onActionEmpty(String type) {
Bundle aargs = new Bundle();
if (EntityFolder.TRASH.equals(type))

@ -203,7 +203,8 @@ class Core {
!EntityOperation.FETCH.equals(op.name) &&
!EntityOperation.SYNC.equals(op.name) &&
!EntityOperation.SUBSCRIBE.equals(op.name) &&
!EntityOperation.PURGE.equals(op.name))
!EntityOperation.PURGE.equals(op.name) &&
!EntityOperation.EXPUNGE.equals(op.name))
throw new MessageRemovedException();
// Process similar operations

@ -198,6 +198,7 @@ public class FragmentOperations extends FragmentBase {
if (delete) {
addAll(ops, db.operation().getOperations(EntityOperation.DELETE));
addAll(ops, db.operation().getOperations(EntityOperation.PURGE));
addAll(ops, db.operation().getOperations(EntityOperation.EXPUNGE));
}
for (EntityOperation op : ops) {

@ -109,7 +109,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="48dp"
android:fontFamily="monospace"
android:text="DELETE, PURGE"
android:text="DELETE, PURGE, EXPUNGE"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"

Loading…
Cancel
Save