From ea5f274f6344c0545461f7443a73bb0659c5a57c Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 21 Mar 2023 15:17:44 +0800 Subject: [PATCH] remove conflicted file --- app/build.gradle | 12 +++++-- app/google-services.json | 2 +- .../com/cege/games/release/MainActivity.java | 20 +++++++++++- app/src/com/jc/jcfw/JcSDK.java | 4 +++ app/src/com/jc/jcfw/util/JsonUtils.java | 31 +++++++++++++++++++ build.gradle | 1 + res/values/strings.xml | 2 +- 7 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 app/src/com/jc/jcfw/util/JsonUtils.java diff --git a/app/build.gradle b/app/build.gradle index ee25b6f..83fbbd7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,11 @@ import org.apache.tools.ant.taskdefs.condition.Os -apply plugin: 'com.android.application' - +//apply plugin: 'com.android.application' +plugins { + id 'com.android.application' + // Add the Google services Gradle plugin + id 'com.google.gms.google-services' +} android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() buildToolsVersion PROP_BUILD_TOOLS_VERSION @@ -139,4 +143,8 @@ dependencies { implementation 'com.google.android.play:core:1.10.0' //PAD资源分发 implementation 'com.facebook.android:facebook-login:latest.release' implementation 'com.facebook.android:facebook-share:latest.release' + // begin of firebase + implementation platform('com.google.firebase:firebase-bom:31.2.2') + implementation 'com.google.firebase:firebase-analytics' + // end of firebase } \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json index 325beca..db99d61 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -7,7 +7,7 @@ "client": [ { "client_info": { - "mobilesdk_app_id": "1:977053300219:android:556f8ae1bb64b47041c75e", + "mobilesdk_app_id": "1:977053300219:android:921a89f1a9a058bd41c75e", "android_client_info": { "package_name": "com.cege.games.release" } diff --git a/app/src/com/cege/games/release/MainActivity.java b/app/src/com/cege/games/release/MainActivity.java index 844d516..9abdb16 100644 --- a/app/src/com/cege/games/release/MainActivity.java +++ b/app/src/com/cege/games/release/MainActivity.java @@ -39,10 +39,12 @@ import com.google.android.gms.common.Scopes; import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.Scope; import com.google.android.gms.tasks.Task; +import com.google.firebase.analytics.FirebaseAnalytics; import com.jc.jcfw.JcSDK; import com.jc.jcfw.appauth.AuthStateManager; import com.jc.jcfw.appauth.JConfiguration; import com.jc.jcfw.util.FileUtils; +import com.jc.jcfw.util.JsonUtils; import com.king.zxing.CameraScan; import com.king.zxing.util.CodeUtils; import com.king.zxing.util.LogUtils; @@ -67,9 +69,12 @@ import net.openid.appauth.browser.BrowserMatcher; import org.cocos2dx.lib.Cocos2dxHelper; import org.cocos2dx.lib.CocosJSHelper; +import org.json.JSONException; +import org.json.JSONObject; import java.util.Arrays; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -139,6 +144,8 @@ public class MainActivity extends UnityPlayerActivity // facebook login private CallbackManager mCallbackManager; + private FirebaseAnalytics mFirebaseAnalytics; + protected String updateUnityCommandLineArguments(String cmdLine) { return cmdLine; } @@ -148,6 +155,8 @@ public class MainActivity extends UnityPlayerActivity requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); Log.i(TAG, "onCreate: " + getIntent().getDataString()); + // Obtain the FirebaseAnalytics instance. + mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); String cmdLine = updateUnityCommandLineArguments(getIntent().getStringExtra("unity")); getIntent().putExtra("unity", cmdLine); @@ -159,7 +168,7 @@ public class MainActivity extends UnityPlayerActivity // begin of google sign GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) - .requestIdToken(getString(R.string.default_web_client_id)) + .requestIdToken(getString(R.string.default_web_client_id1)) .requestScopes(new Scope(Scopes.EMAIL)) // .requestScopes(new Scope("https://www.googleapis.com/auth/drive.appdata")) .build(); @@ -838,4 +847,13 @@ public class MainActivity extends UnityPlayerActivity Log.i(TAG, "login with twitter: " + funId); this.funId = funId; } + + public void logEvent(String content) { + try { + Bundle bundle = JsonUtils.convertJsonToBundle(content); + mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle); + } catch (JSONException e) { + Log.e(TAG, "log event JSONException: " + e.getMessage()); + } + } } \ No newline at end of file diff --git a/app/src/com/jc/jcfw/JcSDK.java b/app/src/com/jc/jcfw/JcSDK.java index 9d81329..9147c74 100644 --- a/app/src/com/jc/jcfw/JcSDK.java +++ b/app/src/com/jc/jcfw/JcSDK.java @@ -98,6 +98,10 @@ public class JcSDK { MainActivity.app.signOutGoogle(funid); } + public static void logEvent(String content) { + MainActivity.app.logEvent(content); + } + public static void oauthCb(String funId, String error, String idToken) { JSONObject result = new JSONObject(); try { diff --git a/app/src/com/jc/jcfw/util/JsonUtils.java b/app/src/com/jc/jcfw/util/JsonUtils.java new file mode 100644 index 0000000..2c9d2fc --- /dev/null +++ b/app/src/com/jc/jcfw/util/JsonUtils.java @@ -0,0 +1,31 @@ +package com.jc.jcfw.util; + +import android.os.Bundle; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.Iterator; + +public class JsonUtils { + public static Bundle convertJsonToBundle(String jsonString) throws JSONException { + Bundle bundle = new Bundle(); + JSONObject jsonObject = new JSONObject(jsonString); + traverseJsonObject(jsonObject, bundle); + return bundle; + } + + public static void traverseJsonObject(JSONObject jsonObject, Bundle bundle) throws JSONException { + Iterator keys = jsonObject.keys(); + while (keys.hasNext()) { + String key = keys.next(); + Object value = jsonObject.get(key); +// if (value instanceof JSONObject) { +// traverseJsonObject((JSONObject) value, bundle); +// } else { +// bundle.putString(key, value.toString()); +// } + bundle.putString(key, value.toString()); + } + } +} diff --git a/build.gradle b/build.gradle index 9052fd9..c138d6f 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ buildscript { // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files + classpath 'com.google.gms:google-services:4.3.15' } } diff --git a/res/values/strings.xml b/res/values/strings.xml index a3625f3..b3df80b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3,7 +3,7 @@ Game view Scan QRCode need camera permission QRCode - 53206975661-ih3r0ubph3rqejdq97b029difbrk2bqj.apps.googleusercontent.com + 53206975661-ih3r0ubph3rqejdq97b029difbrk2bqj.apps.googleusercontent.com 1204701000119770