Dropbox Store and JetPack in Modern Android App Architecture

Jetpack LiveData [All official development resources] | Android Topics

A few days ago, Dropbox acquired an open-source Store library. The aim behind taking the ownership was to modify it to make it more suitable to the prevailing Android developer ecosystem.

Dropbox

Now, Store also includes Google JetPack collection of libraries which poses as a solution for creating current-day Android apps.

Google JetPack makes it possible to create high-quality Android apps while accelerating the development process.

Android Development Blog

There are two objectives that this library fulfills – It leverages advanced Kotlin features in order to reduce the boilerplate code and offers high-level abstractions besides those found in the Android SDK, i.e., Fragments and [Activities]. These allow the developers to present complex tasks in an easier and simpler way.

Like in case of the traditional mobile app architecture, there are numerous components in Jetpack that developers can use independently and cover four areas – Architecture, Foundation, User Interface, and Behavior.

In fact, Google uploaded its own recommended Android app architecture along with JetPack defining the set of modules that make up an Android app and how they interact. As shown in the image, a well-architecture Android app is fundamentally based on the tenets – model-driven UI, separation of concerns, and one-directional dependencies across several modules.

However, though Jetpack offers most of the components for the creation of an Android app based on the architecture suggested by Google, there is an exception – the Repository layer.

On this matter, Mike Nakhimovich, the creator of Store states- 

“Repository currently only has a few code samples and no reusable abstractions that work across different implementations. That’s one of the big reasons why Dropbox is investing in Store–to solve this gap in the architecture model above.”

Modern Android App Architecture with JetPack and Dropbox Store

Store, while relying on a reactive design, aims to support Android app development where data flows in and out of the UI in a seamless manner without forcing the users to navigate back and forth. Mike goes on to say on this matter –

“Reactive front ends led me to think of how we can have declarative data stores with simple APIs that abstract complex features like multi-request throttling and disk caching that are needed in modern mobile applications.”

To explain this in brief – Dropbox Store helps in connecting the app model with an external data source by using a declarative interface centralizing all data-related activities.

Store aims at optimizing network usage in order to keep it at a minimum. This library was rewritten Kotlin backed by Coroutines and Flow, followed by another major change of discarding RxJava for structured concurrency paradigm which is implemented in Kotlin reactive streams.

This switch poses a big impact on ensuring all resources employed in concurrent tasks are freed whenever the task completes, says Mike.

“The big problem with RxJava’s approach to scoping background operations is that it’s too easy for engineers to forget to call dispose. Failing to dispose of active subscriptions directly leads to memory leaks.”

RxJava — Types of Observables. Understanding RxJava for Android… | by Dheeraj Andra | MindOrks | Medium

In addition, the Store also supports disk caching, memory caching with TTL and size policies, explicitly skipping the cache to fetch new data from the data source, multi-casting of responses, among many others.

Now, that Dropbox is implementing many changes in the Store for improvement, it has been set on a path of becoming a great source of resources for all Android app development developers.

Kotlin Programming Language now supported in Android

Google has just unveiled in their I/O 2017 conference that Android will officially support Kotlin programming language and got huge applause from the IT world. It is an open source project under Apache 2.0 license and built by JetBrains who earlier built IntelliJ. Google has announced that Kotlin is brilliantly designed, mature and will take android development to the next level as it is fast and fully supported by Java. Using Kotlin in Android development will be more fun.

For Android developers, Kotlin as a “first-class” language, is a chance to use a modern, powerful and mature language. It will help to solve the run-time exceptions and source code verbosity. Kotlin provides the flexibility which means it can be easily introduced into an existing project. Kotlin emits the java bytecode and can call java and vice versa out of the box. “The effortless inter-operation between the two languages” was a large part of Kotlin’s appeal to the Android team.

Covariance, Contravariance & inline function | The Startup

Developers can play around the Kotlin using Android Studio 3.0 and there is no need to install any extra plugin or worry about the compatibility issue. You can open the existing Java file, and then choose the option “Convert Java File to Kotlin File”. Android Studio will then add all required Kotlin dependencies into your project and the equivalent Kotlin code. Isn’t this cool?

Kotlin’s major goal is to be available on multiple platforms. Also, they are pretty much busy on working on native platforms like iOS, IoT, macOS, embedded systems.

As said by Google, some of the apps have already started using Kotlin like Expedia, Flipboard, Pinterest, Square. They are getting very positive feedback.

Kotlin has a lot in common to Java in structure as it’s object oriented and statically typed. It is designed for the problem that actually Java solves.

Some of the cool features of Kotlin

Features of Kotlin - DEV Community

  1. Nullability is a very common problem in Java. Basically having null references in the application can kill it. Kotlin finds the difference between the reference that can hold the null or that can’t, effortlessly.
  2. Switching from Java is easy as there is an option to convert Java files in Kotlin directly from the plugin in Android Studio.
  3. Kotlin is versatile and interoperable with Java as developers can write their own module that will work with Java code. It’s compatible with the existing Java library.
  4. Kotlin’s architecture is written in such a way that one has to write less code; at least 20% less while development, which is fascinating.
  5. A common problem in Android development that causes inefficiency to Java code is extra garbage collection. So Kotlin does a fabulous job to avoid this problem.
  6. The Lean syntax in Kotlin language is very convenient. Kotlin balances terseness and readability in syntax which helps to write the code faster and allows better productivity.
  7. Kotlin also provides Functional programming support with zero-overhead Lambdas.
  8. It imposes no runtime overhead.
  9. Kotlin’s extension functions are helpful in building really clean APIs and solve a bunch of other problems.
  10. The == operator does exactly what the community expects.

To learn more about Kotlin, check out their official website.

What’s in Store with Android O: Here ye, Android Developers!

Google team has announced the preview release of Android O, here are some changes for the developer with documentation and API differences.

  1. In new API changes, each page which is returned by the Content provider will be counted as a single Cursor object.
  2. Android O will allow you to customize the pairing request dialog when trying to pair with companion devices over Bluetooth, BLE, and Wi-Fi.
  3. There is a specific disk space for each app for caching data. You can get it using-getCacheQuotaBytes(File).
  4. Introduced OpenJDK Java language features in Android.

Here Comes the Android O : Everything About Upcoming Android OS. - Wildnet

Fonts using XML file

You can now use fonts as resources as it is a new feature introduced in Android O. There is no need to keep all fonts in assets. You can access these fonts with the help of newly introduced type, font.

Adaptive Icons

There is this new feature of adaptive launcher icon in Android O that supports visual effects and can display a variety of shapes across different device models. For example– you can configure launcher icon circular on one device and square on another device, it’s totally up to you.

Autosizing TextViews

Android O allows you to let the size of the text expand and contract automatically based on the boundaries of the TextView.

You can set up the TextView auto sizing via code or XML. The two types can be setup like:

  1. Granularity- By using this, you can set up the minimum and maximum range of the text size.
  2. Preset Size- By using this, you can auto size the TextView from the list of predefined sizes.

Generic findViewById

Say goodbye to casting views after findViewById().

Snoozing of Notifications

You can now snooze the notifications and can see later. Developers can also get all the snoozed notifications using- getSnoozedNotifications().

setToolTipText

Set the text on the tooltip that will be displayed in a small popup window. The tooltip will be displayed:

  1. On Long Click, unless is not handled otherwise.
  2. On hover, after a brief delay since the pointer has stopped moving

Android O may release on August 21 | Lifestyle News – India TV

Progress Dialog is no longer there, it’s deprecated now

Progress Dialog is now deprecated in Android O. It uses a progress indicator such as ProgressBar inline inside of an activity rather than using this modal dialog.

A dialog shows a progress indicator and an optional text message or view. Only a text message or a view can be used at the same time. The progress range is 0 to max and cancelable on the back press.

Notification.Builder() is now deprecated

Now we have to use Notification.Builder (context, channelId). ChannelId is a string value and mandatory for all posted notifications.

It’s time to remove BroadCast Receiver from the Manifest

In Android O, they have set the limit on the background executions. You should remove all implicit broadcast that is for intents. If you keep them in place then it will not crash your app but will be of no use when your app will run on Android O.

Autofill Framework

Autofill will save user’s time to fill the information in forms, like details such as credit card or personal account in their devices. The Autofill Framework manages the communication between the app and autofill service.

Developers can start using Android O by setting up the compileSdkVersion as ‘android-O’, targetSdkVersion as ‘O’ and buildToolsVersion as ‘26.0.0-rc1’.
You must set the support dependency as-

dependencies {
compile ‘com.android.support:appcompat-v7:26.0.0-alpha1’
}

error: Content is protected !!