mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-02 14:27:10 +01:00
Use haptic feedback instead of vibration in swipe action.
This commit is contained in:
parent
b4fa21be08
commit
4d1668d0a8
@ -12,7 +12,6 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||||
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
|
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="22" />
|
android:maxSdkVersion="22" />
|
||||||
|
@ -9,9 +9,9 @@ import android.graphics.drawable.ColorDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.VibrationEffect;
|
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -441,14 +441,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
||||||
if (!exceedThreshold) {
|
if (!exceedThreshold) {
|
||||||
exceedThreshold = true;
|
exceedThreshold = true;
|
||||||
if (vibrateWhenActionTriggered && v != null) {
|
viewHolder.itemView.setHapticFeedbackEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
v.vibrate(VibrationEffect.createOneShot(10, 255));
|
|
||||||
} else {
|
|
||||||
//deprecated in API 26
|
|
||||||
v.vibrate(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
||||||
} else {
|
} else {
|
||||||
@ -466,14 +460,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
||||||
if (!exceedThreshold) {
|
if (!exceedThreshold) {
|
||||||
exceedThreshold = true;
|
exceedThreshold = true;
|
||||||
if (vibrateWhenActionTriggered && v != null) {
|
viewHolder.itemView.setHapticFeedbackEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
v.vibrate(VibrationEffect.createOneShot(10, 255));
|
|
||||||
} else {
|
|
||||||
//deprecated in API 26
|
|
||||||
v.vibrate(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,8 +10,8 @@ import android.graphics.drawable.ColorDrawable;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.VibrationEffect;
|
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -192,14 +192,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
||||||
if (!exceedThreshold) {
|
if (!exceedThreshold) {
|
||||||
exceedThreshold = true;
|
exceedThreshold = true;
|
||||||
if (vibrateWhenActionTriggered && v != null) {
|
viewHolder.itemView.setHapticFeedbackEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
v.vibrate(VibrationEffect.createOneShot(10, 255));
|
|
||||||
} else {
|
|
||||||
//deprecated in API 26
|
|
||||||
v.vibrate(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
||||||
} else {
|
} else {
|
||||||
@ -217,14 +211,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
||||||
if (!exceedThreshold) {
|
if (!exceedThreshold) {
|
||||||
exceedThreshold = true;
|
exceedThreshold = true;
|
||||||
if (vibrateWhenActionTriggered && v != null) {
|
viewHolder.itemView.setHapticFeedbackEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
v.vibrate(VibrationEffect.createOneShot(10, 255));
|
|
||||||
} else {
|
|
||||||
//deprecated in API 26
|
|
||||||
v.vibrate(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,9 +14,9 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.VibrationEffect;
|
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -735,14 +735,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
||||||
if (!exceedThreshold) {
|
if (!exceedThreshold) {
|
||||||
exceedThreshold = true;
|
exceedThreshold = true;
|
||||||
if (vibrateWhenActionTriggered && v != null) {
|
viewHolder.itemView.setHapticFeedbackEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
v.vibrate(VibrationEffect.createOneShot(10, 255));
|
|
||||||
} else {
|
|
||||||
//deprecated in API 26
|
|
||||||
v.vibrate(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
||||||
} else {
|
} else {
|
||||||
@ -760,14 +754,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
|
||||||
if (!exceedThreshold) {
|
if (!exceedThreshold) {
|
||||||
exceedThreshold = true;
|
exceedThreshold = true;
|
||||||
if (vibrateWhenActionTriggered && v != null) {
|
viewHolder.itemView.setHapticFeedbackEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
v.vibrate(VibrationEffect.createOneShot(10, 255));
|
|
||||||
} else {
|
|
||||||
//deprecated in API 26
|
|
||||||
v.vibrate(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user