From 535f946239d6b882eea2f4e331968a8be4678701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 25 Feb 2021 18:37:11 +0800 Subject: [PATCH] Fix missing vibration condition --- .github/workflows/debug.yml | 2 +- TMessagesProj/build.gradle | 4 ++-- .../java/org/telegram/ui/AvatarPreviewer.java | 5 ++++- .../org/telegram/ui/Charts/BaseChartView.java | 6 +++++- .../telegram/ui/Components/AlertsCreator.java | 12 +++++++++--- .../ui/Components/FragmentContextView.java | 10 ++++++++-- .../telegram/ui/Components/GroupCallPip.java | 15 +++++++++++---- .../telegram/ui/Components/ProximitySheet.java | 6 +++++- .../java/org/telegram/ui/DialogsActivity.java | 4 +++- .../org/telegram/ui/GroupCallActivity.java | 18 ++++++++++++++---- .../org/telegram/ui/ManageLinksActivity.java | 6 +++++- 11 files changed, 67 insertions(+), 21 deletions(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 2710721b3..2abc16484 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -3,7 +3,6 @@ name: Debug build on: push: branches: - - main - dev paths-ignore: - '**.md' @@ -119,6 +118,7 @@ jobs: echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.3.6528147" >> local.properties - name: Fix BoringSSL + if: steps.cache.outputs.cache-hit != 'true' run: | cd TMessagesProj/jni ./patch_boringssl.sh diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 24f4299f2..01e6ce28d 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -3,8 +3,8 @@ import cn.hutool.core.util.RuntimeUtil apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -def verName = "7.5.0-rc01" -def verCode = 202 +def verName = "7.5.0-rc02" +def verCode = 204 if (System.getenv("DEBUG_BUILD") == "true") { verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1)") diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java b/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java index 235c665cf..db375e3ad 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java @@ -45,6 +45,7 @@ import org.telegram.ui.Components.RadialProgress2; import kotlin.Unit; import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; public class AvatarPreviewer { @@ -435,7 +436,9 @@ public class AvatarPreviewer { } else { moveProgress = Math.max(-1, Math.min(0f, (event.getY() - downY) / AndroidUtilities.dp(56))); if (moveProgress == -1) { - performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + if (!NekoConfig.disableVibration) { + performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } moveAnimator = ValueAnimator.ofFloat(moveProgress, 0); moveAnimator.setDuration(200); moveAnimator.addUpdateListener(a -> { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java index 2b718acc1..4b08d6376 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java @@ -38,6 +38,8 @@ import org.telegram.ui.Components.CubicBezierInterpolator; import java.util.ArrayList; import java.util.Arrays; +import tw.nekomimi.nekogram.NekoConfig; + public abstract class BaseChartView extends View implements ChartPickerDelegate.Listener { public SharedUiComponents sharedUiComponents; @@ -1466,7 +1468,9 @@ public abstract class BaseChartView legendSignatureView.setVisibility(VISIBLE); selectionA = 1f; moveLegend(chartFullWidth * (pickerDelegate.pickerStart) - HORIZONTAL_PADDING); - performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } public long getStartDate() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index 20d270fae..35b4863ed 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -1900,7 +1900,9 @@ public class AlertsCreator { }); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } catch (Exception ignore) { } @@ -2086,7 +2088,9 @@ public class AlertsCreator { }); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } catch (Exception ignore) { } @@ -2290,7 +2294,9 @@ public class AlertsCreator { dayPicker.setFormatter(value -> "" + value); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } catch (Exception ignore) { } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java index 5f3193385..40c013938 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java @@ -70,6 +70,8 @@ import org.telegram.ui.LocationActivity; import java.util.ArrayList; +import tw.nekomimi.nekogram.NekoConfig; + public class FragmentContextView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, VoIPBaseService.StateListener { private ImageView playButton; @@ -326,7 +328,9 @@ public class FragmentContextView extends FrameLayout implements NotificationCent isMuted = false; AndroidUtilities.runOnUIThread(toggleMicRunnable, 90); - muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } }; @@ -418,7 +422,9 @@ public class FragmentContextView extends FrameLayout implements NotificationCent } muteButton.playAnimation(); Theme.getFragmentContextViewWavesDrawable().updateState(true); - muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } }); closeButton = new ImageView(context); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java index 698f63bf8..b525a8b66 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java @@ -13,7 +13,6 @@ import android.graphics.Paint; import android.graphics.PixelFormat; import android.os.Build; import android.os.SystemClock; -import android.provider.Settings; import android.view.Gravity; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; @@ -38,6 +37,8 @@ import org.telegram.messenger.voip.VoIPService; import org.telegram.tgnet.TLRPC; import org.telegram.ui.GroupCallActivity; +import tw.nekomimi.nekogram.NekoConfig; + import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; public class GroupCallPip implements NotificationCenter.NotificationCenterDelegate { @@ -129,7 +130,9 @@ public class GroupCallPip implements NotificationCenter.NotificationCenterDelega return; } AndroidUtilities.runOnUIThread(micRunnable, 90); - performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } pressed = true; } } @@ -253,7 +256,9 @@ public class GroupCallPip implements NotificationCenter.NotificationCenterDelega if (pressed) { if (VoIPService.getSharedInstance() != null) { VoIPService.getSharedInstance().setMicMute(true, false, false); - performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } pressed = false; } else if (event.getAction() == MotionEvent.ACTION_UP && !moving) { @@ -883,7 +888,9 @@ public class GroupCallPip implements NotificationCenter.NotificationCenterDelega iconView.playAnimation(); } if (prepare) { - button.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + button.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } } button.prepareToRemove(prepare); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java index 537756d79..7388286a7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java @@ -37,6 +37,8 @@ import org.telegram.ui.ActionBar.Theme; import java.util.Locale; +import tw.nekomimi.nekogram.NekoConfig; + public class ProximitySheet extends FrameLayout { private VelocityTracker velocityTracker = null; @@ -200,7 +202,9 @@ public class ProximitySheet extends FrameLayout { kmPicker.setTextOffset(AndroidUtilities.dp(20)); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } catch (Exception ignore) { } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 3551d1d80..6e3123063 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -4661,7 +4661,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. updateSelectedCount(); } else { if (dialog instanceof TLRPC.TL_dialogFolder) { - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } BottomBuilder builder = new BottomBuilder(getParentActivity()); final boolean hasUnread = getMessagesStorage().getArchiveUnreadCount() != 0; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java index f917b0150..bbf9a937f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java @@ -107,6 +107,8 @@ import org.telegram.ui.Components.voip.VoIPToggleButton; import java.util.ArrayList; import java.util.Locale; +import tw.nekomimi.nekogram.NekoConfig; + public class GroupCallActivity extends BottomSheet implements NotificationCenter.NotificationCenterDelegate, VoIPBaseService.StateListener { private static final int eveyone_can_speak_item = 1; @@ -226,7 +228,9 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter if (!scheduled || VoIPService.getSharedInstance() == null) { return; } - muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } updateMuteButton(MUTE_BUTTON_STATE_MUTE, true); AndroidUtilities.runOnUIThread(unmuteRunnable, 80); scheduled = false; @@ -1700,7 +1704,9 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter updateMuteButton(MUTE_BUTTON_STATE_UNMUTE, true); if (VoIPService.getSharedInstance() != null) { VoIPService.getSharedInstance().setMicMute(true, true, false); - muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } pressed = false; MotionEvent cancel = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0); @@ -1747,11 +1753,15 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter if (muteButtonState == MUTE_BUTTON_STATE_UNMUTE) { updateMuteButton(MUTE_BUTTON_STATE_MUTE, true); VoIPService.getSharedInstance().setMicMute(false, false, true); - muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } else { updateMuteButton(MUTE_BUTTON_STATE_UNMUTE, true); VoIPService.getSharedInstance().setMicMute(true, false, true); - muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } } }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java index 1324115e1..82304990d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java @@ -75,6 +75,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; +import tw.nekomimi.nekogram.NekoConfig; + public class ManageLinksActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { private ListAdapter listViewAdapter; @@ -651,7 +653,9 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen if ((position >= linksStartRow && position < linksEndRow) || (position >= revokedLinksStartRow && position < revokedLinksEndRow)) { LinkCell cell = (LinkCell) view; cell.optionsView.callOnClick(); - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + if (!NekoConfig.disableVibration) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } return true; } return false;