Haptic feedback

pull/145/head
M66B 7 years ago
parent b50877bfd1
commit 600284b69c

@ -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()))

@ -61,6 +61,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbBrowse" />
<CheckBox
android:id="@+id/cbHaptic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_haptic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSwipe" />
<CheckBox
android:id="@+id/cbDebug"
android:layout_width="wrap_content"
@ -69,6 +79,6 @@
android:layout_marginTop="12dp"
android:text="@string/title_advanced_debug"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSwipe" />
app:layout_constraintTop_toBottomOf="@id/cbHaptic" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@ -84,6 +84,7 @@
<string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_browse">Browse messages on the server</string>
<string name="title_advanced_swipe">Swipe actions</string>
<string name="title_advanced_haptic">Haptic feedback</string>
<string name="title_advanced_debug">Debug mode</string>
<string name="title_select">Select &#8230;</string>

Loading…
Cancel
Save