Add a EXPIRED constant to the PurchaseState enum

pull/14/head
Sam Bosley 14 years ago
parent a8f74da42e
commit 2d20f5fd3e

@ -17,7 +17,10 @@ import android.widget.Button;
import android.widget.Toast; import android.widget.Toast;
import com.timsu.astrid.R; import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.Preferences; import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
import com.todoroo.astrid.billing.BillingConstants.PurchaseState; import com.todoroo.astrid.billing.BillingConstants.PurchaseState;
import com.todoroo.astrid.billing.BillingConstants.ResponseCode; import com.todoroo.astrid.billing.BillingConstants.ResponseCode;
import com.todoroo.astrid.billing.BillingService.RequestPurchase; import com.todoroo.astrid.billing.BillingService.RequestPurchase;
@ -38,9 +41,12 @@ public class BillingActivity extends Activity {
private Button buyMonth; private Button buyMonth;
private Button buyYear; private Button buyYear;
@Autowired private ActFmPreferenceService actFmPreferenceService;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
DependencyInjectionService.getInstance().inject(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.billing_activity); setContentView(R.layout.billing_activity);
@ -53,7 +59,11 @@ public class BillingActivity extends Activity {
ResponseHandler.register(purchaseObserver); ResponseHandler.register(purchaseObserver);
if (!billingService.checkBillingSupported(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) { if (!actFmPreferenceService.isLoggedIn()) {
// Handle
} else if (ActFmPreferenceService.isPremiumUser()) {
// Handle
} else if (!billingService.checkBillingSupported(BillingConstants.ITEM_TYPE_SUBSCRIPTION)) {
showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID); showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID);
} }
} }
@ -62,6 +72,9 @@ public class BillingActivity extends Activity {
buyMonth = (Button) findViewById(R.id.buy_month); buyMonth = (Button) findViewById(R.id.buy_month);
buyYear = (Button) findViewById(R.id.buy_year); buyYear = (Button) findViewById(R.id.buy_year);
buyMonth.setEnabled(false);
buyYear.setEnabled(false);
//TODO: Figure out if we need a payload for any reason //TODO: Figure out if we need a payload for any reason
buyMonth.setOnClickListener(new OnClickListener() { buyMonth.setOnClickListener(new OnClickListener() {
@ -187,26 +200,19 @@ public class BillingActivity extends Activity {
Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState); Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
} }
if (developerPayload == null) { // if (developerPayload == null) {
// // //
} else { // } else {
// // //
} // }
if (purchaseState == PurchaseState.PURCHASED) { if (purchaseState == PurchaseState.PURCHASED) {
// mOwnedItems.add(itemId); // Success
// // Report premium activation to server
// // If this is a subscription, then enable the "Edit } else if (purchaseState == PurchaseState.REFUNDED || purchaseState == PurchaseState.EXPIRED) {
// // Subscriptions" button. // Subscription ended
// for (CatalogEntry e : CATALOG) { // Report premium deactivation to server
// if (e.sku.equals(itemId) &&
// e.managed.equals(Managed.SUBSCRIPTION)) {
// mEditSubscriptionsButton.setVisibility(View.VISIBLE);
// }
// }
} }
// mCatalogAdapter.setOwnedItems(mOwnedItems);
// mOwnedItemsCursor.requery();
} }
@Override @Override

@ -53,7 +53,6 @@ public class BillingConstants {
public static final String ITEM_TYPE_SUBSCRIPTION = "subs"; public static final String ITEM_TYPE_SUBSCRIPTION = "subs";
public static final String PRODUCT_ID_MONTHLY = "premium_monthly"; public static final String PRODUCT_ID_MONTHLY = "premium_monthly";
public static final String PRODUCT_ID_YEARLY = "premium_yearly"; public static final String PRODUCT_ID_YEARLY = "premium_yearly";
@ -81,8 +80,9 @@ public class BillingConstants {
public enum PurchaseState { public enum PurchaseState {
// Responses to requestPurchase or restoreTransactions. // Responses to requestPurchase or restoreTransactions.
PURCHASED, // User was charged for the order. PURCHASED, // User was charged for the order.
CANCELED, // The charge failed on the server. CANCELED, // The charge failed on the server. (NOT THE SAME AS CANCELING A SUBSCRIPTION)
REFUNDED; // User received a refund for the order. REFUNDED, // User received a refund for the order.
EXPIRED; // Subscription expired due to non-payment or cancellation
// Converts from an ordinal value to the PurchaseState // Converts from an ordinal value to the PurchaseState
public static PurchaseState valueOf(int index) { public static PurchaseState valueOf(int index) {

Loading…
Cancel
Save