Monday, August 3, 2015

Calculator VI

Github


What I've done


My UI is now finished. I added a calculator font that looks pretty nice, changed the color of my screen and buttons, and I made a small change to my button placement that I think looks better. Changing the button color was a bit more convoluted than I had hoped. I assumed that I could just change each one's background XML attribute, but that gave me a colored square instead of a colored button. I looked it up and learned about setcolorfilter(), with which I changed each button's color programmatically. I set up a colors.xml file, but the setcolorfilter() doesn't seem to give me a way to reference an xml file, so I had to enter the hex codes for each color I wanted.

I noticed an issue--the app crashed whenever just a period is onscreen and an operation button is pressed. So I added a condition to the relevant methods, that will prevent them from running if the screen just has "." on it.

I also added a second textview that shows operations and a method in my code that displays the correct number and operator.


Lingering Issues


My second textview helped me realize that I have a problem with my operation method. In the cases where I'm chaining together operations, the operator is being changed to the new operator too early. So 1 + 3 - 1, will evaluate as 1 - 3 - 1. So, I've got to fix this, and besides that the only thing left is formatting. I played around with decimal format a bit but it's still not to my working like I had hoped. I think I'm going to just make a method that will format my doubles, and change the formatting if they happen to be of a certain length.

No comments:

Post a Comment