Search in sources :

Example 1 with IabResult

use of org.horaapps.leafpic.util.inapppurchase.IabResult in project LeafPic by HoraApps.

the class DonateActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(org.horaapps.leafpic.R.layout.activity_donate);
    toolbar = (Toolbar) findViewById(org.horaapps.leafpic.R.id.toolbar);
    bar = (SeekBar) findViewById(R.id.seek_bar_donations);
    setNavBarColor();
    cts = new CustomTabService(DonateActivity.this, getPrimaryColor());
    scr = (ScrollView) findViewById(org.horaapps.leafpic.R.id.donateAct_scrollView);
    mHelper = new IabHelper(this, SecretConstants.getBase64EncodedPublicKey(getApplicationContext()));
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                // Oh no, there was a problem.
                Log.d("donateAct", "Problem setting up In-app Billing: " + result);
            }
        // Hooray, IAB is fully set up!
        }
    });
}
Also used : CustomTabService(org.horaapps.leafpic.util.CustomTabService) IabResult(org.horaapps.leafpic.util.inapppurchase.IabResult) IabHelper(org.horaapps.leafpic.util.inapppurchase.IabHelper)

Example 2 with IabResult

use of org.horaapps.leafpic.util.inapppurchase.IabResult in project LeafPic by HoraApps.

the class DonateActivity method setTheme.

private void setTheme() {
    /**** ToolBar *****/
    toolbar.setBackgroundColor(getPrimaryColor());
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_arrow_left).color(Color.WHITE).sizeDp(19));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    toolbar.setTitle(getString(org.horaapps.leafpic.R.string.donate));
    setStatusBarColor();
    setNavBarColor();
    setRecentApp(getString(org.horaapps.leafpic.R.string.donate));
    final Button btnDonateIap = (Button) findViewById(R.id.button_donate_play_store);
    btnDonateIap.setText(String.format("%s %d€", getString(R.string.donate).toUpperCase(), progress));
    themeSeekBar(bar);
    bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            if (i == 0)
                progress = 2;
            else
                progress = (i + 1) * 2;
            btnDonateIap.setText(String.format("%s %d€", getString(R.string.donate).toUpperCase(), progress));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    /**** Title Cards ***/
    ((TextView) findViewById(org.horaapps.leafpic.R.id.team_name)).setTextColor(getAccentColor());
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_item_title)).setTextColor(getAccentColor());
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_item_title)).setTextColor(getAccentColor());
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_item_title)).setTextColor(getAccentColor());
    /** BackGround **/
    findViewById(org.horaapps.leafpic.R.id.donate_background).setBackgroundColor(getBackgroundColor());
    /** Cards **/
    int color = getCardBackgroundColor();
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_card)).setCardBackgroundColor(color);
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_card)).setCardBackgroundColor(color);
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_card)).setCardBackgroundColor(color);
    ((CardView) findViewById(org.horaapps.leafpic.R.id.donate_header_card)).setCardBackgroundColor(color);
    /** Icons **/
    color = getIconColor();
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_icon_title)).setColor(color);
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_icon_title)).setColor(color);
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_icon_title)).setColor(color);
    ((IconicsImageView) findViewById(org.horaapps.leafpic.R.id.donate_header_icon)).setColor(color);
    /** TextViews **/
    color = getTextColor();
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_googleplay_item)).setTextColor(color);
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_paypal_item)).setTextColor(color);
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_item)).setTextColor(color);
    ((TextView) findViewById(org.horaapps.leafpic.R.id.donate_header_item)).setTextColor(color);
    /***** ScrolView *****/
    setScrollViewColor(scr);
    /** ACTIONS **/
    findViewById(org.horaapps.leafpic.R.id.button_donate_paypal).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cts.launchUrl("https://www.paypal.me/HoraApps");
        }
    });
    findViewById(org.horaapps.leafpic.R.id.donate_bitcoin_item).setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("Copied to Clipboard", ((TextView) v).getText());
            clipboard.setPrimaryClip(clip);
            StringUtils.showToast(getApplicationContext(), getString(org.horaapps.leafpic.R.string.address_copied));
            return true;
        }
    });
    findViewById(R.id.button_donate_play_store).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mHelper != null)
                mHelper.flagEndAsync();
            mHelper.launchPurchaseFlow(DonateActivity.this, "donation_" + progress, 123, new IabHelper.OnIabPurchaseFinishedListener() {

                @Override
                public void onIabPurchaseFinished(IabResult result, Purchase info) {
                    mHelper.consumeAsync(info, mPurchaseFinishedListener);
                }
            });
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) Purchase(org.horaapps.leafpic.util.inapppurchase.Purchase) SeekBar(android.widget.SeekBar) CardView(android.support.v7.widget.CardView) IabResult(org.horaapps.leafpic.util.inapppurchase.IabResult) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) View(android.view.View) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) Button(android.widget.Button) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) ClipData(android.content.ClipData)

Aggregations

IabResult (org.horaapps.leafpic.util.inapppurchase.IabResult)2 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 Button (android.widget.Button)1 ScrollView (android.widget.ScrollView)1 SeekBar (android.widget.SeekBar)1 TextView (android.widget.TextView)1 IconicsDrawable (com.mikepenz.iconics.IconicsDrawable)1 IconicsImageView (com.mikepenz.iconics.view.IconicsImageView)1 CustomTabService (org.horaapps.leafpic.util.CustomTabService)1 IabHelper (org.horaapps.leafpic.util.inapppurchase.IabHelper)1 Purchase (org.horaapps.leafpic.util.inapppurchase.Purchase)1