From 546e3492297e070ec1531c241a27aa73d4c079eb Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Thu, 24 Aug 2023 08:40:42 -0300 Subject: [PATCH] refactor: fix compilation errors in FooterStatusDisplayItem.java and EmojiReactionsStatusDisplayItem.java --- .../EmojiReactionsStatusDisplayItem.java | 2 +- .../displayitems/FooterStatusDisplayItem.java | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java index 9f5830c7b..07f74d373 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java @@ -180,7 +180,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem { emojiKeyboard=new CustomEmojiPopupKeyboard( (Activity) item.parentFragment.getContext(), AccountSessionManager.getInstance().getCustomEmojis(session.domain), - session.domain, true); + session.domain, true, item.accountID); emojiKeyboard.setListener(this); space.setVisibility(View.GONE); root.addView(emojiKeyboard.getView()); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index 6745457f2..6338b4cac 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -5,7 +5,11 @@ import android.app.Dialog; import android.content.Context; import android.content.Intent; 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.MotionEvent; import android.view.View; @@ -14,6 +18,8 @@ import android.view.ViewGroup; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.RotateAnimation; import android.widget.Button; import android.widget.FrameLayout; import android.widget.TextView; @@ -466,5 +472,27 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ return R.string.button_share; return 0; } + + private static void vibrateForAction(View view, boolean isPositive) { + if (!GlobalUserPreferences.hapticFeedback) return; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + view.performHapticFeedback(isPositive ? HapticFeedbackConstants.CONFIRM : HapticFeedbackConstants.REJECT); + } else { + Vibrator vibrator = view.getContext().getSystemService(Vibrator.class); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + vibrator.vibrate(VibrationEffect.createPredefined(isPositive ? VibrationEffect.EFFECT_CLICK : VibrationEffect.EFFECT_DOUBLE_CLICK)); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + VibrationEffect effect = isPositive + ? VibrationEffect.createOneShot(75L, 128) + : VibrationEffect.createWaveform(new long[]{0L, 75L, 75L, 75L}, new int[]{0, 128, 0, 128}, -1); + vibrator.vibrate(effect); + } else { + if (isPositive) vibrator.vibrate(75L); + else vibrator.vibrate(new long[]{0L, 75L, 75L, 75L}, -1); + } + } + } } }