Kotlin: Having Fun with Delegation


Kotlin, a new powerful JVM language, offers two types of delegation: property delegation and interface delegation. Inspired by a StackOverflow question I came up with a small solution for lazy closeable properties that demonstrates both of these features.

Multiple Dependencies in Android Preferences


While adding a new feature to my Android app Changelog Droid I discovered the need for a checkbox preference that is dependent on two separate preferences, i.e. the preference is only enabled if two other preferences are cheked. If either one is unchecked, it should be disabled. The (simplified) hierarchy looks as follows:

  • Enable notifications
    • Enable notifications for updated apps
      • Enable detailed notifications for updated apps

Logically, the preference "Enable detailed notifications" should only be enabled, if "Enable notifications for updated apps" is checked and both should only be enabled, if "Enable notifications" is checked. I googled a bit to find out there is no built-in way to achieve this, as preferences can only have one value for the dependency attribute, so I created my own implementation.