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

@ -165,9 +165,9 @@
<string name="c_warning">Внимание</string> <string name="c_warning">Внимание</string>
<string name="c_error">Ошибка</string> <string name="c_error">Ошибка</string>
<string name="c_billing_error">Биллинг не поддерживается!</string> <string name="c_billing_error">Биллинг не поддерживается: вы должны иметь Google Checkout аккаунт привязанный в вашему Google аккаунту и должны быть подключены к интернету.</string>
<string name="c_calc_ad_free_title">Избавиться от рекламы и поддержать проект</string> <string name="c_calc_ad_free_title">Избавиться от рекламы!</string>
<string name="c_calc_ad_free_summary">Скидка 50% для первых 100 покупателей</string> <string name="c_calc_ad_free_summary">Скидка 50% для первых 100 покупателей</string>
</resources> </resources>

View File

@ -165,9 +165,9 @@
<string name="c_warning">Warning</string> <string name="c_warning">Warning</string>
<string name="c_error">Error</string> <string name="c_error">Error</string>
<string name="c_billing_error">Billing is not supported!</string> <string name="c_billing_error">Billing is not supported: you must have Google Checkout account linked to your Google account and must be connected to the internet.</string>
<string name="c_calc_ad_free_title">Get rid of ads and support the project</string> <string name="c_calc_ad_free_title">Get rid of ads!</string>
<string name="c_calc_ad_free_summary">50% offer for first 100 customers</string> <string name="c_calc_ad_free_summary">50% offer for first 100 customers</string>
</resources> </resources>

View File

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