Skip to content

Commit

Permalink
feat(BranchSDK): update the code to handle when user passes a string …
Browse files Browse the repository at this point in the history
…and not an object with all the

Detect that the user is giving a string or a json of strings to be used, the code is limited to

string or object there is no merge of the strings so the user needs to give all the translation
  • Loading branch information
odaumas committed Sep 14, 2016
1 parent 02654c4 commit 30d3e84
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ Once you've created your `Branch Universal Object`, which is the reference to th
| KEY | TYPE | MEANING
| ------------------ | -------- | --------------------
| $fallback_url | `string` | Change the redirect endpoint for all platforms - so you don’t have to enable it by platform
| $desktop_url | `string` | Change the redirect endpoint on desktops
| $desktop_url | `string` | Change the redirect endpoint on desktops
| $android_url | `string` | Change the redirect endpoint for Android
| $ios_url | `string` | Change the redirect endpoint for iOS
| $ipad_url | `string` | Change the redirect endpoint for iPads
| $fire_url | `string` | Change the redirect endpoint for Amazon Fire OS
| $fire_url | `string` | Change the redirect endpoint for Amazon Fire OS
| $blackberry_url | `string` | Change the redirect endpoint for Blackberry OS
| $windows_phone_url | `string` | Change the redirect endpoint for Windows OS

Expand Down Expand Up @@ -443,15 +443,16 @@ The Branch iOS SDK includes a wrapper on the UIActivityViewController that will
| KEY | TYPE | MEANING
| ------------------ | -------- | --------------------
| $fallback_url | `string` | Change the redirect endpoint for all platforms - so you don’t have to enable it by platform
| $desktop_url | `string` | Change the redirect endpoint on desktops
| $desktop_url | `string` | Change the redirect endpoint on desktops
| $android_url | `string` | Change the redirect endpoint for Android
| $ios_url | `string` | Change the redirect endpoint for iOS
| $ipad_url | `string` | Change the redirect endpoint for iPads
| $fire_url | `string` | Change the redirect endpoint for Amazon Fire OS
| $fire_url | `string` | Change the redirect endpoint for Amazon Fire OS
| $blackberry_url | `string` | Change the redirect endpoint for Blackberry OS
| $windows_phone_url | `string` | Change the redirect endpoint for Windows OS

**localization**: `object` - Custom text to share
**localization**: `object` - Custom text to share (From version 2.1.17)

| KEY | TYPE | MEANING
| ------------------ | -------- | --------------------
| shareText | `string` | Content of the message by default: 'This stuff is awesome:'
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="io.branch.sdk"
version="2.1.17-cmt">
version="2.1.17">

<name>branch-cordova-sdk</name>
<description>Branch SDK Plugin</description>
Expand Down
36 changes: 22 additions & 14 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ protected class BranchUniversalObjectWrapper {
public CallbackContext onChannelSelected;

/**
* @param BranchUniversalObject branchUniversalObj
*
* @param branchUniversalObj branchUniversalObj
* @constructor
*/
public BranchUniversalObjectWrapper(BranchUniversalObject branchUniversalObj) {
Expand Down Expand Up @@ -900,12 +901,13 @@ protected class ShowShareSheetListener implements Branch.BranchLinkShareListener
private CallbackContext _onChannelSelected;

/**
* @param CallbackContext onShareLinkDialogLaunched
* @param CallbackContext onShareLinkDialogDismissed
* @param CallbackContext onLinkShareResponse
* @param CallbackContext onChannelSelected
*
* @param onShareLinkDialogLaunched
* @param onShareLinkDialogDismissed
* @param onLinkShareResponse
* @param onChannelSelected
* @constructor
**/
*/
public ShowShareSheetListener(CallbackContext onShareLinkDialogLaunched, CallbackContext onShareLinkDialogDismissed, CallbackContext onLinkShareResponse, CallbackContext onChannelSelected) {

this._onShareLinkDialogDismissed = onShareLinkDialogDismissed;
Expand Down Expand Up @@ -1128,14 +1130,20 @@ public void run() {
} else if (this.action.equals("registerView")) {
registerView(this.args.getInt(0), this.callbackContext);
} else if (this.action.equals("showShareSheet")) {
JSONObject defaultStrings = new JSONObject();
defaultStrings.put("shareText", "This stuff is awesome: ");
defaultStrings.put("shareTitle", "Check this out!");
defaultStrings.put("copyToClipboard", "Copy");
defaultStrings.put("clipboardSuccess", "Added to clipboard");
defaultStrings.put("more", "Show More");
defaultStrings.put("shareWith", "Share With");
showShareSheet(this.args.getInt(0), this.args.getJSONObject(1), this.args.getJSONObject(2), this.args.getJSONObject(3) != null ? this.args.getJSONObject(3) : defaultStrings);
Object userLocalization = this.args.opt(3);
JSONObject localization = new JSONObject();
//Limitation is that the user must override all the strings
if (userLocalization != null && userLocalization instanceof JSONObject) {
localization = (JSONObject) userLocalization;
} else {
localization.put("shareText", "This stuff is awesome:");
localization.put("shareTitle", "Check this out!");
localization.put("copyToClipboard", "Copy");
localization.put("clipboardSuccess", "Added to clipboard");
localization.put("more", "Show More");
localization.put("shareWith", "Share With");
}
showShareSheet(this.args.getInt(0), this.args.getJSONObject(1), this.args.getJSONObject(2), localization);
}
}
} catch (JSONException e) {
Expand Down

0 comments on commit 30d3e84

Please sign in to comment.