Because Developers are Awesome - page 11

Recent posts

How developers can authenticate and authorize users with AWS AppSync

June 01, 2018  7 minute read  

AWS AppSync provides four distinct methods of authorizing users to optimize and restrict data being transferred AWS AppSync is a managed GraphQL data service that supports offline and real-time scenarios. The service allows the developer to optimize the data transfer between client and server. Any non-trivial application will need to authenticate users. It’s the only way to identify a distinct real person using the application. That association is required for private data storage and c...

Unit Testing in Android Studio with Kotlin

May 12, 2018  5 minute read  

I made myself a promise a couple of months ago. My next app would be fully unit tested for the non-UI components and fully instrument-tested for the UI components. That’s a tall order, especially since I’m using the latest and greatest Android Studio Canary. I ran into a few problems. Some can’t be solved and some can. Let’s start with a simple test. I’ve got a class that looks this: data class Note(val id: String = UUID.randomUUID().toString()) { var updated: Long = System.currentTimeMil...

Easy EditText content validation with Kotlin

April 11, 2018  3 minute read  

One of the things that I always deal with in my apps is the need to validate the input fields of a form. I can easily do this with this sample fragment of code (for example, for a length check): field.addTextChangeListener(object: TextWatcher { override fun afterTextChanged(s: Editable?) { val content = s?.text.toString() s?.error = if (content.length >= 6) null else "Minimum length = 6" } override fun beforeTextChanged(s: Editable?) { } override fun onTextChanged(s: Edita...

Using dependency injection with Kotlin

April 06, 2018  6 minute read  

In a recent post, I described how I can do app analytics by using the AWS Mobile SDK and an AWS Mobile Hub project. This is a great way to get usage analytics for your app, but it requires a tight coupling between the provider (the AWS Provider and AnalyticsClient) and the app. You need to initialize the provider early on (preferably in the Application wrapper or the first activity). That causes a tight linkage between the activities where it is used and the client object. This has several i...

Lessons in Kotlin: Toolbar Icons and Reflection

April 01, 2018  5 minute read  

There are many tutorials online on how to produce an Android app bar with an options menu — so much so that it can be boiled down to a few steps, and I’ll reproduce them here: Step 1: Create resources You actually need two resources. The first is a menu: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/mainActionCamera" an...

Lessons in Kotlin Threading: An Animated Splash Screen

March 29, 2018  2 minute read  

I find quite a lot of Android apps have splash screens. Some splash screens are for showing off the logo; others for hiding the extensive data load times. Whatever the reason, it’s a way for a little bit of creativity to shine through. My first effort My new app needs a splash screen. Splash screens aren’t hard until you need to do something that takes some time, and there are many tutorials on how to produce one out on the Internet. I’m going to focus on the one problem I had. Let’s take a...

The React Toolbox - 2018 Edition

March 23, 2018  5 minute read  

It’s been a while since I’ve been in web development. I’ve mostly been concentrating on mobile development instead. But this week I had cause to delve again. It’s amazing how much change there has been in the web world in just 2 years. React has become the force in web frameworks (Sorry Angular — I never liked you anyway) and developers are starting to coalesce around libraries and tools that make their life easier. I thought I’d put down my thoughts on the libraries that are making it into m...

Why I’m refactoring to Kotlin

March 21, 2018  5 minute read  

One of the things that is really cool about software development is that we are continually learning and adjusting. I spent a day recently learning Kotlin. I was so impressed with the language, I decided to refactor my entire Family Photos app. It did not take long. Why do I love Kotlin? I have to admit, I was skeptical at first. After all, I tried Swift for iOS as an alternate language and it felt foreign. Admittedly, Objective-C isn’t much better, but Swift definitely had some issues for ...

Testing Mobile Apps: A Primer

March 11, 2018  10 minute read  

Why should you test your mobile app? A recent study showed that almost a quarter of users only use a mobile app once, and a shocking 95% abandon an app within the first month. Some of the reasons that users abandon an app are due to content and engagement. The biggest non-content reasons for abandonment are application crashes and security concerns. No one can prevent all application crashes. The mobile ecosystem is too broad and unpredictable to provide a 100% guarantee. However, testing ens...

The Six Mobile Apps You Should Write

March 10, 2018  2 minute read  

Take a look at the mobile apps on the app stores and you will see patterns emerge. The same pattern is repeated time and time again. It’s crazy to think about this, but you only need to learn how to write six mobile apps that implement the common patterns. You can then pretty much write any app that is out there. Your First App: Notes or Task List There is a reason that just about every beginner tutorial uses the Todo app or the Notes app as the base. It’s a solid basic app that has a varie...