Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility features #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion Source/Classes/MUAdvancedAudioPreferencesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfac
#pragma mark - Table view data source

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
return 5;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
Expand All @@ -81,6 +81,8 @@ - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSIntege
return 2;
} else if (section == 3) {
return 1;
} else if (section == 4) {
return 1;
}
return 0;
}
Expand Down Expand Up @@ -182,6 +184,17 @@ - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(
[celtSwitch addTarget:self action:@selector(opusCodecForceCELTModeChanged:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = celtSwitch;
}
} else if ([indexPath section] == 4) {
if ([indexPath row] == 0) {
cell.textLabel.text = NSLocalizedString(@"PTT button toggle", nil);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UISwitch *pttToggleSwitch = [[[UISwitch alloc] init] autorelease];
pttToggleSwitch.onTintColor = [UIColor blackColor];
pttToggleSwitch.on = [defaults boolForKey:@"pttToggle"];
pttToggleSwitch.enabled = YES;
[pttToggleSwitch addTarget:self action:@selector(pttToggleChanged:) forControlEvents:UIControlEventValueChanged];
cell.accessoryView = pttToggleSwitch;
}
}

return cell;
Expand All @@ -196,6 +209,8 @@ - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSIntege
return [MUTableViewHeaderLabel labelWithText:NSLocalizedString(@"Audio Output", nil)];
} else if (section == 3) { // Opus Codec
return [MUTableViewHeaderLabel labelWithText:NSLocalizedString(@"Opus Codec", nil)];
} else if (section == 4) { // PTT Toggle
return [MUTableViewHeaderLabel labelWithText:NSLocalizedString(@"PTT Button", nil)];
} else {
return nil;
}
Expand All @@ -210,6 +225,8 @@ - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteg
return [MUTableViewHeaderLabel defaultHeaderHeight];
} else if (section == 3) {
return [MUTableViewHeaderLabel defaultHeaderHeight];
} else if (section == 4) {
return [MUTableViewHeaderLabel defaultHeaderHeight];
}
return 0.0f;
}
Expand Down Expand Up @@ -283,6 +300,10 @@ - (void) opusCodecForceCELTModeChanged:(UISwitch *)sender {
[[NSUserDefaults standardUserDefaults] setBool:sender.on forKey:@"AudioOpusCodecForceCELTMode"];
}

- (void) pttToggleChanged:(UISwitch *)sender {
[[NSUserDefaults standardUserDefaults] setBool:sender.on forKey:@"pttToggle"];
}

- (void) audioSubsystemRestarted:(NSNotification *)notification {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AudioPreprocessor"]) {
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
Expand Down
1 change: 1 addition & 0 deletions Source/Classes/MUApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:
[NSNumber numberWithFloat:0.2f], @"AudioSidetoneVolume",
[NSNumber numberWithBool:YES], @"AudioSpeakerPhoneMode",
[NSNumber numberWithBool:YES], @"AudioOpusCodecForceCELTMode",
[NSNumber numberWithBool:NO], @"pttToggle",
// Network
[NSNumber numberWithBool:NO], @"NetworkForceTCP",
@"MumbleUser", @"DefaultUserName",
Expand Down
23 changes: 21 additions & 2 deletions Source/Classes/MUServerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

#import <MumbleKit/MKAudio.h>

#import <AudioToolbox/AudioServices.h>
#import <UIKit/UIKit.h>

#pragma mark -
#pragma mark MUChannelNavigationItem

Expand Down Expand Up @@ -139,8 +142,15 @@ - (void) viewDidAppear:(BOOL)animated {
[_talkButton setAlpha:0.80f];
[window addSubview:_talkButton];

[_talkButton addTarget:self action:@selector(talkOn:) forControlEvents:UIControlEventTouchDown];
[_talkButton addTarget:self action:@selector(talkOff:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pttToggle"]) {
[_talkButton addTarget:self action:@selector(talkToggle:) forControlEvents:UIControlEventTouchDown];
} else {
[_talkButton addTarget:self action:@selector(talkOn:) forControlEvents:UIControlEventTouchDown];
[_talkButton addTarget:self action:@selector(talkOff:) forControlEvents:UIControlEventTouchUpInside|UIControlEventTouchUpOutside];
}

UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
_talkButton);

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repositionTalkButton) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
[self repositionTalkButton];
Expand Down Expand Up @@ -598,6 +608,7 @@ - (void) repositionTalkButton {
}

- (void) talkOn:(UIButton *)button {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
[button setAlpha:1.0f];
[[MKAudio sharedAudio] setForceTransmit:YES];
}
Expand All @@ -607,6 +618,14 @@ - (void) talkOff:(UIButton *)button {
[[MKAudio sharedAudio] setForceTransmit:NO];
}

- (void) talkToggle:(UIButton *)button {
if ([[MKAudio sharedAudio] forceTransmit]) {
[self talkOff: button];
} else {
[self talkOn: button];
}
}

#pragma mark - Mode switch

- (void) toggleMode {
Expand Down