Search in sources :

Example 1 with IabResult

use of org.sufficientlysecure.donations.google.util.IabResult in project Klyph by jonathangerbaud.

the class DonateFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    thankYou = (TextView) getView().findViewById(R.id.thank_you);
    if (KlyphPreferences.hasUserDonated()) {
        thankYou.setVisibility(View.VISIBLE);
    } else {
        ImageView logo = (ImageView) getActivity().findViewById(R.id.app_logo);
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
                alert.setTitle(R.string.donate_unlock);
                alert.setMessage(R.string.donate_code);
                final EditText editText = new EditText(getActivity());
                alert.setView(editText);
                alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (getActivity().getString(R.string.donation_validation_code).equals(editText.getText().toString())) {
                            handleResult(0, null);
                        }
                    }
                });
                alert.show();
            }
        });
        // inflate google view into stub
        googleViewStub = (ViewStub) getActivity().findViewById(R.id.donate_google_stub);
        googleViewStub.inflate();
        // choose donation amount
        mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner);
        ArrayAdapter<CharSequence> adapter;
        if (mDebug) {
            adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, CATALOG_DEBUG);
        } else {
            adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, mGoogleCatalogValues);
        }
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mGoogleSpinner.setAdapter(adapter);
        Button btGoogle = (Button) getActivity().findViewById(R.id.donations__google_android_market_donate_button);
        btGoogle.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                donateGoogleOnClick(v);
            }
        });
        // verify signatures with
        if (mDebug)
            Log.d(TAG, "Creating IAB helper.");
        mHelper = new IabHelper(getActivity(), mGooglePubkey);
        // enable debug logging (for a production application, you should
        // set this to false).
        mHelper.enableDebugLogging(mDebug);
        // will be called once setup completes.
        if (mDebug)
            Log.d(TAG, "Starting setup.");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

            public void onIabSetupFinished(IabResult result) {
                if (mDebug)
                    Log.d(TAG, "Setup finished.");
                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__google_android_market_not_supported_title, getString(R.string.donations__google_android_market_not_supported));
                    return;
                }
                // Have we been disposed of in the meantime? If so, quit.
                if (mHelper == null)
                    return;
            }
        });
    }
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener) IabResult(org.sufficientlysecure.donations.google.util.IabResult) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) IabHelper(org.sufficientlysecure.donations.google.util.IabHelper) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView)

Example 2 with IabResult

use of org.sufficientlysecure.donations.google.util.IabResult in project Klyph by jonathangerbaud.

the class DonationsFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    /* Flattr */
    if (mFlattrEnabled) {
        // inflate flattr view into stub
        ViewStub flattrViewStub = (ViewStub) getActivity().findViewById(R.id.donations__flattr_stub);
        flattrViewStub.inflate();
        buildFlattrView();
    }
    /* Google */
    if (mGoogleEnabled) {
        // inflate google view into stub
        ViewStub googleViewStub = (ViewStub) getActivity().findViewById(R.id.donations__google_stub);
        googleViewStub.inflate();
        // choose donation amount
        mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner);
        ArrayAdapter<CharSequence> adapter;
        if (mDebug) {
            adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, CATALOG_DEBUG);
        } else {
            adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, mGoogleCatalogValues);
        }
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mGoogleSpinner.setAdapter(adapter);
        Button btGoogle = (Button) getActivity().findViewById(R.id.donations__google_android_market_donate_button);
        btGoogle.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                donateGoogleOnClick(v);
            }
        });
        // Create the helper, passing it our context and the public key to verify signatures with
        if (mDebug)
            Log.d(TAG, "Creating IAB helper.");
        mHelper = new IabHelper(getActivity(), mGooglePubkey);
        // enable debug logging (for a production application, you should set this to false).
        mHelper.enableDebugLogging(mDebug);
        // will be called once setup completes.
        if (mDebug)
            Log.d(TAG, "Starting setup.");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

            public void onIabSetupFinished(IabResult result) {
                if (mDebug)
                    Log.d(TAG, "Setup finished.");
                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__google_android_market_not_supported_title, getString(R.string.donations__google_android_market_not_supported));
                    return;
                }
                // Have we been disposed of in the meantime? If so, quit.
                if (mHelper == null)
                    return;
            }
        });
    }
    /* PayPal */
    if (mPaypalEnabled) {
        // inflate paypal view into stub
        ViewStub paypalViewStub = (ViewStub) getActivity().findViewById(R.id.donations__paypal_stub);
        paypalViewStub.inflate();
        Button btPayPal = (Button) getActivity().findViewById(R.id.donations__paypal_donate_button);
        btPayPal.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                donatePayPalOnClick(v);
            }
        });
    }
}
Also used : ViewStub(android.view.ViewStub) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) IabResult(org.sufficientlysecure.donations.google.util.IabResult) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) IabHelper(org.sufficientlysecure.donations.google.util.IabHelper)

Example 3 with IabResult

use of org.sufficientlysecure.donations.google.util.IabResult in project Rashr by DsLNeXuS.

the class DonationsFragment method onActivityCreated.

@TargetApi(11)
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    /* Google */
    if (mGoogleEnabled) {
        // inflate google view into stub
        ViewStub googleViewStub = (ViewStub) getActivity().findViewById(R.id.donations__google_stub);
        googleViewStub.inflate();
        // choose donation amount
        mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner);
        ArrayAdapter<CharSequence> adapter;
        if (mDebug) {
            adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, CATALOG_DEBUG);
        } else {
            adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, mGoogleCatalogValues);
        }
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mGoogleSpinner.setAdapter(adapter);
        Button btGoogle = (Button) getActivity().findViewById(R.id.donations__google_android_market_donate_button);
        btGoogle.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                donateGoogleOnClick(v);
            }
        });
        // Create the helper, passing it our context and the public key to verify signatures with
        if (mDebug)
            Log.d(TAG, "Creating IAB helper.");
        mHelper = new IabHelper(getActivity(), mGooglePubkey);
        // enable debug logging (for a production application, you should set this to false).
        mHelper.enableDebugLogging(mDebug);
        // will be called once setup completes.
        if (mDebug)
            Log.d(TAG, "Starting setup.");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

            public void onIabSetupFinished(IabResult result) {
                if (mDebug)
                    Log.d(TAG, "Setup finished.");
                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__google_android_market_not_supported_title, getString(R.string.donations__google_android_market_not_supported));
                    return;
                }
                // Have we been disposed of in the meantime? If so, quit.
                if (mHelper == null)
                    return;
            }
        });
    }
    /* PayPal */
    if (mPaypalEnabled) {
        // inflate paypal view into stub
        ViewStub paypalViewStub = (ViewStub) getActivity().findViewById(R.id.donations__paypal_stub);
        paypalViewStub.inflate();
        Button btPayPal = (Button) getActivity().findViewById(R.id.donations__paypal_donate_button);
        btPayPal.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                donatePayPalOnClick(v);
            }
        });
    }
}
Also used : ViewStub(android.view.ViewStub) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) IabResult(org.sufficientlysecure.donations.google.util.IabResult) View(android.view.View) IabHelper(org.sufficientlysecure.donations.google.util.IabHelper) TargetApi(android.annotation.TargetApi)

Aggregations

View (android.view.View)3 OnClickListener (android.view.View.OnClickListener)3 Button (android.widget.Button)3 IabHelper (org.sufficientlysecure.donations.google.util.IabHelper)3 IabResult (org.sufficientlysecure.donations.google.util.IabResult)3 ViewStub (android.view.ViewStub)2 TextView (android.widget.TextView)2 TargetApi (android.annotation.TargetApi)1 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 WebView (android.webkit.WebView)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1