Saturday, November 29, 2014

Load a Bitmap efficiently and set it as a wallpaper for Android devices

In this blogpost I will open the parts of the source-code of my discontinued app called DroidPapers, that I considered as code making my app different from other apps. In the past I released other code to the general public, that were also a part of DroidPapers.

The topic is about Bitmaps and how to efficiently load them into your device's memory and, if needed, set them as a wallpaper.

The code is aimed at Android and written in Java and you need API level 14 (ICS) or higher. Perhaps with some tweaking it might work for other Java-based platforms and Android versions. But that is up to you.

Some requirements I had while making this code:
  • A Bitmap of any size should be loadable on any device, both low-end as high-end.
  • Make as less Bitmaps in memory as possible.
  • Free Bitmaps in memory as soon it is possible.
  • Always check if Bitmaps, and other variables, actually exists in memory before processing.
There are most likely even better ways to process Bitmaps. The code is based on examples found on the Internet and the Android SDK website. The experience I had with this code that error reports about memory hogging were gone.

The code is explained in the code itself. I made two files with one containing the "library" and the other containing the process of the Bitmap.

LibraryWallpaperBitmaps.java

ProcessBitmap.java

Thanks for reading my blog and if you have any questions, feel free to contact me or respond in the comments below.

Sources


Copyright (c) 2015 Joram Teusink

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Saturday, November 22, 2014

The History of DroidPapers, from its start till its end

In this blogpost I am going to talk about my app DroidPapers, and its history. DroidPapers was a wallpaper and ringtone app and offered a service to automatically change the wallpaper of your device on a given interval.

Before I briefly describe a reflection with each generation of the app, I will first going to reflect on my experience with app-development and reasons why I stopped with my app DroidPapers.

Reflection, the good...

What a ride it was! When I first launched DroidPapers there were like two users. Me, and... well, probably someone else. Roughly 2,5 years later there were roughly 10.000 users per month with almost 200.000 pageviews and sessions in the app and website combined. These numbers were higher before, but later on that part.

In the year 2000 (or so) I had a website called photo4u.nl (not affiliated with the current website hosted behind that domain) and it affored a service to host photos for free. What was unique was the fact that it helped users to add the photos to their profile-based websites by generating proper HTML-tags. These tags could be added in order to show a photo (or image) on a profile or website. The most important part though was that it was the first Cloud service in The Netherlands for photos. Somewhere along the line I took a very very wrong turn and the website ultimately went offline (after being rather successful). Don't ask my why... it still hurts to much ;).

My creativity never died though as I was always busy with programming websites for myself or friends. Purely as a hobby to give my urge to be creative, to create stuff people want, a place to thrive.

Couple of years later the world met smartphones and tablets and my love for gadgets was born instantly. In 2012 I therefore decided to put my web-building skills in my efforts to create an app for users with love for Android or wallpapers in general. And this was the moment that the idea of DroidPapers was born. But there were already a lot of apps who offered similar services. So to make a difference, I made the wallpapers in my app unique. Only stock Android wallpapers were to be added.

After some time, it became a kind of boring, because Google did not release new wallpapers every month. Not that I expected this to happen by the way. So I started adding wallpapers from more sources to DroidPapers. The scope became original wallpapers from every device with Android. And to do something different, I added ringtones into the mix.

My app developed nice and easy and sometimes features were added, and even sometimes they were removed. In the last generation of DroidPapers most features were removed and the app became more clean and less cluttered.

I saw the usage growing, but it never surpassed 14.000 installs on devices and with 14.000 users it had reached its maximum potential. Nonetheless, I nice success that I created mostly by myself.

Reflection, the bad...

Not everything went well with DroidPapers. The first reason was technical. Due to my love for web-programming I decided to built my app with PhoneGap Cordova and jQuery Mobile. This way I could use my knowledge of HTML, CSS and Javascript for the development of my app. I think in the long run; this was a wrong decision. Don't get me wrong, I am not saying that web-applications are bad by nature, but for DroidPapers it was better to be a native written app.

The second one was copyright. After a while I contacted Samsung, Motorola, HTC, Sony, Huawei, and LG concerning copyright of their content such as wallpapers and ringtones. I asked them if I could have their content in my app DroidPapers. All replied (which was nice, thank you for that!), but all said no. In respect to their wishes all non open-sourced or free wallpapers were removed from DroidPapers.

And this decision (to abide by the wishes of the companies protecting their copyright) resulted in a big reduction of usage of my app. Many people understood my course of actions, but many went to competing apps or websites. Keep in mind that those services might not have explicit permission to host those wallpapers and ringtones.

Why stop with DroidPapers?

Well, to quote The Matrix: "Everything that has a beginning has an end." [The Oracle]. But there are better reasons though.

The first reason is time. Time, time time. If I could buy it, I would. I believe that the technical state of the current version of DroidPapers is outdated, especially compared to Material Design by Google. But I seriously do not have the time to change the entire code base, make the app native and rework all features in a programming language I yet have to master.

The second reason is career choice. My focus in the past year has changed to Information and IT Security. This very nice field of expertise within the IT-world (and beyond) has caught my attention, devotion and again, my time. I am starting a new platform (on which I will write in a next blog) focusing on Cybersecurity, well... just security. Let's all ditch #cyber.

And I cannot give proper attention to DroidPapers when I start other initiatives, but I also cannot give proper attention to my other initiatives when keeping DroidPapers.

And the last reason is funding. Hosting is not cheap, but I made a promise to my user base. There is no paid-content and there are no ads. Ever. So, wise or not, my funding dried out and the plug has to be pulled.

And these are the reasons that led to my decision to stop the DroidPapers service.

Can I continue it?

Well, you can if you want. You can find the entire source of DroidPapers on my GitHub repo and it is published under the the MIT License.

Word of thanks

First of all, I want to thank every user of DroidPapers, whether he or she still uses it or not. Thanks for making the app for what it is today. Thanks for all the review sites that reviewed my app and thanks for Androidworld.nl for making my app an app of the week.

Second of all, I want to thank Giampaolo in particular for translating DroidPapers to Italian. Thanks for all your time for translating and testing the app! Italian speaking people were the biggest group of users. Thank you all!

First generation

Begins with version 1.0
Release date: 27 June 2012


This was actually the first release of DroidPapers to the Google Play Store. It was a very basic app with one feature, setting the wallpaper as your default background. All wallpapers were included in the APK file and there were only Android AOSP wallpapers.

Second generation

Begins with version 2.0
Release date: 26 September 2012


This generation featured two major new features. The first one was the tablet and smartphone interface. And the second one was the addition of more wallpapers than only AOSP. With this release there was also a website built that hosted the wallpapers. The wallpapers itself were not included in the package anymore.

Third generation

Begins with version 3.0
Release date 10 December 2012

The third generation consisted of a couple of new features. Those were the favorites system, the service to automatically change your wallpaper and an updated framework of Cordova PhoneGap and jQuery Mobile. Also the interface got a nice revamp.


Fourth generation

Begins with version 3.11
Release date 11 June 2013

This generation introduced the side panel menu as Google ment it to be. Further more there were major technical improvements and the website was updated with better styling.


Fifth, and last, generation

Begins with version 4.0
Release date 3 September 2014

This generation introduced the cards based user interface and an updated website the get all user interfaces into one style. Many features were removed and some were improved.


The Statistics

The web-traffic statistics of 2012 and 2013 can be found below.


And for an impression on where DroidPapers was being used, check out this map!


Publication in the Android Magazine (Dutch)

And there has also been a publication in the Android Magazine on August the 13th of 2013 (number 13, page 65).

Want to see more?

If you want to see more videos about DroidPapers on YouTube, then check out this playlist DroidPapers.