Example #1
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    super.loadUrl(getString(R.string.add_url));

    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN
                | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  }
Example #2
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();

    Keyboard keyboard = new Keyboard(this, appView);
    appView.addJavascriptInterface(keyboard, "Keyboard");

    // setContentView(R.layout.main);
    super.loadUrl("file:///android_asset/www/index.html");
  }
Example #3
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    String color_schema =
        pref.getString(
            getString(R.string.color_schema_key), getString(R.string.color_schema_default));
    String language =
        pref.getString(getString(R.string.language_key), getString(R.string.language_default));

    super.loadUrl("file:///android_asset/www/rules.html?" + color_schema + "&" + language);
  }
Example #4
0
  // Submit payment (i.e. "checkout")
  public void pay(Integer btype) {
    PayPalPayment payment;

    PayPal pp = PayPal.getInstance();
    if (pp == null) return;

    // mpjs_buttonType;

    // TBD: payment type: simple, parallel, chained
    payment = getSimplePayment();

    // Intent checkoutIntent = PayPal.getInstance().checkout(payment, this);
    Intent checkoutIntent = pp.checkout(payment, mpl_context, new ResultDelegate());

    // The next two lines should be exchanged for the following commented
    // line when PhoneGap is not used
    DroidGap dgActivity = (DroidGap) mpl_activity;
    dgActivity.startActivityForResult(PayPalPlugin.thisPlugin, checkoutIntent, 1);
    // mpl_activity.startActivityForResult(checkoutIntent, 1);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    super.loadUrl("file:///android_asset/www/index.html");
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    View layout = (View) findViewById(R.id.linearLayout2);
    // layout.setBackgroundColor(SE_TOP_Blue);

    // webView = new WebView(this);
    webView = (WebView) findViewById(R.id.web_view);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(
        new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
            activity.setTitle("Loading...");
            activity.setProgress(progress * 100);

            if (progress == 100) activity.setTitle(R.string.app_name);
          }
        });

    webView.setWebViewClient(
        new WebViewClient() {
          @Override
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(getBaseContext(), "Smart Energy Error Received !", Toast.LENGTH_LONG)
                .show();
          }

          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
          }
        });

    webView.addJavascriptInterface(new JsInterface(webView, this), "jsWebService");
    webView.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
    webView.loadUrl("file:///android_asset/EnergyApp/index.html");
    //		setContentView(webView);

    String urlString = "file:///android_asset/EnergyApp/index.html";
    Toast.makeText(getBaseContext(), "Smart Energy !", Toast.LENGTH_LONG).show();

    smartEnergyDialog =
        new SmartEnergyDialog(
            activity,
            urlString,
            new SmartEnergyDialog.SEDialogListener() {

              public void onComplete(Bundle values) {
                // TODO Auto-generated method stub

              }

              public void onMusicBubbyBrainzError(Error e) {
                // TODO Auto-generated method stub

              }

              public void onError(Error e) {
                // TODO Auto-generated method stub

              }

              public void onCancel() {
                // TODO Auto-generated method stub

              }
            });
    Button energySavorButton = (Button) findViewById(R.id.button1);

    energySavorButton.setBackgroundColor(SE_BLUE);
    energySavorButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            smartEnergyDialog.show();
            postMessage();
          }
        });
  }
 @Override
 protected void onResume() {
   super.onResume();
 }
  /**
   * Tell the client to display a prompt dialog to the user. If the client returns true, WebView
   * will assume that the client will handle the prompt dialog and call the appropriate
   * JsPromptResult method.
   *
   * <p>Since we are hacking prompts for our own purposes, we should not be using them for this
   * purpose, perhaps we should hack console.log to do this instead!
   *
   * @param view
   * @param url
   * @param message
   * @param defaultValue
   * @param result
   */
  @Override
  public boolean onJsPrompt(
      WebView view, String url, String message, String defaultValue, JsPromptResult result) {

    // Security check to make sure any requests are coming from the page initially
    // loaded in webview and not another loaded in an iframe.
    boolean reqOk = false;
    if (url.startsWith("file://")
        || url.indexOf(this.ctx.baseUrl) == 0
        || ctx.isUrlWhiteListed(url)) {
      reqOk = true;
    }

    // Calling PluginManager.exec() to call a native service using
    // prompt(this.stringify(args), "gap:"+this.stringify([service, action, callbackId, true]));
    if (reqOk
        && defaultValue != null
        && defaultValue.length() > 3
        && defaultValue.substring(0, 4).equals("gap:")) {
      JSONArray array;
      try {
        array = new JSONArray(defaultValue.substring(4));
        String service = array.getString(0);
        String action = array.getString(1);
        String callbackId = array.getString(2);
        boolean async = array.getBoolean(3);
        String r = ctx.pluginManager.exec(service, action, callbackId, message, async);
        result.confirm(r);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }

    // Polling for JavaScript messages
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) {
      String r = ctx.callbackServer.getJavascript();
      result.confirm(r);
    }

    // Calling into CallbackServer
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_callbackServer:")) {
      String r = "";
      if (message.equals("usePolling")) {
        r = "" + ctx.callbackServer.usePolling();
      } else if (message.equals("restartServer")) {
        ctx.callbackServer.restartServer();
      } else if (message.equals("getPort")) {
        r = Integer.toString(ctx.callbackServer.getPort());
      } else if (message.equals("getToken")) {
        r = ctx.callbackServer.getToken();
      }
      result.confirm(r);
    }

    // PhoneGap JS has initialized, so show webview
    // (This solves white flash seen when rendering HTML)
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
      ctx.appView.setVisibility(View.VISIBLE);
      ctx.spinnerStop();
      result.confirm("OK");
    }

    // Show dialog
    else {
      final JsPromptResult res = result;
      AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx);
      dlg.setMessage(message);
      final EditText input = new EditText(this.ctx);
      if (defaultValue != null) {
        input.setText(defaultValue);
      }
      dlg.setView(input);
      dlg.setCancelable(false);
      dlg.setPositiveButton(
          android.R.string.ok,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              String usertext = input.getText().toString();
              res.confirm(usertext);
            }
          });
      dlg.setNegativeButton(
          android.R.string.cancel,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              res.cancel();
            }
          });
      dlg.create();
      dlg.show();
    }
    return true;
  }