Merge branch 'remove-beta-build-flag' into 'master'

Remove beta build flag

Closes #1527

See merge request briar/briar!1196
This commit is contained in:
Torsten Grote
2019-11-06 17:53:02 +00:00
7 changed files with 34 additions and 64 deletions

View File

@@ -54,7 +54,6 @@ import static org.acra.ReportField.REPORT_ID;
import static org.acra.ReportField.STACK_TRACE; import static org.acra.ReportField.STACK_TRACE;
import static org.acra.ReportField.USER_APP_START_DATE; import static org.acra.ReportField.USER_APP_START_DATE;
import static org.acra.ReportField.USER_CRASH_DATE; import static org.acra.ReportField.USER_CRASH_DATE;
import static org.briarproject.briar.android.TestingConstants.IS_BETA_BUILD;
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD; import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
@ReportsCrashes( @ReportsCrashes(
@@ -111,7 +110,7 @@ public class BriarApplicationImpl extends Application
Handler[] handlers = rootLogger.getHandlers(); Handler[] handlers = rootLogger.getHandlers();
// Disable the Android logger for release builds // Disable the Android logger for release builds
for (Handler handler : handlers) rootLogger.removeHandler(handler); for (Handler handler : handlers) rootLogger.removeHandler(handler);
if (IS_DEBUG_BUILD || IS_BETA_BUILD) { if (IS_DEBUG_BUILD) {
// We can't set the level of the Android logger at runtime, so // We can't set the level of the Android logger at runtime, so
// raise records to the logger's default level // raise records to the logger's default level
rootLogger.addHandler(new LevelRaisingHandler(FINE, INFO)); rootLogger.addHandler(new LevelRaisingHandler(FINE, INFO));
@@ -119,7 +118,7 @@ public class BriarApplicationImpl extends Application
for (Handler handler : handlers) rootLogger.addHandler(handler); for (Handler handler : handlers) rootLogger.addHandler(handler);
} }
rootLogger.addHandler(logHandler); rootLogger.addHandler(logHandler);
rootLogger.setLevel(IS_DEBUG_BUILD || IS_BETA_BUILD ? FINE : INFO); rootLogger.setLevel(IS_DEBUG_BUILD ? FINE : INFO);
LOG.info("Created"); LOG.info("Created");

View File

@@ -2,6 +2,8 @@ package org.briarproject.briar.android;
import org.briarproject.briar.BuildConfig; import org.briarproject.briar.BuildConfig;
import static java.util.concurrent.TimeUnit.DAYS;
public interface TestingConstants { public interface TestingConstants {
/** /**
@@ -9,12 +11,6 @@ public interface TestingConstants {
*/ */
boolean IS_DEBUG_BUILD = BuildConfig.DEBUG; boolean IS_DEBUG_BUILD = BuildConfig.DEBUG;
/**
* Whether this is a beta build. This should be set to false for final
* release builds.
*/
boolean IS_BETA_BUILD = false;
/** /**
* Whether to prevent screenshots from being taken. Setting this to true * Whether to prevent screenshots from being taken. Setting this to true
* prevents Recent Apps from storing screenshots of private information. * prevents Recent Apps from storing screenshots of private information.
@@ -24,10 +20,9 @@ public interface TestingConstants {
boolean PREVENT_SCREENSHOTS = !IS_DEBUG_BUILD; boolean PREVENT_SCREENSHOTS = !IS_DEBUG_BUILD;
/** /**
* Debug and beta builds expire after 90 days. Final release builds expire * Debug builds expire after 90 days. Release builds expire after 292
* after 292 million years. * million years.
*/ */
long EXPIRY_DATE = IS_DEBUG_BUILD || IS_BETA_BUILD ? long EXPIRY_DATE = IS_DEBUG_BUILD ?
BuildConfig.BuildTimestamp + 90 * 24 * 60 * 60 * 1000L : BuildConfig.BuildTimestamp + DAYS.toMillis(90) : Long.MAX_VALUE;
Long.MAX_VALUE;
} }

View File

@@ -45,7 +45,6 @@ import org.briarproject.briar.android.forum.ForumListFragment;
import org.briarproject.briar.android.fragment.BaseFragment; import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener; import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
import org.briarproject.briar.android.logout.SignOutFragment; import org.briarproject.briar.android.logout.SignOutFragment;
import org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning;
import org.briarproject.briar.android.privategroup.list.GroupListFragment; import org.briarproject.briar.android.privategroup.list.GroupListFragment;
import org.briarproject.briar.android.settings.SettingsActivity; import org.briarproject.briar.android.settings.SettingsActivity;
@@ -66,8 +65,6 @@ import static org.briarproject.bramble.api.lifecycle.LifecycleManager.LifecycleS
import static org.briarproject.briar.android.BriarService.EXTRA_STARTUP_FAILED; import static org.briarproject.briar.android.BriarService.EXTRA_STARTUP_FAILED;
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD; import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_PASSWORD;
import static org.briarproject.briar.android.navdrawer.IntentRouter.handleExternalIntent; import static org.briarproject.briar.android.navdrawer.IntentRouter.handleExternalIntent;
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.NO;
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.UPDATE;
import static org.briarproject.briar.android.util.UiUtils.getDaysUntilExpiry; import static org.briarproject.briar.android.util.UiUtils.getDaysUntilExpiry;
@MethodsNotNullByDefault @MethodsNotNullByDefault
@@ -155,10 +152,10 @@ public class NavDrawerActivity extends BriarActivity implements
super.onStart(); super.onStart();
updateTransports(); updateTransports();
lockManager.checkIfLockable(); lockManager.checkIfLockable();
controller.showExpiryWarning(new UiResultHandler<ExpiryWarning>(this) { controller.showExpiryWarning(new UiResultHandler<Boolean>(this) {
@Override @Override
public void onResultUi(ExpiryWarning expiry) { public void onResultUi(Boolean expiry) {
if (expiry != NO) showExpiryWarning(expiry); if (expiry) showExpiryWarning();
} }
}); });
} }
@@ -347,7 +344,7 @@ public class NavDrawerActivity extends BriarActivity implements
if (item != null) item.setVisible(visible); if (item != null) item.setVisible(visible);
} }
private void showExpiryWarning(ExpiryWarning expiry) { private void showExpiryWarning() {
int daysUntilExpiry = getDaysUntilExpiry(); int daysUntilExpiry = getDaysUntilExpiry();
if (daysUntilExpiry < 0) signOut(); if (daysUntilExpiry < 0) signOut();
@@ -359,21 +356,9 @@ public class NavDrawerActivity extends BriarActivity implements
ImageView expiryWarningClose = ImageView expiryWarningClose =
expiryWarning.findViewById(R.id.expiryWarningClose); expiryWarning.findViewById(R.id.expiryWarningClose);
// show a different snackbar in green if this is an update expiryWarningText.setText(getResources()
if (expiry == UPDATE) { .getQuantityString(R.plurals.expiry_warning,
expiryWarning.setBackgroundColor( daysUntilExpiry, daysUntilExpiry));
ContextCompat.getColor(this, R.color.briar_green_light));
expiryWarningText.setText(
getString(R.string.expiry_update, daysUntilExpiry));
expiryWarningText.setTextColor(
ContextCompat.getColor(this, android.R.color.black));
expiryWarningClose.setColorFilter(
ContextCompat.getColor(this, android.R.color.black));
} else {
expiryWarningText.setText(getResources()
.getQuantityString(R.plurals.expiry_warning,
daysUntilExpiry, daysUntilExpiry));
}
expiryWarningClose.setOnClickListener(v -> { expiryWarningClose.setOnClickListener(v -> {
controller.expiryWarningDismissed(); controller.expiryWarningDismissed();

View File

@@ -10,11 +10,9 @@ import org.briarproject.briar.android.controller.handler.ResultHandler;
@NotNullByDefault @NotNullByDefault
public interface NavDrawerController extends ActivityLifecycleController { public interface NavDrawerController extends ActivityLifecycleController {
enum ExpiryWarning { SHOW, NO, UPDATE }
boolean isTransportRunning(TransportId transportId); boolean isTransportRunning(TransportId transportId);
void showExpiryWarning(ResultHandler<ExpiryWarning> handler); void showExpiryWarning(ResultHandler<Boolean> handler);
void expiryWarningDismissed(); void expiryWarningDismissed();

View File

@@ -26,16 +26,14 @@ import java.util.logging.Logger;
import javax.inject.Inject; import javax.inject.Inject;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.logging.Level.INFO; import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import static java.util.logging.Logger.getLogger;
import static org.briarproject.bramble.util.LogUtils.logException; import static org.briarproject.bramble.util.LogUtils.logException;
import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE; import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE;
import static org.briarproject.briar.android.TestingConstants.IS_BETA_BUILD;
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD; import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
import static org.briarproject.briar.android.controller.BriarControllerImpl.DOZE_ASK_AGAIN; import static org.briarproject.briar.android.controller.BriarControllerImpl.DOZE_ASK_AGAIN;
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.NO;
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.SHOW;
import static org.briarproject.briar.android.navdrawer.NavDrawerController.ExpiryWarning.UPDATE;
import static org.briarproject.briar.android.settings.SettingsFragment.SETTINGS_NAMESPACE; import static org.briarproject.briar.android.settings.SettingsFragment.SETTINGS_NAMESPACE;
import static org.briarproject.briar.android.util.UiUtils.needsDozeWhitelisting; import static org.briarproject.briar.android.util.UiUtils.needsDozeWhitelisting;
@@ -45,9 +43,9 @@ public class NavDrawerControllerImpl extends DbControllerImpl
implements NavDrawerController, EventListener { implements NavDrawerController, EventListener {
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(NavDrawerControllerImpl.class.getName()); getLogger(NavDrawerControllerImpl.class.getName());
private static final String EXPIRY_DATE_WARNING = "expiryDateWarning"; private static final String EXPIRY_DATE_WARNING = "expiryDateWarning";
private static final String EXPIRY_SHOW_UPDATE = "expiryShowUpdate";
private final PluginManager pluginManager; private final PluginManager pluginManager;
private final SettingsManager settingsManager; private final SettingsManager settingsManager;
@@ -103,9 +101,9 @@ public class NavDrawerControllerImpl extends DbControllerImpl
} }
@Override @Override
public void showExpiryWarning(ResultHandler<ExpiryWarning> handler) { public void showExpiryWarning(ResultHandler<Boolean> handler) {
if (!IS_DEBUG_BUILD && !IS_BETA_BUILD) { if (!IS_DEBUG_BUILD) {
handler.onResult(NO); handler.onResult(false);
return; return;
} }
runOnDbThread(() -> { runOnDbThread(() -> {
@@ -113,29 +111,25 @@ public class NavDrawerControllerImpl extends DbControllerImpl
Settings settings = Settings settings =
settingsManager.getSettings(SETTINGS_NAMESPACE); settingsManager.getSettings(SETTINGS_NAMESPACE);
int warningInt = settings.getInt(EXPIRY_DATE_WARNING, 0); int warningInt = settings.getInt(EXPIRY_DATE_WARNING, 0);
boolean showUpdate =
settings.getBoolean(EXPIRY_SHOW_UPDATE, true);
if (warningInt == 0) { if (warningInt == 0) {
// we have not warned before // we have not warned before
handler.onResult(SHOW); handler.onResult(true);
} else { } else {
long warningLong = warningInt * 1000L; long warningLong = warningInt * 1000L;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long daysSinceLastWarning = long daysSinceLastWarning =
(now - warningLong) / 1000 / 60 / 60 / 24; (now - warningLong) / DAYS.toMillis(1);
long daysBeforeExpiry = long daysBeforeExpiry =
(EXPIRY_DATE - now) / 1000 / 60 / 60 / 24; (EXPIRY_DATE - now) / DAYS.toMillis(1);
if (showUpdate) { if (daysSinceLastWarning >= 30) {
handler.onResult(UPDATE); handler.onResult(true);
} else if (daysSinceLastWarning >= 30) {
handler.onResult(SHOW);
} else if (daysBeforeExpiry <= 3 && } else if (daysBeforeExpiry <= 3 &&
daysSinceLastWarning > 0) { daysSinceLastWarning > 0) {
handler.onResult(SHOW); handler.onResult(true);
} else { } else {
handler.onResult(NO); handler.onResult(false);
} }
} }
} catch (DbException e) { } catch (DbException e) {
@@ -151,7 +145,6 @@ public class NavDrawerControllerImpl extends DbControllerImpl
Settings settings = new Settings(); Settings settings = new Settings();
int date = (int) (System.currentTimeMillis() / 1000L); int date = (int) (System.currentTimeMillis() / 1000L);
settings.putInt(EXPIRY_DATE_WARNING, date); settings.putInt(EXPIRY_DATE_WARNING, date);
settings.putBoolean(EXPIRY_SHOW_UPDATE, false);
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE); settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
} catch (DbException e) { } catch (DbException e) {
logException(LOG, WARNING, e); logException(LOG, WARNING, e);

View File

@@ -80,6 +80,7 @@ import static android.view.KeyEvent.KEYCODE_ENTER;
import static android.view.inputmethod.EditorInfo.IME_NULL; import static android.view.inputmethod.EditorInfo.IME_NULL;
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT; import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.DAYS;
import static org.briarproject.briar.BuildConfig.APPLICATION_ID; import static org.briarproject.briar.BuildConfig.APPLICATION_ID;
import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE; import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE;
@@ -151,7 +152,7 @@ public class UiUtils {
public static int getDaysUntilExpiry() { public static int getDaysUntilExpiry() {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long daysBeforeExpiry = (EXPIRY_DATE - now) / 1000 / 60 / 60 / 24; long daysBeforeExpiry = (EXPIRY_DATE - now) / DAYS.toMillis(1);
return (int) daysBeforeExpiry; return (int) daysBeforeExpiry;
} }

View File

@@ -47,11 +47,10 @@
<item quantity="one">This is a test version of Briar. Your account will expire in %d day and cannot be renewed.</item> <item quantity="one">This is a test version of Briar. Your account will expire in %d day and cannot be renewed.</item>
<item quantity="other">This is a test version of Briar. Your account will expire in %d days and cannot be renewed.</item> <item quantity="other">This is a test version of Briar. Your account will expire in %d days and cannot be renewed.</item>
</plurals> </plurals>
<string name="expiry_update">The testing expiry date has been extended. Your account will now expire in %d days.</string>
<string name="expiry_date_reached">This software has expired.\nThank you for testing!</string> <string name="expiry_date_reached">This software has expired.\nThank you for testing!</string>
<string name="download_briar">To continue using Briar, please download version 1.0.</string> <string name="download_briar">To continue using Briar, please download the latest release.</string>
<string name="create_new_account">You will need to create a new account, but you can use the same nickname.</string> <string name="create_new_account">You will need to create a new account, but you can use the same nickname.</string>
<string name="download_briar_button">Download Briar 1.0</string> <string name="download_briar_button">Download Latest Release</string>
<string name="startup_open_database">Decrypting Database…</string> <string name="startup_open_database">Decrypting Database…</string>
<string name="startup_migrate_database">Upgrading Database…</string> <string name="startup_migrate_database">Upgrading Database…</string>
<string name="startup_compact_database">Compacting Database…</string> <string name="startup_compact_database">Compacting Database…</string>