alternative calculator updates

May 25, 2015

I spent a bit of time this weekend working and learning more about Android via Alternative Calculator. These are screen captures from the current implementation running on my Galaxy S4 and Android 5.0.2.

I’ve changed the colors a bit. I got rid of the red display color and picked a dark cyan background. The upper menu bar is an Android blue. These colors will probably change yet again.

I added logic to change the 2nd key and all other affected keys to a dark orange when active. All the keys that are the same color as the 2nd key above will work accordingly. Thus we have the pi constant, the root key, the exponent key, and the inverse trigonometric keys. Once complete the keys revert back to their primary functionality and the key’s background color reverts back to its original color. Or if that’s not what you intended, just press the 2nd key again to revert.

The Deg(ree) key toggles between degrees and Rad(ians). It’s sticky, in that it stays that way unless pressed again. Not even Clear or Clear Entry can change it.

The main algebraic keys now change color to indicate what the last key was pressed in a chain of calculations. I wrote before that one of my biggest pet peeves was being interrupted and when getting back, forgetting where I was at. Hopefully this will help address that problem. Other calculator apps get around this by actually ‘writing’ the full equation as you type it in the display. I personally am not crazy about that, at least now how its implemented. This is, again, something of a compromise.

Finally, I discovered how to set the keys as borderless by setting my custom style parent to “android:Widget.Material.Button.Borderless”. Looks great, but it breaks my current ability to change the key’s background color as I do above. I need to further investigate how to programmatically change the color of a borderless Material button.

Behind the scenes I’ve implemented code for store, recall, and sum, although I’m not so sure sum will last. I’ve never used sum for any reasons. The current number of storage registers is an arbitrary 100 (00-99). I’m also looking at making the registers store imaginary numbers and vectors (both two and three dimensional). Since an imaginary number is usually part of a complex number (two values) it fits within the idea of vectors. For those of you who are wondering what I’m talking about, complex numbers are used in electrical engineering and circuit analysis (among other things).

EE (exponentiation) and the use of parenthesis and algebraic notation are in progress.

There’s also been a bit of refactoring going on. Hard-wired constants, especially strings, are now in strings.xml. That allowed the Java code to be greatly simplified. Hopefully this is a bit more idiomatic Android coding that what I had before.