Refine ebegging

This commit is contained in:
Mygod
2018-07-13 17:41:30 +08:00
parent 33cd906f65
commit ef63f3173b
3 changed files with 5 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 28 targetSdkVersion 28
resConfigs "zh-rCN" resConfigs "zh-rCN"
versionCode 26 versionCode 29
versionName "1.3.5" versionName "1.3.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }

View File

@@ -21,7 +21,6 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.BILLING"/>
<uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>

View File

@@ -47,8 +47,7 @@ class EBegFragment : DialogFragment(), PurchasesUpdatedListener, BillingClientSt
view.findViewById<Button>(R.id.donations__google_android_market_donate_button).setOnClickListener { view.findViewById<Button>(R.id.donations__google_android_market_donate_button).setOnClickListener {
val skus = skus val skus = skus
if (skus == null) { if (skus == null) {
openDialog(android.R.drawable.ic_dialog_alert, openDialog(R.string.donations__google_android_market_not_supported_title,
R.string.donations__google_android_market_not_supported_title,
getString(R.string.donations__google_android_market_not_supported)) getString(R.string.donations__google_android_market_not_supported))
} else billingClient.launchBillingFlow(requireActivity(), BillingFlowParams.newBuilder() } else billingClient.launchBillingFlow(requireActivity(), BillingFlowParams.newBuilder()
.setSku(skus[googleSpinner.selectedItemPosition].sku).setType(BillingClient.SkuType.INAPP).build()) .setSku(skus[googleSpinner.selectedItemPosition].sku).setType(BillingClient.SkuType.INAPP).build())
@@ -60,8 +59,7 @@ class EBegFragment : DialogFragment(), PurchasesUpdatedListener, BillingClientSt
} }
} }
private fun openDialog(icon: Int, title: Int, message: String) = AlertDialog.Builder(requireContext()).apply { private fun openDialog(title: Int, message: String) = AlertDialog.Builder(requireContext()).apply {
setIcon(icon)
setTitle(title) setTitle(title)
setMessage(message) setMessage(message)
isCancelable = true isCancelable = true
@@ -96,8 +94,8 @@ class EBegFragment : DialogFragment(), PurchasesUpdatedListener, BillingClientSt
} }
override fun onConsumeResponse(responseCode: Int, purchaseToken: String?) { override fun onConsumeResponse(responseCode: Int, purchaseToken: String?) {
if (responseCode == BillingClient.BillingResponse.OK) { if (responseCode == BillingClient.BillingResponse.OK) {
openDialog(android.R.drawable.ic_dialog_info, R.string.donations__thanks_dialog_title, openDialog(R.string.donations__thanks_dialog_title, getString(R.string.donations__thanks_dialog))
getString(R.string.donations__thanks_dialog)) dismiss()
} else Crashlytics.log(Log.ERROR, TAG, "onConsumeResponse: $responseCode") } else Crashlytics.log(Log.ERROR, TAG, "onConsumeResponse: $responseCode")
} }
} }