A few XE5-related bits

With XE5 now out, I’ve updated my FMX TClipboard and Mac PDF writer code to compile with it, and in the case of the latter, also made an unrelated fix suggested by Sebastian Zierer. With respect to TClipboard, I must add the caveat that the Android implementation merely delegates to the standard, frankly half-arsed IFMXClipboardService, and as such, only supports text. This is because my investigations into the Android API suggest there is no standard way to exchange pictures over the Android clipboard – if anyone knows something to the contrary, by all means let me know in the comments though. Anyhow, if you want to browse the code, check it out here: http://code.google.com/p/delphi-foundations/source/browse/#svn%2Ftrunk%2FFMX%20Utilities Alternatively, the SVN link is http://delphi-foundations.googlecode.com/svn/trunk/FMX%20Utilities/ I have also just posted to the same place a TCustomIniFile descendant that delegates to the Android SharedPreferences API, which I have unimaginatively called TAndroidPreferencesIniFile (the unit is CCR.PrefsIniFile.Android.pas). This class corresponds to the TMacPreferencesIniFile TApplePreferencesIniFile class I had written previously, which sits on top of the CFPreferences API on OS X and iOS. The idea in both cases is to have classes that roughly correspond to TRegistryIniFile on Windows, providing a consistent interface over whatever is the native preferences store for the platform. Be warned that unlike TIniFile (but like TApplePreferencesIniFile), TAndroidPreferencesIniFile is case sensitive with respect to section and key names. Further, there’s also a slightly annoying issue in which each time an app is deloyed by the IDE, existing preference data gets wiped in the process. Given when you run an Android app from the IDE you see a message saying it is uninstalling the previous version of the app, I imagine the preference wiping is just a function of that. Anyhow, accompanying the main unit is a small (and very crude!) demo designed for a 7″ tablet (a Nook HD in my case): TAndroidPreferencesIniFile demo The demo works best if you write a series of values first, given the third edit box doubles as both the entry field for values to write and default values to read.

Update (17/9/13): originally the unit was called CCR.Android.PrefsIniFile.pas; it’s now CCR.PrefsIniFile.Android.pas for consistency with the naming pattern used by my TClipboard units. I’ve also now added a ‘mobile’ version of the demo which uses TAndroidPreferencesIniFile when targeting Android, TApplePreferencesIniFile when targeting iOS, and TRegistryIniFile when targeting Windows (Delphi provides the Windows option in a mobile project to allow ‘quick and dirty’ debugging).

Update (25/6/15): current version now at http://github.com/chrisrolliston/CCR.PrefsIniFile

9 thoughts on “A few XE5-related bits

  1. Thanks for sharing the code for preferences for all platforms. This has saved me a lot of time! You might want to look at another cross-platform project we’re working on.

    • Thanks for the report – should be fixed in r.96 (just committed it to the trunk), so try it out and let me know.

  2. Pingback: TAndroidPreferencesIniFile fix | Delphi Haven

  3. Hi, compile errors in XE7:
    [DCC Error] CCR.PrefsIniFile.Android.pas(101): E2003 Undeclared identifier: ‘getPreferences’
    [DCC Error] CCR.PrefsIniFile.Android.pas(103): E2003 Undeclared identifier: ‘SharedActivity’
    in unit unit CCR.PrefsIniFile.Android;

    Thanks…

Comments are closed.