Add haptic effect (AND-150)

This commit is contained in:
Grishka 2024-02-28 23:30:08 +03:00
parent 217884aaec
commit e9dde114b7
2 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

View File

@ -6,7 +6,10 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.AlertDialog;
import android.graphics.RectF;
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;
@ -346,6 +349,13 @@ public class ComposePollViewController{
pollOptions.remove(dpo);
pollOptionsView.removeView(view);
addPollOptionBtn.setEnabled(pollOptions.size()<maxPollOptions);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.R){
Vibrator vibrator=fragment.getActivity().getSystemService(Vibrator.class);
if(vibrator.areAllPrimitivesSupported(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE)){
VibrationEffect effect=VibrationEffect.startComposition().addPrimitive(VibrationEffect.Composition.PRIMITIVE_QUICK_RISE).compose();
vibrator.vibrate(effect);
}
}
return;
}
ReorderableLinearLayout.OnDragListener.super.onDragEnd(view);