mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-08 01:53:25 +02:00
Haptic feedback
This commit is contained in:
@@ -247,6 +247,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
return;
|
||||
TupleMessageEx message = getItem(pos);
|
||||
|
||||
Helper.hapticFeedback(itemView);
|
||||
|
||||
if (EntityFolder.DRAFTS.equals(message.folderType))
|
||||
context.startActivity(
|
||||
new Intent(context, ActivityCompose.class)
|
||||
|
||||
@@ -194,7 +194,11 @@ public class FragmentCompose extends FragmentEx {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
free = hasFocus;
|
||||
|
||||
Helper.hapticFeedback(view);
|
||||
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
grpHeader.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
|
||||
if (hasFocus) {
|
||||
addresses = (grpAddresses.getVisibility() != View.GONE);
|
||||
@@ -212,6 +216,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
if (grpHeader.getVisibility() == View.GONE) {
|
||||
free = false;
|
||||
|
||||
getActivity().invalidateOptionsMenu();
|
||||
grpHeader.setVisibility(View.VISIBLE);
|
||||
if (addresses)
|
||||
|
||||
@@ -351,6 +351,9 @@ public class FragmentMessage extends FragmentEx {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
free = true;
|
||||
|
||||
Helper.hapticFeedback(view);
|
||||
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
grpHeader.setVisibility(View.GONE);
|
||||
@@ -373,6 +376,7 @@ public class FragmentMessage extends FragmentEx {
|
||||
public boolean onBackPressed() {
|
||||
if (free && isVisible()) {
|
||||
free = false;
|
||||
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
grpHeader.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -380,6 +380,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Helper.hapticFeedback(view);
|
||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("account", (Long) fab.getTag())
|
||||
|
||||
@@ -37,6 +37,7 @@ public class FragmentOptions extends FragmentEx {
|
||||
private CheckBox cbLight;
|
||||
private CheckBox cbBrowse;
|
||||
private CheckBox cbSwipe;
|
||||
private CheckBox cbHaptic;
|
||||
private CheckBox cbDebug;
|
||||
|
||||
@Override
|
||||
@@ -52,6 +53,7 @@ public class FragmentOptions extends FragmentEx {
|
||||
cbLight = view.findViewById(R.id.cbLight);
|
||||
cbBrowse = view.findViewById(R.id.cbBrowse);
|
||||
cbSwipe = view.findViewById(R.id.cbSwipe);
|
||||
cbHaptic = view.findViewById(R.id.cbHaptic);
|
||||
cbDebug = view.findViewById(R.id.cbDebug);
|
||||
|
||||
// Wire controls
|
||||
@@ -102,6 +104,14 @@ public class FragmentOptions extends FragmentEx {
|
||||
}
|
||||
});
|
||||
|
||||
cbHaptic.setChecked(prefs.getBoolean("haptic", true));
|
||||
cbHaptic.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("haptic", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
cbDebug.setChecked(prefs.getBoolean("debug", false));
|
||||
cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -31,6 +32,7 @@ import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -82,6 +84,12 @@ public class Helper {
|
||||
}
|
||||
};
|
||||
|
||||
static void hapticFeedback(View view) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(view.getContext());
|
||||
if (prefs.getBoolean("haptic", true))
|
||||
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
|
||||
}
|
||||
|
||||
static void view(Context context, Intent intent) {
|
||||
Uri uri = intent.getData();
|
||||
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))
|
||||
|
||||
Reference in New Issue
Block a user