mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
ScopedMessageBox: Replace old AlertWindow uses with new API
This commit is contained in:
parent
79ed81c24a
commit
39a731de46
55 changed files with 893 additions and 677 deletions
|
|
@ -156,12 +156,13 @@ private:
|
|||
voiceProduct.purchasePrice = "In-App purchases unavailable";
|
||||
}
|
||||
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"In-app purchase is unavailable!",
|
||||
"In-App purchases are not available. This either means you are trying "
|
||||
"to use IAP on a platform that does not support IAP or you haven't setup "
|
||||
"your app correctly to work with IAP.",
|
||||
"OK");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"In-app purchase is unavailable!",
|
||||
"In-App purchases are not available. This either means you are trying "
|
||||
"to use IAP on a platform that does not support IAP or you haven't setup "
|
||||
"your app correctly to work with IAP.",
|
||||
"OK");
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -178,11 +179,12 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Your credit card will be charged!",
|
||||
"You are running the sample code for JUCE In-App purchases. "
|
||||
"Although this is only sample code, it will still CHARGE YOUR CREDIT CARD!",
|
||||
"Understood!");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"Your credit card will be charged!",
|
||||
"You are running the sample code for JUCE In-App purchases. "
|
||||
"Although this is only sample code, it will still CHARGE YOUR CREDIT CARD!",
|
||||
"Understood!");
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
guiUpdater.triggerAsyncUpdate();
|
||||
|
|
@ -264,6 +266,7 @@ private:
|
|||
AsyncUpdater& guiUpdater;
|
||||
bool havePurchasesBeenRestored = false, havePricesBeenFetched = false, purchaseInProgress = false;
|
||||
Array<VoiceProduct> voiceProducts;
|
||||
ScopedMessageBox messageBox;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VoicePurchases)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -222,16 +222,17 @@ private:
|
|||
//==============================================================================
|
||||
void showConnectionErrorMessage (const String& messageText)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Connection error",
|
||||
messageText,
|
||||
"OK");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"Connection error",
|
||||
messageText);
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Slider rotaryKnob;
|
||||
OSCSender sender1, sender2;
|
||||
Label senderLabel { {}, "Sender" };
|
||||
ScopedMessageBox messageBox;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSCSenderDemo)
|
||||
};
|
||||
|
|
@ -273,15 +274,16 @@ private:
|
|||
|
||||
void showConnectionErrorMessage (const String& messageText)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Connection error",
|
||||
messageText,
|
||||
"OK");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"Connection error",
|
||||
messageText);
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Slider rotaryKnob;
|
||||
Label receiverLabel { {}, "Receiver" };
|
||||
ScopedMessageBox messageBox;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSCReceiverDemo)
|
||||
};
|
||||
|
|
@ -403,28 +405,28 @@ private:
|
|||
//==============================================================================
|
||||
void handleConnectError (int failedPort)
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"OSC Connection error",
|
||||
"Error: could not connect to port " + String (failedPort),
|
||||
"OK");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"OSC Connection error",
|
||||
"Error: could not connect to port " + String (failedPort));
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void handleDisconnectError()
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Unknown error",
|
||||
"An unknown error occurred while trying to disconnect from UDP port.",
|
||||
"OK");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"Unknown error",
|
||||
"An unknown error occurred while trying to disconnect from UDP port.");
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void handleInvalidPortNumberEntered()
|
||||
{
|
||||
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
|
||||
"Invalid port number",
|
||||
"Error: you have entered an invalid UDP port number.",
|
||||
"OK");
|
||||
auto options = MessageBoxOptions::makeOptionsOk (MessageBoxIconType::WarningIcon,
|
||||
"Invalid port number",
|
||||
"Error: you have entered an invalid UDP port number.");
|
||||
messageBox = AlertWindow::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -457,6 +459,8 @@ private:
|
|||
connectionStatusLabel.setJustificationType (Justification::centredRight);
|
||||
}
|
||||
|
||||
ScopedMessageBox messageBox;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSCMonitorDemo)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -185,21 +185,25 @@ public:
|
|||
{ PushNotifications::getInstance()->removeAllPendingLocalNotifications(); };
|
||||
#endif
|
||||
|
||||
remoteView.getDeviceTokenButton.onClick = []
|
||||
remoteView.getDeviceTokenButton.onClick = [this]
|
||||
{
|
||||
String token = PushNotifications::getInstance()->getDeviceToken();
|
||||
|
||||
DBG ("token = " + token);
|
||||
|
||||
if (token.isEmpty())
|
||||
{
|
||||
showRemoteInstructions();
|
||||
}
|
||||
else
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
{
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Device token")
|
||||
.withMessage (token)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if JUCE_ANDROID
|
||||
|
|
@ -313,12 +317,12 @@ private:
|
|||
String requiredFields = "all required fields";
|
||||
#endif
|
||||
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Incorrect notifications setup")
|
||||
.withMessage ("Please make sure that " + requiredFields + " are set.")
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -565,14 +569,14 @@ private:
|
|||
{
|
||||
ignoreUnused (isLocalNotification);
|
||||
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Received notification")
|
||||
.withMessage ("ID: " + n.identifier
|
||||
+ ", title: " + n.title
|
||||
+ ", body: " + n.body)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
void handleNotificationAction (bool isLocalNotification,
|
||||
|
|
@ -582,7 +586,7 @@ private:
|
|||
{
|
||||
ignoreUnused (isLocalNotification);
|
||||
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Received notification action")
|
||||
.withMessage ("ID: " + n.identifier
|
||||
|
|
@ -590,22 +594,22 @@ private:
|
|||
+ ", body: " + n.body
|
||||
+ ", action: " + actionIdentifier
|
||||
+ ", optionalResponse: " + optionalResponse)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
|
||||
PushNotifications::getInstance()->removeDeliveredNotification (n.identifier);
|
||||
}
|
||||
|
||||
void localNotificationDismissedByUser (const PushNotifications::Notification& n) override
|
||||
{
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Notification dismissed by a user")
|
||||
.withMessage ("ID: " + n.identifier
|
||||
+ ", title: " + n.title
|
||||
+ ", body: " + n.body)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
void deliveredNotificationsListReceived (const Array<PushNotifications::Notification>& notifs) override
|
||||
|
|
@ -615,12 +619,12 @@ private:
|
|||
for (auto& n : notifs)
|
||||
text << "(" << n.identifier << ", " << n.title << ", " << n.body << "), ";
|
||||
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Received notification list")
|
||||
.withMessage (text)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
void pendingLocalNotificationsListReceived (const Array<PushNotifications::Notification>& notifs) override
|
||||
|
|
@ -630,54 +634,54 @@ private:
|
|||
for (auto& n : notifs)
|
||||
text << "(" << n.identifier << ", " << n.title << ", " << n.body << "), ";
|
||||
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Pending notification list")
|
||||
.withMessage (text)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
void deviceTokenRefreshed (const String& token) override
|
||||
{
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Device token refreshed")
|
||||
.withMessage (token)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
#if JUCE_ANDROID
|
||||
void remoteNotificationsDeleted() override
|
||||
{
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Remote notifications deleted")
|
||||
.withMessage ("Some of the pending messages were removed!")
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
void upstreamMessageSent (const String& messageId) override
|
||||
{
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Upstream message sent")
|
||||
.withMessage ("Message id: " + messageId)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
void upstreamMessageSendingError (const String& messageId, const String& error) override
|
||||
{
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Upstream message sending error")
|
||||
.withMessage ("Message id: " + messageId
|
||||
+ "\nerror: " + error)
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
}
|
||||
|
||||
static Array<PushNotifications::Channel> getAndroidChannels()
|
||||
|
|
@ -1207,8 +1211,8 @@ private:
|
|||
|
||||
struct DemoTabbedComponent : public TabbedComponent
|
||||
{
|
||||
explicit DemoTabbedComponent (TabbedButtonBar::Orientation orientation)
|
||||
: TabbedComponent (orientation)
|
||||
DemoTabbedComponent (PushNotificationsDemo& demoIn, TabbedButtonBar::Orientation orientation)
|
||||
: TabbedComponent (orientation), demo (demoIn)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1216,27 +1220,28 @@ private:
|
|||
{
|
||||
if (! showedRemoteInstructions && newCurrentTabName == "Remote")
|
||||
{
|
||||
PushNotificationsDemo::showRemoteInstructions();
|
||||
demo.showRemoteInstructions();
|
||||
showedRemoteInstructions = true;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool showedRemoteInstructions = false;
|
||||
PushNotificationsDemo& demo;
|
||||
};
|
||||
|
||||
static void showRemoteInstructions()
|
||||
void showRemoteInstructions()
|
||||
{
|
||||
#if JUCE_IOS || JUCE_MAC
|
||||
NativeMessageBox::showAsync (MessageBoxOptions()
|
||||
auto options = MessageBoxOptions()
|
||||
.withIconType (MessageBoxIconType::InfoIcon)
|
||||
.withTitle ("Remote Notifications instructions")
|
||||
.withMessage ("In order to be able to test remote notifications "
|
||||
"ensure that the app is signed and that you register "
|
||||
"the bundle ID for remote notifications in "
|
||||
"Apple Developer Center.")
|
||||
.withButton ("OK"),
|
||||
nullptr);
|
||||
.withButton ("OK");
|
||||
messageBox = NativeMessageBox::showScopedAsync (options, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1246,10 +1251,11 @@ private:
|
|||
AuxActionsView auxActionsView;
|
||||
TabbedComponent localNotificationsTabs { TabbedButtonBar::TabsAtTop };
|
||||
RemoteView remoteView;
|
||||
DemoTabbedComponent mainTabs { TabbedButtonBar::TabsAtTop };
|
||||
DemoTabbedComponent mainTabs { *this, TabbedButtonBar::TabsAtTop };
|
||||
TextButton sendButton { "Send!" };
|
||||
Label notAvailableYetLabel { "notAvailableYetLabel",
|
||||
"Push Notifications feature is not available on this platform yet!" };
|
||||
ScopedMessageBox messageBox;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PushNotificationsDemo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue