From 33a3c7645e42c90ca39873ba0c67af30b66a9ec7 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Tue, 8 Oct 2024 23:15:26 +0200 Subject: [PATCH] Change card with volume buttons at most once per second --- .../protect/card_locker/LoyaltyCardViewActivity.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 66bf9f563..ef64ab94c 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -105,16 +105,22 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements final private TaskHandler mTasks = new TaskHandler(); Runnable barcodeImageGenerationFinishedCallback; + private long initTime = System.currentTimeMillis(); + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (settings.useVolumeKeysForNavigation()) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { // Navigate to the previous card - prevNextCard(false); + if (initTime < (System.currentTimeMillis() - 1000)) { + prevNextCard(false); + } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { // Navigate to the next card - prevNextCard(true); + if (initTime < (System.currentTimeMillis() - 1000)) { + prevNextCard(true); + } return true; } }