-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from BranchMetrics/SDK-1409-qr-code-creation
SDK 1409 [Unity] Expose QR code creation methods
- Loading branch information
Showing
52 changed files
with
3,052 additions
and
2,665 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class BranchQRCode | ||
{ | ||
//Primary color of the generated QR code itself | ||
private string codeColor; | ||
|
||
//Secondary color used as the QR Code background | ||
private string backgroundColor; | ||
|
||
//The number of pixels for the QR code's border. Min 1px. Max 20px | ||
private int margin; | ||
|
||
//Output size of QR Code image. Min 300px. Max 2000px | ||
private int width; | ||
|
||
//Image Format of the returned QR code. Can be a JPEG or PNG | ||
private BranchImageFormat imageFormat; | ||
|
||
//A URL of an image that will be added to the center of the QR code. Must be a PNG or JPEG | ||
private string centerLogoUrl; | ||
|
||
//The style of code pattern used to generate the QR-Code | ||
private BranchQRCodePattern codePattern; | ||
|
||
// The style of finder pattern used to generate the QR-Code | ||
private BranchQRCodeFinderPattern finderPattern; | ||
|
||
// Hex string used to change the color of the Qr-Code’s finder pattern | ||
private string finderPatternColor; | ||
|
||
// Direct link to an image to be used as the background image that is set behind the QR Code | ||
private string backgroundImageUrl; | ||
|
||
// Adjusts the opacity of the background image | ||
private int backgroundImageOpacity; | ||
|
||
// Direct link to an image to be used as the code-pattern itself on the QR Code | ||
private string codePatternUrl; | ||
|
||
// Hex string used to change the color of the interior part of a Qr-Code’s finder pattern | ||
private string finderEyeColor; | ||
|
||
public BranchQRCode(string codeColor = "#000000", string backgroundColor = "#FFFFFF", int margin = 1, int width = 512, BranchImageFormat imageFormat = BranchImageFormat.PNG, string centerLogoUrl = "") | ||
{ | ||
Init(codeColor, backgroundColor, margin, width, imageFormat, centerLogoUrl); | ||
} | ||
|
||
private void Init(string codeColor, string backgroundColor, int margin, int width, BranchImageFormat imageFormat, string centerLogoUrl) | ||
{ | ||
this.codeColor = codeColor; | ||
this.backgroundColor = backgroundColor; | ||
this.margin = margin; | ||
this.width = width; | ||
this.imageFormat = imageFormat; | ||
this.centerLogoUrl = centerLogoUrl; | ||
} | ||
|
||
public void loadFromJson(string json) | ||
{ | ||
if (string.IsNullOrEmpty(json)) | ||
return; | ||
|
||
var data = BranchThirdParty_MiniJSON.Json.Deserialize(json) as Dictionary<string, object>; | ||
loadFromDictionary(data); | ||
} | ||
|
||
public void loadFromDictionary(Dictionary<string, object> data) | ||
{ | ||
if (data == null) | ||
return; | ||
|
||
if (data.ContainsKey("code_color") && data["code_color"] != null) | ||
{ | ||
codeColor = data["code_color"].ToString(); | ||
} | ||
if (data.ContainsKey("background_color") && data["background_color"] != null) | ||
{ | ||
backgroundColor = data["background_color"].ToString(); | ||
} | ||
if (data.ContainsKey("margin")) | ||
{ | ||
margin = Convert.ToInt32(data["margin"].ToString()); | ||
} | ||
if (data.ContainsKey("width")) | ||
{ | ||
width = Convert.ToInt32(data["width"].ToString()); | ||
} | ||
if (data.ContainsKey("image_format")) | ||
{ | ||
imageFormat = (BranchImageFormat) Convert.ToInt32(data["imageFormat"].ToString()); | ||
} | ||
if (data.ContainsKey("center_logo_url") && data["center_logo_url"] != null) | ||
{ | ||
centerLogoUrl = data["center_logo_url"].ToString(); | ||
} | ||
} | ||
|
||
public string ToJsonString() | ||
{ | ||
var data = new Dictionary<string, object>(); | ||
|
||
data.Add("code_color", codeColor); | ||
data.Add("background_color", backgroundColor); | ||
data.Add("margin", margin.ToString()); | ||
data.Add("width", width.ToString()); | ||
data.Add("image_format", imageFormat.ToString()); | ||
data.Add("center_logo_url", centerLogoUrl); | ||
|
||
return BranchThirdParty_MiniJSON.Json.Serialize(data); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
+7.32 KB
(110%)
BranchUnityTestBed/Assets/Branch/Demo/Scenes/BranchSDK_Demo.unity
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
BranchUnityTestBed/Assets/Branch/Editor/BranchDependencies.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<dependencies> | ||
<androidPackages> | ||
<androidPackage spec="io.branch.sdk.android:library:5.3.0" /> | ||
<androidPackage spec="io.branch.sdk.android:library:5.8.0" /> | ||
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18+" /> | ||
</androidPackages> | ||
<iosPods> | ||
<iosPod name="BranchSDK" version="~>2.1.0" bitcodeEnabled="false" minTargetSdk="11.0" addToAllTargets="false" /> | ||
<iosPod name="BranchSDK" version="~>3.0.0" bitcodeEnabled="false" minTargetSdk="14.0" addToAllTargets="false" /> | ||
</iosPods> | ||
</dependencies> |
Binary file modified
BIN
+12 Bytes
(100%)
BranchUnityTestBed/Assets/Branch/Resources/BranchData.asset
Binary file not shown.
Binary file removed
BIN
-72.5 KB
BranchUnityTestBed/Assets/ExternalDependencyManager/Editor/1.2.175/Google.IOSResolver.dll
Binary file not shown.
Binary file removed
BIN
-16.1 KB
...chUnityTestBed/Assets/ExternalDependencyManager/Editor/1.2.175/Google.IOSResolver.dll.mdb
Binary file not shown.
13 changes: 0 additions & 13 deletions
13
...tyTestBed/Assets/ExternalDependencyManager/Editor/1.2.175/Google.IOSResolver.dll.mdb.meta
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-70.3 KB
...chUnityTestBed/Assets/ExternalDependencyManager/Editor/1.2.175/Google.JarResolver.dll.mdb
Binary file not shown.
Oops, something went wrong.