diff --git a/Share/src/main/AndroidManifest.xml b/Share/src/main/AndroidManifest.xml index 7bc0a90cb..5cbbcc96d 100644 --- a/Share/src/main/AndroidManifest.xml +++ b/Share/src/main/AndroidManifest.xml @@ -4,7 +4,7 @@ > - + productList = ImmutableList.of(QueryProductDetailsParams.Product.newBuilder() + .setProductId(id) + .setProductType(BillingClient.ProductType.INAPP) + .build()); + QueryProductDetailsParams queryProductDetailsParams = + QueryProductDetailsParams.newBuilder() + .setProductList(productList) + .build(); + billingClient.queryProductDetailsAsync( + queryProductDetailsParams, + (billingResult, list) -> { + //查询商品成功 + int code = billingResult.getResponseCode(); + if (code != BillingClient.BillingResponseCode.OK || list == null || list.isEmpty()) { + String msg = billingResult.getDebugMessage(); + Log.e(TAG, "查询商品失败 code = " + code + " msg = " + msg); + return; + } + Log.e(TAG, "查询商品成功"); + buyIt(activity, orderNumber, list.get(0)); + } + ); + } + + //开始下单,准备生成订单了 + private void buyIt(Activity activity, String orderNumber, ProductDetails productDetails) { + List productDetailsParamsList = new ArrayList<>(); + productDetailsParamsList.add(BillingFlowParams.ProductDetailsParams.newBuilder() + // retrieve a value for "productDetails" by calling queryProductDetailsAsync() + .setProductDetails(productDetails) + // For one-time products, "setOfferToken" method shouldn't be called. + // For subscriptions, to get an offer token, call + // ProductDetails.subscriptionOfferDetails() for a list of offers + // that are available to the user. + //一次性商品不需要传token +// .setOfferToken(selectedOfferToken) + .build()); + + BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder() + .setProductDetailsParamsList(productDetailsParamsList) + .setObfuscatedAccountId(orderNumber)//好像是账号id + .build(); + + BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams); + int code = billingResult.getResponseCode(); + if (code != BillingClient.BillingResponseCode.OK) { + String msg = billingResult.getDebugMessage(); + Log.e(TAG, "购买商品失败 code = " + code + " msg = " + msg); +// ToastUtil.show(getString(R.string.pay_suc)); + return; + } + Log.e(TAG, "购买商品 " + productDetails.toString()); + } + + //消耗商品 支付成功之后,调用我们后台下发商品成功之后,调用消耗 + public void consume(List list) { + if (!init()) { + return; + } + for (Purchase purchase : list) { + getConsumeGoods(purchase); + } + } + + /** + * 消耗所有商品 + */ + public void consumeAll() { + if (!init()) { + return; + } + //以下示例展示了如何提取用户的订阅购买交易。请注意,queryPurchasesAsync() 仅返回有效订阅和非消耗型一次性购买交易。 + QueryPurchasesParams inAppPurchasesQuery = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP).build(); + billingClient.queryPurchasesAsync(inAppPurchasesQuery, (billingResult, list) -> { + if (BillingClient.BillingResponseCode.OK == billingResult.getResponseCode()) { + for (Purchase purchase : list) { + //0:PurchaseState.UNSPECIFIED_STATE:未知状态 + //1:PurchaseState.PURCHASED:付款完成 + //2:PurchaseState.PENDING:购买正在等待付款完成。 + if (Purchase.PurchaseState.PURCHASED == purchase.getPurchaseState()) { + //调用google去消费 + //如果之后还出现谷歌掉单的行为在来处理 + CommonHttpUtil.notifyGoogle(purchase.getPurchaseToken(), + purchase.getProducts().get(0), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + getConsumeGoods(purchase); + } + } + }); + } + } + } + }); + } + + /** + * 公共消费商品接口 + */ + private void getConsumeGoods(Purchase purchase) { + if (purchase != null) { + Log.i(TAG, "-----开始消耗商品:" + purchase.toString()); + ConsumeParams.Builder consumeParams = ConsumeParams.newBuilder(); + consumeParams.setPurchaseToken(purchase.getPurchaseToken()); + //调用消耗商品方法 + consumeAsync(consumeParams.build(), purchase); + } + } + + /** + * 消耗商品 + * int SERVICE_TIMEOUT = -3; //服务超时 + * int FEATURE_NOT_SUPPORTED = -2; //不支持功能 + * int SERVICE_DISCONNECTED = -1; //服务单元已断开 + * int OK = 0; //成功 + * int USER_CANCELED = 1; //用户按上一步或取消对话框 + * int SERVICE_UNAVAILABLE = 2; //网络连接断开 + * int BILLING_UNAVAILABLE = 3; //所请求的类型不支持 Google Play 结算服务 AIDL 版本 + * int ITEM_UNAVAILABLE = 4; //请求的商品已不再出售。 + * int DEVELOPER_ERROR = 5; //提供给 API 的参数无效。此错误也可能说明应用未针对结算服务正确签名或设置,或者在其清单中缺少必要的权限。 + * int ERROR = 6; //API 操作期间出现严重错误 + * int ITEM_ALREADY_OWNED = 7; //未能购买,因为已经拥有此商品 + * int ITEM_NOT_OWNED = 8; //未能消费,因为尚未拥有此商品 + */ + private void consumeAsync(ConsumeParams consumeParams, Purchase purchase) { + if (!init()) { + return; + } + billingClient.consumeAsync(consumeParams, (billingResult, purchaseToken) -> { + if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { + Log.i(TAG, "-----消耗商品成功"); + } else { + Log.i(TAG, "-----消耗商品失败" + billingResult.toString() + "---" + purchaseToken + "--code:" + billingResult.getResponseCode()); + } + }); + } + + @Override + public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List purchases) { + if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK + && purchases != null) { + //支付成功 + if (billingListener != null)//消耗掉商品放到外面调用我们服务器成功的时候去消耗 todo 暂时注释掉 这样可以模拟掉单的问题 + billingListener.onPaySuccess(purchases); + /* + * 一旦您验证了购买交易,您的应用就可以向用户授予使用权了。若要确认与购买交易相关联的用户账号, + * 您可以使用 Purchases.products:get 返回的 ProductPurchase.obfuscatedExternalAccountId(适用于应用内商品的购买交易) + * 和 Purchases.subscriptions:get 返回的 SubscriptionPurchase.obfuscatedExternalAccountId(适用于服务器端的订阅), + * 或者 Purchase.getAccountIdentifiers() 在客户端返回的 obfuscatedAccountId(如果在交易时已使用 setObfuscatedAccountId 设置该 ID)。 + * */ +// purchases.get(0).getAccountIdentifiers() + for (Purchase purchase : purchases) { + Log.d("mLog", "谷歌支付的回调 " + purchase); + } + } else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) { + //取消支付了 + if (billingListener != null) + billingListener.onPayFailed(CommonAppContext.sInstance.getString(R.string.pay_cancel)); + } else { + //支付失败 + if (billingListener != null) + billingListener.onPayFailed(CommonAppContext.sInstance.getString(R.string.pay_fail)); + } + } + + /** + * 检测GooglePlay服务是否可用(需要导入包api "com.google.android.gms:play-services-location:11.8.0",也可以不检查,跳过这个代码) + */ + public boolean getGoogleService() { + GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); + if (googleApiAvailability != null) { + int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(CommonAppContext.sInstance); + return resultCode == ConnectionResult.SUCCESS; + } + return false; + } + + public String getAdId() { + try { + return AdvertisingIdClient.getAdvertisingIdInfo(CommonAppContext.sInstance).getId(); + } catch (Exception e) { + e.printStackTrace(); + Log.e("GooglePlay", "获取谷歌的id错误了"); + } + return "google_default_id"; + } + + public void setBillingListener(GoogleBillingListener listener) { + billingListener = listener; + } + + /** + * 定义接口返回支付结果 + */ + public interface GoogleBillingListener { + void onPaySuccess(List purchases); + + void onPayFailed(String msg); + } + + public static class GooglePlayHelper { + static GooglePlay googlePlay = new GooglePlay(); + } + + public static GooglePlay getInstance() { + return GooglePlayHelper.googlePlay; + } +} diff --git a/common/src/main/java/com/yunbao/common/utils/ProcessImageUtil.java b/common/src/main/java/com/yunbao/common/utils/ProcessImageUtil.java index 1c848afe0..86fee0d3a 100644 --- a/common/src/main/java/com/yunbao/common/utils/ProcessImageUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/ProcessImageUtil.java @@ -83,7 +83,7 @@ public class ProcessImageUtil extends ProcessResultUtil { if (mNeedCrop) { Uri uri = null; if (Build.VERSION.SDK_INT >= 24) { - uri = FileProvider.getUriForFile(mContext, "com.pandora.sy.fileprovider", mCameraResult); + uri = FileProvider.getUriForFile(mContext, "com.newpandora.yo.fileprovider", mCameraResult); } else { uri = Uri.fromFile(mCameraResult); } @@ -195,7 +195,7 @@ public class ProcessImageUtil extends ProcessResultUtil { mCameraResult = getNewFile(); Uri uri = null; if (Build.VERSION.SDK_INT >= 24) { - uri = FileProvider.getUriForFile(mContext, "com.pandora.sy.fileprovider", mCameraResult); + uri = FileProvider.getUriForFile(mContext, "com.newpandora.yo.fileprovider", mCameraResult); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else { uri = Uri.fromFile(mCameraResult); @@ -255,7 +255,7 @@ public class ProcessImageUtil extends ProcessResultUtil { startActivityForResult(intent, mCropResultCallback); } catch (Exception e) { try { - Uri resultUri = FileProvider.getUriForFile(mContext, "com.pandora.sy.fileprovider", mCorpResult); + Uri resultUri = FileProvider.getUriForFile(mContext, "com.newpandora.yo.fileprovider", mCorpResult); if (resultUri == null || mFragment == null || mContext == null) { return; } diff --git a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java index 2cfa48347..90cd72c12 100644 --- a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java @@ -63,7 +63,7 @@ public class VersionUtil { @Override public void onConfirmClick(Dialog dialog, String content) { Intent i = new Intent(android.content.Intent.ACTION_VIEW); - i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pandora.sy")); + i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.newpandora.yo")); context.startActivity(i); context.finish(); } @@ -85,7 +85,7 @@ public class VersionUtil { @Override public void onConfirmClick(Dialog dialog, String content) { Intent i = new Intent(android.content.Intent.ACTION_VIEW); - i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pandora.sy")); + i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.newpandora.yo")); context.startActivity(i); context.finish(); } diff --git a/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java b/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java index 9119f523b..4552663be 100644 --- a/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java @@ -128,7 +128,7 @@ public class APKUpdateCustomPopup extends CenterPopupView { public void onViewClicks() { if (CommonAppConfig.IS_GOOGLE_PLAY == 1) { Intent i = new Intent(android.content.Intent.ACTION_VIEW); - i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pandora.sy")); + i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.newpandora.yo")); mContext.startActivity(i); mContext.finish(); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) { diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 803281b67..3be3715de 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -651,7 +651,7 @@ 歡迎來到PDLIVE 恭喜你獲得了新人獎勵 - com.pandora.sy.fileprovider + com.newpandora.yo.fileprovider 數量 diff --git a/config.gradle b/config.gradle index 6b8b5a680..99c195cef 100644 --- a/config.gradle +++ b/config.gradle @@ -4,7 +4,7 @@ ext { buildToolsVersion: "29.0.2", minSdkVersion : 23, targetSdkVersion : 34, - versionCode : 550, + versionCode : 600, versionName : "6.8.0", namespace : "com.pandoralive.shayu" ] diff --git a/gradle.properties b/gradle.properties index d015f4ba1..6f233b2b9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,6 @@ android.nonTransitiveRClass=false systemProp.http.proxyHost=127.0.0.1 systemProp.https.proxyHost=127.0.0.1 -systemProp.https.proxyPort=9098 -systemProp.http.proxyPort=9098 -#android.enableR8.fullMode=true \ No newline at end of file +systemProp.https.proxyPort=10809 +systemProp.http.proxyPort=10809 +android.enableR8.fullMode=true \ No newline at end of file diff --git a/main/google-services.json b/main/google-services.json deleted file mode 100644 index 293dd2490..000000000 --- a/main/google-services.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "project_info": { - "project_number": "867032862719", - "project_id": "pdlnew", - "storage_bucket": "pdlnew.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:867032862719:android:841a73fdfb6c37453ae1ca", - "android_client_info": { - "package_name": "com.pandora.sy" - } - }, - "oauth_client": [ - { - "client_id": "867032862719-af2dnojobjd8s6ekdr1is1vev8nk36sv.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.pandora.sy", - "certificate_hash": "38cc19306c9facee36a9224e9a4070bc0be15c7d" - } - }, - { - "client_id": "867032862719-ohaa1f18e186qpasvgt7qkk1i1pivniq.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.pandora.sy", - "certificate_hash": "b66dc8d21cfcf6c729577ddcf0c312b2a31ed872" - } - }, - { - "client_id": "867032862719-snpbqruvqcc9fsifjnmm1h3dcgtr8am4.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.pandora.sy", - "certificate_hash": "15fc5e70cf238323bf7111c8c627803985478e87" - } - }, - { - "client_id": "867032862719-ep4r92lpjmn7gs9tg0r7q0l75a4gm9mt.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyAnlY2aBEGyg7QpghHo7EaMRkM89dVNgq8" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "867032862719-ep4r92lpjmn7gs9tg0r7q0l75a4gm9mt.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/EntryActivity.java b/main/src/main/java/com/yunbao/main/activity/EntryActivity.java index df1af477c..e223a0e15 100644 --- a/main/src/main/java/com/yunbao/main/activity/EntryActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/EntryActivity.java @@ -441,7 +441,7 @@ public class EntryActivity extends AppCompatActivity { } else if (loginType == 4) { try { // App-to-app login - Intent loginIntent = LineLoginApi.getLoginIntent(findViewById(R.id.btn_line).getContext(), "1656399535", new LineAuthenticationParams.Builder().scopes(Arrays.asList(Scope.PROFILE)) + Intent loginIntent = LineLoginApi.getLoginIntent(findViewById(R.id.btn_line).getContext(), "2006124380", new LineAuthenticationParams.Builder().scopes(Arrays.asList(Scope.PROFILE)) // .nonce("") // nonce can be used to improve security .build()); startActivityForResult(loginIntent, 1001); diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index 3c2ddda23..c0519899e 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -1,8 +1,6 @@ package com.yunbao.main.activity; -import static com.yunbao.main.activity.MyWalletActivity.dis; - import android.annotation.SuppressLint; import android.os.Bundle; import android.os.Handler; @@ -16,15 +14,17 @@ import android.webkit.WebView; import androidx.fragment.app.Fragment; -import com.facebook.appevents.AppEventsConstants; +import com.android.billingclient.api.Purchase; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.utils.GoogleUtils; +import com.yunbao.common.pay.google.GooglePlay; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.R; import com.yunbao.main.views.TestWebViewClient; +import java.util.List; + @SuppressLint("ValidFragment") public class GoogleFragment extends Fragment { @@ -38,7 +38,7 @@ public class GoogleFragment extends Fragment { private String url; String adid = null; - GoogleUtils googleUtils; + private GooglePlay googlePlay; boolean isGoogleService = true; @@ -62,17 +62,16 @@ public class GoogleFragment extends Fragment { Log.e("ttt", url); rlWebview.loadUrl(url); - googleUtils = new GoogleUtils(getActivity()); + googlePlay = GooglePlay.getInstance(); // 验证是否已在此设备上安装并启用Google Play服务,以及此设备上安装的旧版本是否为此客户端所需的版本 - if (googleUtils.getGoogleService()) { + if (googlePlay.getGoogleService()) { isGoogleService = true; // 支持Google服务 - initGooglePay(); new Thread() { @Override public void run() { - adid = googleUtils.getAdid(); + adid = googlePlay.getAdId(); } }.start(); } @@ -100,11 +99,6 @@ public class GoogleFragment extends Fragment { String TAG = "GooglePay"; - private void initGooglePay() { - googleUtils = new GoogleUtils(getActivity()); - googleUtils.initGooglePay(); - } - private Handler payHandler = new Handler(); //js调用原生 @@ -117,51 +111,31 @@ public class GoogleFragment extends Fragment { mProductId = ProductId; mOrderid = OrderNumber; MoneyUsds = MoneyUsd; - - googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() { + googlePlay.setBillingListener(new GooglePlay.GoogleBillingListener() { @Override - public void onPaySuccess(String token, String orderId) { - payHandler.post(new Runnable() { - @Override - public void run() { - CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() { + public void onPaySuccess(List purchases) { + Log.i("mLog", "调用谷歌支付成功了 " + purchases.toString()); + CommonHttpUtil.notifyGoogle(purchases.get(0).getPurchaseToken(), + purchases.get(0).getProducts().get(0), new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { if (code == 0) { - Bundle params = new Bundle(); - params.putString("currency", "HKD"); - params.putString("money", MoneyUsds); - Bundle fb_params = new Bundle(); - fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); - fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId); - //Google官方充值通知 - Bundle google_params = new Bundle(); - google_params.putString("currency", "HKD"); - google_params.putString("product_id", mProductId); - google_params.putString("transaction_id", mOrderid); - google_params.putString("value", MoneyUsds); - google_params.putString("price", MoneyUsds); - google_params.putString("quantity", "1"); - dis(); + googlePlay.consume(purchases); + getActivity().finish(); ToastUtil.show(getString(R.string.pay_suc)); + } else { + ToastUtil.show(msg); } } }); - } - }); } @Override public void onPayFailed(String msg) { - payHandler.post(new Runnable() { - @Override - public void run() { - ToastUtil.show(msg); - } - }); + ToastUtil.show(msg); } }); - googleUtils.purchase(mProductId); + googlePlay.purchase(getActivity(), mOrderid, mProductId); } lastClickTime = currentTime; diff --git a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java index 2255da348..d13018967 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java @@ -18,17 +18,18 @@ import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; import com.alibaba.android.arouter.facade.annotation.Route; -import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.fragment.LoadingDialog; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.IMLoginManager; +import com.yunbao.common.pay.google.GooglePlay; import com.yunbao.common.pay.hw.HwBuilder; import com.yunbao.common.pay.samsung.SamsungUtil; import com.yunbao.common.utils.GoogleUtils; import com.yunbao.common.utils.L; +import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.main.R; @@ -62,7 +63,7 @@ public class MyWalletActivity extends AbsActivity { public static String orderId; HwBuilder hwBuilder; - GoogleUtils googleUtils; + private GooglePlay googlePlay; LoadingDialog loadingDialog; SamsungUtil samsungUtil; @@ -78,17 +79,15 @@ public class MyWalletActivity extends AbsActivity { mw = MyWalletActivity.this; setTitle(mContext.getString(R.string.wallet)); - if (CommonAppConfig.IS_GOOGLE_PLAY == 1) { - googleUtils = new GoogleUtils(mContext); - googleUtils.initGooglePay(); - } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) { + if (CommonAppConfig.IS_GOOGLE_PLAY == 2) { hwBuilder = new HwBuilder(MyWalletActivity.this); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) { samsungUtil = SamsungUtil.newInstance(mContext); samsungUtil.init(); - }else{ - googleUtils = new GoogleUtils(mContext); - googleUtils.initGooglePay(); + } else { + googlePlay = GooglePlay.getInstance(); + //消耗所有商品 + googlePlay.consumeAll(); } @@ -104,50 +103,8 @@ public class MyWalletActivity extends AbsActivity { loadingDialog.setShowText(getString(R.string.order_query)); if (CommonAppConfig.IS_GOOGLE_PLAY == 1) { - googleUtils.setQueryPurchaseListener(mContext, new GoogleUtils.QueryPurchasesListener() { - @Override - public void onResult(JSONObject obj) { - try { - int code = obj.getInt("querySize"); - if (code == 0) { - payHandler.post(runnable1); - payHandler.postDelayed(runnable2, 1000); - } else { - JSONArray tokenList = obj.getJSONArray("tokenList"); - JSONArray orderList = obj.getJSONArray("orderList"); - String tradeNo = obj.getString("tradeNo"); - - for (int i = 0; i < tokenList.length(); i++) { - int finalI = i; - payHandler.post(new Runnable() { - @Override - public void run() { - //谷歌掉单处理 - try { - CommonHttpUtil.Google_sec_pay(tokenList.getString(finalI), orderList.getString(finalI), tradeNo, new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (finalI == tokenList.length() - 1) { - loadingDialog.setShowText(getString(R.string.order_query_success)); - loadingDialog.dismiss(); - } - ToastUtil.show("充值已到账"); - finish(); - } - }); - } catch (JSONException e) { - e.printStackTrace(); - } - } - }); - } - } - } catch (JSONException e) { - e.printStackTrace(); - } - } - }); - googleUtils.queryPurchasesAsync(); + //消耗所有商品 + googlePlay.consumeAll(); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) { hwBuilder.consume(); payHandler.post(runnable1); @@ -186,12 +143,12 @@ public class MyWalletActivity extends AbsActivity { googleFragment1 = new GoogleFragment(); Bundle bundle1 = new Bundle(); - bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); googleFragment1.setArguments(bundle1); googleFragment2 = new GoogleFragment(); Bundle bundle2 = new Bundle(); - bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); googleFragment2.setArguments(bundle2); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) { //华为 @@ -203,12 +160,12 @@ public class MyWalletActivity extends AbsActivity { huaWeiFragment1 = new HuaWeiFragment(); Bundle bundle1 = new Bundle(); - bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"); + bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo"); huaWeiFragment1.setArguments(bundle1); huaWeiFragment2 = new HuaWeiFragment(); Bundle bundle2 = new Bundle(); - bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"); + bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo"); huaWeiFragment2.setArguments(bundle2); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) { @@ -271,12 +228,12 @@ public class MyWalletActivity extends AbsActivity { huaWeiFragment1 = new HuaWeiFragment(); Bundle bundle1 = new Bundle(); - bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"); + bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo"); huaWeiFragment1.setArguments(bundle1); huaWeiFragment2 = new HuaWeiFragment(); Bundle bundle2 = new Bundle(); - bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"); + bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo"); huaWeiFragment2.setArguments(bundle2); } else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) { rView.setVisibility(View.VISIBLE); @@ -287,12 +244,12 @@ public class MyWalletActivity extends AbsActivity { samsungFragment1 = new SamsungFragment(); Bundle bundle1 = new Bundle(); - bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); samsungFragment1.setArguments(bundle1); samsungFragment2 = new SamsungFragment(); Bundle bundle2 = new Bundle(); - bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); samsungFragment2.setArguments(bundle2); } else { Log.i("tss", "不是首充"); @@ -300,17 +257,17 @@ public class MyWalletActivity extends AbsActivity { walletFragment = new WalletFragment(); Bundle bundle = new Bundle(); - bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); walletFragment.setArguments(bundle); googleFragment1 = new GoogleFragment(); Bundle bundle1 = new Bundle(); - bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); googleFragment1.setArguments(bundle1); googleFragment2 = new GoogleFragment(); Bundle bundle2 = new Bundle(); - bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); + bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=panduo" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")); googleFragment2.setArguments(bundle2); } } @@ -491,7 +448,7 @@ public class MyWalletActivity extends AbsActivity { } catch (JSONException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } diff --git a/main/src/main/res/layout/activity_entry.xml b/main/src/main/res/layout/activity_entry.xml index 98746db2c..88a886002 100644 --- a/main/src/main/res/layout/activity_entry.xml +++ b/main/src/main/res/layout/activity_entry.xml @@ -191,8 +191,7 @@ android:layout_height="57dp" android:layout_gravity="center" android:layout_weight="1" - android:src="@mipmap/login_line" - android:visibility="visible" /> + android:src="@mipmap/login_line" />