Friday, 22 April 2016

Formatting time in Android/Java, the right way

I suppose this is very obvious for someone, but I spent a fair bit of time trying to understand what is the right, no, the right way to do time formatting in Java. I know about Joda, and don't really want to use it (because size, and frankly, I don't need all of it's features). I know about SimpleDateFormat and hate it because I have to hardcode my format. What I wanted is the way to use system-defined, user-preferred way to format time - i.e. if user specified 12-hour time, we want to add AM/PM, and if they happen to use Russian layout, that should magically become "ДП/ПП" however odd I would find this. This is, I think, the quickest the way to get it - using standard framework features:

When using this approach, you will get correctly formatted time, e.g. for 23:10 you will get "23:10" in 24-hour time, "11:10 PM" with English locale and 12-hour time, and "11:10 ПП" in Russian. Makes me very happy this is actually achievable without resorting to hacks like this, or, even worse, this.

Friday, 15 April 2016

Notifications, lockscreen and timed silence

So I got bored the other day and though: why my wonderful Samsung S7 Edge just doesn't seem to support an ability to shut up all the notification sounds for a timed interval? After all, this has been supported by Android Marshmallow since forever, and yet they decided to pull it. Then again, my better half was complaining about exactly the same thing as she always switches sound off for meetings and then inevitably forgets to turn it back on again (something I like to complain about).

Prospects did not look good. But then I thought - hang on a sec, there should be an app for that! So I searched Play Store, and searched again, and there are lots of apps, but they look like shit, and most importantly, are hard to use as I have to define a schedule (like, really, would anybody do that?). And I decided this is something I can fix.

I spent like a Saturday afternoon coding and a proof-of-concept was born - an app which can silence notifications for a period of time. Then I realised that user still has to unlock the screen and launch the app, which is not very user friendly, and remembered about fancy Lollipop notifications which has been there since forever. Et voila - Silencer was born.

 



Don't judge it too harshly as this is just a simple app to solve a simple problem - however, I find it using a lot. When I walk into a meeting, I fire up the screen on my phone and silence all notifications for 30 minutes, without even unlocking it. Try it, might work for you as well :) If you feel this app is desperately lacking something - get back to me and I'll try to add it.

https://play.google.com/store/apps/details?id=info.romankirillov.silencer

Tuesday, 31 March 2015

Software Engineering process, Google way

By: Simon Wingrove (http://www.simonwingrove.com), Roman Kirillov

We often get questions along the lines of “what is the development process at Google?” – meaning the secret sauce which allows project to magically happen and launch on time. There is an abundance of articles and blog posts which describe how Google does things, and probably some of them are right! The truth is, however, that a process that works for one group of smart people will not necessarily work for another. This is why there’s simply no such thing as “the” development process at Google.  Most teams will adopt the approach that suits them best.
Establishing the process for a team is usually not something that happens “because the manager said so” – frankly, engineers have far more say in the matter.  When our team (Google Play for work) realised it was growing to the point where it needed to formalise its practices, the engineers stepped up and self-organised to make it happen.
The cornerstone of any development process is the goal: what are we trying to achieve here? We want to be able to answer a few fundamental questions at any moment in time.
  • Are we on track to deliver?
  • What features are we currently working on?
  • Can we take on more work now and still meet our deadlines?
Engineers are best placed to estimate the complexity of engineering problems, so making sure we can always answer these questions is an engineer-driven process.
Objectives and Key Results – achievable and measurable goals
Across all of Google we use Objectives and Key Results (OKRs). Every team, product area and even the company as a whole has them. OKRs are defined quarterly by the product and engineering managers, with input from the wider team on specific technical questions.

Monday, 15 September 2014

Geeky car insurance

My car insurer of choice - Aviva - takes an interesting approach to estimating the risk score. We all heard about insurers who want to install an extra little box to your car which will estimate your driving style, yada yada. Aviva actually employed slightly different approach: you install an app on your phone, and then check in at every start and end of journey. Once you've driven 200 miles with the app, your driving style is evaluated and you can receive a hefty discount (up to 20%, really) on your insurance premiums.

 

This way no one actually tells you to install the box or the app - but if you do that, you can save few extra quid on your car insurance - for some of the younger drivers insurance premiums can be crippling, so this would be a really good deal (and admit it, some although not all younger drivers can benefit of some err ... improvements with regards to their driving style).

What do you think of this approach? Would you install such an app?

Friday, 22 August 2014

Using GestureDetector in Android ImageView

I've found quite a few discussions on the Internet with regards to using GestureDetector for your ImageView; some of them are more useful than the others. The bottom line is: there are two ways of doing this:

  • Either subclassing ImageView and using newly created view in your activity XML file
  • Or simply delegating all events from ImageView to the gesture detector in your activity.
In fact, second way is extremely simple, so I want to share with you an example of how this can be done.


public class ShowImageActivity extends Activity {

  private static final String TAG = ShowImageActivity.class.getSimpleName();

  class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
    @Override
    public void onLongPress(MotionEvent e) {
      Log.d(TAG, "onLongPress " + e.toString());
    }

    @Override
    public boolean onSingleTapConfirmed(MotionEvent e) {
      Log.d(TAG, "onSingleTapConfirmed " + e.toString());
      return true;
    }

    // You really need all these boilerplate methods for GestureDetector to work

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
      return true;
    }
    @Override
    public boolean onDown(MotionEvent e) {
      return true;
    }
  }
  

Wednesday, 16 July 2014

LG G Watch CPU and RAM

I find it quite amusing that Android Wear LG G Watch has 4 cores and 512Mb of RAM on board - for such a tiny device this is somewhat crazy




shell@dory:/system $ cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 38.40
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 3

processor : 1
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 38.40
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 3

processor : 2
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 38.40
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 3

processor : 3
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 38.40
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 3

Hardware : Qualcomm MSM 8226 DORY (Flattened Device Tree)
Revision : 0007
Serial  : 0000000000000000

shell@dory:/system $ cat /proc/meminfo
MemTotal:         471952 kB
MemFree:           28048 kB
Buffers:           59792 kB
Cached:            98004 kB
SwapCached:            0 kB
Active:           278340 kB
Inactive:          69112 kB
Active(anon):     196048 kB
Inactive(anon):      128 kB
Active(file):      82292 kB
Inactive(file):    68984 kB
Unevictable:         744 kB
Mlocked:               0 kB
HighTotal:             0 kB
HighFree:              0 kB
LowTotal:         471952 kB
LowFree:           28048 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:        190400 kB
Mapped:            63416 kB
Shmem:              5776 kB
Slab:              24568 kB
SReclaimable:      10728 kB
SUnreclaim:        13840 kB
KernelStack:        4752 kB
PageTables:         6008 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      235976 kB
Committed_AS:    6194552 kB
VmallocTotal:     521216 kB
VmallocUsed:       37204 kB
VmallocChunk:     304156 kB


I can easily remember my computer not 5 years ago, and it had specs sufficiently less than that!
Another amusing fact is that Wear has /sdcard mounted (even though there's obviously no SD Card whatsoever) which even has pretty standard for Android devices directory structure. 

Using Android Wear as a camera remote viewfinder

Since the moment I found Android Wear watches (I use LG G Watch) can be used as a remote release for standard Android camera app, I was waiting for the logical conclusion to this functionality - that is, ability to use the watch as a remote viewfinder. Lo and behold, meet github.com/dheera/android-wearcamera - Android Wear Camera by one Dheera Venkatraman (Play Store link). It does exactly what you think it does - when you start this app, it shows you a button-less camera view, which is mirrored on your watch. If this is not an ultimate selfie-tool then I don't know is.


The UI is minimalistic if I ever seen one, but hey - it does work!

Now, there are naturally tons of bells and whistles I would love to see added to this app, but even in its current for it works - and best of all, it is GPL-licensed, so anyone can git clone it and tune it to his or her heart delight!