diff --git a/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java index c48ca9ffe..a1e058034 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java @@ -54,7 +54,6 @@ import static org.acra.ReportField.REPORT_ID; import static org.acra.ReportField.STACK_TRACE; import static org.acra.ReportField.USER_APP_START_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; @ReportsCrashes( @@ -111,7 +110,7 @@ public class BriarApplicationImpl extends Application Handler[] handlers = rootLogger.getHandlers(); // Disable the Android logger for release builds 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 // raise records to the logger's default level rootLogger.addHandler(new LevelRaisingHandler(FINE, INFO)); @@ -119,7 +118,7 @@ public class BriarApplicationImpl extends Application for (Handler handler : handlers) rootLogger.addHandler(handler); } rootLogger.addHandler(logHandler); - rootLogger.setLevel(IS_DEBUG_BUILD || IS_BETA_BUILD ? FINE : INFO); + rootLogger.setLevel(IS_DEBUG_BUILD ? FINE : INFO); LOG.info("Created"); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/TestingConstants.java b/briar-android/src/main/java/org/briarproject/briar/android/TestingConstants.java index e3b970dc9..12620dffc 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/TestingConstants.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/TestingConstants.java @@ -2,6 +2,8 @@ package org.briarproject.briar.android; import org.briarproject.briar.BuildConfig; +import static java.util.concurrent.TimeUnit.DAYS; + public interface TestingConstants { /** @@ -9,12 +11,6 @@ public interface TestingConstants { */ 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 * prevents Recent Apps from storing screenshots of private information. @@ -24,10 +20,9 @@ public interface TestingConstants { boolean PREVENT_SCREENSHOTS = !IS_DEBUG_BUILD; /** - * Debug and beta builds expire after 90 days. Final release builds expire - * after 292 million years. + * Debug builds expire after 90 days. Release builds expire after 292 + * million years. */ - long EXPIRY_DATE = IS_DEBUG_BUILD || IS_BETA_BUILD ? - BuildConfig.BuildTimestamp + 90 * 24 * 60 * 60 * 1000L : - Long.MAX_VALUE; + long EXPIRY_DATE = IS_DEBUG_BUILD ? + BuildConfig.BuildTimestamp + DAYS.toMillis(90) : Long.MAX_VALUE; } diff --git a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java index 78f5fbb17..ae6b6ac15 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerActivity.java @@ -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.BaseFragmentListener; 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.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.activity.RequestCodes.REQUEST_PASSWORD; 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; @MethodsNotNullByDefault @@ -155,10 +152,10 @@ public class NavDrawerActivity extends BriarActivity implements super.onStart(); updateTransports(); lockManager.checkIfLockable(); - controller.showExpiryWarning(new UiResultHandler(this) { + controller.showExpiryWarning(new UiResultHandler(this) { @Override - public void onResultUi(ExpiryWarning expiry) { - if (expiry != NO) showExpiryWarning(expiry); + public void onResultUi(Boolean expiry) { + if (expiry) showExpiryWarning(); } }); } @@ -347,7 +344,7 @@ public class NavDrawerActivity extends BriarActivity implements if (item != null) item.setVisible(visible); } - private void showExpiryWarning(ExpiryWarning expiry) { + private void showExpiryWarning() { int daysUntilExpiry = getDaysUntilExpiry(); if (daysUntilExpiry < 0) signOut(); @@ -359,21 +356,9 @@ public class NavDrawerActivity extends BriarActivity implements ImageView expiryWarningClose = expiryWarning.findViewById(R.id.expiryWarningClose); - // show a different snackbar in green if this is an update - if (expiry == UPDATE) { - expiryWarning.setBackgroundColor( - 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)); - } + expiryWarningText.setText(getResources() + .getQuantityString(R.plurals.expiry_warning, + daysUntilExpiry, daysUntilExpiry)); expiryWarningClose.setOnClickListener(v -> { controller.expiryWarningDismissed(); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerController.java b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerController.java index d2d883e90..44c8c8dfd 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerController.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerController.java @@ -10,11 +10,9 @@ import org.briarproject.briar.android.controller.handler.ResultHandler; @NotNullByDefault public interface NavDrawerController extends ActivityLifecycleController { - enum ExpiryWarning { SHOW, NO, UPDATE } - boolean isTransportRunning(TransportId transportId); - void showExpiryWarning(ResultHandler handler); + void showExpiryWarning(ResultHandler handler); void expiryWarningDismissed(); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerControllerImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerControllerImpl.java index 489be9db3..4af7eded3 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerControllerImpl.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/navdrawer/NavDrawerControllerImpl.java @@ -26,16 +26,14 @@ import java.util.logging.Logger; import javax.inject.Inject; +import static java.util.concurrent.TimeUnit.DAYS; import static java.util.logging.Level.INFO; 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.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.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.util.UiUtils.needsDozeWhitelisting; @@ -45,9 +43,9 @@ public class NavDrawerControllerImpl extends DbControllerImpl implements NavDrawerController, EventListener { 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_SHOW_UPDATE = "expiryShowUpdate"; private final PluginManager pluginManager; private final SettingsManager settingsManager; @@ -103,9 +101,9 @@ public class NavDrawerControllerImpl extends DbControllerImpl } @Override - public void showExpiryWarning(ResultHandler handler) { - if (!IS_DEBUG_BUILD && !IS_BETA_BUILD) { - handler.onResult(NO); + public void showExpiryWarning(ResultHandler handler) { + if (!IS_DEBUG_BUILD) { + handler.onResult(false); return; } runOnDbThread(() -> { @@ -113,29 +111,25 @@ public class NavDrawerControllerImpl extends DbControllerImpl Settings settings = settingsManager.getSettings(SETTINGS_NAMESPACE); int warningInt = settings.getInt(EXPIRY_DATE_WARNING, 0); - boolean showUpdate = - settings.getBoolean(EXPIRY_SHOW_UPDATE, true); if (warningInt == 0) { // we have not warned before - handler.onResult(SHOW); + handler.onResult(true); } else { long warningLong = warningInt * 1000L; long now = System.currentTimeMillis(); long daysSinceLastWarning = - (now - warningLong) / 1000 / 60 / 60 / 24; + (now - warningLong) / DAYS.toMillis(1); long daysBeforeExpiry = - (EXPIRY_DATE - now) / 1000 / 60 / 60 / 24; + (EXPIRY_DATE - now) / DAYS.toMillis(1); - if (showUpdate) { - handler.onResult(UPDATE); - } else if (daysSinceLastWarning >= 30) { - handler.onResult(SHOW); + if (daysSinceLastWarning >= 30) { + handler.onResult(true); } else if (daysBeforeExpiry <= 3 && daysSinceLastWarning > 0) { - handler.onResult(SHOW); + handler.onResult(true); } else { - handler.onResult(NO); + handler.onResult(false); } } } catch (DbException e) { @@ -151,7 +145,6 @@ public class NavDrawerControllerImpl extends DbControllerImpl Settings settings = new Settings(); int date = (int) (System.currentTimeMillis() / 1000L); settings.putInt(EXPIRY_DATE_WARNING, date); - settings.putBoolean(EXPIRY_SHOW_UPDATE, false); settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE); } catch (DbException e) { logException(LOG, WARNING, e); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java b/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java index ae9b8e090..0e6856615 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java @@ -80,6 +80,7 @@ import static android.view.KeyEvent.KEYCODE_ENTER; import static android.view.inputmethod.EditorInfo.IME_NULL; import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT; 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.android.TestingConstants.EXPIRY_DATE; @@ -151,7 +152,7 @@ public class UiUtils { public static int getDaysUntilExpiry() { long now = System.currentTimeMillis(); - long daysBeforeExpiry = (EXPIRY_DATE - now) / 1000 / 60 / 60 / 24; + long daysBeforeExpiry = (EXPIRY_DATE - now) / DAYS.toMillis(1); return (int) daysBeforeExpiry; } diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 6f6584795..5e32aaa6c 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -47,11 +47,10 @@ This is a test version of Briar. Your account will expire in %d day and cannot be renewed. This is a test version of Briar. Your account will expire in %d days and cannot be renewed. - The testing expiry date has been extended. Your account will now expire in %d days. This software has expired.\nThank you for testing! - To continue using Briar, please download version 1.0. + To continue using Briar, please download the latest release. You will need to create a new account, but you can use the same nickname. - Download Briar 1.0 + Download Latest Release Decrypting Database… Upgrading Database… Compacting Database…