fix: DisableVibration In SenderSelectPopup

This commit is contained in:
xtaodada 2022-10-13 00:54:59 +08:00
parent 1da62fa5e2
commit f3ce9849c9
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 29 additions and 16 deletions

View File

@ -2489,9 +2489,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
botCommandsMenuButton.setOnClickListener(view -> {
boolean open = !botCommandsMenuButton.isOpened();
botCommandsMenuButton.setOpened(open);
if (!NekoConfig.disableVibration.Bool()) {
try {
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {}
}
if (hasBotWebView()) {
if (open) {
if (emojiViewVisible || botKeyboardViewVisible) {
@ -2700,9 +2702,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
}
}
if (delegate.getSendAsPeers() != null) {
if (!NekoConfig.disableVibration.Bool()) {
try {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignored) {}
}
if (senderSelectPopupWindow != null) {
senderSelectPopupWindow.setPauseNotifications(false);
senderSelectPopupWindow.startDismissAnimation();
@ -2885,11 +2889,13 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
if (!performedHapticFeedback && value >= endY) {
performedHapticFeedback = true;
if (!NekoConfig.disableVibration.Bool()) {
try {
avatar.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignored) {}
}
}
}
})
.addEndListener((animation, canceled, value, velocity) -> {
if (d.isShowing()) {
@ -3673,9 +3679,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), y);
sendPopupWindow.dimBehind();
doneButtonContainer.invalidate();
if (!NekoConfig.disableVibration.Bool()) {
try {
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {}
}
return false;
});

View File

@ -52,6 +52,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import tw.nekomimi.nekogram.NekoConfig;
import xyz.nextalone.nagram.NaConfig;
public class SenderSelectPopup extends ActionBarPopupWindow {
@ -243,9 +244,11 @@ public class SenderSelectPopup extends ActionBarPopupWindow {
return;
}
if (peerObj.premium_required && !UserConfig.getInstance(UserConfig.selectedAccount).isPremium()) {
if (!NekoConfig.disableVibration.Bool()) {
try {
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignored) {}
}
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (bulletinContainer == null) {
@ -345,7 +348,9 @@ public class SenderSelectPopup extends ActionBarPopupWindow {
bulletinContainer.animate().alpha(0).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (bulletinContainer != null && bulletinContainer.isShown()) {
windowManager.removeViewImmediate(bulletinContainer);
}
if (bulletinHideCallback != null) {
AndroidUtilities.cancelRunOnUIThread(bulletinHideCallback);