|
|
|
@ -73,13 +73,15 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
private Group grpHintActions;
|
|
|
|
|
private Group grpHintSync;
|
|
|
|
|
private Group grpReady;
|
|
|
|
|
private FloatingActionButton fab;
|
|
|
|
|
private FloatingActionButton fabAdd;
|
|
|
|
|
private FloatingActionButton fabCompose;
|
|
|
|
|
private FloatingActionButton fabError;
|
|
|
|
|
|
|
|
|
|
private boolean cards;
|
|
|
|
|
private boolean compact;
|
|
|
|
|
|
|
|
|
|
private long account;
|
|
|
|
|
private boolean primary;
|
|
|
|
|
private boolean show_hidden = false;
|
|
|
|
|
private String searching = null;
|
|
|
|
|
private AdapterFolder adapter;
|
|
|
|
@ -97,6 +99,7 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
// Get arguments
|
|
|
|
|
Bundle args = getArguments();
|
|
|
|
|
account = args.getLong("account", -1);
|
|
|
|
|
primary = args.getBoolean("primary");
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
cards = prefs.getBoolean("cards", true);
|
|
|
|
@ -121,7 +124,8 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
grpHintActions = view.findViewById(R.id.grpHintActions);
|
|
|
|
|
grpHintSync = view.findViewById(R.id.grpHintSync);
|
|
|
|
|
grpReady = view.findViewById(R.id.grpReady);
|
|
|
|
|
fab = view.findViewById(R.id.fab);
|
|
|
|
|
fabAdd = view.findViewById(R.id.fabAdd);
|
|
|
|
|
fabCompose = view.findViewById(R.id.fabCompose);
|
|
|
|
|
fabError = view.findViewById(R.id.fabError);
|
|
|
|
|
|
|
|
|
|
// Wire controls
|
|
|
|
@ -175,15 +179,9 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
adapter = new AdapterFolder(this, account, compact, show_hidden, null);
|
|
|
|
|
rvFolder.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
fab.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
fabAdd.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
if (account < 0) {
|
|
|
|
|
startActivity(new Intent(getContext(), ActivityCompose.class)
|
|
|
|
|
.putExtra("action", "new")
|
|
|
|
|
.putExtra("account", account)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("account", account);
|
|
|
|
|
FragmentFolder fragment = new FragmentFolder();
|
|
|
|
@ -192,20 +190,19 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("folder");
|
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fabError.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
fabCompose.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Intent intent = new Intent(getContext(), ActivitySetup.class)
|
|
|
|
|
.putExtra("target", "accounts");
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
startActivity(new Intent(getContext(), ActivityCompose.class)
|
|
|
|
|
.putExtra("action", "new")
|
|
|
|
|
.putExtra("account", account)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (account < 0)
|
|
|
|
|
fab.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
fabCompose.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
|
new SimpleTask<EntityFolder>() {
|
|
|
|
@ -234,6 +231,15 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fabError.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Intent intent = new Intent(getContext(), ActivitySetup.class)
|
|
|
|
|
.putExtra("target", "accounts");
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
|
|
|
|
|
|
if (cards && !Helper.isDarkTheme(getContext()))
|
|
|
|
@ -241,7 +247,8 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
grpReady.setVisibility(View.GONE);
|
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
|
fab.hide();
|
|
|
|
|
fabAdd.hide();
|
|
|
|
|
fabCompose.hide();
|
|
|
|
|
fabError.hide();
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
@ -267,12 +274,13 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(getContext());
|
|
|
|
|
|
|
|
|
|
if (account < 0 || primary)
|
|
|
|
|
fabCompose.show();
|
|
|
|
|
|
|
|
|
|
// Observe account
|
|
|
|
|
if (account < 0) {
|
|
|
|
|
if (account < 0)
|
|
|
|
|
setSubtitle(R.string.title_folders_unified);
|
|
|
|
|
fab.setImageResource(R.drawable.baseline_edit_24);
|
|
|
|
|
fab.show();
|
|
|
|
|
} else
|
|
|
|
|
else
|
|
|
|
|
db.account().liveAccount(account).observe(getViewLifecycleOwner(), new Observer<EntityAccount>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onChanged(@Nullable EntityAccount account) {
|
|
|
|
@ -288,10 +296,12 @@ public class FragmentFolders extends FragmentBase {
|
|
|
|
|
else
|
|
|
|
|
fabError.hide();
|
|
|
|
|
|
|
|
|
|
if (!primary) {
|
|
|
|
|
if (account == null || account.protocol != EntityAccount.TYPE_IMAP)
|
|
|
|
|
fab.hide();
|
|
|
|
|
fabAdd.hide();
|
|
|
|
|
else
|
|
|
|
|
fab.show();
|
|
|
|
|
fabAdd.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|