diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 39a06b3ca2..e595fb28da 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -122,6 +122,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swAuthNtlm; private SwitchCompat swAuthSasl; private SwitchCompat swExactAlarms; + private SwitchCompat swTestIab; private TextView tvProcessors; private TextView tvMemoryClass; private TextView tvMemoryUsage; @@ -147,7 +148,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "protocol", "debug", "log_level", "use_modseq", "perform_expunge", "auth_plain", "auth_login", "auth_ntlm", "auth_sasl", - "exact_alarms" + "exact_alarms", "test_iab" }; private final static String[] RESET_QUESTIONS = new String[]{ @@ -229,6 +230,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swAuthNtlm = view.findViewById(R.id.swAuthNtlm); swAuthSasl = view.findViewById(R.id.swAuthSasl); swExactAlarms = view.findViewById(R.id.swExactAlarms); + swTestIab = view.findViewById(R.id.swTestIab); tvProcessors = view.findViewById(R.id.tvProcessors); tvMemoryClass = view.findViewById(R.id.tvMemoryClass); tvMemoryUsage = view.findViewById(R.id.tvMemoryUsage); @@ -605,6 +607,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swTestIab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("test_iab", checked).apply(); + } + }); + btnGC.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -821,6 +830,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc setLastCleanup(prefs.getLong("last_cleanup", -1)); + swTestIab.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE); + PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); return view; @@ -991,6 +1002,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swAuthNtlm.setChecked(prefs.getBoolean("auth_ntlm", true)); swAuthSasl.setChecked(prefs.getBoolean("auth_sasl", true)); swExactAlarms.setChecked(prefs.getBoolean("exact_alarms", false)); + swTestIab.setChecked(prefs.getBoolean("test_iab", false)); tvProcessors.setText(getString(R.string.title_advanced_processors, Runtime.getRuntime().availableProcessors())); diff --git a/app/src/main/java/eu/faircode/email/FragmentPro.java b/app/src/main/java/eu/faircode/email/FragmentPro.java index dcf0274063..0be85a230a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPro.java +++ b/app/src/main/java/eu/faircode/email/FragmentPro.java @@ -62,7 +62,7 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha private TextView tvPriceHint; private TextView tvFamilyHint; private TextView tvRestoreHint; - private Button btnCheck; + private Button btnConsume; private static final int HIDE_BANNER = 3; // weeks @@ -90,12 +90,13 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha tvFamilyHint = view.findViewById(R.id.tvFamilyHint); tvRestoreHint = view.findViewById(R.id.tvRestoreHint); - btnCheck = view.findViewById(R.id.btnCheck); + btnConsume = view.findViewById(R.id.btnConsume); btnBackup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - startActivity(new Intent(getContext(), ActivitySetup.class).putExtra("navigate", true)); + startActivity(new Intent(getContext(), ActivitySetup.class) + .putExtra("navigate", true)); } }); btnBackup.setVisibility(View.GONE); @@ -129,8 +130,8 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha btnPurchase.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); + public void onClick(View v) { + LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(v.getContext()); lbm.sendBroadcast(new Intent(ActivityBilling.ACTION_PURCHASE)); } }); @@ -161,11 +162,11 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha } }); - btnCheck.setOnClickListener(new View.OnClickListener() { + btnConsume.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); - lbm.sendBroadcast(new Intent(ActivityBilling.ACTION_PURCHASE_CHECK)); + public void onClick(View v) { + LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(v.getContext()); + lbm.sendBroadcast(new Intent(ActivityBilling.ACTION_PURCHASE_CONSUME)); } }); @@ -175,8 +176,8 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha btnPurchase.setEnabled(!Helper.isPlayStoreInstall()); tvPrice.setText(null); tvRestoreHint.setVisibility(Helper.isPlayStoreInstall() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); - btnCheck.setEnabled(false); - btnCheck.setVisibility(Helper.isPlayStoreInstall() && debug ? View.VISIBLE : View.GONE); + btnConsume.setEnabled(false); + btnConsume.setVisibility(ActivityBilling.isTesting(getContext()) ? View.VISIBLE : View.GONE); return view; } @@ -188,12 +189,10 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha addBillingListener(new ActivityBilling.IBillingListener() { @Override public void onConnected() { - btnCheck.setEnabled(true); } @Override public void onDisconnected() { - btnCheck.setEnabled(false); } @Override @@ -213,10 +212,11 @@ public class FragmentPro extends FragmentBase implements SharedPreferences.OnSha } @Override - public void onPurchased(String sku) { + public void onPurchased(String sku, boolean purchased) { if (ActivityBilling.getSkuPro().equals(sku)) { - btnPurchase.setEnabled(false); + btnPurchase.setEnabled(!purchased); tvPending.setVisibility(View.GONE); + btnConsume.setEnabled(purchased); } } diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 0084ffb50b..73d65c7cd7 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -678,6 +678,17 @@ app:layout_constraintTop_toBottomOf="@id/swAuthSasl" app:switchPadding="12dp" /> + + + app:layout_constraintTop_toBottomOf="@id/swTestIab" />