Open source

Introducing ReactiveSensors

2015-09-05 Android, Java, Open source, RxJava No comments

Another month, another library. Recently, I’ve released yet another reactive library called ReactiveSensors. It’s an open-source Android library monitoring hardware sensors with RxJava Observables. Library is compatible with RxJava 1.0.+ and RxAndroid 1.0.+ and uses them under the hood.

Library is available at: https://github.com/pwittchen/ReactiveSensors.

In my opinion, hardware sensors are perfect case for applying RxJava, because in fact we’re constantly receiving a stream of events emitted by many sensors. With Reactive Programming approach we have plenty of possibilities and easy API for manipulating received sensor’s data.

Usage of the library is really simple. You just need to subscribe an Observable with RxJava in the same way like in any other reactive library.

Code sample below demonstrates how to observe Gyroscope sensor:

Please note that we are filtering events occuring when sensors reading change with ReactiveSensorEvent.filterSensorChanged() method. There’s also event describing change of sensor’s accuracy, which can be filtered with ReactiveSensorEvent.filterAccuracyChanged() method. When we don’t apply any filter, we will be notified both about sensor readings and accuracy changes.

We can observe any hardware sensor in the same way. You can check list of all sensors in official Android documentation.

I’ve created section about Good Practices regarding working with hardware sensors on Android in README.md file in the GitHub repository.You should also read an article about Best Practices for Accessing and Using Sensors in official Android documentation.

Read more in the README.md file located in the repository of the library at: https://github.com/pwittchen/ReactiveSensors.

You can also find JavaDoc at: http://pwittchen.github.io/ReactiveSensors/.

If you want to use ReactiveSensors in your project, add the following dependency to your build.gradle file:

dependencies {
  compile 'com.github.pwittchen:reactivesensors:0.0.1'
}

Feel free to send me feedback, report an issue or fork the library!

Learning Android and being up to date

2015-08-22 Android, Java, Open source No comments

Recently a few people asked me, what are my methods for gathering knowledge and being up to date with all news connected with Android. I didn’t really think about that. I just grabbed all knowledge from a various places and then tried to use it in practice. I decided to sum everything up and create a collection of my knowledge resources. Of course, we are not able to use all of that every day, because it’s too much, but it’s good to know where we can find something interesting. Android is very dynamic mobile platform, which changes really fast. It’s hard to be up to date with all of new features and programming techniques. That’s why it’s worth to find places where we can gather interesting information. Below, I collected some resources, links and information, which I find useful for learning Android & Java and being up to date with Android development.

Podcasts

  • Fragmented Podcast – talks about building good software and becoming better Android developer – you can hear interviews with famous developers like Jake Wharton here

Videos

Collections of articles, issues & libraries

  • Android Weekly – free newsletter that helps us to stay cutting-edge with our Android Development
  • Android Arsenal – huge collection of categorized open-source Android libraries and tools
  • Slicedham.co – collection of engineering stories (not only about Android)

Blogs

Not all articles on the blogs below are connected with Android.

StackOverflow

We can browse interesting topics tagged with Android tag, read them and even try to solve some problems. It will allow us to learn something new or improve existing knowledge.

GitHub repositories

It’s worth to check open-source repositories of great companies and developers to see how smart people solve the problems.
Not all repositories of the companies and developers below are connected with Android, but most of them do.
Moreover, we can still learn a lot from various kinds of OS projects.

Companies

Organizations

Developers

We can also check trending Java repositories or trending repositories in general.

In addition, we can try to analyze source code of various repositories and try to contribute back to them. I guarantee, we’ll learn a lot. We can start with small steps and we don’t have to implement the most complicated features in the beginning.

Twitter

We can follow famous developers or companies. We can also check tags like: #AndroidDev, #Android or #Java and so on.

Experiments & open-source projects

We can create our own projects. We can publish our app on Google Play or create an open-source library on GitHub and let other people use it and review it. Then, we’ll be able to determine if our libraries are usable, code is clean, API is simple and documentation informative enough. In addition, other developers can report bugs or new issues, which will allow improve our projects and develop our programming and communication skills.

Other

Meetings, conferences, hackathons, etc.

Sometimes it’s good to go to a conference, meeting, etc. to talk with people and learn from them. We can take a look at the events around us, attend them or maybe present something. If there’s no events in our location, we can always organize one and ask others for help!

Books

It’s good to have strong basics. Not every book is universal and valuable over the time, but there’re a few fundamental positions for programmers worth reading like Clean Code, Effective Java, Java Concurrency in Practice & Test Driven Development: By Example. It’s an open list and we can always extend it with another position on our shelf.

What else?

Everyone has his or her own method of learning new things. If you know another interesting resources or methods, share them in comments below this article.

Introducing ReactiveNetwork

2015-08-10 Android, Open source, RxJava No comments

I’ve recently released ReactiveNetwork. It is an open-source Android library listening network connection state and change of the WiFi signal strength with RxJava Observables. It’s a successor of Network Events library rewritten with Reactive Programming approach.

Library is compatible with RxJava 1.0.+ and RxAndroid 1.0.+ and uses them under the hood. Min Android SDK version is 9.
JavaDoc can be found at: http://pwittchen.github.io/ReactiveNetwork.
Repository is available at: https://github.com/pwittchen/ReactiveNetwork.

This library is much simpler and easier to use than NetworkEvents. Even code-base is much smaller, but we have to remember that it utilizes powerful RxJava and RxAndroid. RxJava hase huge API and gives a lot of possibilities. That’s why I was able to obtain desired result with fewer lines of code.

Basic library usage is quite simple. E.g if we want to monitor ConnectivityStatus (WIFI_CONNECTED, MOBILE_CONNECTED or OFFLINE), we can create the following subscription, which is quite familiar for software developers who already know RxJava:

When we want to monitor available WiFi Access Points and we want to get fresh list of them whenever strength of the WiFi Access Points signal changes (e.g. when we are moving with a mobile device around), we can use the following code snippet:

If you want to use ReactiveNetwork in your project, add the following dependency to your build.gradle file:

dependencies {
  compile 'com.github.pwittchen:reactivenetwork:0.0.2'
}

Find more in the GitHub repository of the project at: https://github.com/pwittchen/ReactiveNetwork.

It’s worth mentioning that this library was featured on Android Arsenal, Android Weekly and Android Weekly China websites.

I hope you will find it useful and you will make your apps more reactive!
Feel free to fork the library. Any feedback is welcome as usual.

Releasing Prefser 2.0.0

2015-08-06 Android, Open source No comments

I’ve recently released Prefser library v. 2.0.0.
Prefser is a wrapper for Android SharedPreferences with object serialization and RxJava Observables.
This update couldn’t be done without help of awesome open-source community and people who reported new issues and created pull requests.
Thanks for that! A lot of issues related to RxJava was fixed. Moreover, now we can store and retrieve lists of objects of any type with Prefser.
Examples of library usage can be found in README.md file and in unit tests covering 96% of the code.

Below, you can find release notes for this version of the library:

  • fixed not keeping reference to listener when Observable instance is reused
  • fixed not unregistering listener, which causes onNext() even after unsubscribe()
  • fixed possible missed update with getAndObserve()
  • removed observe(sharedPreferences) method – backward incompatible
  • changed observeDefaultPreferences() method name to observePreferences()backward incompatible
  • added TypeToken and use of generics for interfaces
  • added possibility to store Lists of different types of data including custom objects
  • added more unit tests
  • updated test dependencies
  • updated JavaDoc available at http://pwittchen.github.io/prefser/

Feel free to fork the project or report new issues! Any kind of feedback is warmly welcome.

Releasing NetworkEvents 2.0.0

2015-07-31 Android, Open source No comments

I’ve recently released NetworkEvents library v. 2.0.0.
It’s an Android library listening network connection state and change of the Wifi signal strength.
It has a few significant changes in the API and new features, which people were requesting on GitHub.
Moreover, codebase was slightly refactored and updated.

I’m going to keep major.minor.patch convention AKA semantic versioning now:

  • major – new feature or update – backward incompatible
  • minor – new feature – backward compatible
  • patch – bug-fix – backward compatible

A few changes are backward incompatible, so I’ve increased major number.

Below, you can find list of changes. As you can see, there is a lot of stuff. That’s why I’ve made the most important changes bold.

  • removed withPingUrl(url) method
  • removed withPingTimeout() method
  • removed withoutPing() method
  • removed withoutWifiAccessPointsScan() method
  • removed Otto dependency (now, it’s available only for unit tests)
  • removed example-disabling-ping-and-wifi-scan app sample
  • removed example-ping-customization app sample
  • removed NetworkHelper class and moved its method to specific classes with changed scope
  • moved permissions to Manifest of library
  • disabled WiFi scan by default
  • disabled Internet connection check by default
  • added BusWrapper, which is abstraction for Event Bus required by NetworkEvents object
  • added example-greenrobot-bus app sample
  • added enableWifiScan() method
  • added enableInternetCheck() method
  • added getWifiScanResults() method in WifiSignalStrengthChanged event
  • added getMobileNetworkType() method in ConnectivityChanged event
  • added JavaDoc at: http://pwittchen.github.io/NetworkEvents/
  • updated existing sample applications
  • updated documentation in README.md and library code

Feel free to download, use or fork this library!

Releasing Weather Icon View v. 1.0.0 for Android

2015-07-21 Android, Open source No comments

Today I released Weather Icon View library v. 1.0.0
It’s very simple and easy to use Android library, which allows you to use Weather Icons created by Erik Flowers in your mobile applications. This library was already available on GitHub as I wrote in one of my previous posts, but today it was released to Maven Central Repository and you can use it as Maven or Gradle dependency. I was encouraged to make this project more available by the open-source community and people who find it useful as I could read in the issue reported on the repository website. Thanks for that.

You can find more details, usage examples and sample app in the repository of the project at: https://github.com/pwittchen/WeatherIconView.

By the way, this is article no. 100 on this blog. Thanks for your visits. 🙂