Saturday, May 12, 2012

Automatic assignment of custom font in android activity

Custom font in Android is unfortunately not a theme question (correct me if I'm wrong) but is in fact quite simple to implement. In your common base activity overload the setContentView like this:
	public void setContentView(int layoutResId) {
		View root = getWindow().getDecorView().getRootView();
		if (root instanceof ViewGroup) {
			Typeface font = Typeface.createFromAsset(getAssets(), "<<YOUR FONT FROM ASSETS>>");
			iterateKids(root, font);

	private void iterateKids(View view, Typeface font) {
		if (view instanceof TextView) {
		} else if (view instanceof ViewGroup) {
			ViewGroup group = ((ViewGroup)view);
			for (int x=0; x<group.getChildCount(); x++) {
				iterateKids(group.getChildAt(x), font);

it spends aboout 0.3 ~ 2ms on every child in hierarchy (on emulator) so as long as you optimize your layouts to be less than 100 elements a screen it's definitely okay.

Friday, February 17, 2012

Prayer wheel

Disscussion be here

Sunday, January 22, 2012


It's done, compiled and packaged but before publishing i'll have some more testing went live!
And yes, it's about synchronizing stuff and no it's not about google docs.
There's one small issue, but not critical so the public testing can start.  Fixed

What to expect? After migrating to the new phone, settings, practices and their counts automatically restore from nagas knows where.

Let's say if no complaints will show up till 28th of January - I'll publish what I currently have.

Important. Online sync works on devices with Android 2.2 and later. If you're lucky owner of 1.6, the tracker will work but no sync. Sorry.

But. It's not going to be an easy testing.
0. Write down your counters on paper. Hopefully this is the last time. But this is testing and it's 2012.

0.5 If your android version is lower than 2.2 the test is simple. Backup. Install. Run. It works. Done.

I'm using two scenarios after installing the new tracker:
1. First scenario: you've got only one android device
1.0 Common step. Make sure you're on wifi. Data set is not big but android will backup sooner when on wifi. Go to Settings-Accounts and Sync. Make sure you've got "Background data" and "Auto-sync" on.

1.1 Common step. Go to tracker options, change something (not really necessary but still) go back (this is when magic happens). Adding practice is also a good test (magic happens there too).
1.2 Common step. If you're lucky owner of adb you can do "adb shell bmgr backup com.meditationtracker" and then to make sure "adb shell bmgr run"

1.3 Common step. Normally you don't have adb so. Wait for the sync icon in notification panel above to appear and disappear.
1.4 Scary part. Go to Settings-Applications-Manage Applications. Find there Meditation Tracker. Go inside. Click "Erase data". That is the scary step - all your meditation tracker data is gone now. Now click "Uninstall". And let the tracker go.
1.5 Install new tracker again.
1.6 Open it and rejoice. Your practices have been restored.
1.7 Optional step. Complain of something going wrong.

2. Second scenario. Multiple devices with same google account. 
2.1 Read scenario 1.
2.2 If you have or had meditation tracker on your second device (not important one) do there step 1.4. It should be absolutely clean from tracker.
2.3 Do steps 1.0 to 1.3 on your main device.
2.4 Install new tracker on to the other device. Wait for synchronization to complete. Start tracker there. Rejoice seeing practices and counts from main device.
2.5 Optional step 1.7

I've done some UI clean-ups so normal "have a look if everything still works" test is also important.

Fun! Fun! Fun!