Search in sources :

Example 6 with BillingProcessor

use of com.anjlab.android.iab.v3.BillingProcessor in project Phonograph by kabouzeid.

the class PurchaseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_purchase);
    setDrawUnderStatusbar(true);
    ButterKnife.bind(this);
    setStatusbarColor(ACTIVITY_COLOR);
    setNavigationbarColor(ACTIVITY_COLOR);
    setTaskDescriptionColor(ACTIVITY_COLOR);
    setSupportActionBar(toolbar);
    // noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(getString(R.string.buy_pro));
    restoreButton.setEnabled(false);
    purchaseButton.setEnabled(false);
    restoreButton.setOnClickListener(v -> {
        if (restorePurchaseAsyncTask == null || restorePurchaseAsyncTask.getStatus() != AsyncTask.Status.RUNNING) {
            restorePurchase();
        }
    });
    purchaseButton.setOnClickListener(v -> {
        billingProcessor.purchase(PurchaseActivity.this, App.PRO_VERSION_PRODUCT_ID);
        if (!BuildConfig.DEBUG) {
            Answers.getInstance().logAddToCart(new AddToCartEvent().putCurrency(Currency.getInstance("EUR")).putItemId("pro_version").putItemName("Phonograph Pro").putItemPrice(BigDecimal.valueOf(3)));
        }
    });
    billingProcessor = new BillingProcessor(this, App.GOOGLE_PLAY_LICENSE_KEY, this);
    if (!BuildConfig.DEBUG) {
        Answers.getInstance().logContentView(new ContentViewEvent().putContentName("Purchase Activity").putContentId("1"));
    }
}
Also used : AddToCartEvent(com.crashlytics.android.answers.AddToCartEvent) BillingProcessor(com.anjlab.android.iab.v3.BillingProcessor) ContentViewEvent(com.crashlytics.android.answers.ContentViewEvent)

Example 7 with BillingProcessor

use of com.anjlab.android.iab.v3.BillingProcessor in project Android-NotesApp by HelloPraveen.

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    bp = new BillingProcessor(this, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApcobfuZFov1KIJgKEKrzp9PP2n1EbBpV/xf9AyhWYN47QY8/rWGPuKht/7b4DmCVnpd6PrnYJqLt/rqR5c+lifLY5XuUH1VGqnkWA33TkPXm4UkGk3q/jvVIbM5xbcdPLqNkLiEoEuBlmAYNxM6K3lf5Kz+ff1HUH1ljYjDE9M38xS0TiLnQIRPm9cfehNxaKWOF81sx5Q9K3vNB1JoNuMyaMfBFQjfMRL6llsMRF42NEf6W/4/2c5Guxvg2qLo14/gGVRLS5H0ZVwqThNZVYTtLRWWNIrgFIwMnCjcbntFkEBK/B987poGN6miDI2r1m6XALRAgLEzM/IUaPnwnWwIDAQAB", this);
    sv = findViewById(R.id.about_scroll);
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
    Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
    SpannableStringBuilder SS = new SpannableStringBuilder("About");
    SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(SS);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    List<String> l = new ArrayList<>();
    l.add("Project Contributors");
    l.add("Tools & Licenses Used");
    l.add("Donate and Support");
    l.add("Rate the Application");
    final RecyclerView recyclerView = findViewById(R.id.aboutRecyclerView);
    AboutAdapter mAdapter = new AboutAdapter(l);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
    recyclerView.setAdapter(mAdapter);
    recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), new ClickListener() {

        @Override
        public void onClick(View view, final int position) {
            if (position == 0) {
                Intent i = new Intent(AboutActivity.this, ContributorsActivity.class);
                startActivity(i);
            } else if (position == 1) {
                Intent i = new Intent(AboutActivity.this, LicensesActivity.class);
                startActivity(i);
            } else if (position == 2) {
                bp.purchase(AboutActivity.this, "typenote_donate");
            } else if (position == 3) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=io.praveen.typenote")));
            }
        }
    }));
}
Also used : RecyclerTouchListener(io.praveen.typenote.SQLite.RecyclerTouchListener) Typeface(android.graphics.Typeface) BillingProcessor(com.anjlab.android.iab.v3.BillingProcessor) SpannableStringBuilder(android.text.SpannableStringBuilder) ArrayList(java.util.ArrayList) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) AboutAdapter(io.praveen.typenote.SQLite.AboutAdapter) RecyclerView(android.support.v7.widget.RecyclerView) SpannableStringBuilder(android.text.SpannableStringBuilder) ClickListener(io.praveen.typenote.SQLite.ClickListener)

Example 8 with BillingProcessor

use of com.anjlab.android.iab.v3.BillingProcessor in project Android-NotesApp by HelloPraveen.

the class ProActivity method onCreate.

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pro);
    bp = new BillingProcessor(this, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApcobfuZFov1KIJgKEKrzp9PP2n1EbBpV/xf9AyhWYN47QY8/rWGPuKht/7b4DmCVnpd6PrnYJqLt/rqR5c+lifLY5XuUH1VGqnkWA33TkPXm4UkGk3q/jvVIbM5xbcdPLqNkLiEoEuBlmAYNxM6K3lf5Kz+ff1HUH1ljYjDE9M38xS0TiLnQIRPm9cfehNxaKWOF81sx5Q9K3vNB1JoNuMyaMfBFQjfMRL6llsMRF42NEf6W/4/2c5Guxvg2qLo14/gGVRLS5H0ZVwqThNZVYTtLRWWNIrgFIwMnCjcbntFkEBK/B987poGN6miDI2r1m6XALRAgLEzM/IUaPnwnWwIDAQAB", this);
    bp.loadOwnedPurchasesFromGoogle();
    TextView tv = findViewById(R.id.pro_head);
    TextView tv2 = findViewById(R.id.pro_text);
    Button b1 = findViewById(R.id.pro_upgrade);
    Button b2 = findViewById(R.id.pro_redeem);
    Button b3 = findViewById(R.id.pro_restore);
    TextView tv3 = findViewById(R.id.pro_help);
    preferences = PreferenceManager.getDefaultSharedPreferences(ProActivity.this);
    int id = preferences.getInt("premium", 0);
    if (id == 1) {
        tv.setText("You're Premium!");
        tv2.setText("Thanks for upgrading, you'll continue to receive premium features until your lifetime!");
        b1.setVisibility(View.GONE);
        b2.setVisibility(View.GONE);
        b3.setVisibility(View.GONE);
        LinearLayout temp = findViewById(R.id.pro_ll);
        temp.setVisibility(View.GONE);
        tv3.setText("For any queries,\nDon't hesitate to contact at\nhello@praveen.io or @HelloPraveenIO");
    }
    b1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bp.purchase(ProActivity.this, "notes_pro");
        }
    });
    b3.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            bp.purchase(ProActivity.this, "notes_pro");
        }
    });
    b2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Uri redeemUri = Uri.parse("https://play.google.com/redeem");
            Intent redeemIntent = new Intent(Intent.ACTION_VIEW, redeemUri);
            startActivity(redeemIntent);
        }
    });
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
    Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
    SpannableStringBuilder SS = new SpannableStringBuilder("Premium");
    SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(SS);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
}
Also used : Typeface(android.graphics.Typeface) BillingProcessor(com.anjlab.android.iab.v3.BillingProcessor) SpannableStringBuilder(android.text.SpannableStringBuilder) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint) Button(android.widget.Button) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) SpannableStringBuilder(android.text.SpannableStringBuilder) SuppressLint(android.annotation.SuppressLint)

Aggregations

BillingProcessor (com.anjlab.android.iab.v3.BillingProcessor)8 View (android.view.View)5 Intent (android.content.Intent)4 Typeface (android.graphics.Typeface)4 SpannableStringBuilder (android.text.SpannableStringBuilder)4 SuppressLint (android.annotation.SuppressLint)3 TextView (android.widget.TextView)3 Uri (android.net.Uri)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 Button (android.widget.Button)2 LinearLayout (android.widget.LinearLayout)2 AboutAdapter (io.praveen.typenote.SQLite.AboutAdapter)2 ClickListener (io.praveen.typenote.SQLite.ClickListener)2 RecyclerTouchListener (io.praveen.typenote.SQLite.RecyclerTouchListener)2 ArrayList (java.util.ArrayList)2 NonNull (android.support.annotation.NonNull)1 ListView (android.widget.ListView)1