The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

659 lines
30KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "../JuceLibraryCode/JuceHeader.h"
  21. //==============================================================================
  22. class MainContentComponent : public Component,
  23. private Button::Listener,
  24. private ComboBox::Listener,
  25. private ChangeListener,
  26. private ComponentListener,
  27. private PushNotifications::Listener
  28. {
  29. public:
  30. //==============================================================================
  31. MainContentComponent();
  32. ~MainContentComponent();
  33. void paint (Graphics&) override;
  34. void resized() override;
  35. private:
  36. void buttonClicked (Button*) override;
  37. void comboBoxChanged (ComboBox* comboBoxThatHasChanged) override;
  38. void sendLocalNotification();
  39. void fillRequiredParams (PushNotifications::Notification& n);
  40. void fillOptionalParamsOne (PushNotifications::Notification& n);
  41. void fillOptionalParamsTwo (PushNotifications::Notification& n);
  42. void fillOptionalParamsThree (PushNotifications::Notification& n);
  43. void setupAccentColour();
  44. void setupLedColour();
  45. void getDeliveredNotifications();
  46. void changeListenerCallback (ChangeBroadcaster* source) override;
  47. void componentBeingDeleted (Component& component) override;
  48. void handleNotification (bool isLocalNotification, const PushNotifications::Notification& n) override;
  49. void handleNotificationAction (bool isLocalNotification,
  50. const PushNotifications::Notification& n,
  51. const juce::String& actionIdentifier,
  52. const juce::String& optionalResponse) override;
  53. void localNotificationDismissedByUser (const PushNotifications::Notification& n) override;
  54. void deliveredNotificationsListReceived (const Array<PushNotifications::Notification>&) override;
  55. void pendingLocalNotificationsListReceived (const Array<PushNotifications::Notification>&) override;
  56. void deviceTokenRefreshed (const String& token) override;
  57. #if JUCE_ANDROID
  58. void remoteNotificationsDeleted() override;
  59. void upstreamMessageSent (const String& messageId) override;
  60. void upstreamMessageSendingError (const String& messageId, const String& error) override;
  61. static Array<PushNotifications::Channel> getAndroidChannels();
  62. #elif JUCE_IOS
  63. static PushNotifications::Settings getIosSettings();
  64. #endif
  65. struct RequiredParamsView : public Component
  66. {
  67. RequiredParamsView()
  68. {
  69. addAndMakeVisible (identifierLabel);
  70. addAndMakeVisible (identifierEditor);
  71. addAndMakeVisible (titleLabel);
  72. addAndMakeVisible (titleEditor);
  73. addAndMakeVisible (bodyLabel);
  74. addAndMakeVisible (bodyEditor);
  75. #if JUCE_IOS
  76. addAndMakeVisible (categoryLabel);
  77. addAndMakeVisible (categoryComboBox);
  78. categories.add ("okCategory");
  79. categories.add ("okCancelCategory");
  80. categories.add ("textCategory");
  81. for (const auto& c : categories)
  82. categoryComboBox.addItem (c, categoryComboBox.getNumItems() + 1);
  83. categoryComboBox.setSelectedItemIndex (0);
  84. #elif JUCE_ANDROID
  85. #if __ANDROID_API__ >= 26
  86. addAndMakeVisible (channelIdLabel);
  87. addAndMakeVisible (channelIdComboBox);
  88. for (int i = 1; i <= 3; ++i)
  89. channelIdComboBox.addItem (String (i), i);
  90. channelIdComboBox.setSelectedItemIndex (0);
  91. #endif
  92. addAndMakeVisible (iconLabel);
  93. addAndMakeVisible (iconComboBox);
  94. for (int i = 0; i < 5; ++i)
  95. iconComboBox.addItem ("icon" + String (i + 1), i + 1);
  96. iconComboBox.setSelectedItemIndex (0);
  97. #endif
  98. // For now, to be able to dismiss mobile keyboard.
  99. setWantsKeyboardFocus (true);
  100. }
  101. void resized() override
  102. {
  103. const int labelColumnWidth = getWidth() / 3;
  104. #if JUCE_ANDROID && __ANDROID_API__ >= 26
  105. const int rowHeight = getHeight() / 8;
  106. #else
  107. const int rowHeight = getHeight() / 7;
  108. #endif
  109. auto layoutRow = [labelColumnWidth] (Rectangle<int> rowBounds, Component& label, Component& editor)
  110. {
  111. label .setBounds (rowBounds.removeFromLeft (labelColumnWidth));
  112. editor.setBounds (rowBounds);
  113. };
  114. auto bounds = getLocalBounds();
  115. layoutRow (bounds.removeFromTop (rowHeight), identifierLabel, identifierEditor);
  116. layoutRow (bounds.removeFromTop (rowHeight), titleLabel, titleEditor);
  117. layoutRow (bounds.removeFromTop (4 * rowHeight), bodyLabel, bodyEditor);
  118. #if JUCE_IOS
  119. layoutRow (bounds.removeFromTop (rowHeight), categoryLabel, categoryComboBox);
  120. #elif JUCE_ANDROID
  121. #if __ANDROID_API__ >= 26
  122. layoutRow (bounds.removeFromTop (rowHeight), channelIdLabel, channelIdComboBox);
  123. #endif
  124. layoutRow (bounds.removeFromTop (rowHeight), iconLabel, iconComboBox);
  125. #endif
  126. }
  127. Label identifierLabel { "identifierLabel", "Identifier" };
  128. TextEditor identifierEditor;
  129. Label titleLabel { "titleLabel", "Title" };
  130. TextEditor titleEditor;
  131. Label bodyLabel { "bodyLabel", "Body" };
  132. TextEditor bodyEditor;
  133. #if JUCE_IOS
  134. StringArray categories;
  135. Label categoryLabel { "categoryLabel", "Category" };
  136. ComboBox categoryComboBox;
  137. #elif JUCE_ANDROID
  138. Label channelIdLabel { "channelIdLabel", "Channel ID" };
  139. ComboBox channelIdComboBox;
  140. Label iconLabel { "iconLabel", "Icon" };
  141. ComboBox iconComboBox;
  142. #endif
  143. };
  144. struct OptionalParamsOneView : public Component
  145. {
  146. OptionalParamsOneView()
  147. {
  148. addAndMakeVisible (subtitleLabel);
  149. addAndMakeVisible (subtitleEditor);
  150. addAndMakeVisible (badgeNumberLabel);
  151. addAndMakeVisible (badgeNumberComboBox);
  152. addAndMakeVisible (soundToPlayLabel);
  153. addAndMakeVisible (soundToPlayComboBox);
  154. addAndMakeVisible (propertiesLabel);
  155. addAndMakeVisible (propertiesEditor);
  156. #if JUCE_IOS
  157. addAndMakeVisible (fireInLabel);
  158. addAndMakeVisible (fireInComboBox);
  159. addAndMakeVisible (repeatLabel);
  160. addAndMakeVisible (repeatButton);
  161. fireInComboBox.addItem ("Now", 1);
  162. for (int i = 1; i < 11; ++i)
  163. fireInComboBox.addItem (String (10 * i) + "seconds", i + 1);
  164. fireInComboBox.setSelectedItemIndex (0);
  165. #elif JUCE_ANDROID
  166. addAndMakeVisible (largeIconLabel);
  167. addAndMakeVisible (largeIconComboBox);
  168. addAndMakeVisible (badgeIconLabel);
  169. addAndMakeVisible (badgeIconComboBox);
  170. addAndMakeVisible (tickerTextLabel);
  171. addAndMakeVisible (tickerTextEditor);
  172. addAndMakeVisible (autoCancelLabel);
  173. addAndMakeVisible (autoCancelButton);
  174. addAndMakeVisible (alertOnlyOnceLabel);
  175. addAndMakeVisible (alertOnlyOnceButton);
  176. addAndMakeVisible (actionsLabel);
  177. addAndMakeVisible (actionsComboBox);
  178. largeIconComboBox.addItem ("none", 1);
  179. for (int i = 1; i < 5; ++i)
  180. largeIconComboBox.addItem ("icon" + String (i), i + 1);
  181. largeIconComboBox.setSelectedItemIndex (0);
  182. badgeIconComboBox.addItem ("none", 1);
  183. badgeIconComboBox.addItem ("small", 2);
  184. badgeIconComboBox.addItem ("large", 3);
  185. badgeIconComboBox.setSelectedItemIndex (2);
  186. actionsComboBox.addItem ("none", 1);
  187. actionsComboBox.addItem ("ok-cancel", 2);
  188. actionsComboBox.addItem ("ok-cancel-icons", 3);
  189. actionsComboBox.addItem ("text-input", 4);
  190. actionsComboBox.addItem ("text-input-limited_responses", 5);
  191. actionsComboBox.setSelectedItemIndex (0);
  192. #endif
  193. for (int i = 0; i < 7; ++i)
  194. badgeNumberComboBox.addItem (String (i), i + 1);
  195. badgeNumberComboBox.setSelectedItemIndex (0);
  196. #if JUCE_IOS
  197. String prefix = "sounds/";
  198. String extension = ".caf";
  199. #else
  200. String prefix;
  201. String extension;
  202. #endif
  203. soundToPlayComboBox.addItem ("none", 1);
  204. soundToPlayComboBox.addItem ("default_os_sound", 2);
  205. soundToPlayComboBox.addItem (prefix + "demonstrative" + extension, 3);
  206. soundToPlayComboBox.addItem (prefix + "isntit" + extension, 4);
  207. soundToPlayComboBox.addItem (prefix + "jinglebellssms" + extension, 5);
  208. soundToPlayComboBox.addItem (prefix + "served" + extension, 6);
  209. soundToPlayComboBox.addItem (prefix + "solemn" + extension, 7);
  210. soundToPlayComboBox.setSelectedItemIndex (1);
  211. // For now, to be able to dismiss mobile keyboard.
  212. setWantsKeyboardFocus (true);
  213. }
  214. void resized() override
  215. {
  216. const int labelColumnWidth = getWidth() / 3;
  217. #if JUCE_ANDROID
  218. const int rowHeight = getHeight() / 12;
  219. #else
  220. const int rowHeight = getHeight() / 8;
  221. #endif
  222. auto layoutRow = [labelColumnWidth] (Rectangle<int> rowBounds, Component& label, Component& editor)
  223. {
  224. label .setBounds (rowBounds.removeFromLeft (labelColumnWidth));
  225. editor.setBounds (rowBounds);
  226. };
  227. auto bounds = getLocalBounds();
  228. layoutRow (bounds.removeFromTop (rowHeight), subtitleLabel, subtitleEditor);
  229. layoutRow (bounds.removeFromTop (rowHeight), badgeNumberLabel, badgeNumberComboBox);
  230. layoutRow (bounds.removeFromTop (rowHeight), soundToPlayLabel, soundToPlayComboBox);
  231. layoutRow (bounds.removeFromTop (3 * rowHeight), propertiesLabel, propertiesEditor);
  232. #if JUCE_IOS
  233. layoutRow (bounds.removeFromTop (rowHeight), fireInLabel, fireInComboBox);
  234. layoutRow (bounds.removeFromTop (rowHeight), repeatLabel, repeatButton);
  235. #elif JUCE_ANDROID
  236. layoutRow (bounds.removeFromTop (rowHeight), largeIconLabel, largeIconComboBox);
  237. layoutRow (bounds.removeFromTop (rowHeight), badgeIconLabel, badgeIconComboBox);
  238. layoutRow (bounds.removeFromTop (rowHeight), tickerTextLabel, tickerTextEditor);
  239. layoutRow (bounds.removeFromTop (rowHeight), autoCancelLabel, autoCancelButton);
  240. layoutRow (bounds.removeFromTop (rowHeight), alertOnlyOnceLabel, alertOnlyOnceButton);
  241. layoutRow (bounds.removeFromTop (rowHeight), actionsLabel, actionsComboBox);
  242. #endif
  243. }
  244. Label subtitleLabel { "subtitleLabel", "Subtitle" };
  245. TextEditor subtitleEditor;
  246. Label badgeNumberLabel { "badgeNumberLabel", "BadgeNumber" };
  247. ComboBox badgeNumberComboBox;
  248. Label soundToPlayLabel { "soundToPlayLabel", "SoundToPlay" };
  249. ComboBox soundToPlayComboBox;
  250. Label propertiesLabel { "propertiesLabel", "Properties" };
  251. TextEditor propertiesEditor;
  252. #if JUCE_IOS
  253. Label fireInLabel { "fireInLabel", "Fire in" };
  254. ComboBox fireInComboBox;
  255. Label repeatLabel { "repeatLabel", "Repeat" };
  256. ToggleButton repeatButton;
  257. #elif JUCE_ANDROID
  258. Label largeIconLabel { "largeIconLabel", "Large Icon" };
  259. ComboBox largeIconComboBox;
  260. Label badgeIconLabel { "badgeIconLabel", "Badge Icon" };
  261. ComboBox badgeIconComboBox;
  262. Label tickerTextLabel { "tickerTextLabel", "Ticker Text" };
  263. TextEditor tickerTextEditor;
  264. Label autoCancelLabel { "autoCancelLabel", "AutoCancel" };
  265. ToggleButton autoCancelButton;
  266. Label alertOnlyOnceLabel { "alertOnlyOnceLabel", "AlertOnlyOnce" };
  267. ToggleButton alertOnlyOnceButton;
  268. Label actionsLabel { "actionsLabel", "Actions" };
  269. ComboBox actionsComboBox;
  270. #endif
  271. };
  272. struct OptionalParamsTwoView : public Component
  273. {
  274. OptionalParamsTwoView()
  275. {
  276. addAndMakeVisible (progressMaxLabel);
  277. addAndMakeVisible (progressMaxComboBox);
  278. addAndMakeVisible (progressCurrentLabel);
  279. addAndMakeVisible (progressCurrentComboBox);
  280. addAndMakeVisible (progressIndeterminateLabel);
  281. addAndMakeVisible (progressIndeterminateButton);
  282. addAndMakeVisible (categoryLabel);
  283. addAndMakeVisible (categoryComboBox);
  284. addAndMakeVisible (priorityLabel);
  285. addAndMakeVisible (priorityComboBox);
  286. addAndMakeVisible (personLabel);
  287. addAndMakeVisible (personEditor);
  288. addAndMakeVisible (lockScreenVisibilityLabel);
  289. addAndMakeVisible (lockScreenVisibilityComboBox);
  290. addAndMakeVisible (groupIdLabel);
  291. addAndMakeVisible (groupIdEditor);
  292. addAndMakeVisible (sortKeyLabel);
  293. addAndMakeVisible (sortKeyEditor);
  294. addAndMakeVisible (groupSummaryLabel);
  295. addAndMakeVisible (groupSummaryButton);
  296. addAndMakeVisible (groupAlertBehaviourLabel);
  297. addAndMakeVisible (groupAlertBehaviourComboBox);
  298. for (int i = 0; i < 11; ++i)
  299. {
  300. progressMaxComboBox .addItem (String (i * 10) + "%", i + 1);
  301. progressCurrentComboBox.addItem (String (i * 10) + "%", i + 1);
  302. }
  303. progressMaxComboBox .setSelectedItemIndex (0);
  304. progressCurrentComboBox.setSelectedItemIndex (0);
  305. categoryComboBox.addItem ("unspecified", 1);
  306. categoryComboBox.addItem ("alarm", 2);
  307. categoryComboBox.addItem ("call", 3);
  308. categoryComboBox.addItem ("email", 4);
  309. categoryComboBox.addItem ("error", 5);
  310. categoryComboBox.addItem ("event", 6);
  311. categoryComboBox.addItem ("message", 7);
  312. categoryComboBox.addItem ("progress", 8);
  313. categoryComboBox.addItem ("promo", 9);
  314. categoryComboBox.addItem ("recommendation", 10);
  315. categoryComboBox.addItem ("reminder", 11);
  316. categoryComboBox.addItem ("service", 12);
  317. categoryComboBox.addItem ("social", 13);
  318. categoryComboBox.addItem ("status", 14);
  319. categoryComboBox.addItem ("system", 15);
  320. categoryComboBox.addItem ("transport", 16);
  321. categoryComboBox.setSelectedItemIndex (0);
  322. for (int i = -2; i < 3; ++i)
  323. priorityComboBox.addItem (String (i), i + 3);
  324. priorityComboBox.setSelectedItemIndex (2);
  325. lockScreenVisibilityComboBox.addItem ("don't show", 1);
  326. lockScreenVisibilityComboBox.addItem ("show partially", 2);
  327. lockScreenVisibilityComboBox.addItem ("show completely", 3);
  328. lockScreenVisibilityComboBox.setSelectedItemIndex (1);
  329. groupAlertBehaviourComboBox.addItem ("alert all", 1);
  330. groupAlertBehaviourComboBox.addItem ("alert summary", 2);
  331. groupAlertBehaviourComboBox.addItem ("alert children", 3);
  332. groupAlertBehaviourComboBox.setSelectedItemIndex (0);
  333. // For now, to be able to dismiss mobile keyboard.
  334. setWantsKeyboardFocus (true);
  335. }
  336. void resized() override
  337. {
  338. const int labelColumnWidth = getWidth() / 3;
  339. const int rowHeight = getHeight() / 11;
  340. auto layoutRow = [labelColumnWidth] (Rectangle<int> rowBounds, Component& label, Component& editor)
  341. {
  342. label .setBounds (rowBounds.removeFromLeft (labelColumnWidth));
  343. editor.setBounds (rowBounds);
  344. };
  345. auto bounds = getLocalBounds();
  346. layoutRow (bounds.removeFromTop (rowHeight), progressMaxLabel, progressMaxComboBox);
  347. layoutRow (bounds.removeFromTop (rowHeight), progressCurrentLabel, progressCurrentComboBox);
  348. layoutRow (bounds.removeFromTop (rowHeight), progressIndeterminateLabel, progressIndeterminateButton);
  349. layoutRow (bounds.removeFromTop (rowHeight), categoryLabel, categoryComboBox);
  350. layoutRow (bounds.removeFromTop (rowHeight), priorityLabel, priorityComboBox);
  351. layoutRow (bounds.removeFromTop (rowHeight), personLabel, personEditor);
  352. layoutRow (bounds.removeFromTop (rowHeight), lockScreenVisibilityLabel, lockScreenVisibilityComboBox);
  353. layoutRow (bounds.removeFromTop (rowHeight), groupIdLabel, groupIdEditor);
  354. layoutRow (bounds.removeFromTop (rowHeight), sortKeyLabel, sortKeyEditor);
  355. layoutRow (bounds.removeFromTop (rowHeight), groupSummaryLabel, groupSummaryButton);
  356. layoutRow (bounds.removeFromTop (rowHeight), groupAlertBehaviourLabel, groupAlertBehaviourComboBox);
  357. }
  358. Label progressMaxLabel { "progressMaxLabel", "ProgressMax" };
  359. ComboBox progressMaxComboBox;
  360. Label progressCurrentLabel { "progressCurrentLabel", "ProgressCurrent" };
  361. ComboBox progressCurrentComboBox;
  362. Label progressIndeterminateLabel { "progressIndeterminateLabel", "ProgressIndeterminate" };
  363. ToggleButton progressIndeterminateButton;
  364. Label categoryLabel { "categoryLabel", "Category" };
  365. ComboBox categoryComboBox;
  366. Label priorityLabel { "priorityLabel", "Priority" };
  367. ComboBox priorityComboBox;
  368. Label personLabel { "personLabel", "Person" };
  369. TextEditor personEditor;
  370. Label lockScreenVisibilityLabel { "lockScreenVisibilityLabel", "LockScreenVisibility" };
  371. ComboBox lockScreenVisibilityComboBox;
  372. Label groupIdLabel { "groupIdLabel", "GroupID" };
  373. TextEditor groupIdEditor;
  374. Label sortKeyLabel { "sortKeyLabel", "SortKey" };
  375. TextEditor sortKeyEditor;
  376. Label groupSummaryLabel { "groupSummaryLabel", "GroupSummary" };
  377. ToggleButton groupSummaryButton;
  378. Label groupAlertBehaviourLabel { "groupAlertBehaviourLabel", "GroupAlertBehaviour" };
  379. ComboBox groupAlertBehaviourComboBox;
  380. };
  381. struct OptionalParamsThreeView : public Component
  382. {
  383. OptionalParamsThreeView()
  384. {
  385. addAndMakeVisible (accentColourLabel);
  386. addAndMakeVisible (accentColourButton);
  387. addAndMakeVisible (ledColourLabel);
  388. addAndMakeVisible (ledColourButton);
  389. addAndMakeVisible (ledMsToBeOnLabel);
  390. addAndMakeVisible (ledMsToBeOnComboBox);
  391. addAndMakeVisible (ledMsToBeOffLabel);
  392. addAndMakeVisible (ledMsToBeOffComboBox);
  393. addAndMakeVisible (vibratorMsToBeOnLabel);
  394. addAndMakeVisible (vibratorMsToBeOnComboBox);
  395. addAndMakeVisible (vibratorMsToBeOffLabel);
  396. addAndMakeVisible (vibratorMsToBeOffComboBox);
  397. addAndMakeVisible (localOnlyLabel);
  398. addAndMakeVisible (localOnlyButton);
  399. addAndMakeVisible (ongoingLabel);
  400. addAndMakeVisible (ongoingButton);
  401. addAndMakeVisible (timestampVisibilityLabel);
  402. addAndMakeVisible (timestampVisibilityComboBox);
  403. addAndMakeVisible (timeoutAfterLabel);
  404. addAndMakeVisible (timeoutAfterComboBox);
  405. timeoutAfterComboBox.addItem ("No timeout", 1);
  406. for (int i = 0; i < 10; ++i)
  407. {
  408. ledMsToBeOnComboBox .addItem (String (i * 200) + "ms", i + 1);
  409. ledMsToBeOffComboBox .addItem (String (i * 200) + "ms", i + 1);
  410. vibratorMsToBeOnComboBox .addItem (String (i * 500) + "ms", i + 1);
  411. vibratorMsToBeOffComboBox.addItem (String (i * 500) + "ms", i + 1);
  412. timeoutAfterComboBox.addItem (String (5000 + 1000 * i) + "ms", i + 2);
  413. }
  414. ledMsToBeOnComboBox .setSelectedItemIndex (5);
  415. ledMsToBeOffComboBox .setSelectedItemIndex (5);
  416. vibratorMsToBeOnComboBox .setSelectedItemIndex (0);
  417. vibratorMsToBeOffComboBox.setSelectedItemIndex (0);
  418. timeoutAfterComboBox.setSelectedItemIndex (0);
  419. timestampVisibilityComboBox.addItem ("off", 1);
  420. timestampVisibilityComboBox.addItem ("on", 2);
  421. timestampVisibilityComboBox.addItem ("chronometer", 3);
  422. timestampVisibilityComboBox.addItem ("count down", 4);
  423. timestampVisibilityComboBox.setSelectedItemIndex (1);
  424. // For now, to be able to dismiss mobile keyboard.
  425. setWantsKeyboardFocus (true);
  426. }
  427. void resized() override
  428. {
  429. const int labelColumnWidth = getWidth() / 3;
  430. const int rowHeight = getHeight() / 10;
  431. auto layoutRow = [labelColumnWidth] (Rectangle<int> rowBounds, Component& label, Component& editor)
  432. {
  433. label .setBounds (rowBounds.removeFromLeft (labelColumnWidth));
  434. editor.setBounds (rowBounds);
  435. };
  436. auto bounds = getLocalBounds();
  437. layoutRow (bounds.removeFromTop (rowHeight), accentColourLabel, accentColourButton);
  438. layoutRow (bounds.removeFromTop (rowHeight), ledColourLabel, ledColourButton);
  439. layoutRow (bounds.removeFromTop (rowHeight), ledMsToBeOnLabel, ledMsToBeOnComboBox);
  440. layoutRow (bounds.removeFromTop (rowHeight), ledMsToBeOffLabel, ledMsToBeOffComboBox);
  441. layoutRow (bounds.removeFromTop (rowHeight), vibratorMsToBeOnLabel, vibratorMsToBeOnComboBox);
  442. layoutRow (bounds.removeFromTop (rowHeight), vibratorMsToBeOffLabel, vibratorMsToBeOffComboBox);
  443. layoutRow (bounds.removeFromTop (rowHeight), localOnlyLabel, localOnlyButton);
  444. layoutRow (bounds.removeFromTop (rowHeight), ongoingLabel, ongoingButton);
  445. layoutRow (bounds.removeFromTop (rowHeight), timestampVisibilityLabel, timestampVisibilityComboBox);
  446. layoutRow (bounds.removeFromTop (rowHeight), timeoutAfterLabel, timeoutAfterComboBox);
  447. }
  448. Label accentColourLabel { "accentColourLabel", "AccentColour" };
  449. TextButton accentColourButton;
  450. Label ledColourLabel { "ledColourLabel", "LedColour" };
  451. TextButton ledColourButton;
  452. Label ledMsToBeOnLabel { "ledMsToBeOnLabel", "LedMsToBeOn" };
  453. ComboBox ledMsToBeOnComboBox;
  454. Label ledMsToBeOffLabel { "ledMsToBeOffLabel", "LedMsToBeOff" };
  455. ComboBox ledMsToBeOffComboBox;
  456. Label vibratorMsToBeOnLabel { "vibratorMsToBeOnLabel", "VibrationMsToBeOn" };
  457. ComboBox vibratorMsToBeOnComboBox;
  458. Label vibratorMsToBeOffLabel { "vibratorMsToBeOffLabel", "VibrationMsToBeOff" };
  459. ComboBox vibratorMsToBeOffComboBox;
  460. Label localOnlyLabel { "localOnlyLabel", "LocalOnly" };
  461. ToggleButton localOnlyButton;
  462. Label ongoingLabel { "ongoingLabel", "Ongoing" };
  463. ToggleButton ongoingButton;
  464. Label timestampVisibilityLabel { "timestampVisibilityLabel", "TimestampMode" };
  465. ComboBox timestampVisibilityComboBox;
  466. Label timeoutAfterLabel { "timeoutAfterLabel", "Timeout After Ms" };
  467. ComboBox timeoutAfterComboBox;
  468. ColourSelector* accentColourSelector = nullptr;
  469. ColourSelector* ledColourSelector = nullptr;
  470. };
  471. struct AuxActionsView : public Component
  472. {
  473. AuxActionsView()
  474. {
  475. addAndMakeVisible (getDeliveredNotificationsButton);
  476. addAndMakeVisible (removeDeliveredNotifWithIdButton);
  477. addAndMakeVisible (deliveredNotifIdentifier);
  478. addAndMakeVisible (removeAllDeliveredNotifsButton);
  479. #if JUCE_IOS
  480. addAndMakeVisible (getPendingNotificationsButton);
  481. addAndMakeVisible (removePendingNotifWithIdButton);
  482. addAndMakeVisible (pendingNotifIdentifier);
  483. addAndMakeVisible (removeAllPendingNotifsButton);
  484. #endif
  485. // For now, to be able to dismiss mobile keyboard.
  486. setWantsKeyboardFocus (true);
  487. }
  488. void resized() override
  489. {
  490. const int columnWidth = getWidth();
  491. const int rowHeight = getHeight() / 6;
  492. auto bounds = getLocalBounds();
  493. getDeliveredNotificationsButton .setBounds (bounds.removeFromTop (rowHeight));
  494. auto rowBounds = bounds.removeFromTop (rowHeight);
  495. removeDeliveredNotifWithIdButton.setBounds (rowBounds.removeFromLeft (columnWidth / 2));
  496. deliveredNotifIdentifier .setBounds (rowBounds);
  497. removeAllDeliveredNotifsButton .setBounds (bounds.removeFromTop (rowHeight));
  498. #if JUCE_IOS
  499. getPendingNotificationsButton .setBounds (bounds.removeFromTop (rowHeight));
  500. rowBounds = bounds.removeFromTop (rowHeight);
  501. removePendingNotifWithIdButton.setBounds (rowBounds.removeFromLeft (columnWidth / 2));
  502. pendingNotifIdentifier .setBounds (rowBounds);
  503. removeAllPendingNotifsButton .setBounds (bounds.removeFromTop (rowHeight));
  504. #endif
  505. }
  506. TextButton getDeliveredNotificationsButton { "Get Delivered Notifications" };
  507. TextButton removeDeliveredNotifWithIdButton { "Remove Delivered Notif With ID:" };
  508. TextEditor deliveredNotifIdentifier;
  509. TextButton removeAllDeliveredNotifsButton { "Remove All Delivered Notifs" };
  510. #if JUCE_IOS
  511. TextButton getPendingNotificationsButton { "Get Pending Notifications" };
  512. TextButton removePendingNotifWithIdButton { "Remove Pending Notif With ID:" };
  513. TextEditor pendingNotifIdentifier;
  514. TextButton removeAllPendingNotifsButton { "Remove All Pending Notifs" };
  515. #endif
  516. };
  517. struct RemoteView : public Component
  518. {
  519. RemoteView()
  520. {
  521. addAndMakeVisible (getDeviceTokenButton);
  522. #if JUCE_ANDROID
  523. addAndMakeVisible (sendRemoteMessageButton);
  524. addAndMakeVisible (subscribeToSportsButton);
  525. addAndMakeVisible (unsubscribeFromSportsButton);
  526. #endif
  527. }
  528. void resized()
  529. {
  530. const int rowSize = getHeight () / 10;
  531. auto bounds = getLocalBounds().reduced (getWidth() / 10, getHeight() / 10);
  532. bounds.removeFromTop (2 * rowSize);
  533. getDeviceTokenButton .setBounds (bounds.removeFromTop (rowSize));
  534. sendRemoteMessageButton .setBounds (bounds.removeFromTop (rowSize));
  535. subscribeToSportsButton .setBounds (bounds.removeFromTop (rowSize));
  536. unsubscribeFromSportsButton.setBounds (bounds.removeFromTop (rowSize));
  537. }
  538. TextButton getDeviceTokenButton { "GetDeviceToken" };
  539. TextButton sendRemoteMessageButton { "SendRemoteMessage" };
  540. TextButton subscribeToSportsButton { "SubscribeToSports" };
  541. TextButton unsubscribeFromSportsButton { "UnsubscribeFromSports" };
  542. };
  543. Label headerLabel { "headerLabel", "Push Notifications Demo" };
  544. RequiredParamsView requiredParamsView;
  545. OptionalParamsOneView optionalParamsOneView;
  546. OptionalParamsTwoView optionalParamsTwoView;
  547. OptionalParamsThreeView optionalParamsThreeView;
  548. AuxActionsView auxActionsView;
  549. TabbedComponent localNotificationsTabs { TabbedButtonBar::TabsAtTop };
  550. RemoteView remoteView;
  551. TabbedComponent mainTabs { TabbedButtonBar::TabsAtTop };
  552. TextButton sendButton { "Send!" };
  553. Label notAvailableYetLabel { "notAvailableYetLabel", "Push Notifications feature is not available on this platform yet!" };
  554. //==============================================================================
  555. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
  556. };