Apple pushed out a new Xcode and iOS this week with WWDC. Naturally I updated and tried it. Xcode version 8.3.3 (8E3004b) and iOS version 10.3.2 (14F89). I’m running 10.2 Tokyo with the April 2017 Hotfix and it all worked as expected. I deployed to my iPad and the iPhone simulator (I don’t have an iPhone anymore, upgrade to a Pixel XL!)
Are you running Toyko 10.2 with the April 2017 Hotfix? There are updates coming too. Check out the roadmap to see what is planned for 10.2.1 & 10.2.2. Great new features and a lot of fixes too!
I’m a huge fan of the REST Client Components included with RAD Studio. They make it really easy to take advantage of the huge amount of REST services available online.
Here is a quick video of me using the REST Client components to build a REST Client in 5 minuntes.
One thing about more complex REST APIs is REST isn’t a strict protocol like SOAP, it is more of a philosophy in building an API. This usually means I spend a few hours looking at each REST API that I want to work with. Authentication is the thing that really changes from API to API.
That is where the TMS Cloud Pack comes it. They make working with some of the standard large APIs a breeze (get it, a breeze when I am talking about clouds!?!) You just need to setup an API account and get your API key and provide it to the component and it does the rest.
When I started working with it I realized it made sense to have a different VCL and FMX version of the components because they include a browser window that is used when the user needs to authenticate for the OAuth services.
Besides the different browser window I found the FMX and VCL versions very simialr in functionality. So it is just a matter of what frameworks and platforms you want to work with since the FMX versions add support for macOS, iOS and Android in addition to the Windows support in the VCL version.
With the power and variety of REST APIs available today, you really should look at leveraging them in your apps, and if it is one of the APIs that TMS supports, then you will want to use it!
There were a lot of amazing apps submitted for the Embarcadero Cool App Contest. Last month’s winner was 1Password for Windows. Any entries that don’t win one month, are automatically eligible for the next month. We will have our next winner shortly.
In the meantime I thought I would highlight a few of the entries that caught my attention. They are all very cool apps.
The first one I want to highlight is by two sixth grade girls, Suresh and Safalta, from Sherwood Middle School in Shrewsbury, Massachusetts. They created an app to help tackle two big problems at the same time: Hunger and Obesity.
The idea is brilliant: Educate users on lowering their caloric intake to reduce obesity, and then provide a way for them to donate the money they would have spent on junk food to those who are hungry.
One thing I really liked about this entry is they didn’t start with Delphi. Their school taught them to use Java and Python, and they tried a few different tools. They found they were difficult to use, hard to understand and took a lot more code than they wanted. Then they tried Embarcadero Delphi and found it really easy. As they put it, “Embarcadero provided [an] easy button tool for compiling codes for multiple devices including android, iOS etc. which helped us to develop app quite faster. We are planning to recommend the use of Embarcadero [Delphi] to other kids interested in developing apps.”
I’ll share some of what they wrote in their entry too.
Obesity in children and young adults is a global health problem among developed countries. United States ranks first in the world with 35% of male, 39.5% female children, and young adults suffering with obesity. Obesity in children affect an estimated 41 million children worldwide, as per World Health Organization (WHO) and United Nations Children’s Emergency Fund (UNICEF). Obesity leads to major health problems including, type 2 diabetes, high blood pressure, high cholesterol levels, fatty liver disease, gallstones and heart diseases.
Similarly, malnourishment and hunger in poor countries affect 159 million children causing nearly 3.1 million children to die each year in the entire world, as per WHO and UNICEF.
Our goal is to help and motivate kids from developed nations by encouraging them to lose weight by eating less, and use the money saved, to help feed hungry and malnourished children living in poor countries. To achieve this goal, our objective is
To provide a free to all Hunger and Obesity Prevention (HOP) App to help children with obesity, encourage them to lose weight through making conscious efforts to engage in physical activity, avoid junk food and promote eating healthy foods.
Then provide an opportunity for HOP participants to celebrate their achievement, by pledging to donate 25 cents/pound lost to UNICEF for feeding hungry children, as a motivation to lose weight for greater cause.
Purpose: Overeating and genetic reasons are important factors in causing obesity. Eating more food, particularly junk food and lack of physical activity leads to accumulation of excess calories to store as body fat, which then results in weight gain and obesity. Obesity is preventable or reversed by consciously taking control of what you eat, and burning excess calories from the body by exercising regularly.
Our long-term goal is to make an advanced version of HOP with ability to take pictures of food/snacks/drinks and estimate calorie contents, select meals and retrieve calorie information from restaurant menus to keep track of calories consumed each day. In addition, we plan to integrate activity-monitoring apps like “Fitbit” or “Pacer” and precisely monitor the progress with physical activity in fighting obesity.
This basic version of HOP is intended to determine if the user is obese, then set goals to lose weight, track physical activity, dieting plans (such as healthy eating, avoiding junk food and salty snacks), record weight over a period of time. When the participant succeeds in losing 1 pound of their body weight, it means they have cut or burned 3500 calories.
Now we ask the participants to make a pledge to donate the unused calories for saving the lives of starving children. By pledging to do so, it gives a cause for participants with obesity to lose weight and hope for hungry children fighting to survive.
Our HOP App designed to pledge 25 cents to UNICEF on their behalf as a way to celebrate their achievement. However, in future users will have options to donate to any charitable organizations that are associated with feeding hungry children. Our mission is to help ending obesity and hunger in children and give them the gift of life, through motivating obese children to SHARE CALORIES with hungry children.
I’m really excited to see their app develop, and it is great that they chose RAD Studio and Object Pascal / Delphi to build this. Especially with 10.1 Berlin it includes easy components to connect with health devices like scales, heart rate monitors and cadence sensors.
Yesterday, I mentioned I built a REST client and deployed it to iOS and Android inside 5 minutes. Someone asked me to make a video actually showing how it was done. So here it is showing a simple REST client built and deployed to iOS 9.1 and Android 6.0 Marshmallow.
Since I am using SpitCast, and it doesn’t offer an encrypted endpoint for its REST service, I had to modify the Info.plist to allow that on iOS 9.
Could I do it faster without the video recording and explanation? Yes, but I think you get the idea. Delphi makes building multiplatform REST clients really, really easy.
I’m curious to see someone create a client app using other general purpose development tools to connect to a REST service and too see how long that takes.
If I wanted to connect to a different end point to pull down more information on an individual surf spot I could that by handling the OnItemClick event for the List View.
If there is interest I’m happy to share my Sync-Timer source code.
Here is another sample that shows how to use the bind mechanism to launch an remote Android service and communicates to it via the Java Message (JMessage) object. There are a couple manual steps that you need to consult the included readme about. Otherwise it won’t work as expected. There are three projects in the project group. One is the actual Android Service, then the other two are apps that connect to the project. One of them is the host app that will contain the service within its APK.
Remember, you need to add the service to the host application after building the service. Then you can deploy it within the host app APK.
Parallel For Loops are a hassle-free way to supercharge your program with the Parallel Programming Library. The syntax is similar to the standard For loop, with the advantage of each iteration running on in a different task on the thread pool. This allows multiple iterations to run at the same time, taking advantage of the multi-core and hyper-threaded architecture common on laptops, desktops and mobile devices today.
Update: I was chatting with Allen Bauer today and he mentioned that while you technically can use Queue and Synchronize from within a Parallel For loop, he wouldn’t recommend it because it will dramatically reduce the speed of the loop. It is still faster than a linear loop, but not as fast as it could be. I’ll leave these examples here, but keep that in mind when optimizing your parallel code.
Here is the syntax in Object Pascal. The stride is the first parameter is it is optional. It controls how the iterations are grouped when being sent to the CPUs. Min and Max are your usual start and stop range for the loop. The last parameter is an anonymous method that represents the code to be executed on each iterations. It takes an Index parameter that is either an Integer or Int64 that provides the value of the current iteration.
TParallel.For(Stride, Min, Max, procedure (Idx: Integer)
if IsPrime(Idx) then
Here is the C++ code syntax. It takes a event instead of an anonymous method.
Update: Keep in mind that a Parallel For loop isn’t always the best performance option, but it is really easy to use. Check out Stefan Glienke’s Stack Overflow answer for an alternative using the PPL TTask for even better performance.
I’ve been playing with Raize Software‘s new Radiant Shapes components this week. These are the brand new primitive shape component set for FireMonkey on all platforms: Windows, OS X, iOS and Android. I’ve been a long time fan of Raize Components because of their attention to detail and high quality. Radiant Shapes continues this tradition.
Radiant Shapes is made up of 35 reusable shape controls that are all pretty flexible. If you caught Ray Konopka’s RAD In Action: Seeing is Believing on Data Visualization then you have a pretty good idea the importance of using primitive shapes like these to communicate useful information to your users, especially in mobile development.
All of the shapes include useful design time menus to make common changes quickly and easily. You can probably get away without using the Object Inspector for a lot of your common tasks. They also have various customizations that make them very flexible.
One thing that is interesting is they introduce the idea of a TRadiantDimension they allows you to specify some of the sizes as either absolute pixels, or as a scale factor. This gives great flexibility in how they behave when resized.
Ray Konopka introduced the Radiant Shapes during CodeRage 9 with a couple great sessions. You can catch the replay for both Object Pascal and C++.
I really like the TRadiantGear component, so I decided to play with it in detail. You can specify the number of cogs (teeth), their size (as a Radiant Dimension) and the size and visibility of the hole. Just like all the other shapes, they handle hit tests correctly, so at runtime, you can click between the cogs of the gear and it doesn’t produce an onClick event.
Just for fun I put down three gears and used LiveBindings to connect a TTrackBar.Value to their rotation. A little math in the OnAssigningValue event and I had all the gears rotating in unison. The fact that the gears stayed synced up, and the teeth meshed perfectly was really impressive.
procedure TForm4.RotateGearBigAssigningValue(Sender: TObject;
AssignValueRec: TBindingAssignValueRec; var Value: TValue;
var Handled: Boolean);
Value := TValue.From(-1 * (Value.AsExtended / 2 + 18));
procedure TForm4.RotateGearRightAssigningValue(Sender: TObject;
AssignValueRec: TBindingAssignValueRec; var Value: TValue;
var Handled: Boolean);
Value := TValue.From(-1 * (Value.AsExtended + 18));
18 is the offset for the gears (360° / 10 cogs / 2 (half offset) = 18) and the 2 comes from the big gear being twice as big (20 cogs), then the -1 is so they rotate the opposite direction.
Overall I am impressed with the Radiant Shapes. Something I would like to see include a polygon component where I can specify the number of sizes. You can do that with the star and gear, but a flexible polygon would be nice. Also, the shapes can be rotated with the rotation property, but it would be cool if there was a way to rotate it in the designer too. That might be a big undertaking though.
BaaS or Backend As A Service Providers are companies that maintain the backend servers necessary for many application development tasks. They handle things like user authentication, data storage, push notifications, etc. Sometimes they are referred to as mBaaS or Mobile-BaaS because if the heavy focus on mobile application development these days, but they typically are not tied to mobile.
This doesn’t mean you have to use a BaaS provider to send mobile push notifications. This is just the easy way. During CodeRage we’ve had sessions on how to do push notifications without a BaaS provider. It is different for both iOS and Android, so you are looking at a lot more code and effort, but it is possible.
CodeRage 9 had a session by Jeff LeFebvre had a session on Android Push notifications via Google Cloud Messaging (GCM):
For iOS & iPhone use of Apple Push Notifications (APN) Luis Felipe and Anders Ohlsson have some blog posts and videos on the subject. Luis did the original post and video in Spanish, and then Anders translated and expanded on it.
Here is the video replay, slides and resources from my Developer Skill Sprint on the new Multi-Device Designer in RAD Studio XE7. This is one part of the new FireUI, the evolution of FireMonkey.
The Multi-Device Designer is a new feature in Appmethod, RAD Studio, Delphi and C++Builder XE7 that makes it easy to maximize the reuse of your visually designed forms across devices, while also getting the most flexibility and customization as possible.
Design your UI once for Windows, OS X, iOS and Android, then customize it for different screen sizes: iPad, iPhone, Tablet, Google Glass, Surface Pro, etc.