Search in sources :

Example 1 with PlayStore

use of com.frostwire.android.offers.PlayStore in project frostwire by frostwire.

the class BuyActivity method initProductCards.

private void initProductCards(int lastSelectedCardViewId) {
    card30days = findView(R.id.activity_buy_product_card_30_days);
    card1year = findView(R.id.activity_buy_product_card_1_year);
    card6months = findView(R.id.activity_buy_product_card_6_months);
    final PlayStore store = PlayStore.getInstance();
    initProductCard(card30days, store, Products.SUBS_DISABLE_ADS_1_MONTH_SKU, Products.INAPP_DISABLE_ADS_1_MONTH_SKU);
    initProductCard(card1year, store, Products.SUBS_DISABLE_ADS_1_YEAR_SKU, Products.INAPP_DISABLE_ADS_1_YEAR_SKU);
    initProductCard(card6months, store, Products.SUBS_DISABLE_ADS_6_MONTHS_SKU, Products.INAPP_DISABLE_ADS_6_MONTHS_SKU);
    View.OnClickListener cardClickListener = new ProductCardViewOnClickListener();
    card30days.setOnClickListener(cardClickListener);
    card1year.setOnClickListener(cardClickListener);
    card6months.setOnClickListener(cardClickListener);
    initLastCardSelection(lastSelectedCardViewId);
}
Also used : PlayStore(com.frostwire.android.offers.PlayStore) ProductCardView(com.frostwire.android.gui.views.ProductCardView) ProductPaymentOptionsView(com.frostwire.android.gui.views.ProductPaymentOptionsView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 2 with PlayStore

use of com.frostwire.android.offers.PlayStore in project frostwire by frostwire.

the class ApplicationFragment method setupStore.

private void setupStore(long purchaseTimestamp) {
    Preference p = findPreference("frostwire.prefs.offers.buy_no_ads");
    if (p != null && !Constants.IS_GOOGLE_PLAY_DISTRIBUTION) {
        PreferenceCategory category = findPreference("frostwire.prefs.other_settings");
        category.removePreference(p);
    } else if (p != null) {
        PlayStore playStore = PlayStore.getInstance();
        playStore.refresh();
        Collection<Product> purchasedProducts = Products.listEnabled(playStore, Products.DISABLE_ADS_FEATURE);
        if (purchaseTimestamp == 0 && purchasedProducts != null && purchasedProducts.size() > 0) {
            initRemoveAdsSummaryWithPurchaseInfo(p, purchasedProducts);
        // otherwise, a BuyActivity intent has been configured on application_preferences.xml
        } else if (purchaseTimestamp > 0 && (System.currentTimeMillis() - purchaseTimestamp) < 30000) {
            p.setSummary(getString(R.string.processing_payment) + "...");
            p.setOnPreferenceClickListener(null);
        } else {
            p.setSummary(R.string.remove_ads_description);
            p.setOnPreferenceClickListener(preference -> {
                PlayStore.getInstance().endAsync();
                Intent intent = new Intent(getActivity(), BuyActivity.class);
                startActivityForResult(intent, BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE);
                return true;
            });
        }
    }
}
Also used : KitKatStoragePreference(com.frostwire.android.gui.views.preference.KitKatStoragePreference) Preference(android.support.v7.preference.Preference) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Collection(java.util.Collection) Intent(android.content.Intent) PlayStore(com.frostwire.android.offers.PlayStore)

Example 3 with PlayStore

use of com.frostwire.android.offers.PlayStore in project frostwire by frostwire.

the class BuyActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    PlayStore store = PlayStore.getInstance();
    if (store.handleActivityResult(requestCode, resultCode, data)) {
        store.refresh();
        // user clicked outside of the PlayStore purchase dialog
        if (data != null && data.hasExtra("RESPONSE_CODE") && data.getIntExtra("RESPONSE_CODE", 0) != 0) {
            paymentOptionsView.stopProgressBar();
            LOG.info("onActivityResult -> purchase cancelled");
            // finish();
            return;
        }
        // make sure ads won't show on this session any more if we got a positive response.
        Offers.stopAdNetworks(this);
        // now we prepare a result for SettingsActivity since it won't know right away
        // given the purchase process is asynchronous
        LOG.info("onActivityResult -> purchase finished");
        Intent result = new Intent();
        result.putExtra(BuyActivity.EXTRA_KEY_PURCHASE_TIMESTAMP, System.currentTimeMillis());
        setResult(BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE, result);
        finish();
    }
}
Also used : Intent(android.content.Intent) PlayStore(com.frostwire.android.offers.PlayStore)

Aggregations

PlayStore (com.frostwire.android.offers.PlayStore)3 Intent (android.content.Intent)2 Preference (android.support.v7.preference.Preference)1 PreferenceCategory (android.support.v7.preference.PreferenceCategory)1 View (android.view.View)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 ProductCardView (com.frostwire.android.gui.views.ProductCardView)1 ProductPaymentOptionsView (com.frostwire.android.gui.views.ProductPaymentOptionsView)1 KitKatStoragePreference (com.frostwire.android.gui.views.preference.KitKatStoragePreference)1 Collection (java.util.Collection)1