Esempio n. 1
0
  // Grabs assets off the intarwebz and saves them to a local store/jail for hydration.
  private void fetch(JSONArray args) {
    String url;
    String username;
    String password;
    String id;
    try {
      id = args.getString(0);
      url = args.getString(1);
      username = args.getString(2);
      password = args.getString(3);

      // Create directory for app.
      local_path = "/data/data/" + ctx.getPackageName() + "/remote_app/" + id + "/";
      File fp = new File(local_path);
      fp.mkdirs();

      if (fetchApp(url, username, password)) {
        this.success(
            new PluginResult(PluginResult.Status.OK, "file://" + local_path + "index.html"),
            this.callback);
      } else {
        this.error(
            new PluginResult(
                PluginResult.Status.ERROR,
                "Error during app saving or fetching; protocol or IO error likely."),
            this.callback);
      }
    } catch (JSONException e) {
      this.error(
          new PluginResult(
              PluginResult.Status.JSON_EXCEPTION,
              "JSON exception during argument parsing; make sure the app ID, URL, username and password were passed as an argument."),
          this.callback);
    }
  }
Esempio n. 2
0
 // Removes locally-stored app(s).
 private void remove(JSONArray args) {
   try {
     local_path = "/data/data/" + ctx.getPackageName() + "/remote_app/" + args.getString(1) + "/";
     deleteDirectory(new File(local_path));
   } catch (JSONException e) {
     this.error(
         new PluginResult(
             PluginResult.Status.ERROR,
             "JSON exception during argument parsing; make sure the app ID was passed as an argument."),
         this.callback);
   }
 }
Esempio n. 3
0
 // Loads a locally-saved app into the WebView.
 private void load(JSONArray args) {
   try {
     local_path = "/data/data/" + ctx.getPackageName() + "/remote_app/" + args.getString(1) + "/";
     this.success(
         new PluginResult(PluginResult.Status.OK, "file://" + local_path + "index.html"),
         this.callback);
   } catch (JSONException e) {
     this.error(
         new PluginResult(
             PluginResult.Status.ERROR,
             "JSON exception during argument parsing; make sure the app ID was passed as an argument."),
         this.callback);
   }
 }