Skip to content

Commit 31ea00f

Browse files
JordiFBfacebook-github-bot
authored andcommitted
Added Windows SDK: Open SoftKeyboard feature
Summary: Added open softkeyboard feature on Windows platform inside UnitySDK. This feature will open the virtual keyboard in mobile devices, Reviewed By: SergioGuerreroFB Differential Revision: D37788930 fbshipit-source-id: b6c08cd93b021d9ed49c69d5d050e445fd9ba999
1 parent 3d2e959 commit 31ea00f

File tree

14 files changed

+748
-5
lines changed

14 files changed

+748
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [14.1.0]
99

10+
### Added
11+
- Windows platform methods
12+
- FB.Windows.SetSoftKeyboardOpen
13+
1014
### Fixed
1115
- Issue with new Unity Input System and UnitySDK Example.
1216
- Issue with misconfiguration of each DLL when Unity import the package.

Facebook.Unity.Windows/WindowsWrapper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,5 +664,22 @@ public void GetUserLocale(string callbackId, CallbackManager callbackManager)
664664
callbackManager.OnFacebookResponse(new LocaleResult(new ResultContainer(result)));
665665
}
666666
}
667+
668+
public void SetSoftKeyboardOpen(bool open, string callbackId, CallbackManager callbackManager)
669+
{
670+
fbg.Softkeyboard.setSoftKeyboardOpen(open,
671+
(fbg.SoftkeyboardAction success) =>
672+
{
673+
Dictionary<string, object> resultDict = new Dictionary<string, object>() {
674+
{ Constants.CallbackIdKey, callbackId },
675+
{ "success", success },
676+
};
677+
callbackManager.OnFacebookResponse(new SoftKeyboardOpenResult(new ResultContainer(resultDict)));
678+
}, (fbg.Error error) =>
679+
{
680+
SoftKeyboardOpenResult result = new SoftKeyboardOpenResult(WindowsParserBase.SetError(error, callbackId));
681+
callbackManager.OnFacebookResponse(result);
682+
});
683+
}
667684
}
668685
}

Facebook.Unity/CallbackManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ private static void CallCallback(object callback, IResult result)
9898
CallbackManager.TryCallCallback<IFriendFinderInvitationResult>(callback, result) ||
9999
CallbackManager.TryCallCallback<IVirtualGamepadLayoutResult>(callback, result) ||
100100
CallbackManager.TryCallCallback<IDialogResult>(callback, result) ||
101-
CallbackManager.TryCallCallback<ILocaleResult>(callback, result))
101+
CallbackManager.TryCallCallback<ILocaleResult>(callback, result) ||
102+
CallbackManager.TryCallCallback<ISoftKeyboardOpenResult>(callback, result))
102103
{
103104
return;
104105
}

Facebook.Unity/FB.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,16 @@ public static void SetVirtualGamepadLayout(string layout, FacebookDelegate<IVirt
14031403
{
14041404
Windows.WindowsFacebookImpl.SetVirtualGamepadLayout(layout, callback);
14051405
}
1406+
1407+
/// <summary>
1408+
/// Open Virtual Keyboard in mobile devices.
1409+
/// </summary>
1410+
/// <param name="open"> true if you want to open the keyboard</param>
1411+
/// <param name="callback">Callback to be called when request completes.</param>
1412+
public static void SetSoftKeyboardOpen(bool open, FacebookDelegate<ISoftKeyboardOpenResult> callback)
1413+
{
1414+
Windows.WindowsFacebookImpl.SetSoftKeyboardOpen(open, callback);
1415+
}
14061416
}
14071417

14081418
internal abstract class CompiledFacebookLoader : MonoBehaviour

Facebook.Unity/Facebook.Unity.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -142,6 +142,7 @@
142142
<Compile Include="Results\IRewardedVideoResult.cs" />
143143
<Compile Include="Results\IScheduleAppToUserNotificationResult.cs" />
144144
<Compile Include="Results\IShareResult.cs" />
145+
<Compile Include="Results\ISoftKeyboardOpenResult.cs" />
145146
<Compile Include="Results\IVirtualGamepadLayoutResult.cs" />
146147
<Compile Include="Results\LocaleResult.cs" />
147148
<Compile Include="Results\LoginResult.cs" />
@@ -157,6 +158,7 @@
157158
<Compile Include="Results\RewardedVideoResult.cs" />
158159
<Compile Include="Results\ScheduleAppToUserNotificationResult.cs" />
159160
<Compile Include="Results\ShareResult.cs" />
161+
<Compile Include="Results\SoftKeyboardOpenResult.cs" />
160162
<Compile Include="Results\VirtualGamepadLayoutResult.cs" />
161163
<Compile Include="Utils\AsyncRequestString.cs" />
162164
<Compile Include="Utils\FacebookLogger.cs" />
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*As with any software that integrates with the Facebook platform, your use of
2+
* this software is subject to the Facebook Developer Principles and Policies
3+
* [http://developers.facebook.com/policy/]. This copyright notice shall be
4+
* included in all copies or substantial portions of the software.
5+
*
6+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
8+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR
9+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
10+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
11+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+
*/
13+
14+
namespace Facebook.Unity
15+
{
16+
/// <summary>
17+
/// The result of a soft keyboard open
18+
/// </summary>
19+
public interface ISoftKeyboardOpenResult : IResult
20+
{
21+
/// <summary>
22+
/// Gets the soft keyboard open result.
23+
/// </summary>
24+
/// <value>A string that specifies if the soft keyboard has open action was successful.</value>
25+
string Success { get; }
26+
}
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
3+
*
4+
* You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
5+
* copy, modify, and distribute this software in source code or binary form for use
6+
* in connection with the web services and APIs provided by Facebook.
7+
*
8+
* As with any software that integrates with the Facebook platform, your use of
9+
* this software is subject to the Facebook Developer Principles and Policies
10+
* [http://developers.facebook.com/policy/]. This copyright notice shall be
11+
* included in all copies or substantial portions of the software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19+
*/
20+
21+
namespace Facebook.Unity
22+
{
23+
internal class SoftKeyboardOpenResult : ResultBase, ISoftKeyboardOpenResult
24+
{
25+
internal SoftKeyboardOpenResult(ResultContainer resultContainer) : base(resultContainer)
26+
{
27+
if (this.ResultDictionary != null)
28+
{
29+
string success;
30+
if (this.ResultDictionary.TryGetValue("success", out success))
31+
{
32+
this.Success = success;
33+
}
34+
}
35+
}
36+
37+
public string Success { get; private set; }
38+
}
39+
}

Facebook.Unity/Windows/IWindowsFacebook.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ namespace Facebook.Unity.Windows
2323
internal interface IWindowsFacebook : IPayFacebook, IFacebook
2424
{
2525
void SetVirtualGamepadLayout(string layout, FacebookDelegate<IVirtualGamepadLayoutResult> callback);
26+
27+
void SetSoftKeyboardOpen(bool open, FacebookDelegate<ISoftKeyboardOpenResult> callback);
2628
}
2729
}

Facebook.Unity/Windows/IWindowsWrapper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ internal interface IWindowsWrapper
8080
void SetVirtualGamepadLayout(string layout, string callbackId, CallbackManager callbackManager);
8181

8282
void GetUserLocale(string callbackId, CallbackManager callbackManager);
83+
84+
void SetSoftKeyboardOpen(bool open, string callbackId, CallbackManager callbackManager);
8385
}
8486
}

Facebook.Unity/Windows/WindowsFacebook.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ public void SetVirtualGamepadLayout(string layout, FacebookDelegate<IVirtualGame
281281
this.windowsWrapper.SetVirtualGamepadLayout(layout, this.CallbackManager.AddFacebookDelegate(callback), this.CallbackManager);
282282
}
283283

284+
public void SetSoftKeyboardOpen(bool open, FacebookDelegate<ISoftKeyboardOpenResult> callback)
285+
{
286+
this.windowsWrapper.SetSoftKeyboardOpen(open, this.CallbackManager.AddFacebookDelegate(callback), this.CallbackManager);
287+
}
288+
284289
// Not supported by Windows SDK
285290
public override void AppRequest(string message, OGActionType? actionType, string objectId, IEnumerable<string> to, IEnumerable<object> filters, IEnumerable<string> excludeIds, int? maxRecipients, string data, string title, FacebookDelegate<IAppRequestResult> callback)
286291
{

0 commit comments

Comments
 (0)