Commit 317998e2 authored by mengcuiguang's avatar mengcuiguang

添加密钥、添加支付宝授权等

parent fa7d4685
......@@ -156,6 +156,10 @@
android:name=".ui.activitys.AboutusActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.WalletActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.CsjDetailActivity"
android:exported="false"
......@@ -322,7 +326,7 @@
android:configChanges="screenSize|orientation|keyboardHidden"
android:launchMode="singleTask"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
tools:replace="android:configChanges"/>
tools:replace="android:configChanges" />
<!-- 如果targetSdkVersion设置值>=24,则强烈建议添加以下provider,否则会影响app变现 -->
<!-- android:authorities="${packageName}.bd.provider" authorities中${packageName}部分必须替换成app自己的包名 -->
......
package com.duben.roseplaylet.manager
import android.annotation.SuppressLint
import android.app.Activity
import android.os.Handler
import android.os.Message
import android.text.TextUtils
import com.alipay.sdk.app.AuthTask
import com.duben.roseplaylet.MintsApplication
import com.duben.roseplaylet.common.AppConfig
import com.duben.roseplaylet.mvp.model.AuthResult
import com.duben.roseplaylet.mvp.model.BaseResponse
import com.duben.roseplaylet.utils.ToastUtil
import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
import com.duben.library.utils.json.JsonUtil
import com.google.gson.JsonObject
import java.lang.ref.WeakReference
/**
* 支付宝授权
*/
object AlipayAuthManager {
private const val SDK_AUTH_FLAG = 2
@SuppressLint("HandlerLeak")
private val mHandler: Handler = object : Handler() {
override fun handleMessage(msg: Message) {
when (msg.what) {
SDK_AUTH_FLAG -> {
val authResult = AuthResult(msg.obj as Map<String, String>, true)
val resultStatus: String = authResult.getResultStatus()
// 判断resultStatus 为“9000”且result_code
// 为“200”则代表授权成功,具体状态码代表含义可参考授权接口文档
if (TextUtils.equals(
resultStatus,
"9000"
) && TextUtils.equals(authResult.getResultCode(), "200")
) {
// 获取alipay_open_id,调支付时作为参数extern_token 的value
// 传入,则支付账户为该授权账户
println("mcg -->>>>> authinfo=" + JsonUtil.toJson(authResult))
commitAlipayAutoInfo(JsonUtil.toJson(authResult))
} else {
// 其他状态值则为授权失败
authListener?.authFail(resultStatus)
}
}
else -> {}
}
}
}
private fun commitAlipayAutoInfo(info: String) {
val vo = HashMap<String, Any>()
vo.put("user_id", UserManager.getInstance().userID)
vo.put("result", info)
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.reportAlipayMsg(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onError(e: Throwable) {
authListener?.authFail("授权失败!")
}
override fun onNext(t: BaseResponse<Any>) {
if (t.status == 200) {
// UserManager.getInstance().alipaySet = true
authListener?.authSuccess()
} else {
authListener?.authFail(t.message)
}
}
})
}
/**
* 支付宝账户授权业务示例
*/
fun authV2(activity: Activity, listener: AuthListener?) {
authListener = listener
val weakReference = WeakReference(activity)
println("mcg -->>>>> 开始授权")
val vo = HashMap<String, Any>()
vo.put("user_id", UserManager.getInstance().userID)
val baseApplication = MintsApplication.getContext() as MintsApplication
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.getAlipayAuthUrl(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onError(e: Throwable) {
}
override fun onNext(t: BaseResponse<JsonObject>) {
if (t.status == 200) {
val data = t.data
val authInfo = data["url"].asString
val authRunnable = Runnable { // 构造AuthTask 对象
val authTask = AuthTask(weakReference.get())
// 调用授权接口,获取授权结果
val result = authTask.authV2(authInfo, true)
val msg = Message()
msg.what = SDK_AUTH_FLAG
msg.obj = result
mHandler.sendMessage(msg)
}
// 必须异步调用
val authThread = Thread(authRunnable)
authThread.start()
} else {
ToastUtil.show(MintsApplication.getContext(), t.message)
}
}
})
}
private var authListener: AuthListener? = null
interface AuthListener {
fun authSuccess()
fun authFail(resultStatus: String)
}
}
\ No newline at end of file
......@@ -136,9 +136,9 @@ object CsjDJXSdkManager {
vedioBean.coverImage = drama.coverImage
vedioBean.thirdId = drama.id.toString()
// 设置短剧的免费集数
vedioBean.freeIndex = 5
vedioBean.freeIndex = drama.freeSet
// 设置短剧广告解锁剧贪杯
vedioBean.unlockIndex = 1
vedioBean.unlockIndex = drama.lockSet
vedioList.add(vedioBean)
}
listener.dramaCategoryListSuccess(vedioList)
......@@ -154,6 +154,9 @@ object CsjDJXSdkManager {
fun dramaCategoryListFail()
}
/**
* 短剧详情
*/
fun requestDrama(id: Long, callback: (DJXDrama) -> Unit) {
DJXSdk.service().requestDrama(
listOf(id),
......
package com.duben.roseplaylet.mvp.model; import android.text.TextUtils; import java.io.Serializable;import java.util.Map; public class AuthResult implements Serializable { private String resultStatus; private String result; private String memo; private String resultCode; private String authCode; private String alipayOpenId; public AuthResult(Map<String, String> rawResult, boolean removeBrackets) { if (rawResult == null) { return; } for (String key : rawResult.keySet()) { if (TextUtils.equals(key, "resultStatus")) { resultStatus = rawResult.get(key); } else if (TextUtils.equals(key, "result")) { result = rawResult.get(key); } else if (TextUtils.equals(key, "memo")) { memo = rawResult.get(key); } } String[] resultValue = result.split("&"); for (String value : resultValue) { if (value.startsWith("alipay_open_id")) { alipayOpenId = removeBrackets(getValue("alipay_open_id=", value), removeBrackets); continue; } if (value.startsWith("auth_code")) { authCode = removeBrackets(getValue("auth_code=", value), removeBrackets); continue; } if (value.startsWith("result_code")) { resultCode = removeBrackets(getValue("result_code=", value), removeBrackets); continue; } } } private String removeBrackets(String str, boolean remove) { if (remove) { if (!TextUtils.isEmpty(str)) { if (str.startsWith("\"")) { str = str.replaceFirst("\"", ""); } if (str.endsWith("\"")) { str = str.substring(0, str.length() - 1); } } } return str; } @Override public String toString() { return "authCode={" + authCode + "}; resultStatus={" + resultStatus + "}; memo={" + memo + "}; result={" + result + "}"; } private String getValue(String header, String data) { return data.substring(header.length(), data.length()); } /** * @return the resultStatus */ public String getResultStatus() { return resultStatus; } /** * @return the memo */ public String getMemo() { return memo; } /** * @return the result */ public String getResult() { return result; } /** * @return the resultCode */ public String getResultCode() { return resultCode; } /** * @return the authCode */ public String getAuthCode() { return authCode; } /** * @return the alipayOpenId */ public String getAlipayOpenId() { return alipayOpenId; }}
\ No newline at end of file
......@@ -349,6 +349,18 @@ public interface LoanService {
@POST("api/vip/signAfterSeconds")
Observable<BaseResponse<JsonObject>> signAfterSeconds();
/**
* 支付宝获取授权
*/
@POST("api/user/getAlipayAuthUrl")
Observable<BaseResponse<JsonObject>> getAlipayAuthUrl(@Body Map<String, Object> vo);
/**
* 风控标记
*/
@POST("api/user/reportAlipayMsg")
Observable<BaseResponse<Object>> reportAlipayMsg(@Body Map<String, Object> vo);
/**
* 默认http工厂
......
......@@ -42,11 +42,13 @@ class CsjDetailActivity : BaseActivity(), View.OnClickListener {
DJXWidgetDramaDetailParams.DJXDramaEnterFrom.DEFAULT
}
// 看广告解锁剧集数
private val lockSet=3
private var dpWidget: IDJXWidget? = null
private var isInited = false
private var drama: DJXDrama? = null
private var isRewardArrived = false
private val adPositions = mutableListOf<Int>()
private var vedioBean: VedioBean? = null
// 广告模式
......@@ -129,7 +131,7 @@ class CsjDetailActivity : BaseActivity(), View.OnClickListener {
//点击激励视频解锁
val info = DJXDramaUnlockInfo(
drama.id,
vedioBean!!.unlockIndex,
lockSet,
DJXDramaUnlockMethod.METHOD_AD,
false,
unlockType = unlockType
......@@ -140,7 +142,7 @@ class CsjDetailActivity : BaseActivity(), View.OnClickListener {
hide()
val info = DJXDramaUnlockInfo(
drama.id,
vedioBean!!.unlockIndex,
lockSet,
DJXDramaUnlockMethod.METHOD_AD,
cancelUnlock = true
)
......
package com.duben.roseplaylet.ui.activitys
import android.view.View
import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.roseplaylet.R
import com.duben.roseplaylet.manager.AlipayAuthManager
import com.duben.roseplaylet.ui.activitys.base.BaseActivity
import kotlinx.android.synthetic.main.activity_wallet.*
import kotlinx.android.synthetic.main.header_layout.*
/**
* 描述:钱包
* 作者:孟崔广
* 时间:2025/1/9 12:39
*/
class WalletActivity : BaseActivity(), View.OnClickListener {
override fun getContentViewLayoutID() = R.layout.activity_wallet
override fun isApplyKitKatTranslucency() = false
override fun initViewsAndEvents() {
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
initListener()
}
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.iv_left_icon -> finish()
R.id.btn_alipayauth -> {
showToast("支付宝拉起授权")
AlipayAuthManager.authV2(this@WalletActivity,
object : AlipayAuthManager.AuthListener {
override fun authSuccess() {
showToast("支付宝授权成功")
}
override fun authFail(resultStatus: String) {
showToast("支付宝授权失败 " + resultStatus)
}
})
}
}
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
btn_alipayauth.setOnClickListener(this)
}
}
......@@ -17,6 +17,7 @@ import com.duben.roseplaylet.common.AppConfig
import com.duben.roseplaylet.common.Constant
import com.duben.roseplaylet.manager.CsjDJXSdkManager
import com.duben.roseplaylet.manager.LocalVedioManager
import com.duben.roseplaylet.manager.UserManager
import com.duben.roseplaylet.mvp.model.MULTI_ITEM_1
import com.duben.roseplaylet.mvp.model.MULTI_ITEM_3
import com.duben.roseplaylet.mvp.model.VedioBean
......@@ -33,7 +34,6 @@ import kotlinx.android.synthetic.main.fragment_csjmovie.*
class CsjMovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
private var mType = ""
private var mPosition = 0 // 首页-第一个tab-第一个recyclerview Item
companion object {
private const val VIDEO_TYPE = "VIDEO_TYPE"
......@@ -49,7 +49,6 @@ class CsjMovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
}
}
private var hotPage = 1 // 分页
private var hotPageSize = Constant.PAGE_SIZE // 分页
......@@ -64,13 +63,12 @@ class CsjMovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
arguments?.let {
mType = it.getString(VIDEO_TYPE, mType)
mPosition = it.getInt(VIDEO_POSITION, mPosition)
}
}
override fun onResume() {
super.onResume()
// hotPageSize = if (UserManager.getInstance().vipFlag) 12 else 9
hotPageSize = if (UserManager.getInstance().vipFlag) 12 else 9
onRefresh()
}
......@@ -80,14 +78,12 @@ class CsjMovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
fun onRefresh() {
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
println("mcg _______")
hotPage = 1
srlMainPage.resetNoMoreData()
MainExpressManager.instance.destroy()
loadAd()
requestDramaByCategory()
}
}
fun requestDramaByCategory() {
......@@ -148,71 +144,15 @@ class CsjMovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
fun requestDrama(data: VedioBean) {
CsjDJXSdkManager.requestDrama(data.thirdId.toLong()) {
// val intent = Intent(this@DramaDetailConfigActivity, DramaDetailActivity::class.java)
// DramaDetailActivity.outerDrama = it
// DramaDetailActivity.enterFrom =
// DJXWidgetDramaDetailParams.DJXDramaEnterFrom.DEFAULT // todo 加一下入口枚举
// intent.putExtra(
// KEY_DRAMA_AD_MODE,
// if (item_btn_ad_mode.isChecked) DJXDramaUnlockAdMode.MODE_SPECIFIC else DJXDramaUnlockAdMode.MODE_COMMON
// )
// intent.putExtra(KEY_DRAMA_FREE_SET, item_et_free_set.text.toString().toInt())
// intent.putExtra(KEY_DRAMA_LOCK_SET, item_et_lock_set.text.toString().toInt())
// intent.putExtra(
// KEY_DRAMA_PLAY_DURATION,
// item_et_play_duration.text.toString().toInt()
// )
// intent.putExtra(KEY_DRAMA_ENABLE_INFINITY, item_btn_infinity_scroll.isChecked)
// intent.putExtra(KEY_DRAMA_ENABLE_CONTINUES_UNLOCK, item_btn_enable_unlock.isChecked)
// intent.putExtra(KEY_CUSTOM_REPORT_PAGE, item_btn_custom_report_page.isChecked)
// intent.putExtra(KEY_DRAMA_INSERT_DRAW_AD, item_btn_insert_draw_ad.isChecked)
// intent.putExtra(
// KEY_DRAMA_INSERT_DRAW_AD_CONFIG,
// item_et_insert_draw_ad_config.text.toString()
// )
//
// intent.putExtra(KEY_DRAMA_HIDE_LIKE_BUTTON, item_btn_hide_like_button.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_FAVOR_BUTTON, item_btn_hide_favor_button.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_REWARD_DIALOG, item_btn_hide_reward_dialog.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_BACK, item_btn_hide_back.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_TOP_INFO, item_btn_hide_top_info.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_BOTTOM_INFO, item_btn_hide_bottom_info.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_MORE, item_btn_hide_more.isChecked)
// intent.putExtra(KEY_DRAMA_HIDE_CELLULAR_TOAST, item_btn_hide_toast.isChecked)
// intent.putExtra(KEY_DRAMA_INSERT_CUSTOM_VIEW, item_btn_insert_custom_view.isChecked)
// intent.putExtra(
// KEY_DRAMA_SCRIPT_TOP_MARGIN,
// item_et_script_margin.text.toString().toInt()
// )
// intent.putExtra(
// KEY_DRAMA_ICP_BOTTOM_MARGIN,
// item_et_icp_margin.text.toString().toInt()
// )
// intent.putExtra(
// KEY_DRAMA_TOP_OFFSET,
// item_et_top_info_offset.text.toString().let { offset ->
// if (offset.isEmpty()) 0 else offset.toInt()
// })
// intent.putExtra(
// KEY_DRAMA_BOTTOM_OFFSET,
// item_et_bottom_info_offset.text.toString().toInt()
// )
// DJXSdk.service()
// .setGlobalSpeedPlay(item_global_speed.text.toString().toFloat())
// this@DramaDetailConfigActivity.startActivity(intent)
val bundle = Bundle()
val vedioBean = VedioBean()
vedioBean.title = it.title
vedioBean.vedioDesc = it.desc
vedioBean.coverImage = it.coverImage
vedioBean.thirdId = it.id.toString()
// 免费集数
vedioBean.freeIndex = it.freeSet
vedioBean.unlockIndex = it.lockSet
vedioBean.groupId = it.groupId
bundle.putString(Constant.VEDIO_BEAN, JsonUtil.toJson(vedioBean))
CsjDetailActivity.outerDrama = it
CsjDetailActivity.enterFrom =
DJXWidgetDramaDetailParams.DJXDramaEnterFrom.DEFAULT // todo 加一下入口枚举
DJXWidgetDramaDetailParams.DJXDramaEnterFrom.DEFAULT
readyGo(CsjDetailActivity::class.java, bundle)
}
}
......
......@@ -40,7 +40,6 @@ import kotlin.concurrent.schedule
class CsjVedioFragment : LazyLoadBaseFragment(), View.OnClickListener, OnRefreshListener {
companion object {
fun newInstance(): Fragment {
val args = Bundle()
val fragment = CsjVedioFragment()
......@@ -74,10 +73,7 @@ class CsjVedioFragment : LazyLoadBaseFragment(), View.OnClickListener, OnRefresh
override fun onFragmentResume() {
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
if (AppConfig.exitLoginMainRefresh) {
AppConfig.exitLoginMainRefresh = false
loadData()
}
}
}
......
......@@ -25,6 +25,10 @@ import kotlinx.android.synthetic.main.fragment_first.*
*/
class FirstFragment : LazyLoadBaseFragment(), FirstView {
companion object {
var currentPosition = 0
}
private var mSelectTabIndex = 0
private val tabsData = mutableListOf<String>()
private val fragments = mutableListOf<Fragment>()
......@@ -48,6 +52,7 @@ class FirstFragment : LazyLoadBaseFragment(), FirstView {
override fun onFragmentResume() {
if (AppConfig.fragmentClickFlag == Constant.FRAGMENT_CLICK_ONE) {
if (TextUtils.isEmpty(userManager?.userID)) {
firstPresenter.userLogin()
}
......@@ -73,6 +78,7 @@ class FirstFragment : LazyLoadBaseFragment(), FirstView {
}.attach()
tab_recommend.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab?) {
currentPosition = tab!!.position
mSelectTabIndex = tab!!.id
updateTab(tab, true, mSelectTabIndex)
}
......@@ -105,7 +111,7 @@ class FirstFragment : LazyLoadBaseFragment(), FirstView {
val text = it.findViewById<TextView>(R.id.item_tv)
val line = it.findViewById<View>(R.id.item_line)
if (isSelected) {
line.visibility=View.VISIBLE
line.visibility = View.VISIBLE
text.setTextColor(ContextCompat.getColor(requireContext(), R.color.black))
} else {
text.setTextColor(
......@@ -114,7 +120,7 @@ class FirstFragment : LazyLoadBaseFragment(), FirstView {
R.color.black
)
)
line.visibility=View.INVISIBLE
line.visibility = View.INVISIBLE
}
line.background =
ContextCompat.getDrawable(requireContext(), R.drawable.shape_line_corner_red)
......
......@@ -81,16 +81,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
initVp()
initListener()
loadData()
AppPreferencesManager.get().put(Constant.VEDIO_MAIN_COUNT, 0)
if (!UserManager.getInstance().vipFlag) {
AdManager.instance.preLoadAd(requireActivity())
}
Handler(Looper.getMainLooper()).postDelayed({
goToMainActivity()
}, 300)
}
/**
......@@ -111,10 +101,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
BannerManager.loadAd(requireActivity(), fl_main_banner)
if (AppConfig.exitLoginMainRefresh) {
AppConfig.exitLoginMainRefresh = false
loadData()
}
banner?.start()
setWatchingStatus()
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/header_layout" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btn_alipayauth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="15dp"
android:text="支付宝授权"
android:textColor="#454A69"
android:textSize="13sp" />
</LinearLayout>
</LinearLayout>
......@@ -79,7 +79,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:alpha="0.5"
android:text="看完即可解锁1集剧集"
android:text="看完即可解锁剧集"
android:textColor="#161823"
android:textSize="12sp"
tools:ignore="HardcodedText" />
......
......@@ -31,22 +31,22 @@ RELEASE_KEY_ALIAS=mints_roseplaylet
RELEASE_STORE_PASSWORD=mintsroseplaylet
RELEASE_STORE_FILE=mints_roseplaylet.jks
#ShareSDK
RELEASE_SHARESDK_KEY=38af89ff44247
RELEASE_SHARESDK_SECRET=96cb295278eb0f53b70e1cb807a74869
#ShareSDK-done
RELEASE_SHARESDK_KEY=3911a009c7983
RELEASE_SHARESDK_SECRET=a7cf0fd727fe6bb3f401af89b5bc0134
#weixin
WEIXIN_APP_PAY_ID ="wx78fff52fb3b373c5"
WEIXIN_APP_ID =wx78fff52fb3b373c5
WEIXIN_APP_SECRET =63a98dbec4bbc432dc92039be7229540
#umeng
RELEASE_UMENG_KEY=64b8de13a1a164591b5133df
#TalkingData
RELEASE_TALKING_DATA_KEY="51E408B7C0FE404F97A4F80B0BDC3C06"
#umeng-done
RELEASE_UMENG_KEY=677f617e8f232a05f1f2ed7a
#TalkingData-done
RELEASE_TALKING_DATA_KEY="DC37ADC2377443FB8169E55ECEB288F3"
#-done
GROMORE_APP_ID="5458827"
GROMORE_SPLASH_CODE="103327151"
GROMORE_VIDEO_CODE="103327050"
......@@ -54,7 +54,7 @@ GROMORE_EXPRESS_CODE="103326968"
GROMORE_MY_EXPRESS_CODE="103326968"
GROMORE_MAIN_EXPRESS_CODE="103326968"
GROMORE_DRAW_CODE="aa"
GROMORE_BANNER_CODE="102967255"
GROMORE_BANNER_CODE="103326455"
#tengxun IM
TX_XG_ACCESS_ID=""
......@@ -63,5 +63,5 @@ TX_XG_ACCESS_KEY=""
#mob
MobSDK.spEdition=FP
#ditu
RELEASE_MAP_KEY=e43edf1fc38bd7695e36516048830cef
\ No newline at end of file
#GaoDe-done
RELEASE_MAP_KEY=f19c75aa809e37df5c4c1839030b84ba
\ No newline at end of file
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