aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-10-30 01:04:07 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-10-30 01:04:07 +0000
commit4d1668d0a8fc107e1b460be7f1b249de9beaac96 (patch)
treeaeebd65480899b452609b17c33602f8f77ca5939 /app
parentb4fa21be08ba6fe07772c6927a8a65a82bb6b4bd (diff)
downloadinfinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.tar
infinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.tar.gz
infinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.tar.bz2
infinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.tar.lz
infinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.tar.xz
infinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.tar.zst
infinity-for-reddit-4d1668d0a8fc107e1b460be7f1b249de9beaac96.zip
Use haptic feedback instead of vibration in swipe action.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/AndroidManifest.xml1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java22
4 files changed, 15 insertions, 52 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 763d1c03..d636665f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -12,7 +12,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
- <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="22" />
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index e8bc769a..b394cfa0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -9,9 +9,9 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
-import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.DisplayMetrics;
+import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -441,14 +441,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
if (!exceedThreshold) {
exceedThreshold = true;
- if (vibrateWhenActionTriggered && v != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createOneShot(10, 255));
- } else {
- //deprecated in API 26
- v.vibrate(10);
- }
- }
+ viewHolder.itemView.setHapticFeedbackEnabled(true);
+ viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
} else {
@@ -466,14 +460,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
if (!exceedThreshold) {
exceedThreshold = true;
- if (vibrateWhenActionTriggered && v != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createOneShot(10, 255));
- } else {
- //deprecated in API 26
- v.vibrate(10);
- }
- }
+ viewHolder.itemView.setHapticFeedbackEnabled(true);
+ viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
index 5f0f0ba7..4fcbba0e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
@@ -10,8 +10,8 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
-import android.os.VibrationEffect;
import android.os.Vibrator;
+import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -192,14 +192,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
if (!exceedThreshold) {
exceedThreshold = true;
- if (vibrateWhenActionTriggered && v != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createOneShot(10, 255));
- } else {
- //deprecated in API 26
- v.vibrate(10);
- }
- }
+ viewHolder.itemView.setHapticFeedbackEnabled(true);
+ viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
} else {
@@ -217,14 +211,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
if (!exceedThreshold) {
exceedThreshold = true;
- if (vibrateWhenActionTriggered && v != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createOneShot(10, 255));
- } else {
- //deprecated in API 26
- v.vibrate(10);
- }
- }
+ viewHolder.itemView.setHapticFeedbackEnabled(true);
+ viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index e4f6dd94..553df57f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -14,9 +14,9 @@ import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
-import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.DisplayMetrics;
+import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -735,14 +735,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
if (!exceedThreshold) {
exceedThreshold = true;
- if (vibrateWhenActionTriggered && v != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createOneShot(10, 255));
- } else {
- //deprecated in API 26
- v.vibrate(10);
- }
- }
+ viewHolder.itemView.setHapticFeedbackEnabled(true);
+ viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
backgroundLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
} else {
@@ -760,14 +754,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
if (!exceedThreshold) {
exceedThreshold = true;
- if (vibrateWhenActionTriggered && v != null) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- v.vibrate(VibrationEffect.createOneShot(10, 255));
- } else {
- //deprecated in API 26
- v.vibrate(10);
- }
- }
+ viewHolder.itemView.setHapticFeedbackEnabled(true);
+ viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
backgroundRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
} else {