2012-08-14 12:55:58 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
|
|
|
import org.mozilla.gecko.gfx.LayerView;
|
2013-02-07 14:37:06 +00:00
|
|
|
import org.mozilla.gecko.mozglue.GeckoLoader;
|
2012-08-14 12:55:58 +00:00
|
|
|
import org.mozilla.gecko.sqlite.SQLiteBridge;
|
|
|
|
import org.mozilla.gecko.util.GeckoEventListener;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.database.Cursor;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import java.nio.IntBuffer;
|
|
|
|
|
|
|
|
public class RobocopAPI {
|
|
|
|
private final GeckoApp mGeckoApp;
|
|
|
|
|
|
|
|
public RobocopAPI(Activity activity) {
|
|
|
|
mGeckoApp = (GeckoApp)activity;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void registerEventListener(String event, GeckoEventListener listener) {
|
|
|
|
GeckoAppShell.registerEventListener(event, listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void unregisterEventListener(String event, GeckoEventListener listener) {
|
|
|
|
GeckoAppShell.unregisterEventListener(event, listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void broadcastEvent(String subject, String data) {
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(subject, data));
|
|
|
|
}
|
|
|
|
|
2013-09-04 13:58:32 +00:00
|
|
|
public void preferencesGetEvent(int requestId, String[] prefNames) {
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesGetEvent(requestId, prefNames));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void preferencesObserveEvent(int requestId, String[] prefNames) {
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesObserveEvent(requestId, prefNames));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void preferencesRemoveObserversEvent(int requestId) {
|
|
|
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createPreferencesRemoveObserversEvent(requestId));
|
|
|
|
}
|
|
|
|
|
2012-08-14 12:55:58 +00:00
|
|
|
public void setDrawListener(GeckoLayerClient.DrawListener listener) {
|
2013-06-06 18:05:06 +00:00
|
|
|
GeckoAppShell.getLayerView().getLayerClient().setDrawListener(listener);
|
2012-08-14 12:55:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Cursor querySql(String dbPath, String query) {
|
2013-02-07 14:37:06 +00:00
|
|
|
GeckoLoader.loadSQLiteLibs(mGeckoApp, mGeckoApp.getApplication().getPackageResourcePath());
|
2012-08-14 12:55:58 +00:00
|
|
|
return new SQLiteBridge(dbPath).rawQuery(query, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntBuffer getViewPixels(View view) {
|
|
|
|
return ((LayerView)view).getPixels();
|
|
|
|
}
|
|
|
|
}
|