Pro debugging

pull/145/head
M66B 6 years ago
parent 2cab6e2618
commit a7b8fb69ca

@ -35,10 +35,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
protected void onCreate(Bundle savedInstanceState) {
Log.i(Helper.TAG, "Create " + this.getClass().getName() + " version=" + BuildConfig.VERSION_NAME);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean pro = prefs.getBoolean("pro", false);
String theme = (pro ? prefs.getString("theme", "light") : "light");
String theme = (Helper.isPro(this) ? prefs.getString("theme", "light") : "light");
setTheme("light".equals(theme) ? R.style.AppThemeLight : R.style.AppThemeDark);
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
prefs.registerOnSharedPreferenceChangeListener(this);
super.onCreate(savedInstanceState);
}

@ -861,7 +861,7 @@ public class FragmentAccount extends FragmentEx {
Helper.setViewsEnabled(view, true);
boolean pro = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("pro", false);
boolean pro = Helper.isPro(getContext());
etSignature.setHint(pro ? R.string.title_optional : R.string.title_pro_feature);
etSignature.setEnabled(pro);
if (pro) {

@ -31,7 +31,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
import android.provider.OpenableColumns;
import android.text.Html;
@ -713,7 +712,7 @@ public class FragmentCompose extends FragmentEx {
long id = args.getLong("id", -1);
long reference = args.getLong("reference", -1);
long answer = args.getLong("answer", -1);
boolean pro = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pro", false);
boolean pro = Helper.isPro(getContext());
Log.i(Helper.TAG, "Load draft action=" + action + " id=" + id + " reference=" + reference);

@ -807,7 +807,7 @@ public class FragmentMessage extends FragmentEx {
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem target) {
if (PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("pro", false)) {
if (Helper.isPro(getContext())) {
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "reply")
.putExtra("reference", message.id)

@ -508,8 +508,7 @@ public class FragmentMessages extends FragmentEx {
@Override
public void onResume() {
super.onResume();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
grpSupport.setVisibility(prefs.getBoolean("pro", false) ? View.GONE : View.VISIBLE);
grpSupport.setVisibility(Helper.isPro(getContext()) ? View.GONE : View.VISIBLE);
}
@Override
@ -524,7 +523,7 @@ public class FragmentMessages extends FragmentEx {
public boolean onQueryTextSubmit(String query) {
menuSearch.collapseActionView();
if (PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("pro", false)) {
if (Helper.isPro(getContext())) {
Intent intent = new Intent();
intent.putExtra("folder", folder);
intent.putExtra("search", query);
@ -583,7 +582,7 @@ public class FragmentMessages extends FragmentEx {
case R.id.menu_sort_on_unread:
case R.id.menu_sort_on_starred:
if (prefs.getBoolean("pro", false)) {
if (Helper.isPro(getContext())) {
prefs.edit().putString("sort", item.getItemId() == R.id.menu_sort_on_unread ? "unread" : "starred").apply();
item.setChecked(true);
loadMessages();

@ -203,7 +203,7 @@ public class FragmentSetup extends FragmentEx {
tbDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton button, boolean checked) {
if (prefs.getBoolean("pro", false)) {
if (Helper.isPro(getContext())) {
if (checked != (Boolean) button.getTag()) {
button.setTag(checked);
tbDarkTheme.setChecked(checked);
@ -346,8 +346,7 @@ public class FragmentSetup extends FragmentEx {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_export:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("pro", false))
if (Helper.isPro(getContext()))
startActivityForResult(getIntentExport(), ActivitySetup.REQUEST_EXPORT);
else {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

@ -23,6 +23,7 @@ import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.content.res.TypedArray;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
@ -273,4 +274,10 @@ public class Helper {
return Integer.toString(responseCode);
}
}
static boolean isPro(Context context) {
if (false && BuildConfig.DEBUG)
return true;
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pro", false);
}
}

@ -310,7 +310,7 @@ public class ServiceSynchronize extends LifecycleService {
builder.setLights(0xff00ff00, 1000, 1000);
}
if (prefs.getBoolean("pro", false)) {
if (Helper.isPro(this)) {
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
StringBuilder sb = new StringBuilder();
for (EntityMessage message : messages) {

Loading…
Cancel
Save