mirror of
https://gitee.com/shuto-github/phonegap-mobile-accessibility.git
synced 2026-05-26 00:00:06 +08:00
add reduce motion for ios
limit reduce motion check to iOS 8+
This commit is contained in:
committed by
Michael Jordan
parent
e989af802c
commit
dbfde0134d
@@ -31,6 +31,7 @@ static const int BASE_UI_FONT_TEXT_STYLE_BODY_POINT_SIZE = 16;
|
||||
BOOL guidedAccessEnabled;
|
||||
BOOL invertColorsEnabled;
|
||||
BOOL monoAudioEnabled;
|
||||
BOOL reduceMotionEnabled;
|
||||
}
|
||||
|
||||
@property (strong) NSString* callbackId;
|
||||
@@ -40,6 +41,7 @@ static const int BASE_UI_FONT_TEXT_STYLE_BODY_POINT_SIZE = 16;
|
||||
@property BOOL guidedAccessEnabled;
|
||||
@property BOOL invertColorsEnabled;
|
||||
@property BOOL monoAudioEnabled;
|
||||
@property BOOL reduceMotionEnabled;
|
||||
@property double mFontScale;
|
||||
|
||||
|
||||
@@ -51,6 +53,7 @@ static const int BASE_UI_FONT_TEXT_STYLE_BODY_POINT_SIZE = 16;
|
||||
- (void) getTextZoom:(CDVInvokedUrlCommand*)command;
|
||||
- (void) setTextZoom:(CDVInvokedUrlCommand*)command;
|
||||
- (void) updateTextZoom:(CDVInvokedUrlCommand*)command;
|
||||
- (void) isReduceMotionEnabled:(CDVInvokedUrlCommand*)command;
|
||||
- (void) postNotification:(CDVInvokedUrlCommand*)command;
|
||||
- (void) start:(CDVInvokedUrlCommand*)command;
|
||||
- (void) stop:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@@ -39,8 +39,10 @@
|
||||
@synthesize invertColorsEnabled;
|
||||
@synthesize monoAudioEnabled;
|
||||
@synthesize mFontScale;
|
||||
@synthesize reduceMotionEnabled;
|
||||
|
||||
#define iOS7Delta (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 ) ? 20 : 0 )
|
||||
#define iOS8Delta (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 ) ? 30 : 0 )
|
||||
|
||||
// //////////////////////////////////////////////////
|
||||
|
||||
@@ -215,6 +217,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)isReduceMotionEnabled:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self.commandDelegate runInBackground:^{
|
||||
if (iOS8Delta) {
|
||||
self.reduceMotionEnabled = UIAccessibilityIsReduceMotionEnabled();
|
||||
} else {
|
||||
self.reduceMotionEnabled = false;
|
||||
}
|
||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.reduceMotionEnabled];
|
||||
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (void)postNotification:(CDVInvokedUrlCommand *)command
|
||||
{
|
||||
@@ -309,6 +324,7 @@
|
||||
self.guidedAccessEnabled = UIAccessibilityIsGuidedAccessEnabled();
|
||||
self.invertColorsEnabled = UIAccessibilityIsInvertColorsEnabled();
|
||||
self.monoAudioEnabled = UIAccessibilityIsMonoAudioEnabled();
|
||||
self.reduceMotionEnabled = UIAccessibilityIsReduceMotionEnabled();
|
||||
|
||||
NSMutableDictionary* mobileAccessibilityData = [NSMutableDictionary dictionaryWithCapacity:5];
|
||||
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.voiceOverRunning] forKey:@"isScreenReaderRunning"];
|
||||
@@ -316,6 +332,7 @@
|
||||
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.guidedAccessEnabled] forKey:@"isGuidedAccessEnabled"];
|
||||
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.invertColorsEnabled] forKey:@"isInvertColorsEnabled"];
|
||||
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.monoAudioEnabled] forKey:@"isMonoAudioEnabled"];
|
||||
[mobileAccessibilityData setObject:[NSNumber numberWithBool:self.reduceMotionEnabled] forKey:@"isReduceMotionEnabled"];
|
||||
return mobileAccessibilityData;
|
||||
}
|
||||
|
||||
@@ -330,6 +347,7 @@
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityGuidedAccessStatusDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityMonoAudioStatusDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mobileAccessibilityStatusChanged:) name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
|
||||
|
||||
// Update the callback on start
|
||||
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getMobileAccessibilityStatus]];
|
||||
@@ -356,6 +374,7 @@
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityInvertColorsStatusDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityAnnouncementDidFinishNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityMonoAudioStatusDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIAccessibilityReduceMotionStatusDidChangeNotification object:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user