Creative Commons License Tagging Android Implementation for Image

In the previous posting, I tested CCL license tagging Java implementation on Linux desktop. After several conversation and change with Wen, finally I could get Java implementation that extract, manipulate, create, and put Creative Commons license into image files : jpg, png, tif, and gif on Android.

I wrote a wrapper class that enables Android developers easily use in their project to read/create/put Creative Commons license called CCXMPTag. This class uses Adobe XMP Library for Java CS6 and Wen Yu’s PixyMeta Android. This posting is draft of the tutorial.

CCXMPTag source code will be uploaded to https://github.com/creativecommons/seneca

Setting Creative Commons license

CCXMPTag t1 = new CCXMPTag();
t1.setNewValue(CCXMPTag.TAG_LICENSE, CCXMPTag.LICENSE_BYNC);
t1.setNewValue(CCXMPTag.TAG_ATTRIBUTIONNAME, "Hosung Hwang");
t1.setNewValue(CCXMPTag.TAG_ATTRIBUTIONURL, "https://hosunghwang.wordpress.com");
t1.writeInfo("test.jpg", test_out.jpg");

By creating CCXMPTag, empty CC License is created. using setNewValue method, CC property is set. Followings are CC properties defined as static members. Although arguments of setNewValue method are String, using static member protects typos. Those are defined as TAG_XXXX.

Member XMP Property
TAG_LICENSE License
TAG_ATTRIBUTIONNAME AttributionName
TAG_ATTRIBUTIONURL AttributionURL
TAG_MARKED Marked
TAG_TITLE Title
TAG_USAGETERMS UsageTerms

In License property, there are 6 kind of license. License is defined as LICENSE_XXXX.

Member License Name URL
LICENSE_BY Attribution 4.0 International http://creati-ecommons.org/licenses/by/4.0/
LICENSE_BYNC Attribution-NonCommercial 4.0 International http://creati-ecommons.org/licenses/by-nc/4.0/
LICENSE_BYNCND Attribution-NonCommercial-NoDerivs 4.0 International http://creati-ecommons.org/licenses/by-nc-nd/4.0/
LICENSE_BYNCSA Attribution-NonCommercial-ShareAlike 4.0 International http://creati-ecommons.org/licenses/by-nc-sa/4.0/
LICENSE_BYND Attribution-NoDerivs 4.0 International http://creati-ecommons.org/licenses/by-nd/4.0/
LICENSE_BYSA Attribution-ShareAlike 4.0 International http://creati-ecommons.org/licenses/by-sa/4.0/

After setting license information, writeInfo change the XMP tag that is in test.jpg and make new file named test_out.jpg.

Getting Creative Commons License

CCXMPTag t2 = new CCXMPTag("test.jpg");
String a = t2.getValue(CCXMPTag.TAG_ATTRIBUTIONNAME);
String b = t2.getValue(CCXMPTag.TAG_ATTRIBUTIONURL);
String c = t2.getValue(CCXMPTag.TAG_LICENSE);
String d = t2.getValue(CCXMPTag.TAG_MARKED);

By creating CCXMPTag with existing file name, CCXMPTag read XMP from image file. getValue returns Creative Commons property value as a string.

Changing existing XMP tag

CCXMPTag t1 = new CCXMPTag("test.jpg");
if (t1.getValue(CCXMPTag.TAG_LICENSE).equals("http://creati-ecommons.org/licenses/by-nc/4.0/")){
   t1.setNewValue(CCXMPTag.TAG_ATTRIBUTIONNAME, "Hosung Hwang");
   t1.setNewValue(CCXMPTag.TAG_ATTRIBUTIONURL, "https://hosunghwang.wordpress.com");
   t1.writeInfo("test.jpg", test_out.jpg");
}

Simply by reading XMP information from existing image file, read and change values. Since writeInfo takes two arguments, License values read by another file can set to am image file.

Other than these usage,

  • extractInfoFromXML can be used to parse XMP data from String not from image.
  • existValue can be used to check if it has a CC property.
  • deleteValue deletes existing CC property
Advertisements

Markdown format

Recently, I started to use Markdown format as a personal memo format. This is by far the one I was looking for. I always wanted a text format that can be easily formatted as HTML, at the same time, it should be easy to write, and text file itself should be readable. Markdown has all that features and it is already widely being used.
I was thinking about using wiki format. There is local wiki editor and viewer called Zim Desktop Wiki. Emacs also has wiki mode. However, sharing with other devices was painful.

About Markdown

Markdown is developed in 2004 by John Gruber “to write using an easy-to-read, easy-to-write plain text format, and optionally convert it to structurally valid XHTML”

Rules

Following links are useful :
* http://en.wikipedia.org/wiki/Markdown
* https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet

Benefit in the local memo file with emacs

To write everyday activities, I was using text files that are everyday generated by emacs (link). It was good, but to share it, I had to copy it to evernote or something.
By using emacs’ Markdown mode, I can see the text with little bit of formatting using color and bold. Also, it gives fast way to insert Markdown formatting keywords.
Now all my text file extension is .md and emacs generates it automatically.

Benefit in mobile sharing with dropbox

When I put the diary directory’s link to dropbox sync directory, the files are automatically synchronized as soon as I edit them.
There is an Android app called “Draft“. It supports Dropbox synchronization for Text and Markdown format. Also it shows formatted Markdown. Of course, it has editing feature.
As a result, when I add or edit a text in the Android Draft app, it is synchronized to my laptop’s diary directory. Now, I do not need evernote. “Draft” looks like this :
Screenshot_2015-02-11-20-39-01

Benefit with github

github uses Markdown as readme and all kind of text file. So, if I write my local file using markdown, it can be directly used as github text.

Benefit with wordpress

wordpress supports Markdown. This posting and previous posting was written using Markdown. It is much faster than typing html tag for making list and table. Also, my Markdown memo can be directly posted as a wordpress posting.

Chrome Extension

There is a Markdown Preview Plus chrome extension. If the markdown file is opened by chrome using “file:///home/hosung/diary/diary2015_02_08.md” or drag-drop, it shows generated HTML on the page using CSS for github style or other style. Optionally, the page can reload changed file every 1+ seconds.

Emacs Integration

I wrote a simple LISP script to add into .emacs file. By using it, currently editing file can be quickly opened in chrome by typing M-x chrome or Ctrl-Shift-c.

(defun chrome ()
  (interactive)
  (eshell-command
   (format "google-chrome --activate-existing-profile-browser %s" buffer-file-name ))
)
(global-set-key (kbd "C-S-c") 'chrome)

 

Android Version/Source code History

http://source.android.com/source/build-numbers.html#platform-code-names-versions-api-levels-and-ndk-releases

Codenames, Versions, API Levels

Code name Version API level
(no code name) 1.0 API level 1
(no code name) 1.1 API level 2
Cupcake 1.5 API level 3, NDK 1
Donut 1.6 API level 4, NDK 2
Eclair 2.0 API level 5
Eclair 2.0.1 API level 6
Eclair 2.1 API level 7, NDK 3
Froyo 2.2.x API level 8, NDK 4
Gingerbread 2.3 – 2.3.2 API level 9, NDK 5
Gingerbread 2.3.3 – 2.3.7 API level 10
Honeycomb 3.0 API level 11
Honeycomb 3.1 API level 12, NDK 6
Honeycomb 3.2.x API level 13
Ice Cream Sandwich 4.0.1 – 4.0.2 API level 14, NDK 7
Ice Cream Sandwich 4.0.3 – 4.0.4 API level 15, NDK 8
Jelly Bean 4.1.x API level 16
Jelly Bean 4.2.x API level 17
Jelly Bean 4.3.x API level 18
KitKat 4.4 – 4.4.4 API level 19
Lollipop 5.0 API level 21

Source Code Tags and Builds

Build Branch Version Supported devices
LRX22C android-5.0.1_r1 Lollipop Nexus 7 (flo), Nexus 9 (volantis), Nexus 10
LRX21V android-5.0.0_r7.0.1 Lollipop Nexus Player (fugu)
LRX21T android-5.0.0_r6.0.1 Lollipop Nexus 4
LRX21R android-5.0.0_r5.1.0.1 Lollipop Nexus 9 (volantis)
LRX21Q android-5.0.0_r5.0.1 Lollipop Nexus 9 (volantis)
LRX21P android-5.0.0_r4.0.1 Lollipop Nexus 7 (flo/grouper), Nexus 10
LRX21O android-5.0.0_r3.0.1 Lollipop Nexus 5 (hammerhead), Nexus 6 (shamu)
LRX21M android-5.0.0_r2.0.1 Lollipop Nexus Player (fugu)
LRX21L android-5.0.0_r1.0.1 Lollipop Nexus 9 (volantis)
KTU84Q android-4.4.4_r2 KitKat Nexus 5 (hammerhead) (For 2Degrees/NZ, Telstra/AUS and India ONLY)
KTU84P android-4.4.4_r1 KitKat Nexus 5, Nexus 7 (flo/deb/grouper/tilapia), Nexus 4, Nexus 10
KTU84M android-4.4.3_r1.1 KitKat Nexus 5 (hammerhead)
KTU84L android-4.4.3_r1 KitKat Nexus 7 (flo/deb/grouper/tilapia), Nexus 4, Nexus 10
KVT49L android-4.4.2_r2 KitKat Nexus 7 (deb Verizon)
KOT49H android-4.4.2_r1 KitKat Nexus 5, Nexus 7 (flo/deb/grouper/tilapia), Nexus 4, Nexus 10
KOT49E android-4.4.1_r1 KitKat Nexus 5, Nexus 7 (flo/deb/grouper/tilapia), Nexus 4, Nexus 10
KRT16S android-4.4_r1.2 KitKat Nexus 7 (flo/deb/grouper/tilapia), Nexus 4, Nexus 10
KRT16M android-4.4_r1 KitKat Nexus 5 (hammerhead)
JLS36I android-4.3.1_r1 Jelly Bean Nexus 7 (deb)
JLS36C android-4.3_r3 Jelly Bean Nexus 7 (deb)
JSS15R android-4.3_r2.3 Jelly Bean Nexus 7 (flo)
JSS15Q android-4.3_r2.2 Jelly Bean Nexus 7 (flo)
JSS15J android-4.3_r2.1 Jelly Bean Nexus 7 (flo/deb)
JSR78D android-4.3_r2 Jelly Bean Nexus 7 (deb)
JWR66Y android-4.3_r1.1 Jelly Bean Galaxy Nexus, Nexus 7 (grouper/tilapia), Nexus 4, Nexus 10
JWR66V android-4.3_r1 Jelly Bean Galaxy Nexus, Nexus 7 (grouper/tilapia), Nexus 4, Nexus 10
JWR66N android-4.3_r0.9.1 Jelly Bean Galaxy Nexus, Nexus 7 (grouper/tilapia/flo), Nexus 4, Nexus 10
JWR66L android-4.3_r0.9 Jelly Bean Nexus 7
JDQ39E android-4.2.2_r1.2 Jelly Bean Nexus 4
JDQ39B android-4.2.2_r1.1 Jelly Bean Nexus 7
JDQ39 android-4.2.2_r1 Jelly Bean Galaxy Nexus, Nexus 7, Nexus 4, Nexus 10
JOP40G android-4.2.1_r1.2 Jelly Bean Nexus 4
JOP40F android-4.2.1_r1.1 Jelly Bean Nexus 10
JOP40D android-4.2.1_r1 Jelly Bean Galaxy Nexus, Nexus 7, Nexus 4, Nexus 10
JOP40C android-4.2_r1 Jelly Bean Galaxy Nexus, Nexus 7, Nexus 4, Nexus 10
JZO54M android-4.1.2_r2.1 Jelly Bean
JZO54L android-4.1.2_r2 Jelly Bean
JZO54K android-4.1.2_r1 Jelly Bean Nexus S, Galaxy Nexus, Nexus 7
JRO03S android-4.1.1_r6.1 Jelly Bean Nexus 7
JRO03R android-4.1.1_r6 Jelly Bean Nexus S 4G
JRO03O android-4.1.1_r5 Jelly Bean Galaxy Nexus
JRO03L android-4.1.1_r4 Jelly Bean Nexus S
JRO03H android-4.1.1_r3 Jelly Bean
JRO03E android-4.1.1_r2 Jelly Bean Nexus S
JRO03D android-4.1.1_r1.1 Jelly Bean Nexus 7
JRO03C android-4.1.1_r1 Jelly Bean Galaxy Nexus
IMM76L android-4.0.4_r2.1 Ice Cream Sandwich
IMM76K android-4.0.4_r2 Ice Cream Sandwich Galaxy Nexus
IMM76I android-4.0.4_r1.2 Ice Cream Sandwich Galaxy Nexus
IMM76D android-4.0.4_r1.1 Ice Cream Sandwich Nexus S, Nexus S 4G, Galaxy Nexus
IMM76 android-4.0.4_r1 Ice Cream Sandwich
IML77 android-4.0.3_r1.1 Ice Cream Sandwich
IML74K android-4.0.3_r1 Ice Cream Sandwich Nexus S
ICL53F android-4.0.2_r1 Ice Cream Sandwich Galaxy Nexus
ITL41F android-4.0.1_r1.2 Ice Cream Sandwich Galaxy Nexus
ITL41D android-4.0.1_r1.1 Ice Cream Sandwich Galaxy Nexus
ITL41D android-4.0.1_r1 Ice Cream Sandwich Galaxy Nexus
GWK74 android-2.3.7_r1 Gingerbread Nexus S 4G
GRK39F android-2.3.6_r1 Gingerbread Nexus One, Nexus S
GRK39C android-2.3.6_r0.9 Gingerbread Nexus S
GRJ90 android-2.3.5_r1 Gingerbread Nexus S 4G
GRJ22 android-2.3.4_r1 Gingerbread Nexus One, Nexus S, Nexus S 4G
GRJ06D android-2.3.4_r0.9 Gingerbread Nexus S 4G
GRI54 android-2.3.3_r1.1 Gingerbread Nexus S
GRI40 android-2.3.3_r1 Gingerbread Nexus One, Nexus S
GRH78C android-2.3.2_r1 Gingerbread Nexus S
GRH78 android-2.3.1_r1 Gingerbread Nexus S
GRH55 android-2.3_r1 Gingerbread earliest Gingerbread version, Nexus S
FRK76C android-2.2.3_r2 Froyo
FRK76 android-2.2.3_r1 Froyo
FRG83G android-2.2.2_r1 Froyo Nexus One
FRG83D android-2.2.1_r2 Froyo Nexus One
FRG83 android-2.2.1_r1 Froyo Nexus One
FRG22D android-2.2_r1.3 Froyo
FRG01B android-2.2_r1.2 Froyo
FRF91 android-2.2_r1.1 Froyo Nexus One
FRF85B android-2.2_r1 Froyo Nexus One
EPF21B android-2.1_r2.1p2 Eclair
ESE81 android-2.1_r2.1s Eclair
EPE54B android-2.1_r2.1p Eclair Nexus One
ERE27 android-2.1_r2 Eclair Nexus One
ERD79 android-2.1_r1 Eclair Nexus One
ESD56 android-2.0.1_r1 Eclair
ESD20 android-2.0_r1 Eclair
DMD64 android-1.6_r1.5 Donut
DRD20 android-1.6_r1.4
DRD08 android-1.6_r1.3
DRC92 android-1.6_r1.2

View difference

hosung@hosung-Spectre:/media/hosung/SSD/android$ repo forall -pc 'git log --no-merges --oneline android-5.0.0_r1..android-4.4.4_r2' > ../tmp/android-5.0.0_r1-android-4.4.4_r2-diff.txt

adb cheat sheet

http://developer.android.com/tools/help/adb.html

adb devices (list connected devices)
ADB push (sends files to your phone local->remote) — adb push
c:\example.apk /sdcard/example.apk
ADB pull (Receives files from your phone remote->local) — adb pull
/system/app/example.apk c:\example.apk
ADB install (installs application) — adb install c:\example.apk
adb shell (Begins shell connection with phone)
adb reboot (reboots phone)
adb reboot recovery (reboots phone into recovery)
adb reboot bootloader (reboots the phone into bootloader/the white screen)
adb remount (remounts the system)

Activity Manager(am)

adb shell am start -a android.intent.action.VIEW
adb shell am kill android.intent.action.VIEW
adb shell am kill all (kill all background process)
adb shell am display-size 1280×800 (override display size)

recording the display of devices running Android 4.4 (API level 19) and higher
$ adb shell screenrecord /sdcard/demo.mp4
//////////example/////////////////
$ adb shell
shell@ $ screenrecord –verbose /sdcard/demo.mp4
(press Ctrl-C to stop)
shell@ $ exit
$ adb pull /sdcard/demo.mp4
///////////////////////////////////////

LOGCAT
adb logcat
adb shell -> logcat

LOGCAT exclude pattern
adb logcat | grep -Ev “NetworkController|LSAPP”