Added option to enable double tap

This commit is contained in:
M66B
2019-06-26 13:55:35 +02:00
parent 3cf4261118
commit fcd9dbd4e9
4 changed files with 43 additions and 10 deletions

View File

@@ -1401,6 +1401,21 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.putExtra("action", "edit")
.putExtra("id", message.id));
else {
final LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
final Intent viewThread = new Intent(ActivityView.ACTION_VIEW_THREAD)
.putExtra("account", message.account)
.putExtra("thread", message.thread)
.putExtra("id", message.id)
.putExtra("found", viewType == ViewType.SEARCH);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean doubletap = prefs.getBoolean("doubletap", false);
if (!doubletap) {
lbm.sendBroadcast(viewThread);
return;
}
firstClick = !firstClick;
if (firstClick) {
new Handler().postDelayed(new Runnable() {
@@ -1408,14 +1423,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
public void run() {
if (firstClick) {
firstClick = false;
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_THREAD)
.putExtra("account", message.account)
.putExtra("thread", message.thread)
.putExtra("id", message.id)
.putExtra("found", viewType == ViewType.SEARCH));
lbm.sendBroadcast(viewThread);
}
}
}, ViewConfiguration.getDoubleTapTimeout());

View File

@@ -38,6 +38,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swPull;
private SwitchCompat swAutoScroll;
private SwitchCompat swSwipeNav;
private SwitchCompat swDoubleTap;
private SwitchCompat swAutoExpand;
private SwitchCompat swAutoClose;
private SwitchCompat swAutoNext;
@@ -46,7 +47,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swAutoMove;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
"pull", "autoscroll", "swipenav", "doubletap", "autoexpand", "autoclose", "autonext",
"collapse", "autoread", "automove"
};
@@ -63,6 +64,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swPull = view.findViewById(R.id.swPull);
swAutoScroll = view.findViewById(R.id.swAutoScroll);
swSwipeNav = view.findViewById(R.id.swSwipeNav);
swDoubleTap = view.findViewById(R.id.swDoubleTap);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
swAutoClose = view.findViewById(R.id.swAutoClose);
swAutoNext = view.findViewById(R.id.swAutoNext);
@@ -97,6 +99,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swDoubleTap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("doubletap", checked).apply();
}
});
swAutoExpand.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@@ -187,6 +196,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swPull.setChecked(prefs.getBoolean("pull", true));
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
swSwipeNav.setChecked(prefs.getBoolean("swipenav", true));
swDoubleTap.setChecked(prefs.getBoolean("doubletap", false));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
swAutoClose.setChecked(prefs.getBoolean("autoclose", true));
swAutoNext.setChecked(prefs.getBoolean("autonext", false));