disable trial stuff on debug builds

This commit is contained in:
Andrew Dolgov 2014-11-13 11:56:45 +03:00
parent 42eed3019f
commit e483893a24

View File

@ -478,61 +478,64 @@ public class OnlineActivity extends CommonActivity {
} }
public void checkTrial(boolean notify) { public void checkTrial(boolean notify) {
boolean isTrial = getPackageManager().checkSignatures( if (!BuildConfig.DEBUG) {
getPackageName(), "org.fox.ttrss.key") != PackageManager.SIGNATURE_MATCH;
if (isTrial) { boolean isTrial = getPackageManager().checkSignatures(
long firstStart = m_prefs.getLong("date_firstlaunch_trial", -1); getPackageName(), "org.fox.ttrss.key") != PackageManager.SIGNATURE_MATCH;
if (firstStart == -1) {
firstStart = System.currentTimeMillis();
SharedPreferences.Editor editor = m_prefs.edit();
editor.putLong("date_firstlaunch_trial", firstStart);
editor.commit();
}
if (!notify && System.currentTimeMillis() > firstStart + (TRIAL_DAYS * 24 * 60 * 60 * 1000)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setTitle(R.string.trial_expired)
.setMessage(R.string.trial_expired_message)
.setCancelable(false)
.setPositiveButton(getString(R.string.trial_purchase),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
openUnlockUrl();
finish();
} if (isTrial) {
}) long firstStart = m_prefs.getLong("date_firstlaunch_trial", -1);
.setNegativeButton(getString(R.string.cancel),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
finish();
} if (firstStart == -1) {
}); firstStart = System.currentTimeMillis();
AlertDialog dialog = builder.create(); SharedPreferences.Editor editor = m_prefs.edit();
dialog.show(); editor.putLong("date_firstlaunch_trial", firstStart);
editor.commit();
} else { }
int daysLeft = Math.round((firstStart + (TRIAL_DAYS * 24 * 60 * 60 * 1000) - System.currentTimeMillis()) / (24 * 60 * 60 * 1000));
if (!notify && System.currentTimeMillis() > firstStart + (TRIAL_DAYS * 24 * 60 * 60 * 1000)) {
if (notify) {
toast(getResources().getQuantityString(R.plurals.trial_mode_prompt, daysLeft, daysLeft)); AlertDialog.Builder builder = new AlertDialog.Builder(this)
} .setTitle(R.string.trial_expired)
} .setMessage(R.string.trial_expired_message)
} else if (notify) { .setCancelable(false)
//toast(R.string.trial_thanks); .setPositiveButton(getString(R.string.trial_purchase),
} new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
openUnlockUrl();
finish();
}
})
.setNegativeButton(getString(R.string.cancel),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
finish();
}
});
AlertDialog dialog = builder.create();
dialog.show();
} else {
int daysLeft = Math.round((firstStart + (TRIAL_DAYS * 24 * 60 * 60 * 1000) - System.currentTimeMillis()) / (24 * 60 * 60 * 1000));
if (notify) {
toast(getResources().getQuantityString(R.plurals.trial_mode_prompt, daysLeft, daysLeft));
}
}
} else if (notify) {
//toast(R.string.trial_thanks);
}
}
} }
private void openUnlockUrl() { private void openUnlockUrl() {