Long press primary folders to reload

This commit is contained in:
M66B 2018-11-30 13:48:30 +01:00
parent 7048bf0e56
commit 626eef1922
1 changed files with 28 additions and 5 deletions

View File

@ -1165,7 +1165,7 @@ public class FragmentMessages extends FragmentEx {
menu.findItem(R.id.menu_search).setVisible(folder >= 0 && search == null); menu.findItem(R.id.menu_search).setVisible(folder >= 0 && search == null);
menu.findItem(R.id.menu_sort_on).setVisible(TextUtils.isEmpty(search)); menu.findItem(R.id.menu_sort_on).setVisible(TextUtils.isEmpty(search));
menu.findItem(R.id.menu_folders).setVisible(primary >= 0); menu.findItem(R.id.menu_folders).setVisible(primary >= 0);
menu.findItem(R.id.menu_folders).setIcon(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24); //menu.findItem(R.id.menu_folders).setIcon(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24);
menu.findItem(R.id.menu_move_sent).setVisible(outbox); menu.findItem(R.id.menu_move_sent).setVisible(outbox);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
@ -1177,6 +1177,30 @@ public class FragmentMessages extends FragmentEx {
else if ("starred".equals(sort)) else if ("starred".equals(sort))
menu.findItem(R.id.menu_sort_on_starred).setChecked(true); menu.findItem(R.id.menu_sort_on_starred).setChecked(true);
ImageButton ibFolders = new ImageButton(getContext());
ibFolders.setImageResource(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24);
ibFolders.setColorFilter(Helper.resolveColor(getContext(), android.R.attr.textColorPrimary));
ibFolders.setBackground(null);
ibFolders.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onMenuFolders();
}
});
ibFolders.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
ServiceSynchronize.reload(getContext(), "folders");
return true;
}
});
MenuItem menuFolders = menu.findItem(R.id.menu_folders);
menuFolders.setActionView(ibFolders);
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
} }
@ -1198,10 +1222,9 @@ public class FragmentMessages extends FragmentEx {
loadMessages(); loadMessages();
return true; return true;
case R.id.menu_folders: //case R.id.menu_folders:
onMenuFolders(); // onMenuFolders();
loadMessages(); // return true;
return true;
case R.id.menu_move_sent: case R.id.menu_move_sent:
onMenuMoveSent(); onMenuMoveSent();