Commit a27810f4 authored by 王雪伟's avatar 王雪伟

[提交人]:王雪伟

[提交简述] :接入归因SDK和登录
[实现方案] :接入appsflayer接入原生登录和Facebook登录
parent f3b79299
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.mob.sdk'
//apply plugin: 'com.mob.sdk'
apply plugin: 'kotlin-android-extensions'
android {
......@@ -63,37 +63,6 @@ android {
}
}
// MobSDK {
// appKey "357874b62b4c7"
// appSecret "c4d82ff12e0cde832960ddbb8d2d7250"
// gui false
// version '3.9.7'
// ShareSDK {
// loopShare true
// devInfo {
// Facebook {
// id 8
// sortId 8
// appKey "662970168312513"
// callbackUri "https://www.baidu.com"
// officialVersion "default"
// faceBookLoginProtocolScheme "fb662970168312513"
// shareByAppClient true
// enable true
// }
// GooglePlus {
// id 21
// sortId 21
// appId "236300675100-am5pm8km7md1memjevq8rl9pg5c4s4b8.apps.googleusercontent.com"
// callbackUri "http://localhost"
// officialVersion "default"
// shareByAppClient true
// enable true
// }
//
// }
// }
// }
productFlavors {
guanwang {}
......
......@@ -27,6 +27,8 @@
<!-- GooglePay-->
<uses-permission android:name="com.android.vending.BILLING" />
<uses-sdk tools:overrideLibrary="com.bun.miitmdid" />
<application
......@@ -96,6 +98,7 @@
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>
\ No newline at end of file
......@@ -2,7 +2,7 @@ package com.zhangxin.magicbox
import android.app.Application
import android.text.TextUtils
import com.mob.MobSDK
import com.appsflyer.AppsFlyerLib
import com.paypal.checkout.PayPalCheckout
import com.paypal.checkout.config.CheckoutConfig
import com.paypal.checkout.config.Environment
......@@ -15,12 +15,14 @@ import com.zxhl.cms.common.ApplicationAsLibrary
import com.zxhl.cms.common.Config
import com.zxhl.cms.common.Constant
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.EventUtils.onEvent
import com.zxhl.cms.utils.MiitHelper
import com.zxhl.cms.utils.TTAdManagerHolder
import com.zxhl.cms.utils.Utils
import java.util.*
/**
* Created by gaoleichao on 2018/12/26
*/
......@@ -36,27 +38,40 @@ class Appli : Application() {
Config.init(this)
getOaid()
initByteDance()
MobSDK.submitPolicyGrantResult(true, null)
MobSDK.init(this)
// MobSDK.submitPolicyGrantResult(true, null)
// MobSDK.init(this)
initPayPal()
initAppsFlyer()
}
private fun initAppsFlyer() {
val afDevKey = "bbVuECGrv5oci77w97NMVg"
val appsflyer: AppsFlyerLib = AppsFlyerLib.getInstance()
// For debug - remove in production
appsflyer.setDebugLog(true)
//optional
appsflyer.setMinTimeBetweenSessions(0)
appsflyer.init(afDevKey, null, this)
appsflyer.start(this)
}
private fun initPayPal() {
val config = CheckoutConfig(
application = this,
clientId = Constant.PAY_PAL_CLIENT_ID,
environment = Environment.SANDBOX,//正式上线后,改为Environment.LIVE
environment = Environment.LIVE,//正式上线后,改为Environment.LIVE
returnUrl = "com.zhangxin.magicbox://paypalpay",//创建应用时填的RETURN_URL
currencyCode = CurrencyCode.USD,//货币种类:CNY-人民币;HKD-港币;TWD-新台币;USD-美元...
userAction = UserAction.PAY_NOW,
settingsConfig = SettingsConfig(
loggingEnabled = true,
loggingEnabled = false,
shouldFailEligibility = false
)
)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
PayPalCheckout.setConfig(config)
}
EventUtils
}
private fun getOaid() {
......
PACKAGE_NAME=com.zhangxin.magicbox
VERSION_CODE=8
VERSION_NAME=1.0.3.1
\ No newline at end of file
VERSION_CODE=10
VERSION_NAME=1.0.3.2
\ No newline at end of file
......@@ -4,22 +4,23 @@ buildscript {
ext.kotlin_version = '1.4.32'
// ext.kotlin_version = '1.6.20-RC'
repositories {
maven {
url "https://mvn.mob.com/android"
}
// maven {
// url "https://mvn.mob.com/android"
// }
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
classpath "com.mob.sdk:MobSDK:2018.0319.1724"
// classpath "com.mob.sdk:MobSDK:2018.0319.1724"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
// configurations.all {
// resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
// }
}
}
......
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.mob.sdk'
//apply plugin: 'com.mob.sdk'
apply plugin: 'kotlin-android-extensions'
android {
......@@ -33,38 +33,38 @@ android {
}
}
MobSDK {
appKey "//357874b62b4c7"
appSecret "c4d82ff12e0cde832960ddbb8d2d7250"
gui false
version '3.9.7'
appBundleMode true
ShareSDK {
loopShare true
devInfo {
Facebook {
id 8
sortId 8
appKey "1156014961815312"
callbackUri "https://www.baidu.com"
officialVersion "default"
faceBookLoginProtocolScheme "fb1156014961815312"
shareByAppClient true
enable true
}
GooglePlus {
id 21
sortId 21
appId "236300675100-am5pm8km7md1memjevq8rl9pg5c4s4b8.apps.googleusercontent.com"
callbackUri "http://localhost"
officialVersion "default"
shareByAppClient true
enable true
}
}
}
}
// MobSDK {
// appKey "//357874b62b4c7"
// appSecret "c4d82ff12e0cde832960ddbb8d2d7250"
// gui false
// version '3.9.7'
// appBundleMode false
// ShareSDK {
// loopShare true
// devInfo {
// Facebook {
// id 8
// sortId 8
// appKey "1156014961815312"
// callbackUri "https://www.baidu.com"
// officialVersion "default"
// faceBookLoginProtocolScheme "fb1156014961815312"
// shareByAppClient true
// enable true
// }
// GooglePlus {
// id 21
// sortId 21
// appId "236300675100-am5pm8km7md1memjevq8rl9pg5c4s4b8.apps.googleusercontent.com"
// callbackUri "http://localhost"
// officialVersion "default"
// shareByAppClient true
// enable true
// }
//
// }
// }
// }
kotlinOptions {
jvmTarget = "1.8"
......@@ -128,10 +128,17 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
//FaceBookLogin
api 'com.facebook.android:facebook-login:latest.release'
//GoogleLogin
implementation 'com.google.android.gms:play-services-auth:20.1.0'
//GooglePay
implementation("com.android.billingclient:billing:4.1.0")
//PayPal支付
api 'com.paypal.checkout:android-sdk:0.6.0'
// api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10"
// api "androidx.core:core-ktx:1.6.0"
//归因
api 'com.appsflyer:af-android-sdk:6.3.2'
api("com.android.installreferrer:installreferrer:2.2")
}
......@@ -42,6 +42,28 @@
<meta-data
android:name="UMENG_CHANNEL"
android:value="${UMENG_CHANNEL_VALUE}" />
<!-- FaceBook-->
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="@string/facebook_client_token" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
......@@ -48,7 +48,7 @@ object ApiClient {
}
.addInterceptor(paramsInterceptor)
.addInterceptor(headInterceptor)
.build()!!
.build()
private val retrofit = retrofit2.Retrofit.Builder()
.client(httpClient)
......
......@@ -3,6 +3,8 @@ package com.zxhl.cms.utils
import android.content.Context
import android.text.TextUtils
import android.util.Log
import com.appsflyer.AppsFlyerLib
import com.appsflyer.attribution.AppsFlyerRequestListener
import com.umeng.analytics.MobclickAgent
import com.zxhl.cms.AppContext
import com.zxhl.cms.net.ApiClient
......@@ -38,6 +40,7 @@ object EventUtils {
fun onEvent(action: String) {
val jsonObj = getJSON(action)
apiClient(jsonObj)
appFlayerEvent(action,"")
// MobclickAgent.onEvent(AppContext.get(), action)
}
......@@ -45,12 +48,11 @@ object EventUtils {
val jsonObj = getJSON(action)
jsonObj.put("value", value)
apiClient(jsonObj)
appFlayerEvent(action,value)
// MobclickAgent.onEvent(AppContext.get(), action, value)
}
// /**
// * 统计新用户首次登陆 男女生
// */
......@@ -62,8 +64,6 @@ object EventUtils {
private var time: Long = 0
fun getJSON(action: String): JSONObject {
var data = JSONObject()
data.put("event", EVENT)
......@@ -77,20 +77,20 @@ object EventUtils {
val key = AESUtils.encrypt(str)
Log.d("EventUtils", key)
EventApiClient.cfgApi.requestEvent("behavior", key).subscribeOn(Schedulers.io())
.subscribe(object : Observer<Any> {
override fun onComplete() {
.subscribe(object : Observer<Any> {
override fun onComplete() {
}
}
override fun onSubscribe(d: Disposable) {
}
override fun onSubscribe(d: Disposable) {
}
override fun onNext(t: Any) {
}
override fun onNext(t: Any) {
}
override fun onError(e: Throwable) {
}
})
override fun onError(e: Throwable) {
}
})
}
fun apiAppUpload(module: String, event: String, data: JSONObject) {
......@@ -100,20 +100,36 @@ object EventUtils {
val key = AESUtils.encrypt(str)
LogUtils.d("EventUtils", key)
EventApiClient.cfgApi.requestEvent(module, key).subscribeOn(Schedulers.io())
.subscribe(object : Observer<Any> {
override fun onComplete() {
.subscribe(object : Observer<Any> {
override fun onComplete() {
}
override fun onSubscribe(d: Disposable) {
}
override fun onNext(t: Any) {
}
override fun onError(e: Throwable) {
}
})
}
}
override fun onSubscribe(d: Disposable) {
}
fun appFlayerEvent(action: String, value: String) {
var eventValues = HashMap<String, Any>()
eventValues[action] = value
AppsFlyerLib.getInstance().logEvent(AppContext.get(), action, eventValues,object :AppsFlyerRequestListener{
override fun onSuccess() {
Log.e("appsflyer","onSuccess")
}
override fun onNext(t: Any) {
}
override fun onError(p0: Int, p1: String) {
Log.e("appsflyer","p0 $p0 p1 $p1")
}
override fun onError(e: Throwable) {
}
})
})
}
}
\ No newline at end of file
package com.zxhl.cms.utils
import android.app.Activity
import android.content.Intent
import android.os.Handler
import android.util.Log
import com.facebook.*
import com.facebook.login.LoginManager
import com.facebook.login.LoginResult
import com.zxhl.cms.common.Constant
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.other.WxBindEntity
/**
* @author (wangXuewei)
* @datetime 2022-03-26 11:04 GMT+8
* @detail :
*/
class FaceBookLoginUtil {
private val TAG = "FaceBookLoginUtil"
private var mActivity: Activity;
private var mLoginCallBack: LoginCallBack? = null;
private var callbackManager: CallbackManager? = null;
constructor(mActivity: Activity) {
this.mActivity = mActivity
}
interface LoginCallBack {
fun onLoginSuccess()
fun onLoginError(errorMsg: String)
}
fun init() {
callbackManager = CallbackManager.Factory.create()
LoginManager.getInstance().registerCallback(callbackManager,
object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
//延时500毫秒获取信息,不然获取不到
val handler = Handler()
handler.postDelayed(
{
val accessToken = loginResult.accessToken
val profile = Profile.getCurrentProfile()
if (profile != null) {
bindFaceBookLogin(
accessToken.userId,
profile.name,
profile.getProfilePictureUri(
200,
200
).toString()
)
} else {
mLoginCallBack?.onLoginError("Success_未获取到登录信息")
}
}, 500
)
}
override fun onCancel() {
mLoginCallBack?.onLoginError("FaceBookLoginCancel")
}
override fun onError(exception: FacebookException) {
mLoginCallBack?.onLoginError("FaceBookLogin error:" + exception.message)
}
})
}
/**
* faceBook登录
*/
fun faceBookLogin(callBack: LoginCallBack) {
mLoginCallBack = callBack;
val accessToken = AccessToken.getCurrentAccessToken()
val profile = Profile.getCurrentProfile()
if (accessToken != null && !accessToken.isExpired && profile != null) {
bindFaceBookLogin(
accessToken.userId,
profile.name,
profile.getProfilePictureUri(200, 200).toString()
)
} else {
LoginManager.getInstance()
.logInWithReadPermissions(mActivity, listOf("public_profile"));
}
}
/**
* Activity 重写
* */
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
callbackManager?.onActivityResult(requestCode, resultCode, data)
}
/**
* faceBook 绑定后端服务器
* */
private fun bindFaceBookLogin(userId: String?, userName: String?, picture: String?) {
ApiClient.homeApi.authFaceBookLogin(userId, userName, picture)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<WxBindEntity>() {
override fun onSuccess(result: WxBindEntity?) {
SettingPreference.saveToken(result?.token)
UserDataUtils.updateUserInfo(null)
Constant.Switch.isLogin = true
mLoginCallBack?.onLoginSuccess()
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
// callBack.loginSuccess(lottery)
mLoginCallBack?.onLoginError("net code:$code msg:$errorMsg")
}
})
}
/**
* 退出登录
*/
fun signOut() {
}
/**
* 断开链接
*/
fun revokeAccess() {
}
}
\ No newline at end of file
package com.zxhl.cms.utils
import android.app.Activity
import android.content.Intent
import android.util.Log
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.gms.common.api.ApiException
import com.google.android.gms.tasks.OnCompleteListener
import com.google.android.gms.tasks.Task
import com.zxhl.cms.common.Constant
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.other.WxBindEntity
/**
* @author (wangXuewei)
* @datetime 2022-03-25 14:04 GMT+8
* @detail :
*/
class GoogleLoginUtil {
private val TAG = "GoogleLoginUtil"
private val RC_SIGN_IN = 9009
private val googleClientId =
"535211515800-fcblld827b8ojq7dccuohmeo199205ce.apps.googleusercontent.com"
private var mActivity: Activity;
private var mGoogleSignInClient: GoogleSignInClient? = null;
private var mLoginCallBack: LoginCallBack? = null;
constructor(mActivity: Activity) {
this.mActivity = mActivity
}
interface LoginCallBack {
fun onLoginSuccess()
fun onLoginError(errorMsg: String)
}
fun init() {
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(googleClientId)
.requestId()
.requestProfile()
.build()
mGoogleSignInClient = GoogleSignIn.getClient(mActivity, gso);
}
/**
* google登录
*/
fun googleLogin(callBack: LoginCallBack) {
mLoginCallBack = callBack;
val account = GoogleSignIn.getLastSignedInAccount(mActivity)
if (account != null) {
bindGoogle(account.id, account.displayName, account.photoUrl.toString())
} else {
mActivity.runOnUiThread {
val signInIntent = mGoogleSignInClient?.signInIntent
mActivity.startActivityForResult(signInIntent, RC_SIGN_IN)
}
}
}
/**
* Activity 重写
* */
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
if (requestCode === RC_SIGN_IN) {
// The Task returned from this call is always completed, no need to attach
// a listener.
val task: Task<GoogleSignInAccount> = GoogleSignIn.getSignedInAccountFromIntent(data)
handleSignInResult(task)
}
}
private fun handleSignInResult(completedTask: Task<GoogleSignInAccount>) {
try {
// Signed in successfully, show authenticated UI.
val account = completedTask.getResult(ApiException::class.java)
if (account != null) {
bindGoogle(account.id, account.displayName, account.photoUrl.toString())
} else {
mLoginCallBack?.onLoginError("code:-2 msg:account is null")
}
} catch (e: ApiException) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
mLoginCallBack?.onLoginError("code:${e.statusCode} msg:${e.message}")
}
}
/**
* 绑定后端服务器
* */
private fun bindGoogle(userId: String?, userName: String?, picture: String?) {
ApiClient.homeApi.authGoogleLogin(userId, userName, picture)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<WxBindEntity>() {
override fun onSuccess(result: WxBindEntity?) {
SettingPreference.saveToken(result?.token)
UserDataUtils.updateUserInfo(null)
Constant.Switch.isLogin = true
mLoginCallBack?.onLoginSuccess()
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
// callBack.loginSuccess(lottery)
mLoginCallBack?.onLoginError("net code:$code msg:$errorMsg")
}
})
}
/**
* 退出登录
*/
fun signOut() {
mGoogleSignInClient?.signOut()
?.addOnCompleteListener(mActivity) {
// ...
//it.result
}
}
/**
* 断开链接
*/
fun revokeAccess() {
mGoogleSignInClient?.revokeAccess()
?.addOnCompleteListener(mActivity) {
// ...
}
}
}
\ No newline at end of file
......@@ -3,15 +3,8 @@ package com.zxhl.cms.utils
import android.app.Activity
import android.content.Context
import android.util.Log
import android.widget.Toast
import cn.sharesdk.facebook.Facebook
import cn.sharesdk.framework.Platform
import cn.sharesdk.framework.PlatformActionListener
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.google.GooglePlus
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.Constant
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
......@@ -157,29 +150,29 @@ class WeChatUtils {
fun FackBooklogin() {
val plat = ShareSDK.getPlatform(Facebook.NAME)
//授权回调监听,监听oncomplete,onerror,oncancel三种状态
plat.platformActionListener = object : PlatformActionListener {
override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) {
Log.e("MXL", "Data:" + p0?.db?.exportData() + "Image:" + p0?.db?.userIcon)
bindFaceBookLogin(p0?.db?.userId, p0?.db?.userName, p0?.db?.userIcon)
EventUtils.onEvent("FackBookloginSuccess")
}
override fun onError(arg0: Platform, arg1: Int, arg2: Throwable) {
//失败的回调,arg:平台对象,arg1:表示当前的动作(8:有用户信息登录, 1:无用户信息登录),arg2:异常信息
Log.e("MXL", "FaceBook:onError" + arg2.printStackTrace())
EventUtils.onEvent("FackBookloginError", "arg1" + arg1 + " arg2" + arg2.message+" arg2:"+arg2.printStackTrace())
}
override fun onCancel(arg0: Platform, arg1: Int) {
//取消分享的回调
Log.e("MXL", "FaceBook:onCancel")
EventUtils.onEvent("FackBookloginCancel")
}
}
plat.showUser(null)
// val plat = ShareSDK.getPlatform(Facebook.NAME)
////授权回调监听,监听oncomplete,onerror,oncancel三种状态
// plat.platformActionListener = object : PlatformActionListener {
// override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) {
// Log.e("MXL", "Data:" + p0?.db?.exportData() + "Image:" + p0?.db?.userIcon)
// bindFaceBookLogin(p0?.db?.userId, p0?.db?.userName, p0?.db?.userIcon)
// EventUtils.onEvent("FackBookloginSuccess")
// }
//
// override fun onError(arg0: Platform, arg1: Int, arg2: Throwable) {
// //失败的回调,arg:平台对象,arg1:表示当前的动作(8:有用户信息登录, 1:无用户信息登录),arg2:异常信息
// Log.e("MXL", "FaceBook:onError" + arg2.printStackTrace())
// EventUtils.onEvent("FackBookloginError", "arg1" + arg1 + " arg2" + arg2.message+" arg2:"+arg2.printStackTrace())
// }
//
// override fun onCancel(arg0: Platform, arg1: Int) {
// //取消分享的回调
// Log.e("MXL", "FaceBook:onCancel")
// EventUtils.onEvent("FackBookloginCancel")
//
// }
// }
// plat.showUser(null)
}
fun bindFaceBookLogin(userId: String?, userName: String?, picture: String?) {
......@@ -204,43 +197,47 @@ class WeChatUtils {
}
fun GoogleLogin() {
// MobSDK.submitPolicyGrantResult(true, null)
val plat = ShareSDK.getPlatform(GooglePlus.NAME)
ShareSDK.setActivity(mContext as Activity)
//授权回调监听,监听oncomplete,onerror,oncancel三种状态
plat.platformActionListener = object : PlatformActionListener {
override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) {
Log.e("MXL", "onComplete" + p0?.db?.userIcon + p0?.db?.userId)
Log.e("MXL", "Data:" + p0?.db?.exportData())
if (p2 != null) {
val g = Gson()
val obj: JsonObject = g.fromJson(p0?.db?.exportData(), JsonObject::class.java)
Log.e("MXL", "PIC:" + obj.get("picture"))
val pic = obj.get("picture").toString().replace("\"", "")
Log.e("MXL", "image:" + pic)
bindGoogle(p0?.db?.userId, p0?.db?.userName, pic)
EventUtils.onEvent("GoogleLoginSuccess")
}
}
override fun onError(arg0: Platform, arg1: Int, arg2: Throwable) {
//失败的回调,arg:平台对象,arg1:表示当前的动作(8:有用户信息登录, 1:无用户信息登录),arg2:异常信息
Log.e("MXL", "onError" + arg2.printStackTrace())
Log.e("MXL", "onError" + arg2.message)
EventUtils.onEvent("GoogleLoginError", "arg1" + arg1 + " arg2" + arg2.message+" arg2:"+arg2.printStackTrace())
}
override fun onCancel(arg0: Platform, arg1: Int) {
//取消分享的回调
Log.e("MXL", "onCancel")
EventUtils.onEvent("GoogleLoginCancel")
// // MobSDK.submitPolicyGrantResult(true, null)
// val plat = ShareSDK.getPlatform(GooglePlus.NAME)
// ShareSDK.setActivity(mContext as Activity)
////授权回调监听,监听oncomplete,onerror,oncancel三种状态
// plat.platformActionListener = object : PlatformActionListener {
// override fun onComplete(p0: Platform?, p1: Int, p2: HashMap<String, Any>?) {
// Log.e("MXL", "onComplete" + p0?.db?.userIcon + p0?.db?.userId)
// Log.e("MXL", "Data:" + p0?.db?.exportData())
// if (p2 != null) {
// val g = Gson()
// val obj: JsonObject = g.fromJson(p0?.db?.exportData(), JsonObject::class.java)
// Log.e("MXL", "PIC:" + obj.get("picture"))
// val pic = obj.get("picture").toString().replace("\"", "")
// Log.e("MXL", "image:" + pic)
// bindGoogle(p0?.db?.userId, p0?.db?.userName, pic)
// EventUtils.onEvent("GoogleLoginSuccess")
// }
//
// }
//
// override fun onError(arg0: Platform, arg1: Int, arg2: Throwable) {
// //失败的回调,arg:平台对象,arg1:表示当前的动作(8:有用户信息登录, 1:无用户信息登录),arg2:异常信息
// Log.e("MXL", "onError" + arg2.printStackTrace())
// Log.e("MXL", "onError" + arg2.message)
// EventUtils.onEvent("GoogleLoginError", "arg1" + arg1 + " arg2" + arg2.message+" arg2:"+arg2.printStackTrace())
// }
//
// override fun onCancel(arg0: Platform, arg1: Int) {
// //取消分享的回调
// Log.e("MXL", "onCancel")
// EventUtils.onEvent("GoogleLoginCancel")
//
// }
// }
// // plat.authorize()
// plat.showUser(null)
}
}
// plat.authorize()
plat.showUser(null)
}
fun GoogleLogin2() {
}
fun bindGoogle(userId: String?, userName: String?, picture: String?) {
......
<resources>
<string name="facebook_app_id">1156014961815312</string>
<string name="fb_login_protocol_scheme">fb1156014961815312</string>
<string name="facebook_client_token">49f99977bc2d8a18f8271cf643379644</string>
<string name="app_name">MagicBox</string>
<string name="login_faild">登录失败</string>
<string name="login_success">登录成功</string>
......@@ -59,7 +63,7 @@
<string name="order_detail">Order details</string>
<string name="total_price">Total:</string>
<string name="pay">Pay</string>
<string name="order_pay">订单支付</string>
<string name="order_pay">Order payment</string>
<string name="write_info">Please input your delivery address</string>
<!--下单成功-->
<string name="order_suceess_title">Deliver</string>
......
......@@ -4,7 +4,7 @@ if (isDebug.toBoolean()) {
} else {
apply plugin: 'com.android.library'
}
apply plugin: 'com.mob.sdk'
//apply plugin: 'com.mob.sdk'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
......
......@@ -95,7 +95,7 @@ class NewBoxGoodsDetailActivity : BaseActivity(), GoodsDetailContract.View,
}
//试玩
id_detail_shiwan_rl?.setOnClickListener {
if (!Constant.Switch.isLogin){
if (Constant.Switch.isLogin){
JumpUtils.ThirdPardLoginJump()
return@setOnClickListener
}
......
package com.zxhl.main.page.activity
import android.content.Intent
import android.util.Log
import android.view.View
import com.facebook.*
import com.facebook.login.LoginConfiguration
import com.facebook.login.LoginManager
import com.facebook.login.LoginResult
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.NoDoubleClickListener
import com.zxhl.cms.utils.WeChatLoginSuccessCallBall
import com.zxhl.cms.utils.WeChatUtils
import com.zxhl.cms.utils.*
import com.zxhl.cms.widget.LoadingDialog
import com.zxhl.main.R
import kotlinx.android.synthetic.main.activity_layout_third_party_login.*
import java.util.*
class ThirdpartyLoginActivity : BaseActivity(), WeChatLoginSuccessCallBall {
private var wechatutil: WeChatUtils? = null
// private var wechatutil: WeChatUtils? = null
private var mLoading: LoadingDialog? = null
override fun onClick(v: View?) {
}
......@@ -25,25 +32,85 @@ class ThirdpartyLoginActivity : BaseActivity(), WeChatLoginSuccessCallBall {
return R.layout.activity_layout_third_party_login
}
private var googleLogin: GoogleLoginUtil? = null;
private var faceBookLogin: FaceBookLoginUtil? = null;
override fun init() {
wechatutil = WeChatUtils(this, this)
mLoading = LoadingDialog.getLoadingDialog(
this,
getString(R.string.wait_ing),
false,
false
)
// wechatutil = WeChatUtils(this, this)
//googleLogin init
googleLogin = GoogleLoginUtil(this)
googleLogin?.init()
//FaceBook
faceBookLogin = FaceBookLoginUtil(this)
faceBookLogin?.init()
id_ll_google_login?.setOnClickListener(object : NoDoubleClickListener() {
override fun onNoDoubleClick(v: View?) {
EventUtils.onEvent("googleLoginClick")
//WeChatUtils.
wechatutil?.GoogleLogin()
mLoading?.setLoading(getString(R.string.wait_ing2))
mLoading?.show()
googleLogin?.googleLogin(object : GoogleLoginUtil.LoginCallBack {
override fun onLoginSuccess() {
runOnUiThread {
mLoading?.setResult(true, "login success", 0)
finish()
}
}
override fun onLoginError(errorMsg: String) {
EventUtils.onEvent("GoogleLoginError", errorMsg)
runOnUiThread {
mLoading?.setResult(false, "login error", 1000)
}
}
})
}
})
id_ll_facebook_login?.setOnClickListener(object : NoDoubleClickListener() {
override fun onNoDoubleClick(v: View?) {
EventUtils.onEvent("facebookLoginClick")
wechatutil?.FackBooklogin()
}
mLoading?.setLoading(getString(R.string.wait_ing2))
mLoading?.show()
faceBookLogin?.faceBookLogin(object : FaceBookLoginUtil.LoginCallBack {
override fun onLoginSuccess() {
runOnUiThread {
mLoading?.setResult(true, "login success", 0)
finish()
}
}
override fun onLoginError(errorMsg: String) {
if (errorMsg == "Success_未获取到登录信息"){
runOnUiThread {
mLoading?.setResult(false, "try again", 1000)
}
}else{
runOnUiThread {
mLoading?.setResult(false, "login error", 1000)
}
}
EventUtils.onEvent("facebookLoginError", errorMsg)
// Log.e("FaceBookLoginUtil", "error $errorMsg")
}
})
}
})
}
override fun loginSuccess(lottery: String?) {
this.finish()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
faceBookLogin?.onActivityResult(requestCode, resultCode, data)
googleLogin?.onActivityResult(requestCode, resultCode, data)
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="@drawable/bj_login"
android:visibility="gone"/>
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
......
......@@ -46,7 +46,7 @@
android:layout_height="44dp"
app:defaultTabTextColor="@color/color_333333"
app:defaultTabTextHorizontalPadding="12dp"
app:defaultTabTextSize="14sp"
app:defaultTabTextSize="16sp"
app:indicatorColor="@color/color_4c84ff"
app:indicatorCornerRadius="2dp"
app:indicatorWidth="15dp"
......
......@@ -53,6 +53,7 @@
android:layout_height="wrap_content"
android:layout_above="@+id/id_detail_shiwan_rl"
android:layout_marginLeft="8dp"
android:visibility="gone"
android:layout_marginBottom="13dp">
<ImageView
......
......@@ -4,7 +4,7 @@ if (isDebug.toBoolean()) {
} else {
apply plugin: 'com.android.library'
}
apply plugin: 'com.mob.sdk'
//apply plugin: 'com.mob.sdk'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment