Google+ Badge

Saturday, March 18, 2017

First week with Kotlin

Got my first nearly full week of Kotlin in place. I can't say full week as I started the new job on a Tuesday and there was training involved too. I have the iOS / Swift code to follow as well.

I needed to grab the colors used by the client along with redoing one of the main graphics as an SVG image. Previously I had Adobe Illustrator but I don't have that now so I used Vectr (I know, odd spelling) which was fine for the minor image I needed to so. I also found Krita for graphics editing and I used that to size the Android icons. I used another online helper program to do the new rounded version of the icons as well. First time I have created a set of those.

When working from home I used my personal PC to play music via Media Monkey + a helper program that exposed a web site for me to pause / skip songs. Don't have that working in an office so I started using Clementine but it has a bug where it double plays WMA songs which got annoying so I gave Vox a shot. Nice thing is I could drag and drop the playlist right out of Clementine into Vox and Vox has a plug-in so I can use the multi-media keys on the Microsoft Natural 4000 keyboard to play / pause and change the volume.

Speaking of the keyboard, the first one failed. The space bar would either not work or it would repeat spaces forever. Took it back to Microcenter who does things in what I think is an odd manner. I just wanted to swap keyboard - bad for good - but they don't do that. They will refund the bad one and give you store credit then you have to go find the replacement and go back through the line again to buy it. Seems silly to me but I have a working keyboard. I have used this style of keyboard for a long time. Sure, they have died on me in the past after years of service but I have not had a bad one out of the box.

While at Microcenter I also got a small laptop bag and a mouse pad. They want me to take the laptop home every night. No big deal, makes it easier if I need to work from home anyway. On that subject I ordered a USB C to mini-display port and USB-C to USB adapter to have at home so when I do work from home I can use my big monitor, keyboard and mouse. That showed up Friday from Amazon and they work just fine. There is a rumor I will get a separate power brick to have at home as well.

Back to Kotlin. It is very handy that when you copy in Java code it will auto convert it to Kotlin. Makes learning stuff a ton easier as well. Kotlin sure uses a lot of lines of code to do the same thing. Copied in an enumeration where I had a couple of extra fields associated. Kotlin does it with a one line constructor. Since a lot of the work I have done has been the basic setup I have not really gotten deep into Kotlin yet.

I got the first couple of screens ready, login and then the drawer based menu system. I stubbed out fragments for all the main screens and implemented the basic help screen as well. More colors, drawables and a few layouts. Also battled getting the actionbar colors I wanted with some help from Reddit. Demoed the app to the team and they were happy how far along I had gotten it.

The build.gradle files were my next target. I added some booleans so use the BuildConfig file to control access to menu items. I also setup a file so I can run tasks to update the build version string and build number for the command line as well. Tossed in some more libraries I knew I will be using in the next steps including play services so I can get a unique ID the Android way.

Next up is getting Retrofit in place. That is where I will start next week. Need to find some decent tutorials on using it with Kotlin. Will tie in some dependency injection as well. There is some documentation for our REST calls but I am also using Charles Proxy to monitor what iOS is doing. Documentation gets out of date so seeing the raw JSON is usually the way to go. Plus I can see all the data in the request header and the response.

I have not really looking into the Swift code yet. I have been in there to grab some assets including a special font they use. Of course I have the app working on the iOS simulator so I can check out the program flow and screen layouts.

I also configured Slate so I can have a configuration for single screen when I detach at work and another configuration when I am running multiple monitors. Very handy to have all the windows move to the correct position when you start up as the Mac is great at starting the programs again but it sucks at getting them in the proper layout.