-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Amazon in-app purchasing has been added. - Well written support for subscriptions and in-app purchases. - Tests have been added.
- Loading branch information
Showing
21 changed files
with
901 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/src/main/java/com/alphelios/richierich/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package com.alphelios.richierich | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.alphelios.iap.IapConnector | ||
import com.alphelios.iap.PurchaseServiceListener | ||
import com.alphelios.iap.SubscriptionServiceListener | ||
import com.alphelios.richierich.databinding.ActivityMainBinding | ||
|
||
class MainActivity : AppCompatActivity(R.layout.activity_main) { | ||
|
||
private lateinit var binding: ActivityMainBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityMainBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.bottomnavview.itemIconTintList = null | ||
|
||
val skuList = listOf("base", "moderate", "quite", "plenty", "yearly") | ||
val subsList = listOf("subscribe") | ||
|
||
val iapConnector = IapConnector( | ||
this, | ||
skuList, | ||
subsList, | ||
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh09sfdDzMhCh3AG9mq2EsyFUN72FBKabPpMsJyUUwXVsVJRLDWQYKmWnr0bVGsdVHwQtEDi//EY1NubXjCmViAxFnnfbdUrAk9PbRRTaMQ4taifn9fCaQ6XAW70ju3/mXuL+1xX+r8B0O9B373sP0YqiUs0b8HTtTjQoOGtcGb2KlYpQlJjjtISfVpsSk2RdKatkDyeesv+6568O7xgb5zp/KNJk8d1fMqKGWJiveFkZvedDh1ECdi3rSz1aQB+z/aEf6AIiuLzu0V8NNKjvZnxUjVJgL+lcLDrL1YZuKx9h5BX7k8lPZI7fLIVE6b6iNx3msfVdiqPkZ3s49JxA1QIDAQAB", | ||
true | ||
) | ||
|
||
iapConnector.addPurchaseListener(object : PurchaseServiceListener { | ||
override fun onPricesUpdated(iapKeyPrices: Map<String, String>) { | ||
// list of available products will be received here, so you can update UI with prices if needed | ||
} | ||
|
||
override fun onProductPurchased(sku: String?) { | ||
when (sku) { | ||
"base" -> { | ||
|
||
} | ||
"moderate" -> { | ||
|
||
} | ||
"quite" -> { | ||
|
||
} | ||
"plenty" -> { | ||
|
||
} | ||
"subscribe" -> { | ||
|
||
} | ||
"yearly" -> { | ||
|
||
} | ||
} | ||
} | ||
|
||
override fun onProductRestored(sku: String?) { | ||
// will be triggered fetching owned products using IAPManager.init(); | ||
} | ||
}) | ||
|
||
iapConnector.addSubscriptionListener(object : SubscriptionServiceListener { | ||
override fun onSubscriptionRestored(sku: String?) { | ||
// will be triggered upon fetching owned subscription upon initialization | ||
} | ||
|
||
override fun onSubscriptionPurchased(sku: String?) { | ||
// will be triggered whenever subscription succeeded | ||
} | ||
|
||
override fun onPricesUpdated(iapKeyPrices: Map<String, String>) { | ||
// list of available products will be received here, so you can update UI with prices if needed | ||
} | ||
}) | ||
|
||
binding.btPurchaseCons.setOnClickListener { | ||
iapConnector.purchase(this, "base") | ||
} | ||
binding.btnMonthly.setOnClickListener { | ||
iapConnector.purchase(this, "subscribe") | ||
} | ||
|
||
binding.btnYearly.setOnClickListener { | ||
iapConnector.purchase(this, "yearly") | ||
} | ||
binding.btnQuite.setOnClickListener { | ||
iapConnector.purchase(this, "quite") | ||
|
||
} | ||
binding.btnModerate.setOnClickListener { | ||
iapConnector.purchase(this, "moderate") | ||
} | ||
|
||
binding.btnUltimate.setOnClickListener { | ||
iapConnector.purchase(this, "plenty") | ||
|
||
} | ||
} | ||
} |
112 changes: 0 additions & 112 deletions
112
app/src/main/java/com/alphelios/superrich/MainActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.