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

View File

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