Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Working install (failed due to a missing intent handler)

  • Loading branch information...
commit 0afd7cf6f32af762c82519ba8a3c3a408d520138 1 parent 43b064e
@digitarald authored
View
87 src/org/mozilla/labs/Soup/app/SoupActivity.java
@@ -48,7 +48,6 @@
Gravity.CENTER_VERTICAL);
private SoupChromeClient appClient;
- public ProgressDialog progress;
private View childContainer = null;
private WebView childView = null;
@@ -164,22 +163,6 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
}
super.onPageStarted(view, url, favicon);
-
- // try {
- // progress.setTitle("Loading " + new URI(url).getAuthority());
- // } catch (URISyntaxException e) {
- //
- // }
- //
- // if (favicon != null) {
- // progress.setIcon(new BitmapDrawable(favicon));
- // } else {
- // progress.setIcon(null);
- // }
- //
- // if (!progress.isShowing()) {
- // progress.show();
- // }
}
/*
@@ -198,8 +181,6 @@ public void onPageFinished(WebView view, String url) {
// Sets title, handled by application container
SoupActivity.this.setTitle(view.getTitle());
- // progress.dismiss();
-
super.onPageFinished(view, url);
}
}
@@ -342,9 +323,6 @@ private void injectJavaScript(WebView view, boolean trusted) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- progress = new ProgressDialog(this);
- progress.setIndeterminate(true);
-
// Resolve the intent (provided by child classes)
this.onResolveIntent();
}
@@ -379,12 +357,14 @@ public boolean onCreateLayout() {
return false;
}
- super.setStringProperty("loadingDialog", "Loading App");
+ super.setBooleanProperty("keepRunning", false);
+
+ // super.setStringProperty("loadingDialog", "Loading App");
// super.setStringProperty("loadingPageDialog", "Loading App");
// super.setStringProperty("errorUrl", "file:///android_asset/www/error.html");
// super.setIntegerProperty("splashscreen", R.drawable.splash);
- super.init();
+ init();
// Set our own extended webkit client and clientview
appClient = new SoupChromeClient(SoupActivity.this);
@@ -398,6 +378,12 @@ public boolean onCreateLayout() {
return true;
}
+
+ public void init() {
+ super.init();
+
+ appView.setVisibility(View.VISIBLE);
+ }
/**
* Called when a key is pressed.
@@ -484,59 +470,6 @@ public void closeChildView() {
childView = null;
}
- public static JSONArray findAll() {
-
- JSONArray list = new JSONArray();
-
- try {
- // http://www.limejs.com/roundball.webapp
- JSONObject app1 = new JSONObject();
- app1.put("origin", "http://www.limejs.com");
- app1.put("manifest_url", "http://www.limejs.com/roundball.webapp");
- app1.put(
- "manifest",
- new JSONObject(
- "{\"name\":\"Roundball\",\"description\":\"Roundball is a fun match three puzzle game where you form horizontal or vertical lines of at least three similar objects by swapping two adjacent items. The more matches you make, the higher your score. Two game modes: Classic and Timed mode. Works on regular computer or on touchscreens.\",\"launch_path\":\"/static/roundball/index.html\",\"developer\":{\"name\":\"Digital Fruit\",\"url\":\"http://www.limejs.com/\"},\"icons\":{\"128\":\"/static/roundball_icon_128.png\"},\"installs_allowed_from\":[\"*\"]}"));
- list.put(app1);
-
- // http://sinuousgame.com/manifest.webapp
- // JSONObject app2 = new JSONObject();
- // app2.put("origin", "http://sinuousgame.com");
- // app2.put("manifest_url", "http://sinuousgame.com/manifest.webapp");
- // app2.put(
- // "manifest",
- // new JSONObject(
- // "{\"name\":\"Sinuous\",\"description\":\"Avoid the red dots in this fun and addictive game.\",\"launch_path\":\"/\",\"developer\":{\"name\":\"Hakim El Hattab\",\"url\":\"http://hakim.se/experiments/\"},\"icons\":{\"128\":\"/assets/images/icon_128.png\"},\"installs_allowed_from\":[\"*\"]}"));
- // list.put(app2);
- //
- // // http://shazow.net
- // // http://shazow.net/linerage/gameon/manifest.json
- // JSONObject app3 = new JSONObject();
- // app3.put("origin", "http://shazow.net");
- // app3.put("manifest_url", "http://shazow.net/linerage/gameon/manifest.json");
- // app3.put(
- // "manifest",
- // new JSONObject(
- // "{\"name\":\"LineRage\",\"description\":\"You are a line. Don't hit things.\",\"launch_path\":\"/linerage/gameon/index.html\",\"developer\":{\"name\":\"Andrey Petrov\",\"url\":\"http://shazow.net\"},\"icons\":{\"16\":\"/linerage/gameon/icon_16.png\",\"32\":\"/linerage/gameon/icon_32.png\",\"128\":\"/linerage/gameon/icon_128.png\"},\"installs_allowed_from\":[\"*\"]}"));
- // list.put(app3);
- //
- // // http://stillalivejs.t4ils.com
- // // http://stillalivejs.t4ils.com/play/manifest.webapp
- // JSONObject app4 = new JSONObject();
- // app4.put("origin", "http://stillalivejs.t4ils.com");
- // app4.put("manifest_url", "http://stillalivejs.t4ils.com/play/manifest.webapp");
- // app4.put(
- // "manifest",
- // new JSONObject(
- // "{\"name\":\"StillAliveJS\",\"description\":\"StillAliveJS, or SaJS, is a puzzle game inspired by Portal: The Flash Version which is a 2D renewal of Portal, developed by Valve Corporation.\n\nSaJS consists primarily in a series of platform puzzles that must be solved by teleporting the character and other simple objects using a Portal Gun. The unusual physics allowed by this device is the emphasis of StillAliveJS.\",\"launch_path\":\"/play/index.html\",\"developer\":{\"name\":\"t4ils and Zeblackos\",\"url\":\"http://stillalivejs.t4ils.com/\"},\"icons\":{\"128\":\"/play/images/icon128.png\"},\"installs_allowed_from\":[\"*\"]}"));
- // list.put(app4);
-
- } catch (JSONException e) {
- }
-
- return list;
- }
-
protected abstract void onResolveIntent();
}
View
2  src/org/mozilla/labs/Soup/app/SoupApplication.java
@@ -90,7 +90,7 @@ public void onReceiveResult(int resultCode, Bundle resultData) {
Toast.makeText(ctx, "Uploaded " + uploaded + " app(s)",
Toast.LENGTH_SHORT).show();
} else {
- Toast.makeText(ctx, "Nothing to sync", Toast.LENGTH_SHORT).show();
+ // Toast.makeText(ctx, "Nothing to sync", Toast.LENGTH_SHORT).show();
}
setChanged();
View
8 src/org/mozilla/labs/Soup/plugins/MozAppsPlugin.java
@@ -12,6 +12,7 @@
import org.json.JSONArray;
import org.json.JSONObject;
import org.mozilla.labs.Soup.R;
+import org.mozilla.labs.Soup.app.AppActivity;
import org.mozilla.labs.Soup.app.SoupApplication;
import org.mozilla.labs.Soup.http.ImageFactory;
import org.mozilla.labs.Soup.provider.AppsContract.Apps;
@@ -158,6 +159,8 @@ public PluginResult install(final String callbackId,
values.put(Apps.INSTALL_RECEIPT, install_data.optString("receipt"));
}
}
+
+ final String launchUri = origin + manifest.optString("launch_path", "");
ctx.runOnUiThread(new Runnable() {
@@ -210,8 +213,11 @@ public void onClick(DialogInterface dialog, int which) {
success(new PluginResult(Status.OK, 0), callbackId);
- Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, uri);
+ Intent shortcutIntent = new Intent(ctx, AppActivity.class);
+ shortcutIntent.setAction(AppActivity.ACTION_WEBAPP);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ shortcutIntent.putExtra("uri", launchUri);
+ shortcutIntent.putExtra("app_uri", uri);
// TODO: Move one more place to sync
((SoupApplication) ctx.getApplication()).triggerSync();
View
95 src/org/mozilla/labs/Soup/provider/AppsProvider.java
@@ -18,11 +18,7 @@
import java.util.HashMap;
-import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
-import org.mozilla.labs.Soup.app.SoupActivity;
-import org.mozilla.labs.Soup.http.ImageFactory;
import org.mozilla.labs.Soup.provider.AppsContract.Apps;
import android.content.ContentProvider;
@@ -36,7 +32,6 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
-import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.LiveFolders;
import android.text.TextUtils;
@@ -86,96 +81,6 @@ public void onCreate(SQLiteDatabase db) {
Log.d(TAG + ".DatabaseHelper", "onCreate: " + SQL_CREATE);
db.execSQL(SQL_CREATE);
-
- // FIXME: ONLY development
-
- generateData(db);
- }
-
- private void generateData(SQLiteDatabase db) {
- JSONArray list = SoupActivity.findAll();
-
- for (int i = 0, l = list.length(); i < l; i++) {
- JSONObject app = list.optJSONObject(i);
-
- String origin = app.optString("origin");
- JSONObject manifest = app.optJSONObject("manifest");
-
- ContentValues values = new ContentValues();
- try {
- values.put(Apps.NAME, manifest.getString("name"));
- values.put(Apps.DESCRIPTION, manifest.getString("description"));
-
- String iconUrl = origin
- + manifest.getJSONObject("icons").getString("128");
- Bitmap bitmap = ImageFactory.getResizedImage(iconUrl, 72, 72);
-
- if (bitmap != null) {
- values.put(Apps.ICON, ImageFactory.bitmapToBytes(bitmap));
- } else {
- Log.w(TAG + ".DatabaseHelper", "could not fetch icon");
- }
-
- values.put(Apps.ORIGIN, origin);
- values.put(Apps.MANIFEST_URL, app.getString("manifest_url"));
- values.put(Apps.MANIFEST, manifest.toString());
-
- Log.d(TAG + ".DatabaseHelper", "generated " + values);
-
- } catch (JSONException e) {
- Log.d(TAG + ".DatabaseHelper", "loadValue", e);
- continue;
- }
-
- Long now = Long.valueOf(System.currentTimeMillis());
-
- // Make sure that the fields are all set
- if (values.containsKey(AppsContract.Apps.CREATED_DATE) == false) {
- values.put(AppsContract.Apps.CREATED_DATE, now);
- }
- if (values.containsKey(AppsContract.Apps.MODIFIED_DATE) == false) {
- values.put(AppsContract.Apps.MODIFIED_DATE, now);
- }
- if (values.containsKey(AppsContract.Apps.INSTALL_TIME) == false) {
- values.put(AppsContract.Apps.INSTALL_TIME, now);
- }
- if (values.containsKey(AppsContract.Apps.SYNCED_DATE) == false) {
- values.put(AppsContract.Apps.SYNCED_DATE, now);
- }
- if (values.containsKey(AppsContract.Apps.STATUS) == false) {
- values.put(AppsContract.Apps.STATUS, 0);
- }
- if (values.containsKey(AppsContract.Apps.SYNCED_DATE) == false) {
- values.put(AppsContract.Apps.SYNCED_DATE, 0);
- }
-
- if (values.containsKey(AppsContract.Apps.NAME) == false) {
- Resources r = Resources.getSystem();
- values.put(AppsContract.Apps.NAME,
- r.getString(android.R.string.untitled));
- }
- if (values.containsKey(AppsContract.Apps.DESCRIPTION) == false) {
- values.put(AppsContract.Apps.DESCRIPTION, "");
- }
-
- if (values.containsKey(AppsContract.Apps.MANIFEST) == false) {
- values.put(AppsContract.Apps.MANIFEST, new JSONObject().toString());
- }
- if (values.containsKey(AppsContract.Apps.MANIFEST_URL) == false) {
- values.put(AppsContract.Apps.MANIFEST_URL, "");
- }
- if (values.containsKey(AppsContract.Apps.INSTALL_DATA) == false) {
- values.put(AppsContract.Apps.INSTALL_DATA,
- new JSONObject().toString());
- }
-
- long rowId = db.insert(APPS_TABLE_NAME, null, values);
-
- if (rowId > 0) {
- Log.d(TAG + ".loadValues", "Added " + rowId + " with " + values);
- }
-
- }
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.