Commit 5ece9c32 authored by mengcuiguang's avatar mengcuiguang

优化网络架构

parent 53cf96d8
...@@ -174,5 +174,9 @@ dependencies { ...@@ -174,5 +174,9 @@ dependencies {
implementation(name: 'open_ad_sdk_3.7.0.1', ext: 'aar') implementation(name: 'open_ad_sdk_3.7.0.1', ext: 'aar')
// 广点通广告 腾讯 // 广点通广告 腾讯
implementation(name: 'GDTSDK.unionNormal.4.362.1232', ext: 'aar') implementation(name: 'GDTSDK.unionNormal.4.362.1232', ext: 'aar')
//RxPay
implementation 'com.cuieney:rxpay-api:2.2.3'
kapt 'com.cuieney:rxpay-compiler:2.1.1'
implementation 'com.romandanylyk:pageindicatorview:1.0.3'
} }
\ No newline at end of file
...@@ -5,15 +5,27 @@ ...@@ -5,15 +5,27 @@
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application <application
android:name="com.mints.street.AppApplication" android:name="com.mints.street.AppApplication"
...@@ -132,6 +144,30 @@ ...@@ -132,6 +144,30 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape" android:screenOrientation="landscape"
tools:replace="android:screenOrientation" /> tools:replace="android:screenOrientation" />
<!-- WX_APPID必填项 -->
<meta-data
android:name="WX_APPID"
android:value="wx8f26539eabfb04f2" />
<activity
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<!-- 支付宝 -->
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="com.alipay.sdk.app.H5AuthActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import android.content.Context ...@@ -4,6 +4,7 @@ import android.content.Context
import android.os.StrictMode import android.os.StrictMode
import android.os.StrictMode.VmPolicy import android.os.StrictMode.VmPolicy
import android.util.Log import android.util.Log
import com.cuieney.rxpay_annotation.WX
import com.fry.base.base.BaseApp import com.fry.base.base.BaseApp
import com.mints.street.manager.CsjGroMoreManager import com.mints.street.manager.CsjGroMoreManager
import com.mints.street.manager.UmengManager import com.mints.street.manager.UmengManager
...@@ -12,6 +13,7 @@ import java.util.concurrent.TimeoutException ...@@ -12,6 +13,7 @@ import java.util.concurrent.TimeoutException
/** /**
* Created by 冯瑞雨 on 2021/7/1. * Created by 冯瑞雨 on 2021/7/1.
*/ */
@WX(packageName = "com.mints.street")
class AppApplication : BaseApp() { class AppApplication : BaseApp() {
override fun onCreate() { override fun onCreate() {
...@@ -39,6 +41,7 @@ class AppApplication : BaseApp() { ...@@ -39,6 +41,7 @@ class AppApplication : BaseApp() {
* 三方配置 * 三方配置
*/ */
private fun thirdConfig() { private fun thirdConfig() {
// 友盟预初始化
UmengManager.preInit() UmengManager.preInit()
// GroMore // GroMore
......
...@@ -26,11 +26,6 @@ public class TTGroMoreAdManagerHolder { ...@@ -26,11 +26,6 @@ public class TTGroMoreAdManagerHolder {
doInit(context); doInit(context);
} }
public static void initUnitySdkBanner(Activity activity) {
TTMediationAdSdk.initUnityForBanner(activity);
}
//step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明 //step1:接入网盟广告sdk的初始化操作,详情见接入文档和穿山甲平台说明
private static void doInit(Context context) { private static void doInit(Context context) {
if (!sInit) { if (!sInit) {
......
package com.mints.street.api package com.mints.street.api
import com.fry.base.netwrok.HttpManager
import com.mints.street.bean.AwardBean import com.mints.street.bean.AwardBean
import com.mints.street.bean.UserBean import com.mints.street.bean.UserBean
import com.mints.street.netwrok.HttpManager
import io.reactivex.Observable import io.reactivex.Observable
import me.goldze.mvvmhabit.http.BaseResponse import me.goldze.mvvmhabit.http.BaseResponse
import retrofit2.Response import retrofit2.Response
......
package com.mints.street.manager package com.mints.street.manager
import android.text.TextUtils
import com.mints.street.bean.UserBean import com.mints.street.bean.UserBean
import me.goldze.mvvmhabit.utils.SPUtils import com.tencent.mmkv.MMKV
/** /**
* Created by 冯瑞雨 on 2021/7/6. * 描述:管理用户信息
* 作者:孟崔广
* 时间:2021/7/9 14:48
*/ */
object UserManager { class UserManager {
private val spUtils = SPUtils.getInstance("user")
private const val USER_INFO = "user_info"
private var user :UserBean?=null
companion object {
/**
* 游客 or 登录用户
*/
private const val IS_TEMP_USER = "is_temp_user"
/**
* 用户ID
*/
private const val USER_ID = "userId"
/**
* 用户CODE_ID
*/
private const val CODE_ID = "codeId"
/**
* 登陆状态ID
*/
private const val TOKEN_ID = "tokenId"
/**
* 手机号
*/
private const val MOBILE = "mobile"
/**
* 姓名
*/
private const val REAL_NAME = "realName"
/**
* 支付宝
*/
private const val ALIPAY_ACCOUNT = "alipay_account"
/**
* 用户金币
*/
private const val USER_GOLD = "user_gold"
/**
* 用户总金币
*/
private const val USER_SUM_GOLD = "user_sum_gold"
/**
* 用户零钱
*/
private const val USER_CASH = "user_cash"
/**
* 是否老用户 true-老用户
*/
private const val USER_OLD = "user_old"
/**
* 猎豹游戏info
*/
private const val GAME_INFO = "game_info"
/**
* 广告隐藏标识
*/
private const val AD_SHOW_FLAG = "ad_show_flag"
/**
* 微信名称
*/
private const val WX_NAME = "wx_name"
/**
* 微信头像
*/
private const val WX_HEADER = "wx_header"
/**
* 微信id
*/
private const val WX_OPENID = "wx_openid"
val INSTANCE: UserManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
UserManager()
}
}
init {
}
/**
* 保存用户信息
*
* @param userInfo
*/
fun saveUserInfo(userInfo: UserBean) {
val user = userInfo.consumer
val token = userInfo.token
if (token != null) {
MMKV.mmkvWithID(TOKEN_ID).encode(TOKEN_ID, token)
}
if (user != null) {
val mobile: String? = user.mobile
val openid: String? = user.openid
if (mobile == null && openid == null) {
MMKV.mmkvWithID(IS_TEMP_USER).remove(IS_TEMP_USER)
} else {
MMKV.mmkvWithID(IS_TEMP_USER).encode(IS_TEMP_USER, mobile + openid)
}
MMKV.mmkvWithID(USER_ID).encode(USER_ID, user.pk_id.toString())
MMKV.mmkvWithID(CODE_ID).encode(CODE_ID, user.idcode.toString())
MMKV.mmkvWithID(MOBILE).encode(MOBILE, mobile)
MMKV.mmkvWithID(ALIPAY_ACCOUNT)
.encode(ALIPAY_ACCOUNT, user.alipay_account.toString())
MMKV.mmkvWithID(USER_GOLD).encode(USER_GOLD, user.coin.toString())
MMKV.mmkvWithID(USER_CASH)
.encode(USER_CASH, String.format("%.2f", user.surplus))
MMKV.mmkvWithID(USER_SUM_GOLD).encode(USER_SUM_GOLD, user.sumCoin.toString())
MMKV.mmkvWithID(USER_OLD).encode(USER_OLD, !user.isFirstSignInApp)
MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname.toString())
MMKV.mmkvWithID(WX_HEADER).encode(WX_HEADER, user.head)
MMKV.mmkvWithID(WX_OPENID).encode(WX_OPENID, openid)
MMKV.mmkvWithID(GAME_INFO).encode(GAME_INFO, user.gameInfo)
MMKV.mmkvWithID(REAL_NAME).encode(REAL_NAME, user.real_name)
}
}
/**
* 单独获取用户id
*/
fun getMobile(): String {
val kv = MMKV.mmkvWithID(MOBILE)
return kv.decodeString(MOBILE, "")
}
/**
* 判断用户是否已登录
*
* @return true为已登录 false 为未登录
*/
fun userIsLogin(): Boolean {
val kv = MMKV.mmkvWithID(IS_TEMP_USER).decodeString(IS_TEMP_USER, "")
return !TextUtils.isEmpty(kv)
}
/**
* 单独获取用户id
*/
fun getUserID(): String {
val kv = MMKV.mmkvWithID(USER_ID)
return kv.decodeString(USER_ID, "")
}
/**
* 获取用户登陆状态
*/
fun getTokenID(): String {
val kv = MMKV.mmkvWithID(TOKEN_ID)
return kv.decodeString(TOKEN_ID, "")
}
/**
* 获取用户邀请码
*/
fun getCodeID(): String {
val kv = MMKV.mmkvWithID(CODE_ID)
return kv.decodeString(CODE_ID, "")
}
/**
* 获取真实姓名
*/
fun getRealName(): String {
val kv = MMKV.mmkvWithID(REAL_NAME)
return kv.decodeString(REAL_NAME, "")
}
/**
* 设置真实姓名
*
* @param name
*/
fun setRealName(name: String?) {
val kv = MMKV.mmkvWithID(REAL_NAME)
kv.encode(REAL_NAME, name)
}
/**
* 是否老用户 true-老用户
*/
fun getUserOld(): Boolean {
val kv = MMKV.mmkvWithID(USER_OLD)
return kv.decodeBool(USER_OLD, false)
}
fun getAdShowFlag(): Boolean {
val kv = MMKV.mmkvWithID(AD_SHOW_FLAG)
return kv.decodeBool(AD_SHOW_FLAG, false)
}
/**
* 设置真实姓名
*
* @param userOld
*/
fun setUserOld(userOld: Boolean) {
val kv = MMKV.mmkvWithID(USER_OLD)
kv.encode(USER_OLD, userOld)
}
/**
* 获取支付宝账户
*/
fun getAlipayAccount(): String {
val kv = MMKV.mmkvWithID(ALIPAY_ACCOUNT)
return kv.decodeString(ALIPAY_ACCOUNT, "")
}
/**
* 设置支付宝账户
*
* @param alipay
*/
fun setAlipayAccount(alipay: String?) {
val kv = MMKV.mmkvWithID(ALIPAY_ACCOUNT)
kv.encode(ALIPAY_ACCOUNT, alipay)
}
fun getUserSumGold(): String {
val kv = MMKV.mmkvWithID(USER_SUM_GOLD)
return kv.decodeString(USER_SUM_GOLD, "")
}
/**
* 获取用户金币/积分
*/
fun getUserGold(): String {
val kv = MMKV.mmkvWithID(USER_GOLD)
return kv.decodeString(USER_GOLD, "")
}
/**
* 设置用户金币/积分
*
* @param gold
*/
fun setUserGold(gold: String?) {
val kv = MMKV.mmkvWithID(USER_GOLD)
kv.encode(USER_GOLD, gold)
}
/**
* 获取用户零钱
*/
fun getUserCash(): String {
val kv = MMKV.mmkvWithID(USER_CASH)
return kv.decodeString(USER_CASH, "")
}
fun getGameInfo(): String {
val kv = MMKV.mmkvWithID(GAME_INFO)
return kv.decodeString(GAME_INFO, "")
}
fun getWxName(): String {
val kv = MMKV.mmkvWithID(WX_NAME)
return kv.decodeString(WX_NAME, "")
}
fun getWxHeader(): String {
val kv = MMKV.mmkvWithID(WX_HEADER)
return kv.decodeString(WX_HEADER, "")
}
fun getWxOpenid(): String {
val kv = MMKV.mmkvWithID(WX_OPENID)
return kv.decodeString(WX_OPENID, "")
}
/**
* 设置用户零钱
*
* @param cash
*/
fun setUserCash(cash: String?) {
val kv = MMKV.mmkvWithID(USER_CASH)
kv.encode(WX_OPENID, cash)
}
fun setGameInfo(gameInfo: String?) {
val kv = MMKV.mmkvWithID(GAME_INFO)
kv.encode(GAME_INFO, gameInfo)
}
fun setWxName(wxName: String?) {
val kv = MMKV.mmkvWithID(WX_NAME)
kv.encode(WX_NAME, wxName)
}
fun setWxHeader(wxHeader: String?) {
val kv = MMKV.mmkvWithID(WX_HEADER)
kv.encode(WX_HEADER, wxHeader)
}
/**
* mobile
*
* @param mobile
*/
fun setMobile(mobile: String?) {
val kv = MMKV.mmkvWithID(MOBILE)
kv.encode(MOBILE, mobile)
}
fun setAdShowFlag(adShowFlag: Boolean) {
val kv = MMKV.mmkvWithID(AD_SHOW_FLAG)
kv.encode(AD_SHOW_FLAG, adShowFlag)
}
fun userLogout() {
MMKV.mmkvWithID(USER_ID).remove(USER_ID)
MMKV.mmkvWithID(CODE_ID).remove(CODE_ID)
MMKV.mmkvWithID(TOKEN_ID).remove(TOKEN_ID)
MMKV.mmkvWithID(REAL_NAME).remove(REAL_NAME)
MMKV.mmkvWithID(IS_TEMP_USER).remove(IS_TEMP_USER)
MMKV.mmkvWithID(ALIPAY_ACCOUNT).remove(ALIPAY_ACCOUNT)
MMKV.mmkvWithID(USER_GOLD).remove(USER_GOLD)
MMKV.mmkvWithID(USER_CASH).remove(USER_CASH)
MMKV.mmkvWithID(USER_OLD).remove(USER_OLD)
MMKV.mmkvWithID(WX_OPENID).remove(WX_OPENID)
MMKV.mmkvWithID(WX_NAME).remove(WX_NAME)
MMKV.mmkvWithID(WX_HEADER).remove(WX_HEADER)
// MMKV.mmkvWithID(GAME_INFO).remove(GAME_INFO)
}
} }
\ No newline at end of file
package com.fry.base.netwrok; package com.mints.street.netwrok;
import android.os.Process;
import com.fry.base.R;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.ObservableSource; import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer; import io.reactivex.ObservableTransformer;
import io.reactivex.functions.Function; import io.reactivex.functions.Function;
import me.goldze.mvvmhabit.base.AppManager;
import me.goldze.mvvmhabit.http.BaseResponse; import me.goldze.mvvmhabit.http.BaseResponse;
import me.goldze.mvvmhabit.utils.ToastUtils;
import me.goldze.mvvmhabit.utils.Utils;
import retrofit2.Response; import retrofit2.Response;
/** /**
......
package com.fry.base.netwrok; package com.mints.street.netwrok;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
...@@ -6,6 +6,7 @@ import com.fry.base.basenetwork.HttpConfiguation; ...@@ -6,6 +6,7 @@ import com.fry.base.basenetwork.HttpConfiguation;
import com.fry.base.basenetwork.IHttpResponseListener; import com.fry.base.basenetwork.IHttpResponseListener;
import com.fry.base.basenetwork.RetrofitClient; import com.fry.base.basenetwork.RetrofitClient;
import com.fry.base.global.Constants; import com.fry.base.global.Constants;
import com.fry.base.netwrok.OkHttpInterceptor;
import com.fry.base.utils.encry.AESUtils; import com.fry.base.utils.encry.AESUtils;
import com.trello.rxlifecycle2.LifecycleProvider; import com.trello.rxlifecycle2.LifecycleProvider;
......
...@@ -2,12 +2,15 @@ package com.fry.base.netwrok ...@@ -2,12 +2,15 @@ package com.fry.base.netwrok
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import com.fry.base.BuildConfig import com.bytedance.hume.readapk.HumeSDK
import com.fry.base.bean.AppRequest import com.fry.base.bean.AppRequest
import com.fry.base.utils.encry.AESUtils import com.fry.base.utils.encry.AESUtils
import com.fry.base.utils.encry.Base64 import com.fry.base.utils.encry.Base64
import com.fry.base.utils.encry.MD5 import com.fry.base.utils.encry.MD5
import com.google.gson.Gson import com.google.gson.Gson
import com.mints.street.AppApplication
import com.mints.street.manager.UserManager
import com.mints.street.utils.CommonUtils
import okhttp3.* import okhttp3.*
import okio.Buffer import okio.Buffer
import org.json.JSONObject import org.json.JSONObject
...@@ -30,8 +33,7 @@ class OkHttpInterceptor(aesKey: String) : Interceptor { ...@@ -30,8 +33,7 @@ class OkHttpInterceptor(aesKey: String) : Interceptor {
@Throws(IOException::class) @Throws(IOException::class)
override fun intercept(chain: Interceptor.Chain): Response { override fun intercept(chain: Interceptor.Chain): Response {
// val tokenID: String = UserManager.INSTANCE.getTokenID() val tokenID: String = UserManager.INSTANCE.getTokenID()
val tokenID: String = "647ECC8C40A7238E012703044D60D0D95599F1AD1833C4D29670487710D12D315F433703067DF5142735505C42F58997"
val time = System.currentTimeMillis() val time = System.currentTimeMillis()
val channel = createChannel() val channel = createChannel()
var request = chain.request() var request = chain.request()
...@@ -51,18 +53,17 @@ class OkHttpInterceptor(aesKey: String) : Interceptor { ...@@ -51,18 +53,17 @@ class OkHttpInterceptor(aesKey: String) : Interceptor {
* @return * @return
*/ */
private fun createChannel(): String { private fun createChannel(): String {
var channel: String = "" var channel: String = CommonUtils.getAppMetaData(AppApplication.getContext(), "CHANNEL_NAME")
// var channel: String = CommonUtils.getAppMetaData(App.instance, "CHANNEL_NAME") try {
// try { // 穿山甲分包渠道
// // 穿山甲分包渠道 val ttChannel = HumeSDK.getChannel(AppApplication.getContext())
// val ttChannel = HumeSDK.getChannel(App.instance) if (!TextUtils.isEmpty(ttChannel)) {
// if (!TextUtils.isEmpty(ttChannel)) { // 此处方式不能修改,已和后端约定
// // 此处方式不能修改,已和后端约定 channel = channel + "_" + ttChannel
// channel = channel + "_" + ttChannel }
// } } catch (e: Exception) {
// } catch (e: Exception) { e.printStackTrace()
// e.printStackTrace() }
// }
return channel return channel
} }
......
...@@ -14,7 +14,7 @@ import Decoder.BASE64Encoder; ...@@ -14,7 +14,7 @@ import Decoder.BASE64Encoder;
public class AESUtils { public class AESUtils {
private static final String vis = MD5.GetMD5Code("goldcamera_2021").substring(8, 24); private static final String vis = MD5.GetMD5Code("street_2021").substring(8, 24);
// public static final String key = "123456"; // public static final String key = "123456";
public static String CIPHER_ALGORITHM = "AES/CBC/PKCS5Padding"; // optional value AES/DES/DESede public static String CIPHER_ALGORITHM = "AES/CBC/PKCS5Padding"; // optional value AES/DES/DESede
......
#Fri Jul 09 14:18:23 CST 2021 #Fri Jul 09 14:29:26 CST 2021
VERSION_BUILD=2650 VERSION_BUILD=2633
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