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

View File

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

View File

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