Fix playback in feeds on iPad

This commit is contained in:
Bryce Hackel
2024-08-20 18:14:02 -07:00
parent 2ece340746
commit 8eed3ce8bc
3 changed files with 20 additions and 14 deletions

View File

@@ -266,7 +266,7 @@ static const NSInteger YTLiteSection = 789;
return [YTSettingsSectionItemClass itemWithTitle:LOC(sectionLabel)
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
return sectionGestureSelectedModeToString(GetSelection(sectionKey));
return sectionGestureSelectedModeToString(GetInteger(sectionKey));
}
selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger arg1) {
NSArray <YTSettingsSectionItem *> *rows = @[
@@ -280,7 +280,7 @@ static const NSInteger YTLiteSection = 789;
initWithNavTitle:LOC(sectionLabel)
pickerSectionTitle:nil
rows:rows
selectedItemIndex:GetSelection(sectionKey)
selectedItemIndex:GetInteger(sectionKey)
parentResponder:[self parentResponder]
];
[settingsViewController pushViewController:picker];
@@ -559,7 +559,7 @@ static const NSInteger YTLiteSection = 789;
YTSettingsSectionItem *themeGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"THEME_OPTIONS")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
switch (GetSelection(@"appTheme")) {
switch (GetInteger(@"appTheme")) {
case 1:
return LOC(@"OLD_DARK_THEME");
case 0:
@@ -583,7 +583,7 @@ static const NSInteger YTLiteSection = 789;
BASIC_SWITCH(LOC(@"LOW_CONTRAST_MODE"), LOC(@"LOW_CONTRAST_MODE_DESC"), @"lowContrastMode_enabled"),
lowContrastModeSection
];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"THEME_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:GetSelection(@"appTheme") parentResponder:[self parentResponder]];
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"THEME_OPTIONS") pickerSectionTitle:nil rows:rows selectedItemIndex:GetInteger(@"appTheme") parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];
return YES;
}];
@@ -595,7 +595,8 @@ static const NSInteger YTLiteSection = 789;
YTSettingsSectionItem *playbackInFeedsGroup = [YTSettingsSectionItemClass itemWithTitle:LOC(@"PLAYBACK_IN_FEEDS")
accessibilityIdentifier:nil
detailTextBlock:^NSString *() {
switch (GetSelection(@"inline_muted_playback_enabled")) {
// The specific values were gathered by checking the value for each setting
switch (GetInteger(@"inline_muted_playback_enabled")) {
case 3:
return LOC(@"PLAYBACK_IN_FEEDS_WIFI_ONLY");
case 1:
@@ -624,9 +625,14 @@ static const NSInteger YTLiteSection = 789;
}],
];
// It seems values greater than 3 act the same as Always On (Index 1)
int (^getInlineSelection)() = ^int() {
int selection = GetSelection(@"inline_muted_playback_enabled") - 1;
return selection > 3 ? 1 : selection;
// Convert the stored value to an index for a picker (0 to 2)
NSInteger (^getInlineSelection)(void) = ^NSInteger(void) {
NSInteger selection = GetInteger(@"inline_muted_playback_enabled") - 1;
// Check if selection is within the valid bounds [0, 1, 2]
if (selection < 0 || selection > 2) {
return 1;
}
return selection;
};
YTSettingsPickerViewController *picker = [[%c(YTSettingsPickerViewController) alloc] initWithNavTitle:LOC(@"PLAYBACK_IN_FEEDS") pickerSectionTitle:nil rows:rows selectedItemIndex:getInlineSelection() parentResponder:[self parentResponder]];
[settingsViewController pushViewController:picker];

View File

@@ -59,8 +59,8 @@
// Helper methods for key retrieval
#define IsEnabled(key) [[NSUserDefaults standardUserDefaults] boolForKey:key]
#define GetSelection(key) [[NSUserDefaults standardUserDefaults] integerForKey:key]
#define GetFloat(key) [[NSUserDefaults standardUserDefaults] floatForKey:key]
#define GetInteger(key) [[NSUserDefaults standardUserDefaults] integerForKey:key] // NSInteger type
#define GetFloat(key) [[NSUserDefaults standardUserDefaults] floatForKey:key] // float type
// Player Gesture selected mode enum

View File

@@ -723,7 +723,7 @@ BOOL isTabSelected = NO;
void (^runSelectedGesture)(NSString*, CGFloat, CGFloat, CGFloat, CGFloat)
= ^(NSString *sectionKey, CGFloat translationX, CGFloat initialBrightness, CGFloat initialVolume, CGFloat currentTime) {
// Determine the selected gesture mode using the section key
GestureMode selectedGestureMode = (GestureMode)GetSelection(sectionKey);
GestureMode selectedGestureMode = (GestureMode)GetInteger(sectionKey);
// Handle the gesture action based on the selected mode
switch (selectedGestureMode) {
case GestureModeVolume:
@@ -760,21 +760,21 @@ BOOL isTabSelected = NO;
if (startLocation.y <= viewHeight / 3.0) {
gestureSection = GestureSectionTop;
// Cancel the gesture if the mode is disabled
if (GetSelection(@"playerGestureTopSelection") == GestureModeDisabled) {
if (GetInteger(@"playerGestureTopSelection") == GestureModeDisabled) {
panGestureRecognizer.state = UIGestureRecognizerStateCancelled;
return;
}
} else if (startLocation.y <= 2 * viewHeight / 3.0) {
gestureSection = GestureSectionMiddle;
// Cancel the gesture if the mode is disabled
if (GetSelection(@"playerGestureMiddleSelection") == GestureModeDisabled) {
if (GetInteger(@"playerGestureMiddleSelection") == GestureModeDisabled) {
panGestureRecognizer.state = UIGestureRecognizerStateCancelled;
return;
}
} else if (startLocation.y <= viewHeight) {
gestureSection = GestureSectionBottom;
// Cancel the gesture if the mode is disabled
if (GetSelection(@"playerGestureBottomSelection") == GestureModeDisabled) {
if (GetInteger(@"playerGestureBottomSelection") == GestureModeDisabled) {
panGestureRecognizer.state = UIGestureRecognizerStateCancelled;
return;
}