Categories
Android design iOS Tools

Looking at Radiant Shapes

RadiantShapes_Logo
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 PaletteRadiant 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.

Gears

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);
begin
  Value := TValue.From(-1 * (Value.AsExtended / 2 + 18));
end;

procedure TForm4.RotateGearRightAssigningValue(Sender: TObject;
  AssignValueRec: TBindingAssignValueRec; var Value: TValue;
  var Handled: Boolean);
begin
  Value := TValue.From(-1 * (Value.AsExtended + 18));
end;

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.

You can buy the Radiant Shapes from Raize Software for $49, which gives you a 1 year subscription for updates. I did get a complimentary copy from Raize Software to review them.

Be sure to join Ray on Friday the 23rd as he is featured in the Embarcadero Technology Partner Spotlight.

Categories
Android Mobile Tools Video podCast

New XE7 Android Features Skill Sprint

XE7 is full of new features everywhere, but there are some really nice ones specific to Android. Here is a replay of my Skill Sprint session on New Android Features.

The new Android specific features in XE7 include:

There are lots of other new features that are not specific to Android, but that will still help make your apps amazing for Android, iOS, Windows and OS X.

Categories
Android Mobile Source Code Tools webinar

Skill Sprint: Android Voice – Speech Recognition and TTS

Androids can talk and listen!For my Developer Skill Sprint I was originally scheduled to show how to do a Google Glass Voice Trigger. That is pretty cool because it allows you to launch a Google Glass app with your voice, but I decided to expand on that to also show how the Google Glass app can be launched with the results of additional voice input, as well as how to take dictation and do text to speech everywhere else in Android.

I’ve still got a lot of work to do on the components, but they work as is for now. If you want to modify the component code then take a look at my Skill Sprint and blog post on the Android JNI Bridge.

 

Categories
Android Mobile MVP News Source Code Tools webinar

Android JNI Bridge and Custom Classes.dex

By creating a custom Classes.dex you can get access to 3rd party Java JAR APIs from your application. For my Integrate More Android with a JNI Call to your Android App Developer Skill Sprint I created a demo app that demonstrates creating a custom Classes.dex. This is a new feature in XE6 and Appmethod 1.14. [Download the demo] [Download the slides] The Demo app uses the Base64Coder JAR file (included). To build the demo:

  1. Examine the createdex.bat file to make sure it refers to the correct location for your dx.bat utility and the fmx.jar & android-support-v4.jar files.
  2. Run the createdex.bat file to create the classes.dex file which includes the two jar files above, plus the base64coder.jar file.
  3. Double check that the Deployment Manager references the new classes.dex and not the old ones, and that the remote path is “classes\”
  4. Notice that the android.JNI.Base64Coder.pas file wraps and exposes the methods of the base64coder class.
  5. Run the app on your Android device and verify that it works as expected.

The Base64Coder.JAR is Android specific, so it will not work on iOS or Windows. Some additional notes from the Developer Skill Sprint: Some useful units for making JNI calls

  • Androidapi.Jni – Java Native Interface type definitions
  • Androidapi.JNIBridge – The JNI Bridge
  • Androidapi.JNI.JavaTypes – JString and other common types.
  • Androidapi.Helpers – JStringToString and other useful conversions.
  • FMX.Platform.Android– Useful platform methods like GetAndroidApp, MainActivity and ConvertPointToPixel
  • Others useful units: Androidapi.AppGlue, Androidapi.JNIMarshal, Androidapi.JNI.Embarcadero
  • For more see: C:\Program Files (x86)\Embarcadero\Studio\14.0\source\rtl\android (Object Pascal) and C:\Program Files (x86)\Embarcadero\Studio\14.0\include\android\rtl (C++)

You will want to make use of Conditional Defines in Object Pascal and Predefined Macros in C++. In my blog post on Android Settings I showed how to make a JNI call with Object Pascal, but you can also look at the DeviceInfo Mobile Code Snippet in both C++ and Object Pascal. To create your own JNI Bridge wrappers, look at the source code in C:\Program Files (x86)\Embarcadero\Studio\14.0\source\rtl\android (Object Pascal) and C:\Program Files (x86)\Embarcadero\Studio\14.0\include\android\rtl (C++). You can also consider the following 3rd party utilities:

If you just want to include standard Android APIs then check out the FMXExpress (also an Embarcadero MVP) project on GitHub that includes all the Android APIs. Here is the video replay of my skill sprint

Also, check out Brian Long’s video on accessing the Android API with XE5

Categories
Tools

Clone from GitHub in Delphi IDE

There are a lot of interesting Delphi projects showing up on GitHub. GitHub offers a convenient Download ZIP function, not to mention a very easy to use Windows Desktop Client that has full support for managing local repositories, syncing them to GitHub and accessing GitHub projects via Cloning in Desktop.

Sometimes it is nice to just open the project in your IDE of choice directly from GitHub. Turns out this is just as easy as 1-2-3. Right above the Clone in Desktop and Download ZIP buttons there is a checkout URL with support for Subversion. Simple click Subversion, then click copy URL and your can then open the GitHub project directly from the Delphi or RAD Studio IDE.

github-subversion

This maintains the revision history locally so you can browse it from the history tab, but it doesn’t appear to allow checking changes back in.

You probably want to update the SVN client RAD Studio uses. This is easy enough too. Just download and install the Colab SVN 32-bit Windows client (don’t get 64-bit or Edge) and install it normally. Then edit your Registry and browse to “HKEY_CURRENT_USER\Software\Embarcadero\BDS\14.0\Subversion” and add a string value named SvnDllDir. This value of SvnDllDir should be the path to your SVN client install. Something like “C:\Program Files (x86)\Subversion Client” (without the quotes).

If you don’t like the fact the Colab Subversion site requires a login, there are other sources for download the Subversion command-line client. Just be sure you get the 32-bit version since the IDE is 32-bit. You may have luck with with the command-line tools that come with TortoiseSVN, or I’ve tested it with the Command-line client from Assembla and found it worked fine.

Categories
Tools

Where is StringToJString and StrToNSStr in XE6?

The useful helper routines StringToJString and StrToNSStr (and other associated ones) moved between XE5 and XE6. In XE6 you can find them in the units Androidapi.Helpers and Macapi.Helpers respectively. But how to find other useful methods? I’ll tell you what I do: Use Windows Search.

You want to go to Indexing Options to set Windows Search up to be useful.

Windows Search Indexing Options

First select Modify and browse to the Source folder and add it to the list of indexed locations. I like to add the source folder as a favorite in Explorer too, to make it easier to get back there.

C:\Program Files (x86)\Embarcadero\Studio\14.0\source

Next click Advanced and go to the File Types tab and select .PAS file and any other file types you would like to have indexed, and change them to Index Properties and File Contents. It uses the plain text filter, which in my experience is good enough, and your only option (without installing a new one).

Indexing Options - Advanced - File Types

It takes a bit for the index to rebuild, but after that you can quickly search all of the XE6 source to find APIs, Helper Methods or any number of other useful code to aid in your development process. This is where that favorite to the source folder is helpful. Either search from the root of the source folder, or browse into a subfolder to only search specific source files.

There are other indexed searching utilities, and I’ve used many of them in the past. The advantage of Windows Search (probably it’s only advantage) is that it is built in and already running.

Categories
Components Tools

Indispensable Delphi Libraries

What are your indispensable Delphi libraries? The 3rd party libraries you just can’t imagine starting a new project without? I know mine have changed over the years and we have an interesting new crop of libraries in recent years. I listed some unit testing libraries recently, but thought it would be useful to focus on general purpose libraries (as opposed to visual component suits). Here are some open source libraries I either find myself using a lot, or I look forward to using:

I’m sure there are a lot that I am missing . . . What would you add to my list?

Categories
Android Components iOS Tools

Scanning Barcodes with RAD Studio XE5

Turns out there are a few ways to scan a barcode with RAD Studio XE5, and no sooner do I make a video about it then TMS releases a component to scan barcodes, and then Thomas Krampe sends me his component that combines them all together.

Not that we need another barcode scanning app on our smartphones, but it can be a useful feature for an app that performs another purpose to be able to scan a barcode too.

This video was part of our Making the Connection: Programming Devices and Gadgets with RAD Studio webinar. Check out the on demand replay to get the source code.

Categories
REST Source Code Tools

XE5 REST Debugger Supercharged

Some people asked for the source code to using the new XE5 REST Client Library to consume the Kimono web service. The crazy thing is there isn’t any. I decided to make a video about how easy it is to consume REST web services the the new REST Client Library and the REST Debugger. In the process I thought of a way to make it even easier by supercharging the Rest Debugger (source code below).

In this video I show you how to create a REST Web service with Kimono Labs (in beta, so it will change) and then bind that data to your XE5 app using the REST Debugger.

You can supercharge your REST Debugger too. The source code is installed with XE5

C:\Program Files (x86)\Embarcadero\RAD Studio\12.0\source\data\rest\restdebugger

You will want to copy it somewhere else before modifying it. Then add a button where ever you want, and on the click event for the button add the following code:

StreamToClipboard([RESTClient, RESTRequest, RESTResponse, RESTResponseDataSetAdapter, RESTClient.Authenticator]);

And then download uCopyComponents.pas and add it to your project and uses clause. It is pretty simple, but is designed specifically to work with non-visual components, although could be modified to work with visual components too.

If you want to include the TClientDataSet in the copy, then add it to the array (although make sure it is not active). Or you could modify it to add a TFDMemTable. Use it how you wish, I hope it works for you. If you discover any bugs make any changes let me know. If anyone is interested in contributing to it, let me know.

Categories
REST Tools

REST and the Kimono

I love the new TRESTClient components in XE5. Especially the ability to visual bind a REST datasource with the use of the TRESTResponseDataSetAdapter. Now I find I’m always on the look out for new REST datasources. The REST Debugger makes the whole process really easy too.

The other day I hit the mother-load of REST datasources with Kimono Labs. It is a creative web service that makes it easy to scrape a web site and turn it into a REST data source. It looks for repeating data on the page. Their free service is enough to get you started. I created a simple REST datasource of San Francisco 49ers games from their schedule on their web site.

kimonolabs.comA few tips for working with the Kimonolabs REST API.

  • Make sure the web data doesn’t include hyperlinks – if it does, then the REST data will include objects containing the href and the text, which doesn’t map to a grid well.
  • Use results.collection1 as your root element in the TRESTResponseDataSetAdapter and you are off to the races.
  • It doesn’t work with every web page because of malformed pages, but it works with a lot of them.
  • There is no way to edit your API once you’ve finished it (yet), so you end up deleting and recreating it a few times.

They have a lot of videos and tutorials on their site walking you through how to use their service. Take a look and I’m looking forward to your REST enabled apps!