修改谷歌内购逻辑

This commit is contained in:
wushaocheng
2022-09-29 19:01:32 +08:00
parent 54b45b3ca2
commit 090454aaa0
9 changed files with 51 additions and 32 deletions

View File

@@ -32,6 +32,17 @@ android {
flavorDimensions 'default'
}
bundle {
language {
enableSplit = false
}
density {
enableSplit = true
}
abi {
enableSplit = true
}
}
//在apk文件后边生成版本号信息
android.applicationVariants.all {
@@ -127,7 +138,7 @@ android {
buildTypes {
release {
// buildConfigField "String", "BASE_URL", "\"https://api.lecheng163.com/\""
buildConfigField "String", "BASE_URL", "\"https://beta.api.pekolive.com/\""
buildConfigField "String", "BASE_URL", "\"http://beta.api.pekolive.com/\""
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
buildConfigField "String", "BASE_URL_STAGING", "BASE_URL"
buildConfigField "String", "BASE_URL_RELEASE", "BASE_URL"
@@ -138,7 +149,7 @@ android {
}
debug {
buildConfigField "String", "BASE_URL", "\"https://beta.api.pekolive.com/\""
buildConfigField "String", "BASE_URL", "\"http://beta.api.pekolive.com/\""
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
buildConfigField "String", "BASE_URL_STAGING", "\"https://api.lecheng163.com/\""
buildConfigField "String", "BASE_URL_RELEASE", "\"https://api.lecheng163.com/\""

View File

@@ -1,6 +1,5 @@
package com.yizhuan.erban.ui.login;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

View File

@@ -36,7 +36,7 @@ public class BillingManager implements PurchasesUpdatedListener {
private static final String TAG = "BillingManager";
/*购买key*/
private static final String BASE_64_ENCODED_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnagnKdJFBKmp3zb8lmnZfnRcVc7hRf39Zes2YaBQrhNIcesrbtSvV8uCHQrFLan1ekYVPT52mX+AylEvdQ3n5isotS2nfp0jf7l05bJ9bxVKGU7fe2jnT0B+rW2LJpacNzBj/pRDgp1TSN/kl/FI+SXP+jL6f8vhRMwY7GmSvOSHUl/pm8Imi0Se+Y7hBpUtTQioHF0oMiUuNH6vrB/eyx73//thS4D2YylPSN4Q8P4UTLpq4YMCGj8IbY6ZBjDRqGdUfLcb2eU6IRFoyHaBGZWfG/KdrCj1PfnEwh4hIBTBrnZXY1OhPPvztTLVx/sd8iIUX371GJ8GfWfuqvpTXQIDAQAB";
private static final String BASE_64_ENCODED_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs1/xs5aYKXp5iWlhuM763hAaNt3GneWBf2I4DjM2vTf43UWs1wgAnTpMIgoI80epnVPvdqbInu9fPMU7dp8d2XmjOF0GKydvnwUN0BpWKtg0kAcMCd7TW2s+FoZRmii2RkX2VGYMxLsCaN4P++DcpXQ8v8UyfvMNcLiVBeERM8+/FYfB94cA6OEoILb1bYwn4pGb7UlY7h11Zu0Hzmp2g209rfAmVRtO4SnEbvTicQI2l3mC6ggZi3pz5ffZxkWY7D3Y+NPgNogL/ZVZd8S8tt7lwpnmuF9s3fKcj3c6zun+B599YYxDVmZR688f5a43jc81/BHQwWKuMVCyCIPIFwIDAQAB";
/*客户端*/
private BillingClient billingClient;

View File

@@ -7,7 +7,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -59,12 +58,16 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
TextView mTv_gold;
@BindView(R.id.recyclerView)
RecyclerView mRecyclerView;
@BindView(R.id.tv_charge)
TextView mIvCharge;
private ChargeAdapter mChargeAdapter;
private final int BINDCODE_GOLD = 200;
private BillingManager billingManager;
private int mChargePosition = -1;
public static void start(Context context) {
Intent intent = new Intent(context, ChargeActivity.class);
context.startActivity(intent);
@@ -103,12 +106,11 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
@Override
public void onBillingClientSetupFinished() {
Log.i(TAG, "onBillingClientSetupFinished");
PayModel.get().getChargeList(4, AuthModel.get().getCurrentUid())
PayModel.get().getChargeList(1, AuthModel.get().getCurrentUid())
.compose(bindToLifecycle())
.subscribe(chargeListResult -> initProduceList(chargeListResult.getList()));
}
public void initProduceList(List<ChargeBean> chargeBeanList) {
final List<String> productKeys = new ArrayList<>();
@@ -144,10 +146,10 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED &&
purchase.getAccountIdentifiers() != null) {
PayModel.get().verifyOrder(
purchase.getAccountIdentifiers().getObfuscatedAccountId(),
purchase.getSkus().get(0),
purchase.getPackageName(),
purchase.getPurchaseToken())
purchase.getAccountIdentifiers().getObfuscatedAccountId(),
purchase.getSkus().get(0),
purchase.getPackageName(),
purchase.getPurchaseToken())
.compose(bindToLifecycle())
.subscribe(
token -> {
@@ -166,7 +168,7 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
eventValue.put(AFInAppEventParameterName.CONTENT_TYPE, "Gold");
eventValue.put(AFInAppEventParameterName.QUANTITY, 1);
eventValue.put(AFInAppEventParameterName.CONTENT_ID, purchase.getOrderId());
eventValue.put(AFInAppEventParameterName.REVENUE, skuDetails.getPriceAmountMicros() / 1000000f);
eventValue.put(AFInAppEventParameterName.REVENUE, skuDetails.getPriceAmountMicros() / 1000000f);
eventValue.put("Price", skuDetails.getPrice());
eventValue.put(AFInAppEventParameterName.CURRENCY, skuDetails.getPriceCurrencyCode());
AppsFlyerLib.getInstance().logEvent(getApplicationContext(), AFInAppEventType.PURCHASE, eventValue);
@@ -205,15 +207,6 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
}
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
if (billingManager != null) {
billingManager.destroy();
}
}
@Override
protected void onResume() {
super.onResume();
@@ -223,12 +216,29 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
getMvpPresenter().loadUserInfo();
}
@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
if (billingManager != null) {
billingManager.destroy();
}
}
private void initViews() {
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
mChargeAdapter = new ChargeAdapter();
mRecyclerView.setAdapter(mChargeAdapter);
mChargeAdapter.setOnItemClickListener((baseQuickAdapter, view, position) -> {
buyProduct(mChargeAdapter.getItem(position).getSkuDetails());
mChargePosition = position;
});
mIvCharge.setOnClickListener(view -> {
if (mChargePosition != -1) {
ChargeBean bean = mChargeAdapter.getItem(mChargePosition);
if (bean != null && bean.getSkuDetails() != null) {
buyProduct(bean.getSkuDetails());
}
}
});
}

View File

@@ -18,7 +18,7 @@
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_40"
app:layout_constraintTop_toTopOf="parent"
tools:layout_height="50dp" />
@@ -63,6 +63,7 @@
android:layout_centerHorizontal="true"
android:fontFamily="sans-serif-medium"
android:includeFontPadding="false"
android:text="0.0"
android:textColor="@color/color_333333"
android:textSize="@dimen/text_size_30"
android:layout_marginTop="@dimen/dp_4"

View File

@@ -25,7 +25,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.tencent.vasdolly:plugin:3.0.3'
classpath "com.mob.sdk:MobSDK:2018.0319.1724"
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.google.gms:google-services:4.3.13'
}
}

View File

@@ -242,7 +242,7 @@ public class XChatConstants {
/**
* Referer (DEBUG)
*/
public static final String KEY_REFERER_DEBUG = "https://beta.api.pekolive.com/";
public static final String KEY_REFERER_DEBUG = "http://beta.api.pekolive.com/";
/**
* Referer (RELEASE)

View File

@@ -421,12 +421,8 @@ public final class UserModel extends BaseModel implements IUserModel {
})
.doOnSuccess(data -> {
EventBus.getDefault().post(new CurrentUserInfoCompleteEvent());
if (data.getDefUser() != 4 && !data.isBindPhone()) {
EventBus.getDefault().post(new NeedBindPhoneEvent());
} else {
//如果是手机号码注册,完善资料后,登录流程结束,发出加载事件
EventBus.getDefault().post(new LoadLoginUserInfoEvent());
}
//完善资料后,登录流程结束,发出加载事件
EventBus.getDefault().post(new LoadLoginUserInfoEvent());
})
.doOnError(throwable -> {
EventBus.getDefault().post(new CurrentUserInfoCompleteFailEvent(throwable.getMessage()));

View File

@@ -4,6 +4,8 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import com.orhanobut.logger.Logger;
/**
* 设备信息工具类
*/
@@ -29,7 +31,7 @@ public class DeviceUtils {
installed = true;
}
} catch (Exception e) {
// Logger.info(TAG, "isAppInstalled packageName=" + packageName + " "+ e);
Logger.i("isAppInstalled packageName=" + packageName + " "+ e);
}
return installed;
}