Navigate to single system folder

pull/207/head
M66B 3 years ago
parent cb168a6133
commit 69d6d99196

@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -148,10 +149,43 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
if (EntityFolder.OUTBOX.equals(folder.type))
lbm.sendBroadcast(new Intent(ActivityView.ACTION_VIEW_OUTBOX));
else
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", folder.type));
else {
Bundle args = new Bundle();
args.putString("type", folder.type);
new SimpleTask<EntityFolder>() {
@Override
protected EntityFolder onExecute(Context context, Bundle args) throws Throwable {
String type = args.getString("type");
DB db = DB.getInstance(context);
List<EntityFolder> folders = db.folder().getFoldersByType(type);
return (folders != null && folders.size() == 1 ? folders.get(0) : null);
}
@Override
protected void onExecuted(Bundle args, EntityFolder one) {
if (one == null)
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", folder.type));
else
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("account", one.account)
.putExtra("folder", one.id)
.putExtra("type", one.type));
}
@Override
protected void onException(Bundle args, Throwable ex) {
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
.putExtra("type", folder.type));
}
}.execute(context, owner, args, "nav:folder");
}
}
}

@ -219,7 +219,10 @@ public interface DaoFolder {
" WHERE account = :account AND type = :type")
EntityFolder getFolderByType(long account, String type);
@Query("SELECT * FROM folder WHERE type = :type")
@Query("SELECT folder.* FROM folder" +
" JOIN account ON account.id = folder.account" +
" WHERE account.synchronize" +
" AND type = :type")
List<EntityFolder> getFoldersByType(String type);
@Query("SELECT folder.* FROM folder" +

@ -5463,7 +5463,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (name == null)
name = getString(R.string.title_folder_unified);
} else
name = EntityFolder.localizeType(getContext(), type);
name = "»" + EntityFolder.localizeType(getContext(), type);
else {
name = (folders.size() > 0 ? folders.get(0).getDisplayName(getContext()) : "");
if (folders.size() == 1) {

Loading…
Cancel
Save