Browse Source

Removed setting swipe targets

main
M66B 6 years ago
parent
commit
f90165ce71
4 changed files with 12 additions and 125 deletions
  1. +12
    -110
      app/src/main/java/eu/faircode/email/FragmentMessages.java
  2. +0
    -7
      app/src/main/res/layout/fragment_messages.xml
  3. +0
    -5
      app/src/main/res/menu/menu_messages.xml
  4. +0
    -3
      app/src/main/res/values/strings.xml

+ 12
- 110
app/src/main/java/eu/faircode/email/FragmentMessages.java View File

@ -36,7 +36,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.PopupMenu;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -45,12 +44,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import java.io.Serializable;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -75,7 +70,6 @@ public class FragmentMessages extends FragmentEx {
private TextView tvSupport;
private ImageButton ibHintSupport;
private ImageButton ibHintActions;
private View popupAnchor;
private TextView tvNoEmail;
private RecyclerView rvMessage;
private BottomNavigationView bottom_navigation;
@ -100,7 +94,6 @@ public class FragmentMessages extends FragmentEx {
private int autoCount = 0;
private boolean autoExpand = true;
private long swipeTarget = -1;
private List<Long> expanded = new ArrayList<>();
private List<Long> headers = new ArrayList<>();
private List<Long> images = new ArrayList<>();
@ -147,7 +140,6 @@ public class FragmentMessages extends FragmentEx {
tvSupport = view.findViewById(R.id.tvSupport);
ibHintSupport = view.findViewById(R.id.ibHintSupport);
ibHintActions = view.findViewById(R.id.ibHintActions);
popupAnchor = view.findViewById(R.id.popupAnchor);
tvNoEmail = view.findViewById(R.id.tvNoEmail);
rvMessage = view.findViewById(R.id.rvFolder);
bottom_navigation = view.findViewById(R.id.bottom_navigation);
@ -159,8 +151,6 @@ public class FragmentMessages extends FragmentEx {
fab = view.findViewById(R.id.fab);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (folder >= 0)
swipeTarget = prefs.getLong("swipe." + folder, -1);
// Wire controls
@ -277,9 +267,8 @@ public class FragmentMessages extends FragmentEx {
if (dX > margin) {
// Right swipe
Drawable d = getResources().getDrawable(swipeTarget < 0
? (inbox ? R.drawable.baseline_move_to_inbox_24 : R.drawable.baseline_archive_24)
: R.drawable.baseline_folder_24,
Drawable d = getResources().getDrawable(
inbox ? R.drawable.baseline_move_to_inbox_24 : R.drawable.baseline_archive_24,
getContext().getTheme());
int padding = (itemView.getHeight() - d.getIntrinsicHeight());
d.setBounds(
@ -316,16 +305,13 @@ public class FragmentMessages extends FragmentEx {
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putLong("folder", folder);
args.putBoolean("thread", viewType != AdapterMessage.ViewType.THREAD);
args.putInt("direction", direction);
args.putLong("swipeTarget", swipeTarget);
new SimpleTask<MessageTarget>() {
@Override
protected MessageTarget onLoad(Context context, Bundle args) {
long id = args.getLong("id");
long fid = args.getLong("folder");
boolean thread = args.getBoolean("thread");
int direction = args.getInt("direction");
@ -339,21 +325,17 @@ public class FragmentMessages extends FragmentEx {
EntityMessage message = db.message().getMessage(id);
if (fid < 0 || swipeTarget < 0 || direction == ItemTouchHelper.LEFT) {
EntityFolder folder = db.folder().getFolder(message.folder);
if (EntityFolder.ARCHIVE.equals(folder.type) || EntityFolder.TRASH.equals(folder.type))
EntityFolder folder = db.folder().getFolder(message.folder);
if (EntityFolder.ARCHIVE.equals(folder.type) || EntityFolder.TRASH.equals(folder.type))
target = db.folder().getFolderByType(message.account, EntityFolder.INBOX);
else {
if (direction == ItemTouchHelper.RIGHT)
target = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE);
if (direction == ItemTouchHelper.LEFT || target == null)
target = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
if (target == null)
target = db.folder().getFolderByType(message.account, EntityFolder.INBOX);
else {
if (direction == ItemTouchHelper.RIGHT)
target = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE);
else if (direction == ItemTouchHelper.LEFT)
target = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
}
} else
target = db.folder().getFolder(swipeTarget);
if (target == null || !target.account.equals((message.account)))
throw new IllegalArgumentException(getString(R.string.title_no_target));
}
result.target = target.name;
result.display = (target.display == null ? target.name : target.display);
@ -521,7 +503,6 @@ public class FragmentMessages extends FragmentEx {
super.onSaveInstanceState(outState);
outState.putBoolean("autoExpand", autoExpand);
outState.putInt("autoCount", autoCount);
outState.putLong("swipeTarget", swipeTarget);
outState.putLongArray("expanded", Helper.toLongArray(expanded));
outState.putLongArray("headers", Helper.toLongArray(headers));
outState.putLongArray("images", Helper.toLongArray(images));
@ -534,7 +515,6 @@ public class FragmentMessages extends FragmentEx {
if (savedInstanceState != null) {
autoExpand = savedInstanceState.getBoolean("autoExpand");
autoCount = savedInstanceState.getInt("autoCount");
swipeTarget = savedInstanceState.getLong("swipeTarget");
expanded = Helper.fromLongArray(savedInstanceState.getLongArray("expanded"));
headers = Helper.fromLongArray(savedInstanceState.getLongArray("headers"));
images = Helper.fromLongArray(savedInstanceState.getLongArray("images"));
@ -711,7 +691,6 @@ public class FragmentMessages extends FragmentEx {
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).setIcon(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24);
menu.findItem(R.id.menu_swipe).setVisible(folder >= 0);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String sort = prefs.getString("sort", "time");
@ -754,10 +733,6 @@ public class FragmentMessages extends FragmentEx {
loadMessages();
return true;
case R.id.menu_swipe:
onMenuSwipeTarget();
return true;
default:
return super.onOptionsItemSelected(item);
}
@ -777,79 +752,6 @@ public class FragmentMessages extends FragmentEx {
fragmentTransaction.commit();
}
private void onMenuSwipeTarget() {
Bundle args = new Bundle();
args.putLong("folder", folder);
new SimpleTask<List<EntityFolder>>() {
@Override
protected List<EntityFolder> onLoad(Context context, Bundle args) {
long fid = args.getLong("folder");
DB db = DB.getInstance(context);
EntityFolder folder = db.folder().getFolder(fid);
List<EntityFolder> folders = db.folder().getUserFolders(folder.account);
final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
Collections.sort(folders, new Comparator<EntityFolder>() {
@Override
public int compare(EntityFolder f1, EntityFolder f2) {
return collator.compare(f1.name, f2.name);
}
});
EntityFolder junk = db.folder().getFolderByType(folder.account, EntityFolder.JUNK);
if (junk != null && !junk.id.equals(fid))
folders.add(0, junk);
EntityFolder trash = db.folder().getFolderByType(folder.account, EntityFolder.TRASH);
if (trash != null && !trash.id.equals(fid))
folders.add(0, trash);
EntityFolder archive = db.folder().getFolderByType(folder.account, EntityFolder.ARCHIVE);
if (archive != null && !archive.id.equals(fid))
folders.add(0, archive);
EntityFolder sent = db.folder().getFolderByType(folder.account, EntityFolder.SENT);
if (sent != null && !sent.id.equals(fid))
folders.add(0, sent);
EntityFolder inbox = db.folder().getFolderByType(folder.account, EntityFolder.INBOX);
if (inbox != null && !inbox.id.equals(fid))
folders.add(0, inbox);
return folders;
}
@Override
protected void onLoaded(final Bundle args, List<EntityFolder> folders) {
PopupMenu popupMenu = new PopupMenu(getContext(), popupAnchor);
int order = 0;
for (EntityFolder folder : folders) {
String name = (folder.display == null
? Helper.localizeFolderName(getContext(), folder.name)
: folder.display);
popupMenu.getMenu().add(Menu.NONE, folder.id.intValue(), order++, name);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem target) {
swipeTarget = target.getItemId();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putLong("swipe." + folder, swipeTarget).apply();
return true;
}
});
popupMenu.show();
}
}.load(this, args);
}
private void loadMessages() {
final DB db = DB.getInstance(getContext());


+ 0
- 7
app/src/main/res/layout/fragment_messages.xml View File

@ -93,13 +93,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHintActions" />
<View
android:id="@+id/popupAnchor"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvNoEmail"
android:layout_width="wrap_content"


+ 0
- 5
app/src/main/res/menu/menu_messages.xml View File

@ -34,9 +34,4 @@
android:icon="@drawable/baseline_folder_open_24"
android:title="@string/title_folder_primary"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_swipe"
android:title="@string/title_swipe"
app:showAsAction="never" />
</menu>

+ 0
- 3
app/src/main/res/values/strings.xml View File

@ -127,7 +127,6 @@
<string name="title_no_password">Password missing</string>
<string name="title_no_drafts">No primary account or no drafts folder</string>
<string name="title_no_archive">No primary account or no archive folder</string>
<string name="title_no_target">Target folder not set or missing</string>
<string name="title_no_idle">This provider does not support push messages. Reception of new messages can be delayed.</string>
<string name="title_no_uidplus">IMAP UIDPLUS not supported, see the FAQ</string>
<string name="title_account_delete">Delete this account permanently?</string>
@ -234,8 +233,6 @@
<string name="title_sort_on_unread">Unread</string>
<string name="title_sort_on_starred">Starred</string>
<string name="title_swipe">Set right swipe target</string>
<string name="title_previous">Previous</string>
<string name="title_next">Next</string>


Loading…
Cancel
Save