First of all just to avoid misunderstanding I do not suggest making
separate services for appstore adaptors. I just suggested to make
adaptors as Java classes implementing interface which is very similar to
IInAppBillingService interface.
>MarketAdaptor (better name?)
I think the interface name should just describe what it is doing. In our
case it wraps In-App Billing interface of a particular appstore. So I
suggest to call it IAppstoreInAppBillingAdaptor (from my point of view
"appstore" is a better term then "market").
>If we do so, we will need to implement in each marketAdaptor a lot of
method like this
What other methods we would need to implement? I agree with your general
approach that we need to simplify interface of MarketAdaptor. Could you
please write down what would be MarketAdaptor interface in your case?
Just to compare here is how the adaptor interface could look like if we
try to make it close to
interface IAppstoreInAppBillingAdaptor {
int isBillingSupported(int apiVersion, String packageName,
String type);
Bundle getSkuDetails(int apiVersion, String packageName,
String type, in Bundle skusBundle);
Bundle getBuyIntent(int apiVersion, String packageName,
String sku, String type, String developerPayload);
Bundle getPurchases(int apiVersion, String packageName,
String type, String continuationToken);
int consumePurchase(int apiVersion, String packageName,
String purchaseToken);
}
> SamsungMarketAdaptor in function "onPurchaseItemFinished"
should create
> OpenIabResult and OpenPurchase (#) objects and execute listener
(with
> these objects), which it saved when "launchPurchaseFlow"
method was executed.
> Implementation of market adaptor can be divided into several
classes, but
> it isn't very important.
Will OpenIabResult and OpenPurchase be inherited from IabResult and
Purchase? What is difference between OpenIabResult and IabResult? Why not
just use IabResult?
> # - I think it's much easier to create such objects and execute
listener
> than sent data from service to application (in a way similar to code
from
I do not suggest to create a service for each adaptor. I just advocated
that adaptor has interface similar to IInAppBillingService rather than
similar to IabHelper (for example to use JSON not Java classes for
results).
> About OpenIabHelper. In the constructor we create 4 (more?)
Market
> Adaptors
> and trying to find the market, application was download from. In
each
> method of this class we need to do something like that. If same
method
> exists in MarketAdaptor interface, we just call
> currentMarket.methodName(...). Otherwise we call similar method
in
> currentMarket, previously add some information (e. g. we have 3
> methods queryInventoryAsync in OpenIabHelper, but only one in
> marketAdaptor).
May be creating all market adaptors even if they are not needed could be
too big overhead (it will link big JAR files). I thought about creating
additional "checker" classes that could just check if the
application was downloaded from the corresponding store. Something
like
interface IAppstoreInAppBillingChecker {
boolean wasStoreUsedToInstall(String packageName);
}
class SamsungInAppBillingChecker implements IAppstoreInAppBillingChecker
{
...
}
....
> About name of main class ("OpenIabHelper" or
"IabHelper"). I think we
> should call it OpenIabHelper. It isn't very hard for developer to
rename
> classname (just a few clicks in IDE). But in GoogleMarketAdaptor we
will
> probably want to use IabHelper (by Google). If so, we will have in
the
> project two different classes with same name (our IabHelper &
IabHelper by
> Google) and that's not very good.
Why do we need Google's IabHelper at all? Our IabHelper will include all
needed code from IabHelper. So our IabHelper will just *replace* Google's
IabHelper (Google's IabHelper is distributed under Apache 2 license so we
have no problems just copy/paste code from it to our IabHelper).
> Do you have any suggestions? Or maybe do you know some weak points
in this
> architecture?
Another small reason to make adaptor's interface close to
IInAppBillingService rather than to IabHelper is that some developers
(although I do not think that many) could work with IInAppBillingService
directly. Using IabHelper is optional.
Best regards,
Vassili
============