From e63bc374cf8ed56641f4584e11b18d5a66e97b21 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Fri, 16 Aug 2024 01:13:22 -0700 Subject: [PATCH] Fix defaults and text descriptions --- Source/Settings.xm | 83 ++++++++++++------- YTLitePlus.xm | 6 +- .../ar.lproj/Localizable.strings | 3 + .../bg.lproj/Localizable.strings | 3 + .../de.lproj/Localizable.strings | 3 + .../en.lproj/Localizable.strings | 3 + .../es.lproj/Localizable.strings | 3 + .../fr.lproj/Localizable.strings | 3 + .../ja.lproj/Localizable.strings | 3 + .../pt.lproj/Localizable.strings | 3 + .../ro.lproj/Localizable.strings | 3 + .../ru.lproj/Localizable.strings | 3 + .../template.lproj/Localizable.strings | 3 + .../tr.lproj/Localizable.strings | 3 + .../vi.lproj/Localizable.strings | 3 + .../zh_TW.lproj/Localizable.strings | 3 + 16 files changed, 100 insertions(+), 31 deletions(-) diff --git a/Source/Settings.xm b/Source/Settings.xm index a974503..2c0e14b 100644 --- a/Source/Settings.xm +++ b/Source/Settings.xm @@ -211,11 +211,11 @@ static const NSInteger YTLiteSection = 789; static NSString* (^sectionGestureSelectedModeToString)(GestureMode) = ^(GestureMode sectionIndex) { switch (sectionIndex) { case GestureModeVolume: - return LOC(@"Volume (Beta)"); + return LOC(@"Volume"); case GestureModeBrightness: - return LOC(@"Brightness (Beta)"); + return LOC(@"Brightness"); case GestureModeSeek: - return LOC(@"Seek (Beta)"); + return LOC(@"Seek"); default: return @"Invalid index - Report bug"; } @@ -260,86 +260,114 @@ static const NSInteger YTLiteSection = 789; ]; }; // Configuration picker for deadzone to pick from 0 to 100 pixels with interval of 10 + NSMutableArray *deadzoneValues = [NSMutableArray array]; + for (CGFloat value = 0; value <= 100; value += 10) { + [deadzoneValues addObject:@(value)]; + } YTSettingsSectionItem *deadzonePicker = [YTSettingsSectionItemClass - itemWithTitle:LOC(@"Deadzone (Beta)") + itemWithTitle:LOC(@"Deadzone") + titleDescription:LOC(@"Minimum distance to move before a gesture is recognized") accessibilityIdentifier:nil detailTextBlock:^NSString *() { - return [NSString stringWithFormat:@"%ld px", (long)GetFloat(@"playerGestureDeadzone") * 10]; + return [NSString stringWithFormat:@"%ld px", (long)GetFloat(@"playerGesturesDeadzone")]; } selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { - // Generate rows for deadzone picker + // Generate rows for deadzone picker using the predefined array NSMutableArray *deadzoneRows = [NSMutableArray array]; - for (int i = 0; i <= 10; i++) { + for (NSNumber *deadzoneValue in deadzoneValues) { + CGFloat deadzone = [deadzoneValue floatValue]; [deadzoneRows addObject:[YTSettingsSectionItemClass - checkmarkItemWithTitle:[NSString stringWithFormat:@"%ld px", (long)i * 10] + checkmarkItemWithTitle:[NSString stringWithFormat:@"%ld px", (long)deadzone] selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { - [[NSUserDefaults standardUserDefaults] setInteger:i forKey:@"playerGestureDeadzone"]; + [[NSUserDefaults standardUserDefaults] setFloat:deadzone forKey:@"playerGesturesDeadzone"]; [settingsViewController reloadData]; return YES; } ]]; } + // Determine the index of the currently selected deadzone + CGFloat currentDeadzone = GetFloat(@"playerGesturesDeadzone"); + NSUInteger selectedIndex = [deadzoneValues indexOfObject:@(currentDeadzone)]; + if (selectedIndex == NSNotFound) { + selectedIndex = 0; // Default to the first item if the current deadzone is not found + } // Present deadzone picker when selecting this settings item YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] - initWithNavTitle:LOC(@"Deadzone (Beta)") + initWithNavTitle:LOC(@"Deadzone") pickerSectionTitle:nil rows:deadzoneRows - selectedItemIndex:GetFloat(@"playerGestureDeadzone") + selectedItemIndex:selectedIndex parentResponder:[self parentResponder] ]; [settingsViewController pushViewController:picker]; return YES; } ]; + [sectionItems addObject:deadzonePicker]; + // Configuration picker for sensitivity to pick from 0.5 to 2.0 with interval of 0.1 + NSMutableArray *sensitivityValues = [NSMutableArray array]; + for (CGFloat value = 0.5; value <= 2.0; value += 0.1) { + [sensitivityValues addObject:@(value)]; + } YTSettingsSectionItem *sensitivityPicker = [YTSettingsSectionItemClass - itemWithTitle:LOC(@"Sensitivity (Beta)") + itemWithTitle:LOC(@"Sensitivity") + titleDescription:LOC(@"Multiplier on volume and brightness gestures") accessibilityIdentifier:nil detailTextBlock:^NSString *() { - return [NSString stringWithFormat:@"%.1f", GetFloat(@"playerGestureSensitivity") * 0.1 + 0.5]; + return [NSString stringWithFormat:@"%.1f", GetFloat(@"playerGesturesSensitivity")]; } selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { - // Generate rows for sensitivity picker + // Generate rows for sensitivity picker using the predefined array NSMutableArray *sensitivityRows = [NSMutableArray array]; - for (int i = 5; i <= 20; i++) { + for (NSNumber *sensitivityValue in sensitivityValues) { + CGFloat sensitivity = [sensitivityValue floatValue]; [sensitivityRows addObject:[YTSettingsSectionItemClass - checkmarkItemWithTitle:[NSString stringWithFormat:@"%.1f", i * 0.1] + checkmarkItemWithTitle:[NSString stringWithFormat:@"%.1f", sensitivity] selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { - [[NSUserDefaults standardUserDefaults] setInteger:i forKey:@"playerGestureSensitivity"]; + [[NSUserDefaults standardUserDefaults] setFloat:sensitivity forKey:@"playerGesturesSensitivity"]; [settingsViewController reloadData]; return YES; } ]]; } + // Determine the index of the currently selected sensitivity + CGFloat currentSensitivity = GetFloat(@"playerGesturesSensitivity"); + NSUInteger selectedIndex = [sensitivityValues indexOfObject:@(currentSensitivity)]; + if (selectedIndex == NSNotFound) { + selectedIndex = 0; // Default to the first item if the current sensitivity is not found + } // Present sensitivity picker YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] - initWithNavTitle:LOC(@"Sensitivity (Beta)") + initWithNavTitle:LOC(@"Sensitivity") pickerSectionTitle:nil rows:sensitivityRows - selectedItemIndex:GetFloat(@"playerGestureSensitivity") + selectedItemIndex:selectedIndex parentResponder:[self parentResponder] ]; [settingsViewController pushViewController:picker]; return YES; } ]; + [sectionItems addObject:sensitivityPicker]; // High level gestures menu YTSettingsSectionItem *playerGesturesGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"Player Gestures (Beta)") accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) { NSArray *rows = @[ // Description header item [YTSettingsSectionItemClass - itemWithTitle:nil - accessibilityIdentifier:nil - detailTextBlock:^NSString *() { - return LOC(@"Configure horizontal pan gestures for the player."); - } + itemWithTitle:nil + titleDescription:LOC(@"Configure horizontal pan gestures for the player.") + accessibilityIdentifier:nil + detailTextBlock:nil selectBlock:nil ], + // Toggle for enabling gestures + BASIC_SWITCH(LOC(@"PLAYER_GESTURES_TOGGLE"), nil, @"playerGestures_enabled"), // Pickers for each gesture section - createSectionGestureSelector(@"Top Section (Beta)", @"playerGestureTopSelection"), - createSectionGestureSelector(@"Middle Section (Beta)", @"playerGestureMiddleSelection"), - createSectionGestureSelector(@"Bottom Section (Beta)", @"playerGestureBottomSelection"), + createSectionGestureSelector(@"Top Section", @"playerGestureTopSelection"), + createSectionGestureSelector(@"Middle Section", @"playerGestureMiddleSelection"), + createSectionGestureSelector(@"Bottom Section", @"playerGestureBottomSelection"), // Pickers for configuration settings deadzonePicker, sensitivityPicker @@ -372,7 +400,6 @@ static const NSInteger YTLiteSection = 789; BASIC_SWITCH(LOC(@"HIDE_HUD_MESSAGES"), LOC(@"HIDE_HUD_MESSAGES_DESC"), @"hideHUD_enabled"), BASIC_SWITCH(LOC(@"HIDE_COLLAPSE_BUTTON"), LOC(@"HIDE_COLLAPSE_BUTTON_DESC"), @"disableCollapseButton_enabled"), BASIC_SWITCH(LOC(@"HIDE_SPEED_TOAST"), LOC(@"HIDE_SPEED_TOAST_DESC"), @"hideSpeedToast_enabled"), - BASIC_SWITCH(LOC(@"ENABLE_UYOU_GESTURES"), LOC(@"ENABLE_UYOU_GESTURES_DESC"), @"playerGestures_enabled"), ]; YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"VIDEO_CONTROLS_OVERLAY_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:NSNotFound parentResponder:[self parentResponder]]; [settingsViewController pushViewController:picker]; diff --git a/YTLitePlus.xm b/YTLitePlus.xm index fed5597..fc8e947 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -681,7 +681,7 @@ BOOL isTabSelected = NO; // Constant for the deadzone radius that can be changed in the settings static CGFloat deadzoneRadius = (CGFloat)GetFloat(@"playerGesturesDeadzone"); // Constant for the sensitivity factor that can be changed in the settings - static CGFloat sensitivityFactor = (CGFloat)GetFloat(@"playerGestureSensitivity"); + static CGFloat sensitivityFactor = (CGFloat)GetFloat(@"playerGesturesSensitivity"); /***** Helper functions *****/ // Helper function to adjust brightness @@ -1084,7 +1084,7 @@ BOOL isTabSelected = NO; if (![allKeys containsObject:@"playerGesturesDeadzone"]) { [[NSUserDefaults standardUserDefaults] setFloat:20.0 forKey:@"playerGesturesDeadzone"]; } - if (![allKeys containsObject:@"playerGestureSensitivity"]) { - [[NSUserDefaults standardUserDefaults] setFloat:1.0 forKey:@"playerGestureSensitivity"]; + if (![allKeys containsObject:@"playerGesturesSensitivity"]) { + [[NSUserDefaults standardUserDefaults] setFloat:1.0 forKey:@"playerGesturesSensitivity"]; } } diff --git a/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings index ce93d10..88493c7 100644 --- a/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ar.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "خيارات تراكب ضوابط الفيديو"; diff --git a/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings b/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings index 076d430..a5dbeda 100644 --- a/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/bg.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Заменете бутоните 'Копиране на настройки' и 'Поставяне на настройки'"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Заменете бутоните с 'Експортиране на настройки' и 'Импортиране на настройки'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Опции за контрол на видеото"; diff --git a/lang/YTLitePlus.bundle/de.lproj/Localizable.strings b/lang/YTLitePlus.bundle/de.lproj/Localizable.strings index da044fe..07b2ada 100644 --- a/lang/YTLitePlus.bundle/de.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/de.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Overlay-Optionen für Videosteuerungen"; diff --git a/lang/YTLitePlus.bundle/en.lproj/Localizable.strings b/lang/YTLitePlus.bundle/en.lproj/Localizable.strings index 4af6499..618bcb2 100644 --- a/lang/YTLitePlus.bundle/en.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/en.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Video Controls Overlay Options"; diff --git a/lang/YTLitePlus.bundle/es.lproj/Localizable.strings b/lang/YTLitePlus.bundle/es.lproj/Localizable.strings index 83a74d7..69d06dd 100644 --- a/lang/YTLitePlus.bundle/es.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/es.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Opciones de superposición de controles de vídeo"; diff --git a/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings b/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings index 74e2201..f5b24b8 100644 --- a/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/fr.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Options de l'overlay des contrôles vidéo"; diff --git a/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings index 6400844..5dd4f3c 100644 --- a/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ja.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "動画コントロールオーバーレイの設定"; diff --git a/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings b/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings index f9200e3..c8e734d 100644 --- a/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/pt.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Substituir os Botões 'Copiar Configurações' e 'Colar Configurações'"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Substitui os Botões 'Exportar Configurações' e 'Importar Configurações'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Opções de Sobreposição de Controles de Vídeo"; diff --git a/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings index fac3b20..3be083e 100644 --- a/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ro.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Opțiuni Overlay Controale Video"; diff --git a/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings b/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings index 11889b4..0efbea6 100644 --- a/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/ru.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Video Controls Overlay Options"; diff --git a/lang/YTLitePlus.bundle/template.lproj/Localizable.strings b/lang/YTLitePlus.bundle/template.lproj/Localizable.strings index 473514e..5efa1cd 100644 --- a/lang/YTLitePlus.bundle/template.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/template.lproj/Localizable.strings @@ -28,6 +28,9 @@ https://github.com/PoomSmart/Return-YouTube-Dislikes/tree/main/layout/Library/Ap "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Video Controls Overlay Options"; diff --git a/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings b/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings index 62afeea..815d24a 100644 --- a/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/tr.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "'Ayarları Kopyala' ve 'Ayarları Yapıştır' Düğmelerini Değiştir"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Düğmeleri 'Ayarları Dışa Aktar' ve 'Ayarları İçe Aktar' ile değiştirir"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "Video Kontrol Seç."; diff --git a/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings b/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings index d8dea0e..af9750c 100644 --- a/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/vi.lproj/Localizable.strings @@ -13,6 +13,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video player options "VIDEO_PLAYER_OPTIONS" = "Tùy chọn trình phát video"; diff --git a/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings b/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings index 7fd520a..47ef9c2 100644 --- a/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings +++ b/lang/YTLitePlus.bundle/zh_TW.lproj/Localizable.strings @@ -14,6 +14,9 @@ "REPLACE_COPY_AND_PASTE_BUTTONS" = "Replace 'Copy Settings' & 'Paste Settings' Buttons"; "REPLACE_COPY_AND_PASTE_BUTTONS_DESC" = "Replaces the Buttons to 'Export Settings' and 'Import Settings'"; +// Player Gestures +"PLAYER_GESTURES_TOGGLE" = "Enable Player Gestures"; + // Video controls overlay options "VIDEO_CONTROLS_OVERLAY_OPTIONS" = "影片區覆蓋按鈕設定";