This commit is contained in:
Sergey Solovyev
2012-01-05 13:25:40 +04:00
parent 22f46ea921
commit d26a084e50
3 changed files with 22 additions and 18 deletions

View File

@@ -29,23 +29,27 @@ public class CalculatorPreferencesActivity extends PreferenceActivity implements
final Preference addFreePreference = findPreference(CalculatorApplication.AD_FREE_P_KEY);
addFreePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
if (!CalculatorApplication.isAdFree(this)) {
addFreePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
// check billing availability
if (BillingController.checkBillingSupported(CalculatorPreferencesActivity.this) != BillingController.BillingStatus.SUPPORTED) {
// warn about not supported billing
new AlertDialog.Builder(CalculatorPreferencesActivity.this).setTitle(R.string.c_error).setMessage(R.string.c_billing_error).create().show();
} else {
if (!CalculatorApplication.isAdFree(CalculatorPreferencesActivity.this)) {
// not purchased => show purchase window for user
BillingController.requestPurchase(CalculatorPreferencesActivity.this, CalculatorApplication.AD_FREE_PRODUCT_ID, true);
// check billing availability
if (BillingController.checkBillingSupported(CalculatorPreferencesActivity.this) != BillingController.BillingStatus.SUPPORTED) {
// warn about not supported billing
new AlertDialog.Builder(CalculatorPreferencesActivity.this).setTitle(R.string.c_error).setMessage(R.string.c_billing_error).create().show();
} else {
if (!CalculatorApplication.isAdFree(CalculatorPreferencesActivity.this)) {
// not purchased => show purchase window for user
BillingController.requestPurchase(CalculatorPreferencesActivity.this, CalculatorApplication.AD_FREE_PRODUCT_ID, true);
}
}
}
return true;
}
});
return true;
}
});
} else {
addFreePreference.setEnabled(false);
}
final SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
preferences.registerOnSharedPreferenceChangeListener(this);