@Kroll.method public String decode(HashMap args) { // decode string back to plain text // KrollDict arg = new KrollDict(args); String txt = arg.getString("cipherText"); byte[] bytesEncoded = Base64.decode(txt, 0); String keyString = arg.getString("privateKey"); PrivateKey key; try { byte[] encodedKey = Base64.decode(keyString, 0); PKCS8EncodedKeySpec x509KeySpec = new PKCS8EncodedKeySpec(encodedKey); KeyFactory keyFact = KeyFactory.getInstance("RSA", "BC"); key = keyFact.generatePrivate(x509KeySpec); } catch (Exception e) { return "error key"; } byte[] decodedBytes = null; try { Cipher c = Cipher.getInstance("RSA"); c.init(Cipher.DECRYPT_MODE, key); decodedBytes = c.doFinal(bytesEncoded); } catch (Exception e) { Log.e(TAG, "RSA decryption error " + e.toString()); return "error"; } return new String(decodedBytes); }
@Kroll.method public String encode(HashMap args) { // encode text to cipher text // KrollDict arg = new KrollDict(args); String txt = arg.getString("plainText"); String keyString = arg.getString("publicKey"); byte[] encodedBytes = null; Key key; try { byte[] encodedKey = Base64.decode(keyString, 0); X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(encodedKey); KeyFactory keyFact = KeyFactory.getInstance("RSA", "BC"); key = keyFact.generatePublic(x509KeySpec); } catch (Exception e) { return "error key"; } try { Cipher c = Cipher.getInstance("RSA"); c.init(Cipher.ENCRYPT_MODE, key); encodedBytes = c.doFinal(txt.getBytes()); } catch (Exception e) { Log.e(TAG, "RSA encryption error " + e.toString()); } return Base64.encodeToString(encodedBytes, Base64.NO_WRAP); }
// Handle creation options @Override public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); // The identifier is what Branch will use to de-dupe the content across many different Universal // Objects if (options.containsKey("canonicalIdentifier")) { Log.d(LCAT, "setCanonicalIdentifier"); branchUniversalObject.setCanonicalIdentifier(options.getString("canonicalIdentifier")); } // This is where you define the open graph structure and how the object will appear on Facebook // or in a deepview if (options.containsKey("title")) { Log.d(LCAT, "setTitle"); branchUniversalObject.setTitle(options.getString("title")); } if (options.containsKey("contentDescription")) { Log.d(LCAT, "setContentDescription"); branchUniversalObject.setContentDescription(options.getString("contentDescription")); } if (options.containsKey("contentImageUrl")) { Log.d(LCAT, "setContentImageUrl"); branchUniversalObject.setContentImageUrl(options.getString("contentImageUrl")); } // You use this to specify whether this content can be discovered publicly - default is public if (options.containsKey("contentIndexingMode")) { Log.d(LCAT, "setContentIndexingMode"); if (options.getString("contentIndexingMode").equals("private")) { Log.d(LCAT, "private"); branchUniversalObject.setContentIndexingMode( BranchUniversalObject.CONTENT_INDEX_MODE.PRIVATE); } else { Log.d(LCAT, "public"); branchUniversalObject.setContentIndexingMode( BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC); } } // Here is where you can add custom keys/values to the deep link data if (options.containsKey("contentMetadata")) { Log.d(LCAT, "addContentMetadata"); Object contentMetadata = options.get("contentMetadata"); Map<String, String> hashMap = (Map<String, String>) contentMetadata; for (Iterator iterator = hashMap.keySet().iterator(); iterator.hasNext(); ) { String key = (String) iterator.next(); branchUniversalObject.addContentMetadata(key, hashMap.get(key)); } } }
private Intent createAlarmServiceIntent(KrollDict args) { String serviceName = args.getString("service"); Intent intent = new Intent(TiApplication.getInstance().getApplicationContext(), AlarmServiceListener.class); intent.putExtra("alarm_service_name", serviceName); // Pass in flag if we need to restart the service on each call intent.putExtra("alarm_service_force_restart", (optionIsEnabled(args, "forceRestart"))); // Check if the user has selected to use intervals boolean hasInterval = (args.containsKeyAndNotNull("interval")); long intervalValue = 0; if (hasInterval) { Object interval = args.get("interval"); if (interval instanceof Number) { intervalValue = ((Number) interval).longValue(); } else { hasInterval = false; } } intent.putExtra("alarm_service_has_interval", hasInterval); if (hasInterval) { intent.putExtra("alarm_service_interval", intervalValue); } utils.debugLog( "created alarm service intent for " + serviceName + "(forceRestart: " + (optionIsEnabled(args, "forceRestart") ? "true" : "false") + ", intervalValue: " + intervalValue + ")"); return intent; }
@Override public void processProperties(KrollDict d) { // TODO Auto-generated method stub super.processProperties(d); if (d.containsKey(TiC.PROPERTY_TITLE)) { actionBar.setTitle(d.getString(TiC.PROPERTY_TITLE)); } if (d.containsKey(TiC.PROPERTY_SWIPEABLE)) { swipeable = d.getBoolean(TiC.PROPERTY_SWIPEABLE); } }
private void handleBackgroundImage(KrollDict d) { String bg = d.getString(TiC.PROPERTY_BACKGROUND_IMAGE); String bgSelected = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE); String bgFocused = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_IMAGE); String bgDisabled = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_IMAGE); String bgColor = d.getString(TiC.PROPERTY_BACKGROUND_COLOR); String bgSelectedColor = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR); String bgFocusedColor = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_COLOR); String bgDisabledColor = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_COLOR); if (bg != null) { bg = resolveImageUrl(bg); } if (bgSelected != null) { bgSelected = resolveImageUrl(bgSelected); } if (bgFocused != null) { bgFocused = resolveImageUrl(bgFocused); } if (bgDisabled != null) { bgDisabled = resolveImageUrl(bgDisabled); } if (bg != null || bgSelected != null || bgFocused != null || bgDisabled != null || bgColor != null || bgSelectedColor != null || bgFocusedColor != null || bgDisabledColor != null) { if (background == null) { applyCustomBackground(false); } Drawable bgDrawable = TiUIHelper.buildBackgroundDrawable( bg, d.getBoolean(TiC.PROPERTY_BACKGROUND_REPEAT), bgColor, bgSelected, bgSelectedColor, bgDisabled, bgDisabledColor, bgFocused, bgFocusedColor); background.setBackgroundDrawable(bgDrawable); } }
private void handleBackgroundImage(KrollDict d) { String bg = d.getString(TiC.PROPERTY_BACKGROUND_IMAGE); String bgSelected = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE); String bgFocused = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_IMAGE); String bgDisabled = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_IMAGE); String bgColor = d.getString(TiC.PROPERTY_BACKGROUND_COLOR); String bgSelectedColor = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR); String bgFocusedColor = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_COLOR); String bgDisabledColor = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_COLOR); TiContext tiContext = getProxy().getTiContext(); if (bg != null) { bg = tiContext.resolveUrl(null, bg); } if (bgSelected != null) { bgSelected = tiContext.resolveUrl(null, bgSelected); } if (bgFocused != null) { bgFocused = tiContext.resolveUrl(null, bgFocused); } if (bgDisabled != null) { bgDisabled = tiContext.resolveUrl(null, bgDisabled); } if (bg != null || bgSelected != null || bgFocused != null || bgDisabled != null || bgColor != null || bgSelectedColor != null || bgFocusedColor != null || bgDisabledColor != null) { if (background == null) { applyCustomBackground(false); } Drawable bgDrawable = TiUIHelper.buildBackgroundDrawable( tiContext, bg, bgColor, bgSelected, bgSelectedColor, bgDisabled, bgDisabledColor, bgFocused, bgFocusedColor); background.setBackgroundDrawable(bgDrawable); } }
public void setLocalizedText(String idPropertyName, String idPropertyValue) { if (langConversionTable == null) { return; } for (String propertyName : langConversionTable.keySet()) { String thisIdPropertyName = langConversionTable.getString(propertyName); if (idPropertyName.equals(thisIdPropertyName)) { try { String localText = getLocalizedText(idPropertyValue); setPropertyAndFire(propertyName, localText); } catch (ResourceNotFoundException e) { Log.w(LCAT, "Localized text key '" + idPropertyValue + "' is invalid."); } break; } } }
@Override public void processProperties(KrollDict d) { TiImageView view = getView(); View parentView = getParentView(); if (view == null) { return; } if (d.containsKey(TiC.PROPERTY_WIDTH)) { if (TiC.LAYOUT_FILL.equals(d.getString(TiC.PROPERTY_WIDTH)) && parentView != null) { // Use the parent's width when it's fill requestedWidth = TiConvert.toTiDimension(parentView.getMeasuredWidth(), TiDimension.TYPE_WIDTH); } else { requestedWidth = TiConvert.toTiDimension(d, TiC.PROPERTY_WIDTH, TiDimension.TYPE_WIDTH); } } if (d.containsKey(TiC.PROPERTY_HEIGHT)) { // Use the parent's height when it's fill if (TiC.LAYOUT_FILL.equals(d.getString(TiC.PROPERTY_HEIGHT)) && parentView != null) { requestedHeight = TiConvert.toTiDimension(parentView.getMeasuredHeight(), TiDimension.TYPE_HEIGHT); } else { requestedHeight = TiConvert.toTiDimension(d, TiC.PROPERTY_HEIGHT, TiDimension.TYPE_HEIGHT); } } if (d.containsKey(TiC.PROPERTY_IMAGES)) { setImageSource(d.get(TiC.PROPERTY_IMAGES)); setImages(); } else if (d.containsKey(TiC.PROPERTY_URL)) { Log.w(TAG, "The url property of ImageView is deprecated, use image instead."); if (!d.containsKey(TiC.PROPERTY_IMAGE)) { d.put(TiC.PROPERTY_IMAGE, d.get(TiC.PROPERTY_URL)); } } if (d.containsKey(TiC.PROPERTY_CAN_SCALE)) { view.setCanScaleImage(TiConvert.toBoolean(d, TiC.PROPERTY_CAN_SCALE)); } if (d.containsKey(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)) { view.setEnableZoomControls(TiConvert.toBoolean(d, TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)); } if (d.containsKey(TiC.PROPERTY_DEFAULT_IMAGE)) { Object defaultImage = d.get(TiC.PROPERTY_DEFAULT_IMAGE); try { Object image = d.get(TiC.PROPERTY_IMAGE); if (image instanceof String) { String imageUrl = TiUrl.getCleanUri((String) image).toString(); URI imageUri = new URI(imageUrl); if (URLUtil.isNetworkUrl(imageUrl) && !TiResponseCache.peek(imageUri)) { setDefaultImageSource(defaultImage); } } else if (image == null) { setDefaultImageSource(defaultImage); } } catch (URISyntaxException e) { setDefaultImageSource(defaultImage); } catch (NullPointerException e) { setDefaultImageSource(defaultImage); } } if (d.containsKey(TiC.PROPERTY_IMAGE)) { // processProperties is also called from TableView, we need check if we changed before // re-creating the // bitmap boolean changeImage = true; Object newImage = d.get(TiC.PROPERTY_IMAGE); TiDrawableReference source = makeImageSource(newImage); // Check for orientation only if they specified an image if (d.containsKey(TiC.PROPERTY_AUTOROTATE)) { source.setAutoRotate(d.getBoolean(TiC.PROPERTY_AUTOROTATE)); } if (imageSources != null && imageSources.size() == 1) { if (imageSources.get(0).equals(source)) { changeImage = false; } } if (changeImage) { setImageSource(source); firedLoad = false; setImage(false); } } else { if (!d.containsKey(TiC.PROPERTY_IMAGES)) { getProxy().setProperty(TiC.PROPERTY_IMAGE, null); if (defaultImageSource != null) { setDefaultImage(); } } } super.processProperties(d); }
public void handleKeyboard(KrollDict d) { int type = KEYBOARD_ASCII; boolean passwordMask = false; boolean editable = true; int autocorrect = InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; int autoCapValue = 0; if (d.containsKey(TiC.PROPERTY_AUTOCORRECT) && !TiConvert.toBoolean(d, TiC.PROPERTY_AUTOCORRECT, true)) { autocorrect = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; } if (d.containsKey(TiC.PROPERTY_EDITABLE)) { editable = TiConvert.toBoolean(d, TiC.PROPERTY_EDITABLE, true); } if (d.containsKey(TiC.PROPERTY_AUTOCAPITALIZATION)) { switch (TiConvert.toInt( d.get(TiC.PROPERTY_AUTOCAPITALIZATION), TEXT_AUTOCAPITALIZATION_NONE)) { case TEXT_AUTOCAPITALIZATION_NONE: autoCapValue = 0; break; case TEXT_AUTOCAPITALIZATION_ALL: autoCapValue = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_CAP_WORDS; break; case TEXT_AUTOCAPITALIZATION_SENTENCES: autoCapValue = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; break; case TEXT_AUTOCAPITALIZATION_WORDS: autoCapValue = InputType.TYPE_TEXT_FLAG_CAP_WORDS; break; default: Log.w( TAG, "Unknown AutoCapitalization Value [" + d.getString(TiC.PROPERTY_AUTOCAPITALIZATION) + "]"); break; } } if (d.containsKey(TiC.PROPERTY_PASSWORD_MASK)) { passwordMask = TiConvert.toBoolean(d, TiC.PROPERTY_PASSWORD_MASK, false); } if (d.containsKey(TiC.PROPERTY_KEYBOARD_TYPE)) { type = TiConvert.toInt(d.get(TiC.PROPERTY_KEYBOARD_TYPE), KEYBOARD_DEFAULT); } int typeModifiers = autocorrect | autoCapValue; int textTypeAndClass = typeModifiers; // For some reason you can't set both TYPE_CLASS_TEXT and TYPE_TEXT_FLAG_NO_SUGGESTIONS // together. // Also, we need TYPE_CLASS_TEXT for passwords. if ((autocorrect != InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS || passwordMask) && type != KEYBOARD_DECIMAL_PAD) { textTypeAndClass = textTypeAndClass | InputType.TYPE_CLASS_TEXT; } tv.setCursorVisible(true); switch (type) { case KEYBOARD_DEFAULT: case KEYBOARD_ASCII: // Don't need a key listener, inputType handles that. break; case KEYBOARD_NUMBERS_PUNCTUATION: textTypeAndClass |= (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT); tv.setKeyListener( new NumberKeyListener() { @Override public int getInputType() { return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT; } @Override protected char[] getAcceptedChars() { return new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '-', '+', '_', '*', '-', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '=', '{', '}', '[', ']', '|', '\\', '<', '>', ',', '?', '/', ':', ';', '\'', '"', '~' }; } }); break; case KEYBOARD_URL: Log.d(TAG, "Setting keyboard type URL-3", Log.DEBUG_MODE); tv.setImeOptions(EditorInfo.IME_ACTION_GO); textTypeAndClass |= InputType.TYPE_TEXT_VARIATION_URI; break; case KEYBOARD_DECIMAL_PAD: textTypeAndClass |= (InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED); case KEYBOARD_NUMBER_PAD: tv.setKeyListener(DigitsKeyListener.getInstance(true, true)); textTypeAndClass |= InputType.TYPE_CLASS_NUMBER; break; case KEYBOARD_PHONE_PAD: tv.setKeyListener(DialerKeyListener.getInstance()); textTypeAndClass |= InputType.TYPE_CLASS_PHONE; break; case KEYBOARD_EMAIL_ADDRESS: textTypeAndClass |= InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; break; } if (passwordMask) { textTypeAndClass |= InputType.TYPE_TEXT_VARIATION_PASSWORD; // Sometimes password transformation does not work properly when the input type is set after // the transformation method. // This issue has been filed at http://code.google.com/p/android/issues/detail?id=7092 tv.setInputType(textTypeAndClass); tv.setTransformationMethod(PasswordTransformationMethod.getInstance()); // turn off text UI in landscape mode b/c Android numeric passwords are not masked correctly // in landscape mode. if (type == KEYBOARD_NUMBERS_PUNCTUATION || type == KEYBOARD_DECIMAL_PAD || type == KEYBOARD_NUMBER_PAD) { tv.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); } } else { tv.setInputType(textTypeAndClass); if (tv.getTransformationMethod() instanceof PasswordTransformationMethod) { tv.setTransformationMethod(null); } } if (!editable) { tv.setKeyListener(null); tv.setCursorVisible(false); } // setSingleLine() append the flag TYPE_TEXT_FLAG_MULTI_LINE to the current inputType, so we // want to call this // after we set inputType. if (!field) { tv.setSingleLine(false); } }
@Override public void processProperties(KrollDict d) { super.processProperties(d); if (d.containsKey(TiC.PROPERTY_ENABLED)) { tv.setEnabled(TiConvert.toBoolean(d, TiC.PROPERTY_ENABLED, true)); } if (d.containsKey(TiC.PROPERTY_MAX_LENGTH) && field) { maxLength = TiConvert.toInt(d.get(TiC.PROPERTY_MAX_LENGTH), -1); } // Disable change event temporarily as we are setting the default value disableChangeEvent = true; if (d.containsKey(TiC.PROPERTY_VALUE)) { tv.setText(d.getString(TiC.PROPERTY_VALUE)); } else { tv.setText(""); } disableChangeEvent = false; if (d.containsKey(TiC.PROPERTY_COLOR)) { tv.setTextColor(TiConvert.toColor(d, TiC.PROPERTY_COLOR)); } if (d.containsKey(TiC.PROPERTY_HINT_TEXT)) { tv.setHint(d.getString(TiC.PROPERTY_HINT_TEXT)); } if (d.containsKey(TiC.PROPERTY_ELLIPSIZE)) { if (TiConvert.toBoolean(d, TiC.PROPERTY_ELLIPSIZE)) { tv.setEllipsize(TruncateAt.END); } else { tv.setEllipsize(null); } } if (d.containsKey(TiC.PROPERTY_FONT)) { TiUIHelper.styleText(tv, d.getKrollDict(TiC.PROPERTY_FONT)); } if (d.containsKey(TiC.PROPERTY_TEXT_ALIGN) || d.containsKey(TiC.PROPERTY_VERTICAL_ALIGN)) { String textAlign = null; String verticalAlign = null; if (d.containsKey(TiC.PROPERTY_TEXT_ALIGN)) { textAlign = d.getString(TiC.PROPERTY_TEXT_ALIGN); } if (d.containsKey(TiC.PROPERTY_VERTICAL_ALIGN)) { verticalAlign = d.getString(TiC.PROPERTY_VERTICAL_ALIGN); } handleTextAlign(textAlign, verticalAlign); } if (d.containsKey(TiC.PROPERTY_RETURN_KEY_TYPE)) { handleReturnKeyType(TiConvert.toInt(d.get(TiC.PROPERTY_RETURN_KEY_TYPE), RETURNKEY_DEFAULT)); } if (d.containsKey(TiC.PROPERTY_KEYBOARD_TYPE) || d.containsKey(TiC.PROPERTY_AUTOCORRECT) || d.containsKey(TiC.PROPERTY_PASSWORD_MASK) || d.containsKey(TiC.PROPERTY_AUTOCAPITALIZATION) || d.containsKey(TiC.PROPERTY_EDITABLE)) { handleKeyboard(d); } if (d.containsKey(TiC.PROPERTY_AUTO_LINK)) { TiUIHelper.linkifyIfEnabled(tv, d.get(TiC.PROPERTY_AUTO_LINK)); } }
@Override public void processProperties(KrollDict d) { boolean showHorizontalScrollBar = false; boolean showVerticalScrollBar = false; if (d.containsKey(SHOW_HORIZONTAL_SCROLL_INDICATOR)) { showHorizontalScrollBar = TiConvert.toBoolean(d, SHOW_HORIZONTAL_SCROLL_INDICATOR); } if (d.containsKey(SHOW_VERTICAL_SCROLL_INDICATOR)) { showVerticalScrollBar = TiConvert.toBoolean(d, SHOW_VERTICAL_SCROLL_INDICATOR); } if (showHorizontalScrollBar && showVerticalScrollBar) { Log.w(LCAT, "Both scroll bars cannot be shown. Defaulting to vertical shown"); showHorizontalScrollBar = false; } int type = TYPE_VERTICAL; if (d.containsKey("width") && d.containsKey("contentWidth")) { Object width = d.get("width"); Object contentWidth = d.get("contentWidth"); if (width.equals(contentWidth) || showVerticalScrollBar) { type = TYPE_VERTICAL; } } if (d.containsKey("height") && d.containsKey("contentHeight")) { Object height = d.get("height"); Object contentHeight = d.get("contentHeight"); if (height.equals(contentHeight) || showHorizontalScrollBar) { type = TYPE_HORIZONTAL; } } // android only property if (d.containsKey("scrollType")) { Object scrollType = d.get("scrollType"); if (scrollType.equals("vertical")) { type = TYPE_VERTICAL; } else if (scrollType.equals("horizontal")) { type = TYPE_HORIZONTAL; } } // we create the view here since we now know the potential widget type View view = null; switch (type) { case TYPE_HORIZONTAL: Log.d(LCAT, "creating horizontal scroll view"); view = new TiHorizontalScrollView( getProxy().getContext(), d.containsKey("layout") && d.getString("layout").equals("vertical")); break; case TYPE_VERTICAL: default: Log.d(LCAT, "creating vertical scroll view"); view = new TiVerticalScrollView( getProxy().getContext(), d.containsKey("layout") && d.getString("layout").equals("vertical")); } setNativeView(view); nativeView.setHorizontalScrollBarEnabled(showHorizontalScrollBar); nativeView.setVerticalScrollBarEnabled(showVerticalScrollBar); super.processProperties(d); }
// ----------- Private Methods ----------// private LinkProperties createLinkPropertiesDict(KrollDict options, KrollDict controlParams) { Log.d(LCAT, "start createLinkPropertiesDict"); LinkProperties linkProperties = new LinkProperties(); if (options.containsKey("feature")) { linkProperties.setFeature(options.getString("feature")); } if (options.containsKey("alias")) { linkProperties.setAlias(options.getString("alias")); } if (options.containsKey("channel")) { linkProperties.setChannel(options.getString("channel")); } if (options.containsKey("stage")) { linkProperties.setStage(options.getString("stage")); } if (options.containsKey("duration")) { linkProperties.setDuration(options.getInt("duration")); } if (options.containsKey("tags")) { ArrayList<String> tags = (ArrayList<String>) options.get("tags"); for (String tag : tags) { linkProperties.addTag(tag); } } if (controlParams.containsKey("$fallback_url")) { Log.d(LCAT, "addControlParameter $fallback_url"); linkProperties.addControlParameter("$fallback_url", controlParams.getString("$fallback_url")); } if (controlParams.containsKey("$desktop_url")) { Log.d(LCAT, "addControlParameter $desktop_url"); linkProperties.addControlParameter("$desktop_url", controlParams.getString("$desktop_url")); } if (controlParams.containsKey("$android_url")) { Log.d(LCAT, "addControlParameter $android_url"); linkProperties.addControlParameter("$android_url", controlParams.getString("$android_url")); } if (controlParams.containsKey("$ios_url")) { Log.d(LCAT, "addControlParameter $ios_url"); linkProperties.addControlParameter("$ios_url", controlParams.getString("$ios_url")); } if (controlParams.containsKey("$ipad_url")) { Log.d(LCAT, "addControlParameter $ipad_url"); linkProperties.addControlParameter("$ipad_url", controlParams.getString("$ipad_url")); } if (controlParams.containsKey("$fire_url")) { Log.d(LCAT, "addControlParameter $fire_url"); linkProperties.addControlParameter("$fire_url", controlParams.getString("$fire_url")); } if (controlParams.containsKey("$blackberry_url")) { Log.d(LCAT, "addControlParameter $blackberry_url"); linkProperties.addControlParameter( "$blackberry_url", controlParams.getString("$blackberry_url")); } if (controlParams.containsKey("$windows_phone_url")) { Log.d(LCAT, "addControlParameter $windows_phone_url"); linkProperties.addControlParameter( "$windows_phone_url", controlParams.getString("$windows_phone_url")); } return linkProperties; }
@Kroll.method public void generateShortUrl(KrollDict options, KrollDict controlParams) { Log.d(LCAT, "start generateShortUrl"); LinkProperties linkProperties = new LinkProperties(); if (options.containsKey("feature")) { linkProperties.setFeature(options.getString("feature")); } if (options.containsKey("alias")) { linkProperties.setAlias(options.getString("alias")); } if (options.containsKey("channel")) { linkProperties.setChannel(options.getString("channel")); } if (options.containsKey("stage")) { linkProperties.setStage(options.getString("stage")); } if (options.containsKey("duration")) { linkProperties.setDuration(options.getInt("duration")); } if (options.containsKey("tags")) { ArrayList<String> tags = (ArrayList<String>) options.get("tags"); for (String tag : tags) { linkProperties.addTag(tag); } } if (controlParams.containsKey("$fallback_url")) { Log.d(LCAT, "addControlParameter $fallback_url"); linkProperties.addControlParameter("$fallback_url", controlParams.getString("$fallback_url")); } if (controlParams.containsKey("$desktop_url")) { Log.d(LCAT, "addControlParameter $desktop_url"); linkProperties.addControlParameter("$desktop_url", controlParams.getString("$desktop_url")); } if (controlParams.containsKey("$android_url")) { Log.d(LCAT, "addControlParameter $android_url"); linkProperties.addControlParameter("$android_url", controlParams.getString("$android_url")); } if (controlParams.containsKey("$ios_url")) { Log.d(LCAT, "addControlParameter $ios_url"); linkProperties.addControlParameter("$ios_url", controlParams.getString("$ios_url")); } if (controlParams.containsKey("$ipad_url")) { Log.d(LCAT, "addControlParameter $ipad_url"); linkProperties.addControlParameter("$ipad_url", controlParams.getString("$ipad_url")); } if (controlParams.containsKey("$fire_url")) { Log.d(LCAT, "addControlParameter $fire_url"); linkProperties.addControlParameter("$fire_url", controlParams.getString("$fire_url")); } if (controlParams.containsKey("$blackberry_url")) { Log.d(LCAT, "addControlParameter $blackberry_url"); linkProperties.addControlParameter( "$blackberry_url", controlParams.getString("$blackberry_url")); } if (controlParams.containsKey("$windows_phone_url")) { Log.d(LCAT, "addControlParameter $windows_phone_url"); linkProperties.addControlParameter( "$windows_phone_url", controlParams.getString("$windows_phone_url")); } final Activity activity = this.getActivity(); branchUniversalObject.generateShortUrl( activity, linkProperties, new GenerateShortUrlListener()); }
public static TiAnnotation fromDict(final KrollDict dict) { TiAnnotation a = null; if (dict.containsKeyAndNotNull(TiC.PROPERTY_ID)) { a = new TiAnnotation(dict.getString(TiC.PROPERTY_ID)); } else { a = new TiAnnotation(); dict.put(TiC.PROPERTY_ID, a.getId()); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_TITLE)) { a.setTitle(dict.getString(TiC.PROPERTY_TITLE)); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_SUBTITLE)) { a.setSubtitle(dict.getString(TiC.PROPERTY_SUBTITLE)); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_LATITUDE)) { a.setLatitude(dict.getDouble(TiC.PROPERTY_LATITUDE)); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_LONGITUDE)) { a.setLongitude(dict.getDouble(TiC.PROPERTY_LONGITUDE)); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_IMAGE) || dict.containsKeyAndNotNull(TiC.PROPERTY_PIN_IMAGE)) { a.setImage(dict.getString(TiC.PROPERTY_IMAGE)); if (a.getImage() == null) { a.setImage(dict.getString(TiC.PROPERTY_PIN_IMAGE)); } } if (dict.containsKeyAndNotNull(TiC.PROPERTY_PINCOLOR)) { Object pinColor = dict.get(TiC.PROPERTY_PINCOLOR); if (pinColor instanceof String) { a.setPinColor((String) pinColor); } else { a.setPinColor(dict.getInt(TiC.PROPERTY_PINCOLOR)); } } if (dict.containsKeyAndNotNull(TiC.PROPERTY_LEFT_BUTTON)) { a.setLeftButton(TiConvert.toString(dict, TiC.PROPERTY_LEFT_BUTTON)); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_RIGHT_BUTTON)) { a.setRightButton(TiConvert.toString(dict, TiC.PROPERTY_RIGHT_BUTTON)); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_LEFT_VIEW)) { Object leftView = dict.get(TiC.PROPERTY_LEFT_VIEW); if (leftView instanceof TiViewProxy) { a.setLeftView((TiViewProxy) leftView); } } if (dict.containsKeyAndNotNull(TiC.PROPERTY_RIGHT_VIEW)) { Object rightView = dict.get(TiC.PROPERTY_RIGHT_VIEW); if (rightView instanceof TiViewProxy) { a.setRightView((TiViewProxy) rightView); } } if (dict.containsKeyAndNotNull(TiC.PROPERTY_ANIMATE)) { a.setAnimate(dict.getBoolean(TiC.PROPERTY_ANIMATE)); } else { a.setAnimate(Boolean.FALSE); } if (dict.containsKeyAndNotNull(TiC.PROPERTY_CENTER)) { a.setCenter(dict.getBoolean(TiC.PROPERTY_CENTER)); } else { a.setCenter(Boolean.TRUE); } return a; }