Android meets Arduino!

As you guys know, I don’t really do “product reviews”. But if I find a handy tool, and use it, then it is fun to share that info with others. One such tool is Bluino Loader, an Android app that lets you create Arduino files, upload them to your boards, and even monitor the serial connection over USB. It’s pretty handy!

As with any “code from your phone app”, it is a bit tedious to type a lot of code with the Android keyboard. So I don’t use this app a lot when it comes time to create code. One of the big things that I like to do with it, though, is to monitor the serial output over a USB OTG cable.

Using the OTG cable, I can hook the Arduino Uno board directly to the phone, which also powers the board. Then I can open up Bluino Loader and click the icon at the top to monitor the serial connection. It can’t get much simpler than that. Within seconds I have serial data coming in and being displayed in the terminal. I even used it to test out the 433 MHz transmit and receive functions from my last test project. Worked like a charm!

Linux – keep it simple.

Triple check that, will ya?

device-2017-03-08-124806A long long time ago
I can still remember how
That App used to make me smile….
And I knew if I had my chance
That I could make those dice dance
And maybe they’d be happy for a while….

Uh, wrong lyrics. Actually, it was quite a while ago that I made the Android app, Ships, Captain, and Crew! After the move from GitHub to GitLab, I decided to look over some of my old issues that were imported with GitLab’s great import tool. Among them, I found two issues for this old app that I had made.

The first was that of an issue with screen rotation causing the app to restart. I quickly fixed that by just setting the activity to portrait mode in the manifest file. You can check my commit if you need details.

The second issue was a bit more complicated, in that there was a problem with checking the dice for a ship, captain, or crew. Essentially, if you rolled a 4, 5, 6, 1, and 3, it would say you only have a ship (the 6) and no captain (5) or crew (4). Obviously that’s wrong. The issue is that you need a 6 before you can keep a 5 or 4. And since the dice were checked in order, when it looked at the 5 or 4, it did not have a 6 yet, so they were not “kept”.

This is how I fixed it:

for (int i = 0; i < 3; i++) {

// Check three times.

myNumber = firstDie;

diceCheck();

if (waschecked){

firstnotchecked = false;

}

dieOne.setImageResource(id);

myNumber = secondDie;

diceCheck();

if (waschecked){

secondnotchecked = false;

}

dieTwo.setImageResource(id);

myNumber = thirdDie;

diceCheck();

if (waschecked){

thirdnotchecked = false;

}

dieThree.setImageResource(id);

myNumber = fourthDie;

diceCheck();

if (waschecked){

fourthnotchecked = false;

}

dieFour.setImageResource(id);

myNumber = fifthDie;

diceCheck();

if (waschecked){

fifthnotchecked = false;

}


dieFive.setImageResource(id);


}

As you can see,  I told it to check the dice, first to last, three times. Yes, this is ugly and poor programming. Actually, I was almost ashamed of this early work, it looked so congested and terrible. However, my goal today was the quick fix, so that’s what I did. Hopefully, the update will be available on F-Droid soon, so you’ll have to check it out!

Linux – keep it simple.

Ubuntu Touch: Making a new app

Realizing that there are a few apps missing from the Ubuntu Touch OpenStore, and being an Android app developer, I thought I would try to bridge the gap. Rolling up my sleeves proved to be a bit harder than I thought, though. I came to realize that UT doesn’t use java – at all. The Mir interface doesn’t support the java commands to display or draw things on the screen, so I was a bit stuck.

However, wanting to press on, I did manage to learn how to make a basic “hello world” app. While there are a few tutorials available, it got overly complicated, and I ran into some snags, so I thought I’d share the simplified version here. This is the pertinent info from the UBports website:

 

  • Add the PPA to your system: sudo add-apt-repository ppa:bhdouglass/clickable
  • Update your package list: sudo apt-get update
  • Install clickable: sudo apt-get install clickable
  • Configure docker for clickable: clickable setup-docker

After learning how this works, creating a new, blank or empty app is simple:

alaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/ubports_apps$ mkdir newapp
alaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/ubports_apps$ cd newapp/
alaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/ubports_apps/newapp$ clickable init
Available app templates:
[1] pure-qml-cmake – Pure QML App (built using CMake)
[2] cmake – C++/QML App (built using CMake)
[3] python-cmake – Python/QML App (built using CMake)
[4] html – HTML App
[5] webapp – Simple Webapp
Choose an app template [1]: 4
Generating new app from template: HTML App
You’ve cloned /home/alaskalinuxuser/.cookiecutters/ut-app-html-template before. Is it okay to delete and re-clone it? [yes]: yes
Cloning into ‘ut-app-html-template’…
remote: Counting objects: 28, done.
remote: Total 28 (delta 0), reused 0 (delta 0), pack-reused 28
Unpacking objects: 100% (28/28), done.
Checking connectivity… done.
title [App Title]: newapp
description [A short description of your app]: this is my newapp
app_name [appname]: newapp
app_full_name [appname.yourname]: newapp.alaskalinuxuser
version [1.0.0]:
maintainer_name [Your FullName]: alaskalinuxuser
maintainer_email [email@domain.org]:
Select open_source_license:
1 – GNU General Public License v3
2 – MIT license
3 – BSD license
4 – ISC license
5 – Apache Software License 2.0
6 – Not open source
Choose from 1, 2, 3, 4, 5, 6 [1]: 5
Your new app has been generated, go to the app’s directory and run clickable to get started
alaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/ubports_apps/newapp$

After creating a directory to store your app, you just run the command “clickable init” to create a new app. The prompts will ask you for your name, version number, email address and license type for the app. Pretty straight forward. Then you can edit the created app files to your liking, and just run clickable to build it:

alalaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/ubports_apps/newapp$ clickable
No clickable.json was found, using defaults and cli args
Auto detected template to be “pure”
Copied files to temp directory for click building
Successfully built package in ‘./newapp.alaskalinuxuser_1.0.0_all.click’.
337 KB/s (15836 bytes in 0.045s)
Installing files [=========================]
Finished [=========================]
Installing files [=========================]
Starting [=========================]
Finished [=========================]
Installed newapp.alaskalinuxuser-1.0.0.all (installed:click,removable=1,app_name=newapp) summary goes here
alaskalinuxuser@alaskalinuxuser-OptiPlex-7010:~/ubports_apps/newapp$

And voila! If your phone is plugged in, and developer mode is enabled, it can install it and run it on your phone. I also found it useful to use:

$ clickable –desktop

when you want to test it out on your computer, rather than put it on the phone. It seems to work rather well. As a side note, the first time you run it, clickable will download about 500 MB of UT files. This only happens once, not once per app, just once on your machine.

There is also the Ubuntu-sdk, although not supported, it is available if you would like a gui, rather than command line when making your apps. You can install it like so:

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
sudo apt update && sudo apt dist-upgrade
sudo apt install ubuntu-sdk
sudo reboot # or logout/login

ubuntu-sdk

I’ve tried it out, and to be honest, I prefer the command line, but I might just need to play with it a bit more to get the hang of using it. Hopefully, this will help you if you are trying to get started on app making. I plan to go over how to make an app for XMPP soon.

Linux – keep it simple.

Added reset button to the Beginning Chess Engine app, but it doesn’t do what you think….

As you can see, I added a reset button to the app for the Beginning Chess Engine.

added_reset

Originally, I had intended to have the board simply reset back to the starting position. However, for some odd reason, when I would reset the board pieces, odd things would happen….

Like a rook would randomly turn into a king when you move the knight.

So, I decided to have the app close, and then call itself to be opened again a few milliseconds later. It’s a little odd, since the app “closes” and then “opens” again, so it looks like it crashed, only to pop up again.

If this were my chess playing app, I would need to focus in on that a little more, however, I am trying to focus on the engine itself, not the remnants that are somehow misconstrued during recreating the original board.

Here’s the commit:

https://github.com/alaskalinuxuser/BeginnerChessEngine/commit/3f6aae2c2e5327d341e15cb50c9d702dc4356fd7

And one issue closed! Only 9+ more to go!

Linux – keep it simple.

Beginner chess engine has a new repository!

The beginner chess engine has a brand new repository so I can more accurately track issues. Before, it was a small part of a larger repository holding different programs, but I have so many issues that I wasn’t to track, that it became difficult to use in that manner.

So, I’ve opened a fresh repository for it:

https://github.com/alaskalinuxuser/BeginnerChessEngine

Be sure to check it out and see all of the issues that I am tracking! Also, of you try it out, you are welcome to add issues as well.

Note: This beginner chess engine is just a simple chess engine that is programmed by a beginner (me), but also recognize that the goal is a drop in engine that is open source for other programmers to use to make their own chess games on Android (or perhaps other) devices.

With that in mind, the app is supposed to allow controls for the engine tester to try things out, and adjust settings for use in their projects. Not so much for the user to play chess, although I hope to make a chess playing app in the future as well.

Linux – keep it simple.

Making an Android chess app….

begginerchess

Lately I’ve been amusing myself in my spare time by learning how to make a chess engine. I don’t want anyone to think that I came up with this on my own, I’m taking a tutorial through Youtube videos by a man called Logic Crazy. Be sure to check out the link for his tutorial, I’ve found it to be fun and informative!

Logic Crazy seems to have a website with several other variants of chess engines, as well as engines for a couple of different games. And that is also worthy of a good long look. For myself, I’m just trying to learn the basics of Java programming.

Logic Crazy’s design is for an actual Java program to be run on your computer. I on the other hand, am adapting it for an app to be used on an Android phone, which I’m hoping will be fun, but also a great learning experience. My free time is a little bit limited these days, but hopefully you’ll be seeing more posts about it soon.

Linux – keep it simple.

libGDX music and sound fail….

While finishing my Android app developer course, I ran into this error during game development:

[CODE]

——— beginning of crash
06-09 13:01:19.410 30345-30366/? E/AndroidRuntime: FATAL EXCEPTION: GLThread 758
Process: com.alaskalinuxuser.criticalvelocity, PID: 30345
com.badlogic.gdx.utils.GdxRuntimeException: Error loading audio file: data/spblk.mp3
Note: Internal audio files must be placed in the assets directory.
at com.badlogic.gdx.backends.android.AndroidAudio.newMusic(AndroidAudio.java:120)
at com.alaskalinuxuser.criticalvelocity.criticalvelocity.create(criticalvelocity.java:55)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1532)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)
Caused by: java.io.FileNotFoundException: data/spblk.mp3
at android.content.res.AssetManager.openAssetFd(Native Method)
at android.content.res.AssetManager.openFd(AssetManager.java:363)
at com.badlogic.gdx.backends.android.AndroidFileHandle.getAssetFileDescriptor(AndroidFileHandle.java:237)
at com.badlogic.gdx.backends.android.AndroidAudio.newMusic(AndroidAudio.java:110)
at com.alaskalinuxuser.criticalvelocity.criticalvelocity.create(criticalvelocity.java:55)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1532)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)

[/CODE]

It took a long time to figure out the issue, so I thought I would try to save someone else the trouble.

It hinges on this line from the libGDX wiki example:

Music music = Gdx.audio.newMusic(Gdx.files.internal(“data/mymusic.mp3”));

Which my line looked like this:

bgMusic = Gdx.audio.newMusic(Gdx.files.internal(“data/spblk.mp3”));

Should work right? But it didn’t. I had to change my line to this to make it work:

bgMusic = Gdx.audio.newMusic(Gdx.files.internal(“spblk.mp3”));

And put the mp3 file in the “assets” folder.

Hopefully, this will save someone else a really long, frustrating search!

Linux – keep it simple.

Signing and installing your MechDome converted app on a simulated iPhone

In our last post, I talked about a really neat website: MechDome, which automatically converts your Android app into an iPhone application. If you haven’t read that article, I suggest you do to learn more about MechDome, which I think is going to be very big for Android developers in general. At the end of our last post, we had downloaded our converted app and run it in an iPhone simulator on our virtual Apple computer. In that post, though, I skipped all of the details of how we do that, and I would like to take a look at that question now.

So, get your Apple fired up (online, virtual, physical, etc.) and download your converted app from MechDome!

Now that you have your app downloaded, go ahead and launch Xcode. If you don’t have Xcode, it can be installed from the iStore. Once Xcode is open, go ahead and edit your preferences.

Xcode –> Preferences –> Accounts

If this is the first time you’ve been here, like it was for me, then it will be blank. press the “+” sign at the bottom and add your Apple ID account.

Once your Apple ID is added, you can now select it, and click on “View Details”. In the resulting popup, click “Create” for iOS developement. This will create the certificate you need for “signing” your test apps on your local simulator. There is not much to tell you how it went, but if the button to create disappears, it worked, so click “done”.

Now you are ready to launch the simulator. There is probably a better way to do this, but here is the simplest methode I found. Since you have Xcode open, go ahead and launch a new project. It will load fairly quickly with a default empty project. Now, press the play button at the top of the screen, which will automatically launch the simulator, boot the iPhone, and launch your empty app project.

Once that is open, you are litterally done with Xcode, so you can quite or close it, and the simulated iPhone will stay open.

Click on the iPhone window, and from the top menu, select Hardware –> Home to get back to the iPhone home screen.

Now open your OSX terminal. You can open it from the launcher by typing term and clicking on the terminal icon.

In your terminal, navigate to the downloaded zip file. For me, it was in “Downloads” and looked like an “app” but it was a directory.

$ cd Downloads

$ ls

stuff
stuff
stuff
Hourglass.app
stuff
etc….

Now, find your new certificate (key) to sign the app with:

$ security find-identity -p codesigning -v login.keychain
1) ALPHANUMERIC4404038dkldsf03893 “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)”
2) ALPHANUMERIC4404038dkldsf03893 “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)”
3) ALPHANUMERIC4404038dkldsf03893 “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)”

And set the default keychain:

$ security default-keychain -s login.keychain

And sign your “app”:

$ codesign -vfs “NAMEOFCERT: APPLEID@EMAIL (MOREALPHANUMERIC)” –keychain login.keychain ./Hourglass.app/

Now that it is signed, you can install it into the already running iPhone simulator with the following:

$ xcrun simctl install booted Hourglass.app/

You should see it show up on your iPhone home screen, but it may be on one of the other screens, so swipe left and right to find it. Once you found it, go ahead and click on it to launch the app! There you go! Barring any other issues, it should work as expected.

hourglass

Apple – er, uh, wait! Linux – keep it simple!

 

MechDome: Run your Android apps on iPhones and iPads!

As an open source developer of simple Android applications, I can’t tell you how ecstatic I am about a new website: MechDome  (https://www.mechdome.com/). Finally, a one stop shop to turn your Android app into one that can be used on iOS devices, in minutes!

Can this really be? Is it really that simple? Drag and drop your Android apk file into their website and it spits out an iOS application? Well, I decided to try it for myself, and I’ve devoted this entire post to my experience.

TLDR: MechDome ROCKS! It successfully converted my opensource app: Hourglass, into an app for iPhones. If you are an Android developer, you should head over to MechDome right now!

Still with me? Great, then here are my thoughts on MechDome ….

Website Experience:

mechdome_home

The MechDome website is intuitively laid out in an informative and well thought out manner. From the opening page you will see all the information you need to get started, as well as informative placards telling you what MechDome will do for your app, namely convert it from a native Android apk to a native iOS application.

mechdome_intro

After clicking “Create App” at the top, you are asked to sign up for an account. The process is clean and intuitive, and I really liked the color scheme. Perhaps one of the best features of the website is the modern user interface and clean look.

I also tested the website out on my cell phone, and it worked beautifully.
mechdome_icon

Within a minute I had my app uploaded and was ready to test out this process. You have a couple of options about Firebase or Google ads, etc., as well as the option to use a custom icon. I think the choice to use a custom icon is great, as you may want something that looks more “iPhone-ish” or something to differentiate between your Android and iOS applications visually. After choosing your options, press save.

Once your settings are properly set, all you have to do is click the Simulator button. Presumably, when they open up the options to go to the Apple store, you can simply press the iOS button instead, but for now, free accounts are only able to upload one app for the simulator.

This is the only “problem” I saw with the website. After clicking the Simulator button, the button starts spinning, but there is no sort of progress report. After a while of waiting I ended up closing the browser, opening the page again and found the button still spinning, so I left the screen to do some research. After a few minutes, however, I received an email telling me that my app was ready for download.

So if you convert an app, after clicking Simulator, you can go about your business knowing that an email will be sent to you when your app is ready. That is really convenient. I do think the website should indicate that, though, after you click the Simulator button.

I tried this twice with my two email accounts. The first app I tested was done in a few minutes. The second app I tested was not done for several hours. Both of the apps were about the same size, albeit one was a little more complicated than the other.

mechdome_appready

Once your app is ready, the Simulator button changes from the orange “refresh” symbol to a green “download” symbol to let you know your app is ready for download.

A quick tap of the download button and I had a shiny new zip folder on my hard drive. Simple, short, sweet!

Now all I had to do is test it…..

App conversion:

It actually took me a while to get the hang of how to use an Apple computer so I could test the app that I converted. Since that is a bit of a rabbit trail, I will save that for the next post. Here I will just talk about how well the app conversion worked.

As I said before, I used my two email accounts to “cheat” and use MechDome twice. Currently, free accounts only get one trial download/conversion for simulator use only. Both apps that I tested did work rather well, so I will only discuss the open source app that I tested, which was my Hourglass app, available on F-Droid and the Google Play Store.

Here’s a few screen shots of my app in iOS action:

This slideshow requires JavaScript.

Overall the app worked great! It looked pretty close to what it looks like on Android, and as far as I could tell, every part of the app, every button, every slider, etc., worked flawlessly.

Notifications, however, were a bit different. Not wrong, just different. First, as you can see in the slideshow, I was prompted to ask if I would allow this app to send notifications or not. Choosing yes allowed the notification to pass through, and you could see it in the notifications bar, if you pull the bar down. When the timer on the app reaches 0:00, it is supposed to have a popup to tell you that your timer is up, but that didn’t happen. If the app was open, then that would transpire, but not if the app was closed. However, the sounds still played, so it seems to still function great as a background timer.

The other app I converted was a customer feedback type of app, which was not open source, so there are no pictures of it here, sorry. An interesting note, it used parse extensively, and seemed to work flawlessly. This proved to me that parse, networking, and intents were working great! The only oddity was the color of the “stars” for the ratings. In the Android version, the stars were orange/yellow, but in the iOS version, the stars were an odd gray color. Still functional, just a bit of a visual oddity. Overall, I was really impressed. Two thumbs way up from this Android developer!

Open source and Pricing potential:

I exchanged a few emails with the MechDome staff and was really impressed by how quickly they responded, as well as their professionalism, enthusiasm, and helpful attitude. In those emails I asked them about general pricing and open source development. They have not publicly finalized any pricing options, but it sounds like they plan on a tier subscriptions. Perhaps those who do multiple apps, or apps of a certain magnitude will fall under larger “tiers” and be charge extra.

Within our emails, we had a brief discussion in which I was proposing an open source developer account option. While I cannot speak on their behalf, they did seem very favorable to supporting open source development. Obviously, if you are making free applications, it doesn’t work to pay money to convert them for the iOS systems. They were curious to know what my thoughts are for what an open source developer account might look like.

These sort of things are probably best left to bean counters who usually handle this thing, but here are my thoughts on how to best support open source development:

  • Ideal: Give users the opportunity to create an open source developer account that can convert a limited number of open source apps per month, such as two or three, for free. No subscription costs, and if the account stays active, then it will not expire.
  • Less than ideal, but still helpful: Give users who already have paid subscriptions the ability to convert open source applications without counting against their monthly quota or subscription.
  • A one time setup cost: Another option might be a one time cost, rather than a subscription, for an open source account. E.g., a $25 setup fee for open source users to set up a developer account.

With either of the above options they will help support open source development. However, I suspect that if it costs anything for a subscription, a lot of open source developers will not be able to participate.

For instance, my open source applications and software work garner me $0 currently. I receive no donations currently, and do not get paid for my open source work, I don’t currently support advertisements, because this is my hobby. So if the subscription costs too much, I would not be able to maintain the subscription.

But, if there was a one time fee (like there is to get a Google developer account and put apps on the Play Store), or a free account with limited use for the open source developer, then I would be all in! Obviously, any account that used the software improperly, to convert closed source materials for free would need to be prosecuted, etc., but that is something I’m sure MechDome  is already looking at from a legal standpoint.

These are just my thoughts, and they do not reflect MechDome‘s opinion on the matter, as that remains to be seen. Hopefully they will consider the open source community and help it thrive by allowing some sort of use of their conversion software, because MechDome has proven to me to be exceptional when it comes to quality and customer service so far! Now all we have to wait on is their pricing.

In the mean time, head over to MechDome and try converting an app yourself! It works great! If you have trouble running that app in the simulator, be sure to check out my next post!

Linux – keep it simple.

P.S. I don’t want to sound like a broken record, MechDome is not offering me any special deals, payment, or benefits to write this, I just really liked my test run of their conversion software on their website.

Just letting the user know…

When making apps, I have begun to realize that I don’t do a very good job of creating intuitive and informative interfaces. The fact that the user his the export button doesn’t really tell the Just Notes app user that they actually did anything, or that notes were exported. That is why I added this commit:

https://github.com/alaskalinuxuser/app_justnotes/commit/9162b2bb87c46574765ced7b4a7f9b8ff223756f

Essentially, I created a pop up (called a toast) that tells the user their notes were, in fact, exported. Something I probably should have done a long time ago!

Linux – keep it simple.