Taming websockets with Coroutines, Clean Architecture and a library

Websocket integration is one of the biggest issues I had in my whole experience with Android. Why is it such a huge pain? There are several reasons behind that:

  1. Connection should remain stable no matter what – and we know how complex the Android lifecycle can be.
  2. Sending data can be a one-way operation without giving any result – did you succeed in sending it or did you fail? Only Server knows.
  3. Retrying connection or network requests can be tricky to implement – from pushing logic to interactors to having an internal logic inside a repository, be sure – nothing will work at 100%. Not even at 90% either.
  4. To get it right you need both frontend and backend collaboration. Nothing can be done if both sides do it separated from each other.
Continue reading “Taming websockets with Coroutines, Clean Architecture and a library”

Don’t forget about the difference between android:windowActionBar vs windowActionBar in your theme

What is the difference between this piece of code:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="windowActionBar">false</item>
</style>

and this one:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowActionBar">false</item>
</style>
Continue reading “Don’t forget about the difference between android:windowActionBar vs windowActionBar in your theme”

Are you a product developer or a project developer?

I am so sad to see really good developers leaving because we are not doing products but projects

an unknown CTO

Believe it or not, I heard the above on a lunch with the whole Android team and with the CTO of the whole company that I was working for. What does it mean to build a project vs building a product? Is there such a huge difference when you are developing a software solution? Let’s dig deeper into this.

Continue reading “Are you a product developer or a project developer?”

Enable bluetooth headset microphone on Ubuntu 20.04

After months and months dealing with this freaking issue that has become a pain in the ass, for real, there is this article:

That made things working again. I just cannot believe how much effort is needed to make a simple bluetooth headset work on Ubuntu. It still doesn’t work great, but it is fine.

Continue reading “Enable bluetooth headset microphone on Ubuntu 20.04”

How to make DatePicker stretch when CalendarView does not fit the screen?

In Android we have to deal with both big screen and small screens, tablets, watches, TVs and many other devices. In our case, we had a device with a 3.2″ display and other one with 5″ display. And on both of them we show a DatePicker dialog to choose a date. And guess what? Especially for the current month of October, there was a small difference. Can you guess it in the screenshot below?

One day is missing
Continue reading “How to make DatePicker stretch when CalendarView does not fit the screen?”

Approaches not to cause a crash when setting toolbar title on the activity through a fragment

Setting a toolbar title on the activity should be easy, right? But what about if you want do it through a fragment? Still easy? Well, not exactly.

The issue is that you may try to touch the toolbar in a moment where the activity is actually still not inflated. This will cause an exception immediately and your app will crash. What is the exact issue?

Continue reading “Approaches not to cause a crash when setting toolbar title on the activity through a fragment”

Fix the display of the toolbar in Android Studio

From time to time I get this really nasty bug where the toolbar in Android Studio is aligned to the start of the screen.

I mean the part where you select the device and press Run, for some reason sometimes just moves to the left and bringing it back to the right is a bit of a pain. Also if you hide the main navigation toolbar by accident, then it is really hard to bring it back. Here is the solution:

  1. Close Android Studio.
  2. Go to Home/.config/Google/AndroidStudio2020.3/options
  3. Delete ui.Inf.xml

After that just start Android Studio as normal and all of the toolbars will be placed as they were by default.