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;
}
});
}
}
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);
}
});
}
}
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);
}
});
}
}
Aggregations