Configure list of purchasable items in linphonerc

This commit is contained in:
Sylvain Berfini 2015-05-20 13:54:27 +02:00
parent e82385749c
commit ff64caaa8f
3 changed files with 18 additions and 4 deletions

View file

@ -33,4 +33,5 @@ log_collection_upload_server_url=https://www.linphone.org:444/lft.php
user_certificates_path=/data/data/org.linphone/files user_certificates_path=/data/data/org.linphone/files
[in-app-purchase] [in-app-purchase]
server_url=https://www.linphone.org/inapp.php server_url=https://www.linphone.org/inapp.php
purchasable_items_ids=test_account_subscription

View file

@ -19,6 +19,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
import java.util.ArrayList;
import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAddress.TransportType; import org.linphone.core.LinphoneAddress.TransportType;
import org.linphone.core.LinphoneAuthInfo; import org.linphone.core.LinphoneAuthInfo;
@ -1155,6 +1157,19 @@ public class LinphonePreferences {
public String getInAppPurchaseValidatingServerUrl() { public String getInAppPurchaseValidatingServerUrl() {
return getConfig().getString("in-app-purchase", "server_url", null); return getConfig().getString("in-app-purchase", "server_url", null);
} }
public ArrayList<String> getInAppPurchasables() {
ArrayList<String> purchasables = new ArrayList<String>();
String list = getConfig().getString("in-app-purchase", "purchasable_items_ids", null);
if (list != null) {
for(String purchasable : list.split(";")) {
if (purchasable.length() > 0) {
purchasables.add(purchasable);
}
}
}
return purchasables;
}
public String getDebugPopupAddress(){ public String getDebugPopupAddress(){
return getConfig().getString("app", "debug_popup_magic", null); return getConfig().getString("app", "debug_popup_magic", null);

View file

@ -55,7 +55,6 @@ import de.timroes.axmlrpc.XMLRPCServerException;
*/ */
public class InAppPurchaseHelper { public class InAppPurchaseHelper {
public static final int API_VERSION = 3; public static final int API_VERSION = 3;
public static final String TEST_ITEM = "test_account_subscription";
public static final int ACTIVITY_RESULT_CODE_PURCHASE_ITEM = 11089; public static final int ACTIVITY_RESULT_CODE_PURCHASE_ITEM = 11089;
public static final String SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST"; public static final String SKU_DETAILS_ITEM_LIST = "ITEM_ID_LIST";
@ -182,8 +181,7 @@ public class InAppPurchaseHelper {
private ArrayList<Purchasable> getAvailableItemsForPurchase() { private ArrayList<Purchasable> getAvailableItemsForPurchase() {
ArrayList<Purchasable> products = new ArrayList<Purchasable>(); ArrayList<Purchasable> products = new ArrayList<Purchasable>();
ArrayList<String> skuList = new ArrayList<String> (); ArrayList<String> skuList = LinphonePreferences.instance().getInAppPurchasables();
skuList.add(TEST_ITEM);
Bundle querySkus = new Bundle(); Bundle querySkus = new Bundle();
querySkus.putStringArrayList(SKU_DETAILS_ITEM_LIST, skuList); querySkus.putStringArrayList(SKU_DETAILS_ITEM_LIST, skuList);