Ejemplo n.º 1
0
 public boolean validatesSecureCertificate() {
   if (proxy.hasDynamicValue("validatesSecureCertificate")) {
     return TiConvert.toBoolean(proxy.getDynamicValue("validatesSecureCertificate"));
   } else {
     if (proxy
         .getTiContext()
         .getTiApp()
         .getDeployType()
         .equals(TiApplication.DEPLOY_TYPE_PRODUCTION)) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
 public KrollCallback getCallback(String name) {
   Object value = proxy.getDynamicValue(name);
   if (value != null && value instanceof KrollCallback) {
     return (KrollCallback) value;
   }
   return null;
 }
Ejemplo n.º 3
0
  @Override
  public void put(String name, Scriptable start, Object value) {
    boolean isDynamic = false;
    if (start instanceof KrollObject) {
      KrollObject object = (KrollObject) start;
      if (object.target instanceof TiProxy) {
        TiProxy proxy = (TiProxy) object.target;
        if (proxy.getDynamicProperties() != null) {
          isDynamic = proxy.getDynamicProperties().containsKey(name);
        }
      }
    }

    if (has(name, start)
        || (value != null && (value instanceof KrollObject /*|| value instanceof Function*/))
            && !isDynamic) {
      super.put(name, start, value);
    } else {
      handleMethodOrProperty(name, start, false, value);
    }
  }
Ejemplo n.º 4
0
  public DocumentProxy getResponseXML() {
    // avoid eating up tons of memory if we have a large binary data blob
    if (TiMimeTypeHelper.isBinaryMimeType(contentType)) {
      return null;
    }
    if (responseXml == null && (responseData != null || responseText != null)) {
      try {
        responseXml = XMLModule.parse(proxy.getTiContext(), getResponseText());
      } catch (Exception e) {
        Log.e(LCAT, "Error parsing XML", e);
      }
    }

    return responseXml;
  }
Ejemplo n.º 5
0
  public void open(String method, String url) {
    if (DBG) {
      Log.d(LCAT, "open request method=" + method + " url=" + url);
    }

    this.method = method;

    String cleanUrl = url;
    if (url.startsWith("http")) {
      int beginQ = url.indexOf('?');
      if (beginQ > 7 && url.length() > beginQ) {
        String left = url.substring(0, beginQ);
        String right = url.substring(beginQ + 1);
        // first decoding below, in case it's partially encoded already.
        cleanUrl = Uri.encode(Uri.decode(left), ":/") + "?" + Uri.encode(Uri.decode(right), "&=#");
      } else {
        cleanUrl = Uri.encode(Uri.decode(url), ":/#");
      }
    }

    uri = Uri.parse(cleanUrl);

    host = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
    if (uri.getUserInfo() != null) {
      credentials = new UsernamePasswordCredentials(uri.getUserInfo());
    }
    setReadyState(READY_STATE_OPENED);
    setRequestHeader("User-Agent", (String) proxy.getDynamicValue("userAgent"));
    // Causes Auth to Fail with twitter and other size apparently block X- as well
    // Ticket #729, ignore twitter for now
    if (!uri.getHost().contains("twitter.com")) {
      setRequestHeader("X-Requested-With", "XMLHttpRequest");
    } else {
      Log.i(LCAT, "Twitter: not sending X-Requested-With header");
    }
  }
Ejemplo n.º 6
0
  @Override
  public void propertyChanged(String key, Object oldValue, Object newValue, TiProxy proxy) {
    if (DBG) {
      Log.d(LCAT, "Property: " + key + " old: " + oldValue + " new: " + newValue);
    }
    if (key.equals("enabled")) {
      tv.setEnabled(TiConvert.toBoolean(newValue));
    } else if (key.equals("value")) {
      tv.setText((String) newValue);
    } else if (key.equals("color")) {
      tv.setTextColor(TiConvert.toColor((String) newValue));
    } else if (key.equals("passwordMask")) {
      if (TiConvert.toBoolean(newValue) == true) {
        // This shouldn't be needed but it's belts & braces
        tv.setKeyListener(TextKeyListener.getInstance(false, Capitalize.NONE));
        // Both setTransform & keyboard type are required
        tv.setTransformationMethod(PasswordTransformationMethod.getInstance());
        // We also need to set the keyboard type - otherwise the password mask won't be applied
        handleKeyboardType(KEYBOARD_PASSWORD, false);
      } else {
        handleKeyboardType(KEYBOARD_DEFAULT, false);
      }
    } else if (key.equals("hintText")) {
      tv.setHint((String) newValue);
    } else if (key.equals("textAlign") || key.equals("verticalAlign")) {
      String textAlign = null;
      String verticalAlign = null;
      if (key.equals("textAlign")) {
        textAlign = TiConvert.toString(newValue);
      }
      if (key.equals("verticalAlign")) {
        verticalAlign = TiConvert.toString(newValue);
      }
      handleTextAlign(textAlign, verticalAlign);
    } else if (key.equals("autocapitalization")) {

      // TODO Missing
      Capitalize autoCapValue = null;

      switch (TiConvert.toInt(newValue)) {
        case TEXT_AUTOCAPITALIZATION_NONE:
          autoCapValue = Capitalize.NONE;
          break;

        case TEXT_AUTOCAPITALIZATION_ALL:
          autoCapValue = Capitalize.CHARACTERS;
          break;

        case TEXT_AUTOCAPITALIZATION_SENTENCES:
          autoCapValue = Capitalize.SENTENCES;
          break;

        case TEXT_AUTOCAPITALIZATION_WORDS:
          autoCapValue = Capitalize.WORDS;
          break;

        default:
          Log.w(LCAT, "Unknown AutoCapitalization Value [" + TiConvert.toString(newValue) + "]");
          break;
      }

      if (null != autoCapValue) {
        tv.setKeyListener(TextKeyListener.getInstance(false, autoCapValue));
      }

    } else if (key.equals("keyboardType") || (key.equals("autocorrect"))) {
      TiDict d = proxy.getDynamicProperties();
      boolean autocorrect = false;
      if (d.containsKey("autocorrect")) {
        autocorrect = d.getBoolean("autocorrect");
      }

      handleKeyboardType(TiConvert.toInt(d, "keyboardType"), autocorrect);
    } else if (key.equals("returnKeyType")) {
      handleReturnKeyType(TiConvert.toInt(newValue));
    } else if (key.equals("font")) {
      TiUIHelper.styleText(tv, (TiDict) newValue);
    } else {
      super.propertyChanged(key, oldValue, newValue, proxy);
    }
  }