Monday, December 29, 2014

User location API's in Android

With the new framework with Google Play, you have to update your code now to use this unified GoogleApiClient.Builder() approach:

http://android-developers.blogspot.com/2014/02/new-client-api-model-in-google-play.html

There are now actually two ways to get location from Android. The 2nd way attempts to unify the various LocationProviders (GPS, network, other applications, etc.) into one API:

http://www.rahuljiresal.com/2014/02/user-location-on-android/

Friday, December 12, 2014

How to map multiple keyboards to the same OSX mappings

If you're trying to use Karabiner to support key remappings for multiple devices, you can take advantage of the templating syntax:

You can have your product and vendor ID definitions here:

<?xml version="1.0"?>
<root>
<symbol_map type="KeyCode" name="PAGE_UP" value="0x74" />
<symbol_map type="KeyCode" name="PAGE_DOWN" value="0x79" />
<windownamedef>
<name>emacs_terminal</name>
<regex>emacs</regex>
</windownamedef>
<appdef>
<appname>PyCharm</appname>
<equal>com.jetbrains.pycharm</equal>
</appdef>
<appdef>
<appname>Chrome</appname>
<equal>com.google.Chrome</equal>
</appdef>
<devicevendordef>
<vendorname>KINESIS</vendorname>
<vendorid>0x518</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>ADVANTAGE</productname>
<productid>0x0001</productid> <!--0x518 0x0001 -->
</deviceproductdef>
<devicevendordef>
<vendorname>KINESIS2</vendorname>
<vendorid>0x0557</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>CLASSIC</productname>
<productid>0x2221</productid> <!--0x0557 0x2221-->
</deviceproductdef>
<include path="{{ ENV_HOME }}/Dropbox/Keyboard/core.xml">
<replacementdef>
<replacementname>PRODUCT</replacementname>
<replacementvalue>DeviceVendor::KINESIS</replacementvalue>
</replacementdef>
<replacementdef>
<replacementname>KEY</replacementname>
<replacementvalue>DeviceProduct::ADVANTAGE</replacementvalue>
</replacementdef>
</include>
</root>
view raw gistfile1.txt hosted with ❤ by GitHub


You define your main key remappings here:

<?xml version="1.0"?>
<root>
<item>
<identifier>emacs_pageup_pagedown_{{ PRODUCT}}</identifier>
<name>Emacs pageup/pagedown</name>
<windowname_only>emacs_terminal</windowname_only>
<device_only>{{ PRODUCT }}, {{ KEY }} </device_only>
<autogen>__KeyToKey__ KeyCode::PAGE_UP, KeyCode::V, ModifierFlag::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::PAGE_DOWN, KeyCode::V, ModifierFlag::CONTROL_L</autogen>
<autogen>__KeyToKey__ KeyCode::CONTROL_L, KeyCode::CONTROL_L</autogen>
<autogen>__KeyToKey__ KeyCode::CONTROL_R, KeyCode::CONTROL_R</autogen>
</item>
<item>
<identifier>Option_Tab_Remapping_{{ PRODUCT }}</identifier>
<name>Kinesis remapping</name>
<device_only>{{ PRODUCT }}, {{ KEY }} </device_only>
<autogen>__KeyToKey__ KeyCode::TAB, ModifierFlag::OPTION_L, KeyCode::TAB, ModifierFlag::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::C, ModifierFlag::CONTROL_L, KeyCode::C, ModifierFlag::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::V, ModifierFlag::CONTROL_L, KeyCode::V, ModifierFlag::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::T, ModifierFlag::CONTROL_L, KeyCode::T, ModifierFlag::COMMAND_L</autogen>
</item>
<item>
<identifier>PyCharm_{{ PRODUCT }}</identifier>
<name>PyCharm</name>
<only>PyCharm,Chrome</only>
<device_only>{{ PRODUCT }}, {{ KEY }} </device_only>
<autogen>__KeyToKey__ KeyCode::CONTROL_L, KeyCode::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::CONTROL_R, KeyCode::COMMAND_R</autogen>
</item>
</root>
view raw gistfile1.txt hosted with ❤ by GitHub

Wednesday, December 10, 2014

Using padding in ListViews

Don't forget to use scrollbarStyle and clipToPadding according to this post!

https://plus.google.com/+AndroidDevelopers/posts/LpAA7q4jw9M

The difference between gravity and layout_gravity -- one deals with the parent (layout_), the other deals with the child.

http://stackoverflow.com/questions/13965883/what-is-exact-difference-between-gravity-and-layout-gravity