@Kroll.setProperty @Kroll.method public void setContentIndexingMode(String contentIndexingMode) { Log.d(LCAT, "setContentIndexingMode"); if (contentIndexingMode.equals("private")) { branchUniversalObject.setContentIndexingMode( BranchUniversalObject.CONTENT_INDEX_MODE.PRIVATE); } else { branchUniversalObject.setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC); } }
// 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)); } } }
@Kroll.method public void showShareSheet(KrollDict options, KrollDict controlParams) { Log.d(LCAT, "start showShareSheet"); final Activity activity = this.getActivity(); ShareSheetStyle shareSheetStyle = new ShareSheetStyle(activity, "Check this out!", "This stuff is awesome: ") .setCopyUrlStyle( activity.getResources().getDrawable(android.R.drawable.ic_menu_send), "Copy", "Added to clipboard") .setMoreOptionStyle( activity.getResources().getDrawable(android.R.drawable.ic_menu_search), "Show more") .addPreferredSharingOption(SharingHelper.SHARE_WITH.FACEBOOK) .addPreferredSharingOption(SharingHelper.SHARE_WITH.EMAIL); LinkProperties linkProperties = createLinkPropertiesDict(options, controlParams); branchUniversalObject.showShareSheet( activity, linkProperties, shareSheetStyle, new ShowShareSheetListener()); }
@Kroll.setProperty @Kroll.method public void addContentMetadata(String key, String value) { Log.d(LCAT, "addContentMetadata"); branchUniversalObject.addContentMetadata(key, value); }
@Kroll.getProperty @Kroll.method public boolean isPublicallyIndexable() { Log.d(LCAT, "isPublicallyIndexable"); return branchUniversalObject.isPublicallyIndexable(); }
@Kroll.setProperty @Kroll.method public void setContentImageUrl(String contentImageUrl) { Log.d(LCAT, "setContentImageUrl"); branchUniversalObject.setContentImageUrl(contentImageUrl); }
@Kroll.getProperty @Kroll.method public String getContentImageUrl() { Log.d(LCAT, "getContentImageUrl"); return branchUniversalObject.getImageUrl(); }
@Kroll.setProperty @Kroll.method public void setContentDescription(String contentDescription) { Log.d(LCAT, "setContentDescription"); branchUniversalObject.setContentDescription(contentDescription); }
@Kroll.getProperty @Kroll.method public String getContentDescription() { Log.d(LCAT, "getContentDescription"); return branchUniversalObject.getDescription(); }
@Kroll.setProperty @Kroll.method public void setTitle(String title) { Log.d(LCAT, "setTitle"); branchUniversalObject.setTitle(title); }
@Kroll.getProperty @Kroll.method public String getTitle() { Log.d(LCAT, "getTitle"); return branchUniversalObject.getTitle(); }
@Kroll.setProperty @Kroll.method public void setCanonicalIdentifier(String canonicalIdentifier) { Log.d(LCAT, "setCanonicalIdentifier"); branchUniversalObject.setCanonicalIdentifier(canonicalIdentifier); }
// ----------- Property Getter/Setter ----------// @Kroll.getProperty @Kroll.method public String getCanonicalIdentifier() { Log.d(LCAT, "getCanonicalIdentifier"); return branchUniversalObject.getCanonicalIdentifier(); }
@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()); }
// ----------- Methods ----------// @Kroll.method public void registerView() { Log.d(LCAT, "start registerView"); branchUniversalObject.registerView(); }