mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Platform: Remove compatibility checks for iOS 10
This commit is contained in:
parent
e71ebb3407
commit
6428f43eeb
6 changed files with 153 additions and 367 deletions
|
|
@ -298,10 +298,8 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater
|
|||
{
|
||||
options |= AVAudioSessionCategoryOptionDefaultToSpeaker
|
||||
| AVAudioSessionCategoryOptionAllowBluetooth
|
||||
| AVAudioSessionCategoryOptionAllowAirPlay;
|
||||
|
||||
if (@available (iOS 10.0, *))
|
||||
options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP;
|
||||
| AVAudioSessionCategoryOptionAllowAirPlay
|
||||
| AVAudioSessionCategoryOptionAllowBluetoothA2DP;
|
||||
}
|
||||
|
||||
JUCE_NSERROR_CHECK ([[AVAudioSession sharedInstance] setCategory: category
|
||||
|
|
@ -738,19 +736,10 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater
|
|||
&hostUrl,
|
||||
&dataSize);
|
||||
if (err == noErr)
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
[[UIApplication sharedApplication] openURL: (NSURL*) hostUrl
|
||||
options: @{}
|
||||
completionHandler: nil];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
[[UIApplication sharedApplication] openURL: (NSURL*) hostUrl];
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -633,7 +633,7 @@ public:
|
|||
{
|
||||
const auto value = (newValue != nullptr ? *newValue : juceParam->getValue()) * getMaximumParameterValue (*juceParam);
|
||||
|
||||
if (@available (macOS 10.12, iOS 10.0, *))
|
||||
if (@available (macOS 10.12, *))
|
||||
{
|
||||
[param setValue: value
|
||||
originator: editorObserverToken.get()
|
||||
|
|
|
|||
|
|
@ -395,18 +395,11 @@ bool JUCE_CALLTYPE Process::openDocument (const String& fileName, [[maybe_unused
|
|||
: [NSURL URLWithString: fileNameAsNS];
|
||||
|
||||
#if JUCE_IOS
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
[[UIApplication sharedApplication] openURL: filenameAsURL
|
||||
options: @{}
|
||||
completionHandler: nil];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
return [[UIApplication sharedApplication] openURL: filenameAsURL];
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
#else
|
||||
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
|
||||
|
||||
|
|
|
|||
|
|
@ -1159,12 +1159,7 @@ static bool doKeysUp (UIViewComponentPeer* owner, NSSet<UIPress*>* presses, UIPr
|
|||
if (auto* target = [self getTextInputTarget])
|
||||
{
|
||||
if (action == @selector (paste:))
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
return [[UIPasteboard generalPasteboard] hasStrings];
|
||||
|
||||
return [[UIPasteboard generalPasteboard] string] != nil;
|
||||
}
|
||||
}
|
||||
|
||||
return [super canPerformAction: action withSender: sender];
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ struct PushNotificationsDelegateDetails
|
|||
using Category = PushNotifications::Settings::Category;
|
||||
|
||||
static void* actionToNSAction (const Action& a)
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
if (a.style == Action::text)
|
||||
{
|
||||
|
|
@ -59,27 +57,7 @@ struct PushNotificationsDelegateDetails
|
|||
options: NSUInteger (a.destructive << 1 | (! a.triggerInBackground) << 2)];
|
||||
}
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
auto action = [[UIMutableUserNotificationAction alloc] init];
|
||||
|
||||
action.identifier = juceStringToNS (a.identifier);
|
||||
action.title = juceStringToNS (a.title);
|
||||
action.behavior = a.style == Action::text ? UIUserNotificationActionBehaviorTextInput
|
||||
: UIUserNotificationActionBehaviorDefault;
|
||||
action.parameters = varToNSDictionary (a.parameters);
|
||||
action.activationMode = a.triggerInBackground ? UIUserNotificationActivationModeBackground
|
||||
: UIUserNotificationActivationModeForeground;
|
||||
action.destructive = (bool) a.destructive;
|
||||
|
||||
[action autorelease];
|
||||
|
||||
return action;
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
|
||||
static void* categoryToNSCategory (const Category& c)
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
auto actions = [NSMutableArray arrayWithCapacity: (NSUInteger) c.actions.size()];
|
||||
|
||||
|
|
@ -95,27 +73,6 @@ struct PushNotificationsDelegateDetails
|
|||
options: c.sendDismissAction ? UNNotificationCategoryOptionCustomDismissAction : 0];
|
||||
}
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
auto category = [[UIMutableUserNotificationCategory alloc] init];
|
||||
category.identifier = juceStringToNS (c.identifier);
|
||||
|
||||
auto actions = [NSMutableArray arrayWithCapacity: (NSUInteger) c.actions.size()];
|
||||
|
||||
for (const auto& a : c.actions)
|
||||
{
|
||||
auto* action = (UIUserNotificationAction*) actionToNSAction (a);
|
||||
[actions addObject: action];
|
||||
}
|
||||
|
||||
[category setActions: actions forContext: UIUserNotificationActionContextDefault];
|
||||
[category setActions: actions forContext: UIUserNotificationActionContextMinimal];
|
||||
|
||||
[category autorelease];
|
||||
|
||||
return category;
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
static UILocalNotification* juceNotificationToUILocalNotification (const PushNotifications::Notification& n)
|
||||
|
|
@ -418,10 +375,7 @@ private:
|
|||
//==============================================================================
|
||||
bool PushNotifications::Notification::isValid() const noexcept
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
return title.isNotEmpty() && body.isNotEmpty() && identifier.isNotEmpty() && category.isNotEmpty();
|
||||
|
||||
return title.isNotEmpty() && body.isNotEmpty() && category.isNotEmpty();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -446,8 +400,6 @@ struct PushNotifications::Pimpl
|
|||
|
||||
auto categories = [NSMutableSet setWithCapacity: (NSUInteger) settings.categories.size()];
|
||||
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
for (const auto& c : settings.categories)
|
||||
{
|
||||
auto* category = (UNNotificationCategory*) PushNotificationsDelegateDetails::categoryToNSCategory (c);
|
||||
|
|
@ -464,33 +416,11 @@ struct PushNotifications::Pimpl
|
|||
{
|
||||
requestSettingsUsed();
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
|
||||
for (const auto& c : settings.categories)
|
||||
{
|
||||
auto* category = (UIUserNotificationCategory*) PushNotificationsDelegateDetails::categoryToNSCategory (c);
|
||||
[categories addObject: category];
|
||||
}
|
||||
|
||||
UIUserNotificationType type = NSUInteger ((bool)settings.allowBadge << 0
|
||||
| (bool)settings.allowSound << 1
|
||||
| (bool)settings.allowAlert << 2);
|
||||
|
||||
UIUserNotificationSettings* s = [UIUserNotificationSettings settingsForTypes: type categories: categories];
|
||||
[[UIApplication sharedApplication] registerUserNotificationSettings: s];
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
|
||||
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
}
|
||||
|
||||
void requestSettingsUsed()
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:
|
||||
^(UNNotificationSettings* s)
|
||||
|
|
@ -508,33 +438,12 @@ struct PushNotifications::Pimpl
|
|||
owner.listeners.call ([&] (Listener& l) { l.notificationSettingsReceived (settings); });
|
||||
}
|
||||
];
|
||||
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
|
||||
UIUserNotificationSettings* s = [UIApplication sharedApplication].currentUserNotificationSettings;
|
||||
|
||||
settings.allowBadge = s.types & UIUserNotificationTypeBadge;
|
||||
settings.allowSound = s.types & UIUserNotificationTypeSound;
|
||||
settings.allowAlert = s.types & UIUserNotificationTypeAlert;
|
||||
|
||||
for (UIUserNotificationCategory *c in s.categories)
|
||||
settings.categories.add (PushNotificationsDelegateDetails::uiUserNotificationCategoryToCategory (c));
|
||||
|
||||
owner.listeners.call ([&] (Listener& l) { l.notificationSettingsReceived (settings); });
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
}
|
||||
|
||||
bool areNotificationsEnabled() const { return true; }
|
||||
|
||||
void sendLocalNotification (const Notification& n)
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
UNNotificationRequest* request = PushNotificationsDelegateDetails::juceNotificationToUNNotificationRequest (n);
|
||||
|
||||
|
|
@ -547,22 +456,8 @@ struct PushNotifications::Pimpl
|
|||
NSLog (nsStringLiteral ("addNotificationRequest error: %@"), error);
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
|
||||
auto* notification = PushNotificationsDelegateDetails::juceNotificationToUILocalNotification (n);
|
||||
|
||||
[[UIApplication sharedApplication] scheduleLocalNotification: notification];
|
||||
[notification release];
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
}
|
||||
|
||||
void getDeliveredNotifications() const
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
[[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:
|
||||
^(NSArray<UNNotification*>* notifications)
|
||||
|
|
@ -575,50 +470,24 @@ struct PushNotifications::Pimpl
|
|||
owner.listeners.call ([&] (Listener& l) { l.deliveredNotificationsListReceived (notifs); });
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not supported on this platform
|
||||
jassertfalse;
|
||||
owner.listeners.call ([] (Listener& l) { l.deliveredNotificationsListReceived ({}); });
|
||||
}
|
||||
}
|
||||
|
||||
void removeAllDeliveredNotifications()
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not supported on this platform
|
||||
jassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
void removeDeliveredNotification ([[maybe_unused]] const String& identifier)
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
|
||||
NSArray<NSString*>* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)];
|
||||
|
||||
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers: identifiers];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not supported on this platform
|
||||
jassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
void setupChannels ([[maybe_unused]] const Array<ChannelGroup>& groups, [[maybe_unused]] const Array<Channel>& channels)
|
||||
{
|
||||
}
|
||||
|
||||
void getPendingLocalNotifications() const
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
[[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:
|
||||
^(NSArray<UNNotificationRequest*>* requests)
|
||||
|
|
@ -629,54 +498,19 @@ struct PushNotifications::Pimpl
|
|||
notifs.add (PushNotificationsDelegateDetails::unNotificationRequestToJuceNotification (r));
|
||||
|
||||
owner.listeners.call ([&] (Listener& l) { l.pendingLocalNotificationsListReceived (notifs); });
|
||||
}
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
|
||||
Array<PushNotifications::Notification> notifs;
|
||||
|
||||
for (UILocalNotification* n in [UIApplication sharedApplication].scheduledLocalNotifications)
|
||||
notifs.add (PushNotificationsDelegateDetails::uiLocalNotificationToJuceNotification (n));
|
||||
|
||||
owner.listeners.call ([&] (Listener& l) { l.pendingLocalNotificationsListReceived (notifs); });
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
void removePendingLocalNotification (const String& identifier)
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
NSArray<NSString*>* identifiers = [NSArray arrayWithObject: juceStringToNS (identifier)];
|
||||
|
||||
[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers: identifiers];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not supported on this platform
|
||||
jassertfalse;
|
||||
}
|
||||
}
|
||||
|
||||
void removeAllPendingLocalNotifications()
|
||||
{
|
||||
if (@available (iOS 10, *))
|
||||
{
|
||||
[[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests];
|
||||
}
|
||||
else
|
||||
{
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
|
||||
|
||||
[[UIApplication sharedApplication] cancelAllLocalNotifications];
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
}
|
||||
}
|
||||
|
||||
String getDeviceToken()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -146,15 +146,12 @@ struct CameraDevice::Pimpl
|
|||
|
||||
private:
|
||||
static NSArray<AVCaptureDevice*>* getDevices()
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
std::unique_ptr<NSMutableArray<AVCaptureDeviceType>, NSObjectDeleter> deviceTypes ([[NSMutableArray alloc] initWithCapacity: 2]);
|
||||
|
||||
[deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInWideAngleCamera];
|
||||
[deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInTelephotoCamera];
|
||||
|
||||
if (@available (iOS 10.2, *))
|
||||
[deviceTypes.get() addObject: AVCaptureDeviceTypeBuiltInDualCamera];
|
||||
|
||||
if (@available (iOS 11.1, *))
|
||||
|
|
@ -167,9 +164,6 @@ private:
|
|||
return [discoverySession devices];
|
||||
}
|
||||
|
||||
return [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void printDebugCameraInfo (AVCaptureDevice* device)
|
||||
{
|
||||
|
|
@ -211,11 +205,8 @@ private:
|
|||
JUCE_CAMERA_LOG ("Supports custom exposure: " + String ((int)[device isExposureModeSupported: AVCaptureExposureModeCustom]));
|
||||
JUCE_CAMERA_LOG ("Supports point of interest exposure: " + String ((int)device.exposurePointOfInterestSupported));
|
||||
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
JUCE_CAMERA_LOG ("Device type: " + nsStringToJuce (device.deviceType));
|
||||
JUCE_CAMERA_LOG ("Locking focus with custom lens position supported: " + String ((int)device.lockingFocusWithCustomLensPositionSupported));
|
||||
}
|
||||
|
||||
if (@available (iOS 11.0, *))
|
||||
{
|
||||
|
|
@ -238,8 +229,6 @@ private:
|
|||
{
|
||||
JUCE_CAMERA_LOG ("Media type: " + nsStringToJuce (format.mediaType));
|
||||
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
String colourSpaces;
|
||||
|
||||
for (NSNumber* number in format.supportedColorSpaces)
|
||||
|
|
@ -253,7 +242,6 @@ private:
|
|||
}
|
||||
|
||||
JUCE_CAMERA_LOG ("Supported colour spaces: " + colourSpaces);
|
||||
}
|
||||
|
||||
JUCE_CAMERA_LOG ("Video field of view: " + String (format.videoFieldOfView));
|
||||
JUCE_CAMERA_LOG ("Video max zoom factor: " + String (format.videoMaxZoomFactor));
|
||||
|
|
@ -581,13 +569,10 @@ private:
|
|||
: captureSession (cs),
|
||||
captureOutput (createCaptureOutput()),
|
||||
photoOutputDelegate (nullptr)
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
static PhotoOutputDelegateClass cls;
|
||||
photoOutputDelegate.reset ([cls.createInstance() init]);
|
||||
PhotoOutputDelegateClass::setOwner (photoOutputDelegate.get(), this);
|
||||
}
|
||||
|
||||
captureSession.addOutputIfPossible (captureOutput);
|
||||
}
|
||||
|
|
@ -606,8 +591,6 @@ private:
|
|||
printImageOutputDebugInfo (captureOutput);
|
||||
|
||||
if (auto* connection = findVideoConnection (captureOutput))
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]])
|
||||
{
|
||||
|
|
@ -620,7 +603,6 @@ private:
|
|||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto* stillImageOutput = (AVCaptureStillImageOutput*) captureOutput;
|
||||
auto outputConnection = [stillImageOutput connectionWithMediaType: AVMediaTypeVideo];
|
||||
|
|
@ -657,15 +639,10 @@ private:
|
|||
private:
|
||||
static AVCaptureOutput* createCaptureOutput()
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
return [AVCapturePhotoOutput new];
|
||||
|
||||
return [AVCaptureStillImageOutput new];
|
||||
}
|
||||
|
||||
static void printImageOutputDebugInfo (AVCaptureOutput* captureOutput)
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
{
|
||||
if ([captureOutput isKindOfClass: [AVCapturePhotoOutput class]])
|
||||
{
|
||||
|
|
@ -717,7 +694,6 @@ private:
|
|||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto* stillImageOutput = (AVCaptureStillImageOutput*) captureOutput;
|
||||
|
||||
|
|
@ -745,7 +721,7 @@ private:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
class API_AVAILABLE (ios (10.0)) PhotoOutputDelegateClass : public ObjCClass<NSObject>
|
||||
class PhotoOutputDelegateClass : public ObjCClass<NSObject>
|
||||
{
|
||||
public:
|
||||
PhotoOutputDelegateClass() : ObjCClass<NSObject> ("PhotoOutputDelegateClass_")
|
||||
|
|
@ -996,7 +972,6 @@ private:
|
|||
|
||||
void startRecording (const File& file, AVCaptureVideoOrientation orientationToUse)
|
||||
{
|
||||
if (@available (iOS 10.0, *))
|
||||
printVideoOutputDebugInfo (movieFileOutput);
|
||||
|
||||
auto url = [NSURL fileURLWithPath: juceStringToNS (file.getFullPathName())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue