package it.unipr.mobdev;

import android.content.Context;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

public class MyJavaScriptInterface {
    Context mContext;

    /** Instantiate the interface and set the context */
    public MyJavaScriptInterface(Context c) {
        mContext = c;
    }

    /** Show a toast from the web page */
    @JavascriptInterface
    public void showToast(String toast) {
    	Log.d(MainActivity.TAG,"JavaScriptInterface ---> showToast !");
        Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
    }
    
    @JavascriptInterface
    public String getData() {
    	Log.d(MainActivity.TAG,"JavaScriptInterface ---> showToast !");
        return "<p>Stored Bookmarks: " + BookmarkManager.getInstance(mContext).getBookmarkList().size() +"</p>";
    }
}