Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
olga-salina committed Sep 11, 2024
2 parents aa9e39e + 5f2bf9f commit 71a8b2b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 15 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Changelog
## [6.0.10] - Login SDK - 2024-09-11
### Changed
- `authenticateViaDeviceId` SDK method. Added `deviceId` optional parameter.

### Fixed
- Fixed an issue when the login via `startSocialAuth` or `startAuthWithXsollaWidget` methods displayed an error in WebView.

## [2.2.14] - Demo Apps - 2024-09-11
### Fixed
- Fixed an inaccurate error message after registration.

## [2.5.10] - Store SDK - 2024-08-21
### Changed
- `createOrderFromCartById`, `createOrderFromCurrentCart`, and `createOrderByItemSku` SDK methods. Added an optional parameter `externalTransactionToken`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SignUpFragment : BaseFragment() {
}

override fun onError(throwable: Throwable?, errorMessage: String?) {
showSnack(throwable?.javaClass?.name ?: errorMessage ?: "Error")
showSnack(errorMessage ?: throwable?.javaClass?.name ?: "Error")
v.isEnabled = true
}
})
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ buildscript {
ext.payments_sdk_version_name = '1.4.1'
ext.store_sdk_version_name = '2.5.10'
ext.inventory_sdk_version_name = '2.0.4'
ext.login_sdk_version_name = '6.0.9'
ext.login_sdk_version_name = '6.0.10'

ext.googleplay_sdk_version_name = "0.0.1"

ext.sample_app_version_name = '2.2.13'
ext.sample_app_version_code = 42
ext.sample_app_version_name = '2.2.14'
ext.sample_app_version_code = 43

ext.sdk_min = 21
ext.sdk_target = 33
Expand Down
35 changes: 30 additions & 5 deletions xsolla-login-sdk/src/main/java/com/xsolla/android/login/XLogin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -411,22 +411,32 @@ class XLogin private constructor(
* Authenticates the user via a particular device ID.
*
* @param callback Status callback.
* @param deviceId Platform specific unique device ID (optional). If not passed, the 'Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)' platform parameter is used.
*
* @see [More about the use cases](https://developers.xsolla.com/sdk/android/authentication/auth-via-device-id/).
*/
@SuppressLint("HardwareIds")
@JvmStatic
fun authenticateViaDeviceId(
callback: AuthViaDeviceIdCallback
callback: AuthViaDeviceIdCallback,
deviceId: String? = null
) {
runIo {
runBlocking {
val body = AuthViaDeviceIdBody(
device = Build.MANUFACTURER + " " + Build.MODEL,
deviceId = Settings.Secure.getString(
var resultDeviceId: String = if(deviceId == null) {
Settings.Secure.getString(
getInstance().context.contentResolver,
Settings.Secure.ANDROID_ID
)
} else {
deviceId!!
}

resultDeviceId = getSafeDeviceId(resultDeviceId)

val body = AuthViaDeviceIdBody(
device = Build.MANUFACTURER + " " + Build.MODEL,
deviceId = resultDeviceId
)
try {
val res = XLoginApi.loginApi.authViaDeviceId(
Expand Down Expand Up @@ -1589,7 +1599,7 @@ class XLogin private constructor(
*
* @param socialNetwork Name of a social network. Provider must be connected to Login in Publisher Account.
* Can be `amazon`, `apple`, `baidu`, `battlenet`, `discord`, `facebook`, `github`, `google`, `instagram`, `kakao`, `linkedin`, `mailru`, `microsoft`, `msn`, `naver`, `ok`, `paradox`, `paypal`, `psn`, `qq`, `reddit`, `steam`, `twitch`, `twitter`, `vimeo`, `vk`, `wechat`, `weibo`, `yahoo`, `yandex`, `youtube`, `xbox`, `playstation`.
* @param callback Callback that indicates the success of failure of an action.
* @param callback Callback that indicates the success of failure of an action.
*/
@JvmStatic
fun unlinkSocialNetwork(
Expand Down Expand Up @@ -1763,5 +1773,20 @@ class XLogin private constructor(
return resultUrl
}

@JvmStatic
fun getSafeDeviceId(deviceId: String): String {

var resultDeviceId = deviceId
val minDeviceIdLength = 16
val maxDeviceIdLength = 36

if(deviceId.length < minDeviceIdLength) {
resultDeviceId = deviceId.padStart(minDeviceIdLength,'0')
} else if(deviceId.length > maxDeviceIdLength) {
resultDeviceId = deviceId.substring(0, maxDeviceIdLength)
}

return resultDeviceId
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,12 @@ internal class ActivityAuthWebView : ActivityAuth() {
webView.webViewClient = object : WebViewClient() {
@Deprecated("Deprecated in Java")
override fun shouldOverrideUrlLoading(webView: WebView, url: String): Boolean {
webView.loadUrl(url)
return true
}

override fun doUpdateVisitedHistory(view: WebView, url: String, isReload: Boolean) {
if (url.startsWith(callbackUrl)) {
handleCallbackUrlRedirect(Uri.parse(url))
return true
}
super.doUpdateVisitedHistory(view, url, isReload)
webView.loadUrl(url)
return true
}
}
}
Expand Down

0 comments on commit 71a8b2b

Please sign in to comment.