This commit is contained in:
CounterFire2023 2023-11-06 17:56:00 +08:00
parent 92cf4860f8
commit e7d518e406
3 changed files with 9 additions and 11 deletions

View File

@ -49,7 +49,6 @@ import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener
import org.cocos2dx.lib.CocosJSHelper
import org.json.JSONException
import org.json.JSONObject
import java.io.File
import java.util.Arrays
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
@ -202,7 +201,7 @@ class MainActivity : UnityPlayerActivity(), Cocos2dxHelperListener {
} else {
Log.w(
TAG,
"already login, accessToken not expired, id token:: " + state.idToken
"already login, accessToken not expired, id token:: ${state.idToken}"
)
JcSDK.nativeCb(this.funId, null, state.idToken)
}
@ -221,7 +220,7 @@ class MainActivity : UnityPlayerActivity(), Cocos2dxHelperListener {
try {
val account = completedTask.getResult(ApiException::class.java)
Log.w(TAG, "signIn success: ")
Log.w(TAG, "gsa idToken: " + account.idToken)
Log.w(TAG, "gsa idToken: ${account.idToken}")
JcSDK.nativeCb(funId, null, account.idToken)
// Signed in successfully, show authenticated UI.
} catch (e: ApiException) {
@ -406,10 +405,10 @@ class MainActivity : UnityPlayerActivity(), Cocos2dxHelperListener {
}
fun storagePass(funID: String?, account: String?, password: String?) {
Log.i(TAG, String.format("storagePass with: %s | %s", funID, account))
Log.i(TAG, "storagePass with: $funID | $account")
funId = funID
mWalletUtil!!.updateParams(funID, account)
mWalletUtil!!.savePassToLocal(password) { _file: File? ->
mWalletUtil!!.savePassToLocal(password) {
if (isGooglePlayServicesAvailable) {
if (!GoogleSignIn.hasPermissions(
GoogleSignIn.getLastSignedInAccount(Cocos2dxHelper.getActivity()),
@ -469,7 +468,7 @@ class MainActivity : UnityPlayerActivity(), Cocos2dxHelperListener {
) {
loginAndRequestDrivePermission(RC_REQUEST_DRIVE_TO_READ)
} else {
mWalletUtil!!.downloadCfgWithGPS { _file: File? -> mWalletUtil!!.passLocal }
mWalletUtil!!.downloadCfgWithGPS { mWalletUtil!!.passLocal }
}
} else {
mWalletUtil!!.passLocal
@ -483,7 +482,7 @@ class MainActivity : UnityPlayerActivity(), Cocos2dxHelperListener {
if (state.isAuthorized) {
if (state.needsTokenRefresh) {
Log.d(TAG, "need refresh accessToken")
mAppAuthSvr!!.refreshToken(funID) { _result: String? ->
mAppAuthSvr!!.refreshToken(funID) {
mWalletUtil!!.downloadCfgWithApi(
state.accessToken
) { mWalletUtil!!.passLocal }
@ -517,7 +516,7 @@ class MainActivity : UnityPlayerActivity(), Cocos2dxHelperListener {
}
fun getClientId(funID: String?) {
Log.i(TAG, "getClientId ")
Log.i(TAG, "getClientId with funId: $funID")
}
companion object {

View File

@ -34,9 +34,9 @@ import org.json.JSONException
import org.json.JSONObject
import java.util.function.Consumer
const val FUNID_PREFIX = "webpage_"
class WebPageActivity : Activity() {
private var mWebView: WebView? = null
private val FUNID_PREFIX = "webpage_"
private val actionMap: MutableMap<String, Consumer<JSONObject>> = Maps.newHashMap()
@SuppressLint("SetJavaScriptEnabled", "DefaultLocale")
override fun onCreate(savedInstanceState: Bundle?) {
@ -50,7 +50,6 @@ class WebPageActivity : Activity() {
webSettings?.domStorageEnabled = true
webSettings?.databaseEnabled = true
webSettings?.allowContentAccess = true
webSettings?.setAppCacheEnabled(true)
webSettings?.builtInZoomControls = true
webSettings?.useWideViewPort = true
webSettings?.loadWithOverviewMode = true

View File

@ -34,7 +34,7 @@ class WalletUtil(private val mContext: Context) {
account = null
}
public fun errorCB(msg: String?) {
fun errorCB(msg: String?) {
JcSDK.nativeCb(funID, msg, null)
clearParams()
}