It was hack-a-thon days at work so I decided to try Flutter. I found a blank starter app then spent 10 Google Searches to about every two lines of code I actually wrote it seemed like. Flutter and Dart have both been evolving so much that a number of searches showed old information. At least most of the Stack Overflow stuff pointed you to the newer way of doing things.
For the past two years I have been doing Kotlin so I kept forgetting to add ; to the end of lines. Already know the IDE but I did not want to pollute Android Studio so I grabbed IntelliJ and set up under that. Configuration was pretty straight forward and since I am on a MacBook I could test both iOS and Android builds. Did all the work on Android emulator then tried it on iOS from time to time.
I used the Material look and I have zero if / then checks for Android or iOS. Small app so that does not prove a lot but for what I did I ran into no issues.
App has an image, read from assets, and 6 buttons with icons from the Icons package and text in a grid layout to go to other areas. One button shows an Alert Dialog. One goes to a screen with a ListView. The ListView is populated with items I read from a JSON file in the assets area.
I learned about Row, Column, Container, ListView, TextStyle, Expanded and all sorts of Widget properties. I have used a lot of layout managers over the years so I was able to get up to speed pretty quickly but I did a lot of searches to find what I needed and I refactored the layout code at least 6 times. Lots of indenting and easy to screw up a ( ) and [ ] matches or miss the ; at the end. The errors given by IDE generally pretty good.
Imported Intl, DateFormat and Decimal. Wrote converters for JSON as I have Date Time and Decimal needs due to Double having accuracy issues. Learned how to grab a file from assets. I did not mess with any network stuff as you need to login with OAuth first to get to any of our data and that seems like it would eat up both days.
Felt like I got a lot done in a day and a half. Very frustrating at first as getting anything simple to work took a lot of web searching and I went down so many wrong paths. First I was setting up the icon buttons as decorated columns then found I should be using FlatButton instead so I could get the actually tapped event and the tapped visual effects. Initial ListView code I found was very complicated but I found a simpler version and got it running quickly.
So am I a Flutter convert? No, I just wanted to see what it is all about. We use a number of 3rd parties for interaction with Credit Card readers and what not that probably would be a massive pain to deal with in Flutter. I was impressed at the speed of testing stuff in my small two screen app. The instant run is nice. Having an identical app on two platforms is sweet. Setting up images sucked as you have to manually add them into the YAML file. I just want all things in a directory to be there. On-line help is all over the place, some old, some new, some expecting you to know a lot especially when they talk about packages. They don't always mention what to add to your YAML so you do another search to find out that info.
Do I see some usages here? Kinda, like any app that appears to start out small you go "oh, I could do this simple app and get a free iOS version" but then you start adding more and more stuff then you hit some wall where you need something deeper in hardware and you are screwed.
Next areas would be doing actual REST calls, doing complicated UI work, SQLite interaction, lifecycle fun, shared preferences, animations, and basically being a real full featured app.
Glad I had time to play with it as was paid to do it. Time to save the code to Git and move back into my Kotlin reality. Worry is when I demo it this afternoon that the big bosses will think I found the holy grail of coding. Setting expectations is the key here.
Showing posts with label kotlin. Show all posts
Showing posts with label kotlin. Show all posts
Friday, April 19, 2019
Sunday, December 17, 2017
Going full ConstraintLayout
Started a new project and decided to go full ConstraintLayout. I figure it is the future so I might as well use it. I used AutoLayout when I was doing iOS work so I have the general idea down.
First off I am using 1.1 because it has Barriers, Guides and Groups. To properly replace TableLayouts you need Barriers. This allows you to say "Hey, here are X controls, I want an edge to be based on the longest one". This is what happens with stretched TableLayout columns. It also means your layout will adjust if you change text label widths which can easily happen in other languages. Trying to stay on top of the internationalization game.
Group is nice if you need to hide a group of controls which you may need to do if you have a Switch that toggles visibility of a number of items.
Guides allow you to do percentage layouts. This gets rid of that deprecated layout.
Now my layouts are nice and flat. I went back to previous app and converted most of those layouts as well. The conversion tool in Android Studio is hit and miss. If you have just a RelativeLayout it will probably do a decent job converting it but you may have to set a width to 0dp here and there as the control may be set to start / end against another control but have a width of match_parent.
I also find you have to put in spacer controls at the bottom of some layouts, especially row layouts used in a RecyclerView, as the bottom margin is ignored for the lowest item in a layout. Did not cause too many issues.
I recommend you give this a shot as well.
First off I am using 1.1 because it has Barriers, Guides and Groups. To properly replace TableLayouts you need Barriers. This allows you to say "Hey, here are X controls, I want an edge to be based on the longest one". This is what happens with stretched TableLayout columns. It also means your layout will adjust if you change text label widths which can easily happen in other languages. Trying to stay on top of the internationalization game.
Group is nice if you need to hide a group of controls which you may need to do if you have a Switch that toggles visibility of a number of items.
Guides allow you to do percentage layouts. This gets rid of that deprecated layout.
Now my layouts are nice and flat. I went back to previous app and converted most of those layouts as well. The conversion tool in Android Studio is hit and miss. If you have just a RelativeLayout it will probably do a decent job converting it but you may have to set a width to 0dp here and there as the control may be set to start / end against another control but have a width of match_parent.
I also find you have to put in spacer controls at the bottom of some layouts, especially row layouts used in a RecyclerView, as the bottom margin is ignored for the lowest item in a layout. Did not cause too many issues.
I recommend you give this a shot as well.
Friday, June 2, 2017
App is on the Play Store
Did the official release of the app Wednesday morning. By Friday I had over 10,000 installs. They did send out a bulk email to our current clients and many of them were hungry for the Android version. Various folks bought an iOS device and used that until the Android version was ready.
Gotta say it is an ego boost to hit 10,000 installs in a few days. I do realize this will taper off now but I am still supporting 10k users as the sole developer, the iOS guy pitched in on some of the code, of the app.
App is not 100% feature matched with iOS as of yet so I am working on adding the final matching features then we will work on improving the app and there are many other new features we will release in sync as time goes on.
Reviews have been pretty positive. Some are having issues with data outside the apps control. They are addressing those issues at the server level. I am using Flurry to track various things and to capture any issues found. The Play Store is also catching crashes. So far there have been about 17 unique crash events affecting just a few people. I have been able to track down and solve most of them. Some have nothing in the stack trace for me to even guess what is happening and a few were in the Flurry Library.
While I like Flurry the documentation is sad. You can't find any one place to tell you the latest version. Most of the official Flurry pages mention some flavor of 6.x but I found one place that said 7.0.0 so that was what I was using. I then decided to go to source, the jcenter repository, and found 7.1.1 was available. Since I had fixed a number of issues I had issues in this library I went ahead and did a fast followup release that I hope will knock things down close to zero other than maybe the issues that don't have a useful stack trace.
I would say our QA department did a bang up job as the issues found have been very obscure and timing based. The app seems really solid.
Excited to get more data out of Flurry as well. I have set up a couple of reports there already but I can tell the data is lagging a bit because I can see a lot more action in real-time than is getting reported in the Explorer. Once we have a good solid week of data it will be more interesting and we can monitor things over time.
So why Flurry? At my last job we started using Google Analytics but it was just not cutting it for Mobile. Reporting with Fabric / Crashlytics did not seem to cover what we needed. Firebase seemed really powerful if you were willing to pay for BigData to do your queries. Flurry seemed to kind of hit the sweet spot for free data analysis. It is pretty easy to implement and a few simple helper bits for Kotlin and I was able to get a decent set of analytics in place in about a day.
Next up on the learning side of things is constraints layouts. I can quickly layout everything I can think up with a mix of Relative, Linear, Table, and Grid layouts but Constraints is the future and the sooner I learn it the better. The conversion tools seems a bit iffy so learning from scratch is probably the way to go.
I did get bit by the Java to Kotlin conversion tool as well. I had written an image cropping custom control in Java. Since I am doing full on Kotlin now and I needed to enhance this custom contol I had Android Studio convert it to Java. It compiled but did not work correctly. It decided to typecast a multiplication for me from Float to Int but I needed the multiplication to happen fully as a Float and the final result to be an Int. It decided to convert the code to case the number I was multiplying by first. Since that number was between 0.0 and 1.0 that cast was pointless. Simple enough to fix and I had a good idea what to do since I wrote the original code.
Gotta say it is an ego boost to hit 10,000 installs in a few days. I do realize this will taper off now but I am still supporting 10k users as the sole developer, the iOS guy pitched in on some of the code, of the app.
App is not 100% feature matched with iOS as of yet so I am working on adding the final matching features then we will work on improving the app and there are many other new features we will release in sync as time goes on.
Reviews have been pretty positive. Some are having issues with data outside the apps control. They are addressing those issues at the server level. I am using Flurry to track various things and to capture any issues found. The Play Store is also catching crashes. So far there have been about 17 unique crash events affecting just a few people. I have been able to track down and solve most of them. Some have nothing in the stack trace for me to even guess what is happening and a few were in the Flurry Library.
While I like Flurry the documentation is sad. You can't find any one place to tell you the latest version. Most of the official Flurry pages mention some flavor of 6.x but I found one place that said 7.0.0 so that was what I was using. I then decided to go to source, the jcenter repository, and found 7.1.1 was available. Since I had fixed a number of issues I had issues in this library I went ahead and did a fast followup release that I hope will knock things down close to zero other than maybe the issues that don't have a useful stack trace.
I would say our QA department did a bang up job as the issues found have been very obscure and timing based. The app seems really solid.
Excited to get more data out of Flurry as well. I have set up a couple of reports there already but I can tell the data is lagging a bit because I can see a lot more action in real-time than is getting reported in the Explorer. Once we have a good solid week of data it will be more interesting and we can monitor things over time.
So why Flurry? At my last job we started using Google Analytics but it was just not cutting it for Mobile. Reporting with Fabric / Crashlytics did not seem to cover what we needed. Firebase seemed really powerful if you were willing to pay for BigData to do your queries. Flurry seemed to kind of hit the sweet spot for free data analysis. It is pretty easy to implement and a few simple helper bits for Kotlin and I was able to get a decent set of analytics in place in about a day.
Next up on the learning side of things is constraints layouts. I can quickly layout everything I can think up with a mix of Relative, Linear, Table, and Grid layouts but Constraints is the future and the sooner I learn it the better. The conversion tools seems a bit iffy so learning from scratch is probably the way to go.
I did get bit by the Java to Kotlin conversion tool as well. I had written an image cropping custom control in Java. Since I am doing full on Kotlin now and I needed to enhance this custom contol I had Android Studio convert it to Java. It compiled but did not work correctly. It decided to typecast a multiplication for me from Float to Int but I needed the multiplication to happen fully as a Float and the final result to be an Int. It decided to convert the code to case the number I was multiplying by first. Since that number was between 0.0 and 1.0 that cast was pointless. Simple enough to fix and I had a good idea what to do since I wrote the original code.
Saturday, May 13, 2017
2 months into Kotlin and the app is in Beta
I have not quite been at the new job 2 months yet and I submitted the app to a closed Beta on the Google Play Store. First interaction with the new Play Store UI which was a bit frustrating. I got all the pieces in place finally. You have to jump around a lot between the app and managing the Beta email list.
Feels darn good to have the app out there. It has been a bit of a challenge due to server side fun. There were some REST calls that seems quite silly and they worked them over so I sent / received a lot less traffic to do the work I needed.
Learned how to use a 3rd party UPC scanner, credit card swiper and credit card signature control. The CC swiper was the hardest as the documentation was lacking and so, thanks to the fine decompiler in Android Studio, I ended up sniffing around the API the hard way to find what I wanted.
Basic stats on the app
26 Activities
9 Fragments
11 Dialogs
15 Adapters (ListView or RecyclerView)
5 Custom controls written by me
59 Layouts (lots of row types)
48 unique REST calls
Not a small app but not massive either. All the code I wrote was in Kotlin, no Java on my side. For my first full Kotlin app I am very happy with the language. I would not switch back to Java at this time. I learned a ton and refactored a lot during the app development cycle. I kept finding better ways to do things in Kotlin saving even more lines of code. Support for round icons for Nougat and above. Making all the special permission asking calls as well. Not too many of them but the CC swiper needs to have access to the microphone, I need access to external storage and locations services.
QA has been pretty smooth too. They are finding the edge case stuff because we have a great QA team. I just don't see NPE things which were always frustrating when doing Java coding. I have been able to knock out the bugs within an hour of them showing up in most cases.
There is more to do on the app to get it in feature sync with the iOS version. What is there is very functional and fully usable by the target audience. It is also only being released to a small Beta team to start. I will continue to add the other features with a planned full release in early June. I need to deal with returns, some image capture and manipulation, and tie in to social media apps. There are parts of the Android app that are cleaner and easier to use than the iOS app so it also needs to get in sync with Android on that side. Good to have each team member push the other one.
Late in testing we were having some timeouts with the credit card processing. 3rd party service we use. Default timeout is 10 seconds for Retrofit + OKHTTP. Upped that to 30 seconds and things went smoother. Very happy with Retrofit, OKHTTP and Moshi. Had not used them before. I was on Volley + GSON in the past. Don't miss Volley at all. Retrofit makes it super easy to set up the REST calls with annotations. Using Moshi because it is already being used by the OKHTTP stack so what the heck. No need to toss in another library.
Time to enjoy the fact it was released and then start hammering away at the next parts of the app. Will be interesting to see what feedback we get from the Beta group. QA, other staff and myself had beat on it pretty hard. I pulled it into DDMS and went to each screen and did a kill process to make sure it survives that. Couple of tweaks there and all was fine. My first proguard configuration worked as well. I was able to run every part of the app. Hopefully this works fine on all the devices out there - looking at you Samsung.
Went minimum SDK level of 19. I have tested on 480x800 displays as well. Figure that covers a massive majority of phones. My guess is most real world devices with be above 19 and with much larger screens. QA did testing on 7" tablets as well. No special tablet code in there as far as bonus layouts. I see some places that would be handy though.
I have a Note 4 running Marshmallow and have been testing on that when not in an emulator. Good to have a Samsung Device for testing but I really want to upgrade my phone. Waiting for the new Pixel 2 and OnePlus 5 to arrive before I pull the trigger
Feels darn good to have the app out there. It has been a bit of a challenge due to server side fun. There were some REST calls that seems quite silly and they worked them over so I sent / received a lot less traffic to do the work I needed.
Learned how to use a 3rd party UPC scanner, credit card swiper and credit card signature control. The CC swiper was the hardest as the documentation was lacking and so, thanks to the fine decompiler in Android Studio, I ended up sniffing around the API the hard way to find what I wanted.
Basic stats on the app
26 Activities
9 Fragments
11 Dialogs
15 Adapters (ListView or RecyclerView)
5 Custom controls written by me
59 Layouts (lots of row types)
48 unique REST calls
Not a small app but not massive either. All the code I wrote was in Kotlin, no Java on my side. For my first full Kotlin app I am very happy with the language. I would not switch back to Java at this time. I learned a ton and refactored a lot during the app development cycle. I kept finding better ways to do things in Kotlin saving even more lines of code. Support for round icons for Nougat and above. Making all the special permission asking calls as well. Not too many of them but the CC swiper needs to have access to the microphone, I need access to external storage and locations services.
QA has been pretty smooth too. They are finding the edge case stuff because we have a great QA team. I just don't see NPE things which were always frustrating when doing Java coding. I have been able to knock out the bugs within an hour of them showing up in most cases.
There is more to do on the app to get it in feature sync with the iOS version. What is there is very functional and fully usable by the target audience. It is also only being released to a small Beta team to start. I will continue to add the other features with a planned full release in early June. I need to deal with returns, some image capture and manipulation, and tie in to social media apps. There are parts of the Android app that are cleaner and easier to use than the iOS app so it also needs to get in sync with Android on that side. Good to have each team member push the other one.
Late in testing we were having some timeouts with the credit card processing. 3rd party service we use. Default timeout is 10 seconds for Retrofit + OKHTTP. Upped that to 30 seconds and things went smoother. Very happy with Retrofit, OKHTTP and Moshi. Had not used them before. I was on Volley + GSON in the past. Don't miss Volley at all. Retrofit makes it super easy to set up the REST calls with annotations. Using Moshi because it is already being used by the OKHTTP stack so what the heck. No need to toss in another library.
Time to enjoy the fact it was released and then start hammering away at the next parts of the app. Will be interesting to see what feedback we get from the Beta group. QA, other staff and myself had beat on it pretty hard. I pulled it into DDMS and went to each screen and did a kill process to make sure it survives that. Couple of tweaks there and all was fine. My first proguard configuration worked as well. I was able to run every part of the app. Hopefully this works fine on all the devices out there - looking at you Samsung.
Went minimum SDK level of 19. I have tested on 480x800 displays as well. Figure that covers a massive majority of phones. My guess is most real world devices with be above 19 and with much larger screens. QA did testing on 7" tablets as well. No special tablet code in there as far as bonus layouts. I see some places that would be handy though.
I have a Note 4 running Marshmallow and have been testing on that when not in an emulator. Good to have a Samsung Device for testing but I really want to upgrade my phone. Waiting for the new Pixel 2 and OnePlus 5 to arrive before I pull the trigger
Sunday, April 2, 2017
3 Weeks in using Kotlin
After using Kotlin for just three weeks I say it would be very hard to go back to Java. Everything takes less code, is just easier to do and the code readability just makes more sense. Part of it is using new libraries such as Retrofit as well. It is just super easy to set up a REST call.
I have created a small Kotlin utility that coverts JSON right out of Charles Proxy to best guess Kotlin objects used by Moshi. I am also use Moshi to pass the objects from one Activity to another. So nice to not need to configure a bunch of parameters to set in the Intent to send over data, just one and it contains the full object as a string that I convert right back to a full object when I get it on the other side. Every bit of data is there ready to use and it just takes one line on each side to send / receive.
I am up to 24 fragments / activities already. A bunch of adapters as I am using ListView when it fits and configured my first Kotlin RecyclerView as well. All pretty clean and easy and working like a champ. There is a ton of code that is done and a lot more to do. My Trello checklist keeps growing.
The iOS code uses a bar code scanner. I set that up on Friday. Went in really easily and with a lot less code that what the iOS guy had to do. I did create and swap out the icon for that action as iOS was using a camera which made no sense to me. On the iOS simulator a UIViewController showed up for a brief moment and disappeared so I had no idea what this area was even doing. I asked QA, who has a real device, and found out I needed a bar code scanner.
The switch to Kotlin should have happened some time back. It is hard to get yourself to do it on an existing product. I was totally starting from scratch here so it really was the perfect time to give it a shot. If I had gotten a little ways in and found I could not handle it I could have backed out and just gone Java. I force myself to keep going. Really were very few struggle areas and that was related to trying new 3rd party libraries and not Kotlin.
As I have worked along there has been a bit of code refactoring as I have found better ways to do things and I have taken cut / paste code and moved it into one location. You don't know it needs to be shared until you use it multiple times. I have a bunch of other ideas for refactoring as well running through my head this weekend that I will give a shot this week. Want to get the code as far along as possible for QA to be able to start in depth testing before I get too refactor crazy.
There is a need to connect to a credit card reader in the near future. I have not messed with that library yet. Hoping it is pretty straight forward. Something I might end up tackling this week.
I have been shooting for breadth over depth for the first three weeks. Get as menu drawer menu items to show something as possible. This might be the initial list and the first details screen. Next up is taking each screen and filling everything out. The ability to add a new order, the order detail screen, navigation form order to order etc. The order detail screen can be accessed from a lot of places and is key to things working. It will be RecyclerView based with a lot of business logic as to what to show when.
Knocking out all the main stuff gets the REST calls in place and allows me to demo a lot of aspects. Most of that is request / reply / show data so not much can go wrong. The next steps will be the business logic and where I actually POST / PUT stuff back to the server. Data validation, hide / show of controls, etc. and that is where the real meat of QA will reside. Set up to tackle a chuck of that this week. Kotlin probably does not help nor hinder that area. It is learning business logic and applying it in code.
Kotlin has won me over. I don't see going back to Java for Android.
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 version.properties 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.
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 version.properties 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.
Friday, March 10, 2017
Moving to Kotlin
I am going to start a new job and my goal is to go Kotlin. I have been writing Android apps in Java for a number of years. Part of that time I also wrote iOS apps in ObjC. At the job I just left I only did Java Android programming.
I learned a lot at the job including ButterKnife, Dagger, Google Analytics, Flurry Analytics, Event Bus, Twillio, BrainTree, Timber, Vector Drawables, and Glide. All of those things make Java programming easier. I also used a number of things that I used at previous jobs including Volley, GSON, AndroidSVG, and Google Play Services.
Now it is time to move forward into the land of Kotlin. I have been using it for a number of smaller command line utilities. I had used Python for things like that in the past and I found I can whip them out just as quickly in Kotlin plus it let me learn a new language that I could also use for Android.
I then stepped up and converted a small app that I had done in Java to Kotlin using the Anko library and then I wrote an animation test program from scratch from Kotlin using XML for the layout. Gave me a good peek into a number of aspects of Kotlin. I learned how to setup Kotlin for Android. My utilities were done with IntelliJ.
The old company was moving away from native development so there was not desire there to change to a new native language even if we did it bits and pieces at a time. Sure there was no harm doing some one off utilities but no way I was going to get Kotlin into the main apps.
Next up was taking some time to learn what libraries I might be able to use with Kotlin. There was an excellent talk by Jake Wharton about Okio. It started from the base of the pyramid and worked all the way up through OkHTTP, Moshi and Retrofit. Gave me a great understanding of the entire tree and what it is much better than NIO. Excited to use this chain of tools and to get away from the massive boilerplate of Volley when making REST calls. Annotations are your friend.
Don't know if I will use DSL and Anko but I might use the SQLite aspects of it. I like some of what it offers but also like seeing the preview of my layouts in XML. I do plan on using ConstraintLayout as I have used MigLayout for Java desktop and Autolayout for iOS so I think I can pick it up pretty quickly. I can pull off all kinds of things with RelativeLayout, LinearLayout, TableLayout, GridLayout and PercentLayout bit it seems silly to keep mixing all those together.
Scary to make all these changes at the same time. Kotlin will have me looking up how to do some things I already know to do easily in Java and general syntax. I have a decent base of knowledge now but I will probably fall back into old habits for speed. I know there is a lot of new syntax to use with Kotlin. Of course working code is what counts, using every trick may tighten up the code but is not a requirement. As I learn more I am sure I will go back to fairly fresh code and update it. Refactoring as you learn is a good idea.
I have watched enough Kotlin videos to know what bits and pieces are there so I will attempt to use as much as I have learned. I also think the iOS code written in Swift by the current developer will help me make the switch as it has a lot of the same programming patterns used by Kotlin.
Having a solid Android understanding is huge. I already know what I can do in Android, know about Activity and Fragment life cycles, know what the various Views do and can do recycler views with multiple row types. It will be more about learning syntax of a language and how to tie things together using Kotlin patterns.
Nervous and excited for this new life adventure. Not going to miss the old semicolon and constant null pointer checks. Will take a little bit but I bet my programming speed increases and I actually end up writing less code than I have been writing in Java.
I learned a lot at the job including ButterKnife, Dagger, Google Analytics, Flurry Analytics, Event Bus, Twillio, BrainTree, Timber, Vector Drawables, and Glide. All of those things make Java programming easier. I also used a number of things that I used at previous jobs including Volley, GSON, AndroidSVG, and Google Play Services.
Now it is time to move forward into the land of Kotlin. I have been using it for a number of smaller command line utilities. I had used Python for things like that in the past and I found I can whip them out just as quickly in Kotlin plus it let me learn a new language that I could also use for Android.
I then stepped up and converted a small app that I had done in Java to Kotlin using the Anko library and then I wrote an animation test program from scratch from Kotlin using XML for the layout. Gave me a good peek into a number of aspects of Kotlin. I learned how to setup Kotlin for Android. My utilities were done with IntelliJ.
The old company was moving away from native development so there was not desire there to change to a new native language even if we did it bits and pieces at a time. Sure there was no harm doing some one off utilities but no way I was going to get Kotlin into the main apps.
Next up was taking some time to learn what libraries I might be able to use with Kotlin. There was an excellent talk by Jake Wharton about Okio. It started from the base of the pyramid and worked all the way up through OkHTTP, Moshi and Retrofit. Gave me a great understanding of the entire tree and what it is much better than NIO. Excited to use this chain of tools and to get away from the massive boilerplate of Volley when making REST calls. Annotations are your friend.
Don't know if I will use DSL and Anko but I might use the SQLite aspects of it. I like some of what it offers but also like seeing the preview of my layouts in XML. I do plan on using ConstraintLayout as I have used MigLayout for Java desktop and Autolayout for iOS so I think I can pick it up pretty quickly. I can pull off all kinds of things with RelativeLayout, LinearLayout, TableLayout, GridLayout and PercentLayout bit it seems silly to keep mixing all those together.
Scary to make all these changes at the same time. Kotlin will have me looking up how to do some things I already know to do easily in Java and general syntax. I have a decent base of knowledge now but I will probably fall back into old habits for speed. I know there is a lot of new syntax to use with Kotlin. Of course working code is what counts, using every trick may tighten up the code but is not a requirement. As I learn more I am sure I will go back to fairly fresh code and update it. Refactoring as you learn is a good idea.
I have watched enough Kotlin videos to know what bits and pieces are there so I will attempt to use as much as I have learned. I also think the iOS code written in Swift by the current developer will help me make the switch as it has a lot of the same programming patterns used by Kotlin.
Having a solid Android understanding is huge. I already know what I can do in Android, know about Activity and Fragment life cycles, know what the various Views do and can do recycler views with multiple row types. It will be more about learning syntax of a language and how to tie things together using Kotlin patterns.
Nervous and excited for this new life adventure. Not going to miss the old semicolon and constant null pointer checks. Will take a little bit but I bet my programming speed increases and I actually end up writing less code than I have been writing in Java.
Friday, October 7, 2016
Got a new developer laptop, here are my thoughts on it so far
I work from home and by the end of the day I am done sitting in my home office and am ready to spend some time around the family. I also work on some side projects and take some time to learn new things on my own outside of office hours.
I want to pick up more Kotlin programming so I have been playing around with that. Having a laptop I can use in the family area made a lot of sense to me. I looked over a ton of machines, tried some out at Microcenter then did a lot more research.
There were some initial requirements:
15.6 - 17.3" screen
Touchscreen
16GB RAM minimum (OK with manual upgrade)
256GB SSD minimum (OK with manual upgrade if multiple SSD slots)
Decent video card - nVidia preferred
Keyboard must have numeric keypad along with HOME, END, PG UP, PG DN keys
Back lighting on the keyboard
Ports to support multiple monitors
I started with the ASUS ZenBook Pro UX501VW. Thought it would be great to have 5121GB SSD, no moving parts HDD. Nice and light as well. The problem? No END key, the power key is in that place. Of course you can turn off the num-lock and use that end key but I use the numeric keypad a lot as well. Plus it had a lot of glare to the screen and the reviews point out the color accuracy sucks especially for yellows. I tried one out at Microcenter and eliminated it but was very sad about that. It also has a pseudo 4K screen that does not play nice with all apps. Windows needs to catch up.
Lots of people liked the MSI models. They require you to use the FN key to get to HOME and END so those were out as well. I looked at various Acer and HP models but each had a fatal flaw. I was getting close on some of the HP models. They seemed to have good screens, keyboards and sound systems. But I just could not do it. Once you starting adding touch screen, the memory and SSD the prices started to jump quickly.
Then I found the Asus G725VL on the Microsoft store for $500 off. Hit all the requirements
17.3" touchsreen
24 GB of RAM
256 GB SSD
1T HD
965M nVidia video card
Full keyboard with numpad, separate HOME, END, PG UP, PG DN keys
Fast charge USB port that even works when laptop is off
Multiple ports for extra monitors
CD/DVD drive
Plus it is the Microsoft Signature Edition so no bloatware. They kept that promise. There was nothing for me to uninstall. Came from MS store with free shipping. Odd thing is they shipping in just the Asus box - no extra padding at all. At least we had to sign for it as it was very obvious what was in the box so you would not want it just sitting on your front steps. At least the Asus box is nice and thick and was not damaged at all.
Machine boots in 10 seconds. Runs like a champ, is nice and quiet. Keyboard has good travel and 3 levels of back lighting. Screen is semi-gloss and looks good in everything but direct sunlight. I really like the touchscreen as well. When I do Android work I can pop-up the emulator and treat it like a real device when it comes to scrolling, tapping, long press and swiping. It does not support pinch zoom. The PC does for Windows but does not for the emulator. It is in Google's list to address.
Using the touch screen is nature in Windows as well. We are all pretty used to using a touch device such as a tablet or a phone so you want to do it on your computer screen as well. Tapping a button or scrolling works great.
I have had no issues with wireless internet connectivity. It also has standard port to hook right in to a wired connection as well.
As stated boot times are quick, starting any program off the SSD is very fast. Android compile speeds with the source code, SDK and tools off the SSD are are top notch in speed as well.
What is wrong with it?
1T HDD is only 5,400 RPM. Wish it was 7,200 but since I can fit all the stuff I want to access quickly I can fit onto the 256GB SDD. I put music, videos, images, utilities, etc. out on the HDD.
It is heavy but I don't plan to haul it all over the place. It may go to an offsite meeting from time to time but that is about it. I would not recommend this for a college student to haul about. The power brick is just that - a brick. Needs to be big to power this beast.
The trackpad itself is responsive but the buttons seems to miss clicks at times. Still trying to get used to that. Track pad is nice and big so you don't have to lift and scroll over and over. Responds to multiple finger scrolling and the like as well. It does show finger prints as well but you tend to slide around so they kind of smear on to the pad.
While the back lighting is good the font used on the keys is a bit much on the Star Trek / gaming side. The font could be more readable. I touch type quickly so I generally and not looking at the font but it is still weird.
Sound is just OK, on the muddy side and full volume is way too low. You can tweak some of it with the Asus Sonic Sound Studio control panel. Headphone volume is great. Good thing there are separate settings for that vs. speakers so you can set speakers at full volume and headphones at 50%. I was able to get headphones to sound respectable. Still need to work on the speaker side of things.
I know new Pascal based machines are coming out. They cost a whole lot more and were very game oriented. I needed something I could game on but was mainly for Android development. This machine hit all the big items on my list. I am very happy with the purchase. There is space under a one screw to remove panel to add another SSD if I need it. I have a feeling the current configuration will last a pretty long time.
At first I was trying to figure out how to right click on the screen. I thought maybe two fingers or quick taps. Turns out you long press then a rectangle will start to grow from where you finger is then a release will show the right mouse click menu. Windows realizes you use a finger so there is more spacing between the menu items as well for easier tap zones. Would not game doing this but it works fine for doing user interface based interactions.
No regrets on this machine. Doing everything I ask of it. I was not expecting perfect and it is not but it hits the majority of the areas I need, just missing some minor things but none of those things were on my must must have so I don't feel I settled.
Compared to the new stuff coming out this is a B for gamers, it is a A for developers.
I want to pick up more Kotlin programming so I have been playing around with that. Having a laptop I can use in the family area made a lot of sense to me. I looked over a ton of machines, tried some out at Microcenter then did a lot more research.
There were some initial requirements:
15.6 - 17.3" screen
Touchscreen
16GB RAM minimum (OK with manual upgrade)
256GB SSD minimum (OK with manual upgrade if multiple SSD slots)
Decent video card - nVidia preferred
Keyboard must have numeric keypad along with HOME, END, PG UP, PG DN keys
Back lighting on the keyboard
Ports to support multiple monitors
I started with the ASUS ZenBook Pro UX501VW. Thought it would be great to have 5121GB SSD, no moving parts HDD. Nice and light as well. The problem? No END key, the power key is in that place. Of course you can turn off the num-lock and use that end key but I use the numeric keypad a lot as well. Plus it had a lot of glare to the screen and the reviews point out the color accuracy sucks especially for yellows. I tried one out at Microcenter and eliminated it but was very sad about that. It also has a pseudo 4K screen that does not play nice with all apps. Windows needs to catch up.
Lots of people liked the MSI models. They require you to use the FN key to get to HOME and END so those were out as well. I looked at various Acer and HP models but each had a fatal flaw. I was getting close on some of the HP models. They seemed to have good screens, keyboards and sound systems. But I just could not do it. Once you starting adding touch screen, the memory and SSD the prices started to jump quickly.
Then I found the Asus G725VL on the Microsoft store for $500 off. Hit all the requirements
17.3" touchsreen
24 GB of RAM
256 GB SSD
1T HD
965M nVidia video card
Full keyboard with numpad, separate HOME, END, PG UP, PG DN keys
Fast charge USB port that even works when laptop is off
Multiple ports for extra monitors
CD/DVD drive
Plus it is the Microsoft Signature Edition so no bloatware. They kept that promise. There was nothing for me to uninstall. Came from MS store with free shipping. Odd thing is they shipping in just the Asus box - no extra padding at all. At least we had to sign for it as it was very obvious what was in the box so you would not want it just sitting on your front steps. At least the Asus box is nice and thick and was not damaged at all.
Machine boots in 10 seconds. Runs like a champ, is nice and quiet. Keyboard has good travel and 3 levels of back lighting. Screen is semi-gloss and looks good in everything but direct sunlight. I really like the touchscreen as well. When I do Android work I can pop-up the emulator and treat it like a real device when it comes to scrolling, tapping, long press and swiping. It does not support pinch zoom. The PC does for Windows but does not for the emulator. It is in Google's list to address.
Using the touch screen is nature in Windows as well. We are all pretty used to using a touch device such as a tablet or a phone so you want to do it on your computer screen as well. Tapping a button or scrolling works great.
I have had no issues with wireless internet connectivity. It also has standard port to hook right in to a wired connection as well.
As stated boot times are quick, starting any program off the SSD is very fast. Android compile speeds with the source code, SDK and tools off the SSD are are top notch in speed as well.
What is wrong with it?
1T HDD is only 5,400 RPM. Wish it was 7,200 but since I can fit all the stuff I want to access quickly I can fit onto the 256GB SDD. I put music, videos, images, utilities, etc. out on the HDD.
It is heavy but I don't plan to haul it all over the place. It may go to an offsite meeting from time to time but that is about it. I would not recommend this for a college student to haul about. The power brick is just that - a brick. Needs to be big to power this beast.
The trackpad itself is responsive but the buttons seems to miss clicks at times. Still trying to get used to that. Track pad is nice and big so you don't have to lift and scroll over and over. Responds to multiple finger scrolling and the like as well. It does show finger prints as well but you tend to slide around so they kind of smear on to the pad.
While the back lighting is good the font used on the keys is a bit much on the Star Trek / gaming side. The font could be more readable. I touch type quickly so I generally and not looking at the font but it is still weird.
Sound is just OK, on the muddy side and full volume is way too low. You can tweak some of it with the Asus Sonic Sound Studio control panel. Headphone volume is great. Good thing there are separate settings for that vs. speakers so you can set speakers at full volume and headphones at 50%. I was able to get headphones to sound respectable. Still need to work on the speaker side of things.
I know new Pascal based machines are coming out. They cost a whole lot more and were very game oriented. I needed something I could game on but was mainly for Android development. This machine hit all the big items on my list. I am very happy with the purchase. There is space under a one screw to remove panel to add another SSD if I need it. I have a feeling the current configuration will last a pretty long time.
At first I was trying to figure out how to right click on the screen. I thought maybe two fingers or quick taps. Turns out you long press then a rectangle will start to grow from where you finger is then a release will show the right mouse click menu. Windows realizes you use a finger so there is more spacing between the menu items as well for easier tap zones. Would not game doing this but it works fine for doing user interface based interactions.
No regrets on this machine. Doing everything I ask of it. I was not expecting perfect and it is not but it hits the majority of the areas I need, just missing some minor things but none of those things were on my must must have so I don't feel I settled.
Compared to the new stuff coming out this is a B for gamers, it is a A for developers.
Wednesday, January 20, 2016
Hey, I want to be an Android programmer. Tell me what to do.
How many times have you seen a post on various forums about someone wanting to be an Android programmer? Is there a simple answer? Of course not, programming is not easy and there are piles of things you end up doing during any given day.
Wait a minute there! Isn't all I have to do is learn Java and some Android libraries? Oh, how we all wish but there is a lot more going on and that is just the start. Yes, you need to learn Java (or Kotlin) and you need to learn about the SDK as well but there is a ton more.
Today it hit me I had been in the following in just one day:
It is not just learning Java and an API. I could not get Adobe Illustrator to do exactly what I wanted to I directly edited the SVG file. How many languages and file formats have I been in today already? Piles of them and I was able to quickly do the list above and I am sure I missed stuff.
Obviously Java, Kotlin and Groovy have a similar syntax so it is not like I am switching from assembler to JavaScript mentally but there are differences so you do have to perform a mental switch.
I don't mess with graphics every day but we have been setting up a number of build flavors this week so I have been doing a lot of graphics work along with "normal" programming. Honestly there is no such thing as normal. I shift around all the time. I decide to write the utilities in Kotlin as something new to learn, it was not required by my job. Glad I did, gives me a better appreciation of the language. Really want v1 to move out of beta before I use it for my Android apps.
Developers have to understand more than just the language they are using. You end up using a lot of tools like Git, Paint.NET, Adobe Illustrator, Adobe Photoshop, different IDEs, text editors and various utilities. Plus you get to keep the OS on your machine updated along with IDE, SDK, Language versions and tools.
Never know when the boss will need your help on a spreadsheet, document or power point as well. You have to be able to run at least a minimal feature set in a ton of tools just to keep up with life as a developer.
I am unsure how a new developer even gets started. I have amassed a large quantity of knowledge over the years. I can apply that to Kotlin when I experimented with it this week. I already knew the IDE, the .plist file format, XML, how to use collections, etc. I was picking up a new syntax but when you start from scratch you are tossed into a tank of sharks. The only way is to start small. Just work on one concept then move on. If you try to do an entire game or program with multiple screens you will go nuts before you get very far.
Wait a minute there! Isn't all I have to do is learn Java and some Android libraries? Oh, how we all wish but there is a lot more going on and that is just the start. Yes, you need to learn Java (or Kotlin) and you need to learn about the SDK as well but there is a ton more.
Today it hit me I had been in the following in just one day:
- Java writing the main app code
- Kotlin working on a utility program to convert iOS plist to Android format
- Groovy because I was editing the gradle build scripts
- Bash as I updated my Java version and needed to change my .profile
- Various Linux terminal commands
- Various Git commands on command line and in Source Tree
- Vector Graphics as I was working on a new image I needed
- XML for the Android layout manager, string tables and color tables
- PNG images for new icons
- REST calls
- JSON parsing for REST call responses
- Sublime text editor creating and running macros against text files
- File manipulation in Finder
- Looking at ObjC in Xcode that I am converting to Android
- Using IntelliJ, Android Studio and Xcode
It is not just learning Java and an API. I could not get Adobe Illustrator to do exactly what I wanted to I directly edited the SVG file. How many languages and file formats have I been in today already? Piles of them and I was able to quickly do the list above and I am sure I missed stuff.
Obviously Java, Kotlin and Groovy have a similar syntax so it is not like I am switching from assembler to JavaScript mentally but there are differences so you do have to perform a mental switch.
I don't mess with graphics every day but we have been setting up a number of build flavors this week so I have been doing a lot of graphics work along with "normal" programming. Honestly there is no such thing as normal. I shift around all the time. I decide to write the utilities in Kotlin as something new to learn, it was not required by my job. Glad I did, gives me a better appreciation of the language. Really want v1 to move out of beta before I use it for my Android apps.
Developers have to understand more than just the language they are using. You end up using a lot of tools like Git, Paint.NET, Adobe Illustrator, Adobe Photoshop, different IDEs, text editors and various utilities. Plus you get to keep the OS on your machine updated along with IDE, SDK, Language versions and tools.
Never know when the boss will need your help on a spreadsheet, document or power point as well. You have to be able to run at least a minimal feature set in a ton of tools just to keep up with life as a developer.
I am unsure how a new developer even gets started. I have amassed a large quantity of knowledge over the years. I can apply that to Kotlin when I experimented with it this week. I already knew the IDE, the .plist file format, XML, how to use collections, etc. I was picking up a new syntax but when you start from scratch you are tossed into a tank of sharks. The only way is to start small. Just work on one concept then move on. If you try to do an entire game or program with multiple screens you will go nuts before you get very far.
Subscribe to:
Posts (Atom)