Calling Java Methods with JavaScript from Crosswalk

mXWalkView = (XWalkView) findViewById(R.id.activity_main);
XWalkSettings webSettings = mXWalkView.getSettings();
webSettings.setJavaScriptEnabled(true);
public class JsInterface {
	public JsInterface() {
	}
	
	@JavascriptInterface
	public String sayHello() {
		return "Hello World!";
	}
}
mXWalkView.addJavascriptInterface(new JsInterface(), "NativeInterface");
<a href="#" onclick="clicked()">Say Hello</a>
function clicked() {
    alert(NativeInterface.sayHello());
}

References
http://zhangwenli.com/blog/2014/08/25/crosswalk-calling-java-methods-with-javascript/
https://developer.android.com/guide/webapps/webview.html#BindingJavaScript
http://stackoverflow.com/questions/25478434/crosswalk-call-java-method-from-javascript

Embedding Crosswalk on Android

download Crosswalk .aar file
https://download.01.org/crosswalk/releases/crosswalk/android/maven2/

Then copy to libs folder

allprojects {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}
compile(name:'xwalk_core_library', ext:'aar')
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:id="@+id/container"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             tools:context="iterator.ir.bmi.MainActivity"
             tools:ignore="MergeRootFrame">

    <org.xwalk.core.XWalkView
            android:id="@+id/xwalkview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</FrameLayout>
public class MainActivity extends XWalkActivity {

    XWalkView mXWalkView;

    @Override
    protected void onXWalkReady() {
// Do anyting with the embedding API
        mXWalkView.load("file:///android_asset/www/index.html", null);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mXWalkView = (XWalkView) findViewById(R.id.xwalkview);
    }
}

References
https://developer.chrome.com/multidevice/webview/gettingstarted
https://crosswalk-project.org/documentation/android/embedding_crosswalk_rvw.html
http://stackoverflow.com/questions/40256449/intellij-idea-how-to-import-aar
https://download.01.org/crosswalk/releases/crosswalk/android/maven2/

Installing Apache Cassandra on Ubuntu

echo "deb http://www.apache.org/dist/cassandra/debian 39x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
sudo apt-get update
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-key A278B781FE4B2BDA
sudo apt-get install cassandra
sudo service cassandra start
sudo service cassandra stop

References
http://cassandra.apache.org/download/

Disabling the track stick in Linux

xinput list
 ⎡ Virtual core pointer                    	id=2
 ⎜   ↳ Virtual core XTEST pointer              	id=4
 ⎜   ↳ Wacom Graphire2 4x5 eraser              	id=9
 ⎜   ↳ Wacom Graphire2 4x5 cursor              	id=10
 ⎜   ↳ Wacom Graphire2 4x5                     	id=11
 ⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad        	id=14
 ⎜   ↳ Macintosh mouse button emulation        	id=15
 ⎜   ↳ DualPoint Stick                         	id=13
 ⎣ Virtual core keyboard                   	id=3
     ↳ Virtual core XTEST keyboard             	id=5
     ↳ Video Bus                               	id=6
     ↳ Power Button                            	id=7
     ↳ Sleep Button                            	id=8
     ↳ AT Translated Set 2 keyboard            	id=12

The device I want to disable has id 13. Use xinput to list its properties:

xinput -list-props 13

Device ‘DualPoint Stick’:
Device Enabled (117): 0
[…several lines removed…]

xinput -set-prop 13 117 0

Once I knew the solution, I could easily find other posts that mentions it. But what good is that?🙂

Actually, the device is is dynamically allocated, and can change. So a better command to disable the stick is:

xinput -set-prop "DualPoint Stick" "Device Enabled" 0

References
https://cederlys.wordpress.com/2010/07/13/disabling-the-track-stick-in-ubuntu/