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

[提交人]:王雪伟

[提交简述] :添加翻译
[实现方案] :
parent 9f96b6e2
...@@ -89,4 +89,5 @@ dependencies { ...@@ -89,4 +89,5 @@ dependencies {
implementation(name: 'alipaySdk-15.6.4-20190611174341', ext: 'aar') implementation(name: 'alipaySdk-15.6.4-20190611174341', ext: 'aar')
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' //implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation("com.android.billingclient:billing:4.1.0")
} }
...@@ -3,7 +3,17 @@ ...@@ -3,7 +3,17 @@
package="com.zxhl.cms"> package="com.zxhl.cms">
<application> <application>
<activity android:name=".googlepay.GooglePayActivity"></activity> <activity android:name=".googlepay.GooglePayActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="google_pay"
android:scheme="magicbox" />
</intent-filter>
</activity>
<activity android:name=".common.WebActivity"> <activity android:name=".common.WebActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
......
package com.zxhl.cms.googlepay package com.zxhl.cms.googlepay
import android.util.Log
import android.view.View import android.view.View
import com.android.billingclient.api.*
import com.android.billingclient.api.BillingClient.SkuType
import com.zxhl.cms.AppContext
import com.zxhl.cms.R import com.zxhl.cms.R
import com.zxhl.cms.common.base.BaseActivity import com.zxhl.cms.common.base.BaseActivity
import kotlinx.android.synthetic.main.activity_google_pay.*
class GooglePayActivity : BaseActivity() { class GooglePayActivity : BaseActivity() {
private val TAG = "GooglePayActivity"
private val purchasesUpdatedListener =
PurchasesUpdatedListener { billingResult, purchases ->
// To be implemented in a later section.
Log.d(TAG, "purchasesUpdatedListener" + billingResult.responseCode)
Log.d(TAG, "purchasesUpdatedListener" + purchases?.size)
}
private var billingClient = BillingClient.newBuilder(AppContext.get())
.setListener(purchasesUpdatedListener)
.enablePendingPurchases()
.build()
override fun onClick(v: View?) { override fun onClick(v: View?) {
TODO("Not yet implemented")
} }
override fun layoutID(): Int { override fun layoutID(): Int {
...@@ -15,6 +33,50 @@ class GooglePayActivity : BaseActivity() { ...@@ -15,6 +33,50 @@ class GooglePayActivity : BaseActivity() {
} }
override fun init() { override fun init() {
id_btn_google_pay.setOnClickListener {
}
startConnection()
} }
fun startConnection() {
billingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult: BillingResult) {
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
// The BillingClient is ready. You can query purchases here.
// BillingClient准备好了。你可以在这里查询购买情况。
//querySkuDetails()
querySkuDetails()
}
Log.d(TAG, billingResult.toString())
}
override fun onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// 尝试在下一次请求时重新启动连接
// Google Play by calling the startConnection() method.
// 谷歌通过调用startConnection()方法来播放。
startConnection()
Log.d(TAG, "onBillingServiceDisconnected")
}
})
}
fun querySkuDetails() {
val skuList: MutableList<String> = ArrayList()
skuList.add("premium_upgrade")
skuList.add("gas")
val params = SkuDetailsParams.newBuilder()
params.setSkusList(skuList).setType(SkuType.INAPP)
billingClient.querySkuDetailsAsync(
params.build()
) { billingResult, skuDetailsList ->
// Process the result.
Log.d(TAG, "billingResult ${billingResult.responseCode}")
Log.d(TAG, "skuDetailsList ${skuDetailsList?.size}")
}
}
} }
\ No newline at end of file
package com.zxhl.cms.pay package com.zxhl.cms.pay
import android.content.Intent
import android.os.Handler import android.os.Handler
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
...@@ -10,6 +11,7 @@ import com.zxhl.cms.R ...@@ -10,6 +11,7 @@ import com.zxhl.cms.R
import com.zxhl.cms.common.Constant import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.common.base.BaseActivity import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.googlepay.GooglePayActivity
import com.zxhl.cms.net.SettingPreference import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.model.box.AppInEntity import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.net.model.video.MemberEntity import com.zxhl.cms.net.model.video.MemberEntity
...@@ -71,6 +73,7 @@ class PayActivity : BaseActivity(), PayContract.View, ...@@ -71,6 +73,7 @@ class PayActivity : BaseActivity(), PayContract.View,
) )
id_img_back?.setOnClickListener { id_img_back?.setOnClickListener {
finish() finish()
startActivity(Intent(this,GooglePayActivity::class.java))
} }
id_activity_member_close?.setOnClickListener { id_activity_member_close?.setOnClickListener {
finish() finish()
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".googlepay.GooglePayActivity"> tools:context=".googlepay.GooglePayActivity">
</androidx.constraintlayout.widget.ConstraintLayout> <Button
\ No newline at end of file android:id="@+id/id_btn_google_pay"
android:text="GooglePay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
...@@ -72,11 +72,11 @@ ...@@ -72,11 +72,11 @@
<string name="box_detail_open_box_one_lottery_btn">Open</string> <string name="box_detail_open_box_one_lottery_btn">Open</string>
<string name="box_detail_open_box_five_lottery_btn">Open 5x</string> <string name="box_detail_open_box_five_lottery_btn">Open 5x</string>
<string name="box_detail_open_box_shop_pool_tips">爆率按商品等级划分</string> <string name="box_detail_open_box_shop_pool_tips">爆率按商品等级划分</string>
<string name="box_detail_open_box_bottom_desc">到我的底线咯</string> <string name="box_detail_open_box_bottom_desc">No more data</string>
<string name="box_detail_open_box_shop_pool_gailv">概率%1$s</string> <string name="box_detail_open_box_shop_pool_gailv">概率%1$s</string>
<string name="box_detail_open_box_result_btn_happy">开心收下</string> <string name="box_detail_open_box_result_btn_happy">Take it</string>
<string name="box_detail_open_box_result_btn_try">试试手气</string> <string name="box_detail_open_box_result_btn_try">Try my luck</string>
<string name="box_detail_open_box_result_btn_konw">我知道了</string> <string name="box_detail_open_box_result_btn_konw">Got it</string>
<string name="box_detail_open_box_result_btn_one_again">Open</string> <string name="box_detail_open_box_result_btn_one_again">Open</string>
<string name="box_detail_open_box_result_btn_five_again">再来五发</string> <string name="box_detail_open_box_result_btn_five_again">再来五发</string>
<string name="box_detail_open_box_result_btn_receive">立即收下</string> <string name="box_detail_open_box_result_btn_receive">立即收下</string>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<LinearLayout <LinearLayout
android:id="@+id/id_props_card_bg" android:id="@+id/id_props_card_bg"
android:layout_width="wrap_content" android:layout_width="260dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:background="@drawable/props_card_bj_dialog_chongchou_weihuode" android:background="@drawable/props_card_bj_dialog_chongchou_weihuode"
......
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