上架小米,vivo配置信息

This commit is contained in:
Martin 2024-10-07 10:00:33 +08:00
parent 37d213f031
commit 921f80dd7a
8 changed files with 205 additions and 1 deletions

View File

@ -4,7 +4,7 @@ ext {
buildToolsVersion: "29.0.2", buildToolsVersion: "29.0.2",
minSdkVersion : 23, minSdkVersion : 23,
targetSdkVersion : 34, targetSdkVersion : 34,
versionCode : 698, versionCode : 700,
versionName : "6.8.1" versionName : "6.8.1"
] ]
manifestPlaceholders = [ manifestPlaceholders = [

1
lib_xiaomi_pay/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,39 @@
apply plugin: 'com.android.library'
apply from: "../package_config.gradle"
android {
namespace "com.shayu.lib_xiaomi_pay"
compileSdk rootProject.ext.android.compileSdkVersion
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode rootProject.ext.android.versionCode
versionName rootProject.ext.android.versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_18
targetCompatibility JavaVersion.VERSION_18
}
}
dependencies {
implementation rootProject.ext.dependencies["appcompat-androidx"]
//
api ' implementation "com.xiaomi.billingclient:billing:1.1.3"'
implementation 'com.android.billingclient:billing:7.1.0'
//implementation platform('com.google.firebase:firebase-bom:30.5.0')
//implementation 'com.google.firebase:firebase-crashlytics'
}

View File

30
lib_xiaomi_pay/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,30 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View File

@ -0,0 +1,129 @@
package com.shayu.lib_xiaomi.utils;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingFlowParams;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchasesUpdatedListener;
import com.android.billingclient.api.SkuDetails;
import com.android.billingclient.api.SkuDetailsParams;
import com.android.billingclient.api.SkuDetailsResponseListener;
import java.util.ArrayList;
import java.util.List;
/**
* 小米支付
*/
public class XiaomiBillingManage {
private Activity mContext;
private String TAG = "XiaomiBillingManage";
BillingClient billingClient;
public XiaomiBillingManage(Activity activity) {
this.mContext = activity;
}
/**
* 此监听器可接收应用中所有购买交易的更新
*/
private PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
@Override
public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
// To be implemented in a later section.
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
if (purchases != null && purchases.size() > 0) {
//处理购买
}
} else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {
//支付取消
} else {
//处理其他响应码
}
}
};
/**
* 连接到Google Play Billing服务
*/
private final BillingClientStateListener billingClientStateListener = new BillingClientStateListener() {
@Override
public void onBillingServiceDisconnected() {
Log.d("TAG", "onBillingServiceDisconnected");
}
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
Log.d("TAG", "Service.code : " + billingResult.getResponseCode() + " msg : " + billingResult.getDebugMessage());
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
}
}
};
/**
* 初始化小米支付
* @param mContext
*/
public void initXiaomiPay(Context mContext) {
billingClient = BillingClient.newBuilder(mContext).setListener(purchasesUpdatedListener).build();
}
/**
*建立连接
*/
public void connectXiaomiPay(){
billingClient.startConnection(billingClientStateListener);
//billingClient.launchBillingFlow(mContext,)
}
/**
* 判断服务是否可用
*/
public boolean isReady(){
if (billingClient == null) {
return false;
}
return billingClient.isReady();
}
public void querySkuList(){
List<String> skuList = new ArrayList<>();
skuList.add("Game-10");//以实际业务为准
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(@NonNull BillingResult billingResult,
@Nullable List<SkuDetails> list) {
Log.d("TAG", "onSkuDetailsResponse");
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
if (list != null && list.size() > 0) {
// get list
Log.e("xiaomi_pay",list.get(0).getSubscriptionPeriod());
//创建BillingFlowParams对象
BillingFlowParams params = BillingFlowParams.newBuilder()
.setSkuDetails(list.get(0))
.setIsOfferPersonalized(true)
.setObfuscatedAccountId("xxx")
.setObfuscatedProfileId("yyy")
.build();
BillingResult result = billingClient.launchBillingFlow(mContext, params);
}
}
}
});
}
}

View File

@ -10,3 +10,4 @@ include ':IAP6Helper'
include ':lib_faceunity' include ':lib_faceunity'
//include ':SVGAlibrary' //include ':SVGAlibrary'
include ':TabLayout' include ':TabLayout'
//include ':lib_xiaomi_pay'