creativepsyco’s Blog

Trolling you digitally

about me

I’m a software developer from India now living in Singapore. I build apps and products, such as BeeTalk, a consumer chat app for mobile. These days I am building Pie, a chat for work. In my free time I try to contirbute to open source projects and try out cooking experiments.

Here I ramble about things such as software development, building products, and living life. And of course my rants about things in general

Styling Material Toolbar in Android

Android Lollipop was released back in Google I/O reflecting the new Material Design philosophy. It was followed soon by the AppCompat Library updating to v21. The Library brought in a new Action Bar pattern called Toolbar which behaves more like a custom view with a promise to customize the look and feel of it instead of the quirks of the ActionBar. The Action Bar was both less customizable and hard to style. With Toolbar some of it goes away as the Toolbar behaves more like a view group and you can initialize it with various different views which previously you could not.

written in Android Read on →

Set Background That Does Not Resize on Soft Keyboard

Problem

Here is an interesting problem. Let’s say you are in a particular view, and you want to be able to set a background. You simple use the View.setBackground(Drawable) or View.setBackgroundDrawable(Drawable) call to do this. However once you do this, you realize that whenever the soft keyboard is opened it pushes your view to the top/resizes it such that your background looks squished.

written in Android Read on →

Blogging With Octopress From 2 Computers

I use Octopress to blog from multiple computers, work and home computers, sometimes Virtual Machines even. I don’t have a track of where my latest post is going to be written from.

However, recently while deploying I encountered this strange error:

1
2
3
4
5
6
7
8
## Pushing generated _deploy website
To git@github.com:creativepsyco/creativepsyco.github.com.git
 ! [rejected]        master –> master (non-fast-forward)
 error: failed to push some refs to 'git@github.com:creativepsyco/creativepsyco.github.com.git'
 hint: Updates were rejected because the tip of your current branch is behind
 hint: its remote counterpart. Integrate the remote changes (e.g.
 hint: 'git pull …') before pushing again.
 hint: See the 'Note about fast-forwards' in 'git push —help' for details.

written in hacks, octopress Read on →

WebView Vulnerability in Facebook Android SDK: Embedded OAuth

Reposting this from my FB feed

TL;DR

Don’t put your FB username and password within mobile apps when you don’t have the native FB app installed!

Today I learnt that the Facebook SDK for Android is very insecure. At first I thought Man in the Middle attacks on the SDK OAuth authentication process is not possible, but if you are embedding someone else’s WebView within your own App via the SDK, you can very well control them, either via Reflection, or just by modifying the SDK code coz FB makes the SDK a public download which you then compile to link in your app. If the SDK does not find the FB app installed on a user’s phone, it resorts to using the fallback mechanism of using an embedded WebView for authentication.

written in android, hacks Read on →

Rooting Samsung Galaxy S3 GT-I9305 With CyanogenMod Jelly Bean 4.2.2

After getting the 4.3 update my Samsung Galaxy S3 started having weird battery problems, it was a high I moved to a custom ROM since they were a lot stable than a few years back and offered a much better stock Android experience without any bloated software than device OEMs put inside.

In this post, I shall roughly tell you how I installed a custom on my Samsung Phone.

Warning: Rooting voids the warranty of your device. We and the developers of these files are not responsible if anything happens to your device. Use this rooting guide at your own risk!

written in android, hacks Read on →

Doing a Proper Github Pull Request

While there may be different kind of development strategies floating around the merge vs rebase git model, one thing is for sure, you would at the end of the day want a clean merge from the contributors so that it can be tracked tested and cherry-picked if it needs to. This is where pull-requests are so effective.

What is a pull-request?

From the Official Github Guide:

Pull requests let you tell others about changes you’ve pushed to a GitHub repository. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.

Pull requests are useful in the shared repository model where contributors can work on different topic branches and then file a pull request to be able to initiate discussion about potential changes which does not need to affect the rest of the project.

Example

Here is an example of a pull request I filed for Square’s Wire open source project.

written in code quality, development Read on →

Android Activity: Problem With Posting Runnables

A lot of times in Android you end up writing code like this:

1
2
3
4
5
6
7
8
9
10
//—— Normal Code above —–
Runnable runnable  = new Runnable() {
    @Override
    public void run() {
        // Do something stupid
    }
}
// Singleton Handler Manager — not an instance one, am I smart?
HandlerManager.getInstance().postDelayed(runnable, 20000); // Run this after 20 seconds! Delay processing of data
finish();

That is, cooking up a lot of Runnables and posting them on the Handler to be run after a period of time. It happens.

As our role as developers trying to get a feature done in time, sometimes these Runnnables are the only hope. However, this Runnable introduces a potential memory leak.

written in android, memory-leak Read on →

Optimizing Google Protocol Buffers With Wire

The concept of Protocol Buffers by Google is amazing.

Why should you use it

Protocol Buffers is a serialization strategy, much like XML or JSON. A lot of mobile apps and web services make use of JSON for passing information. However, protocol buffers are inherently compressed formats and not intented for the human eye (readability wise). You should definitely take a look at it if you feel that you are using a lot of the mobile data or if the primary target group of your app is the domain of mobile. It however, makes sense to use them for internal RPC related APIs and communication channels.

written in Android, Protocol Buffers Read on →

Open Source Is an Ideology Not a Verb

Extracts From a software about-me page

MyAwesomeSauce is created by @me and open-sourced on Github

Our library has been open-sourced and served under the GPL License v2 to facilitate ease of use among developers

Seriously? Are you trying to market your creation or genuinely serving the interests of the open source community

From Ben Balter:

To say “hey, we’ve got something decent here, let’s take this closed-sourced project and just hit publish” misses the mark. Your motivation can’t be to seek free labor, as in “hey, if developers want to give us their time, great, let’s put this out there and see what happens we have nothing to lose”, or about sporadically seeking to garner good will from a niche community of dedicated fans. Trust me, an open source developer can smell astroturf a mile a way, and that’s exactly how far they’ll stay.

Open source is a philosophy, not something that you get to choose between waterfall, agile or open source (if there is such a thing). Its not about the code you write but rather, the procedure and democracy of how that code was written, reviewed and published.

So save yourself the trouble to say something to be open-source when you actually mean it in terms of the processes and the people involved. Don’t get trapped in the danger zone :–)

written in open-source, philosophy