mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 23:59:54 +01:00
Moved the expiry check to the splash screen.
This avoids a possible problem where the app expires while it's running and every activity shows the expiry warning, leaving the user with no way to quit.
This commit is contained in:
@@ -18,8 +18,6 @@ import android.os.IBinder;
|
|||||||
|
|
||||||
public class BriarActivity extends RoboFragmentActivity {
|
public class BriarActivity extends RoboFragmentActivity {
|
||||||
|
|
||||||
// This build expires on 7 February 2014
|
|
||||||
private static final long EXPIRY_DATE = 1391731200 * 1000L;
|
|
||||||
private static final int REQUEST_PASSWORD = 1;
|
private static final int REQUEST_PASSWORD = 1;
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
@@ -34,13 +32,7 @@ public class BriarActivity extends RoboFragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
if(System.currentTimeMillis() >= EXPIRY_DATE) {
|
if(databaseConfig.getEncryptionKey() == null) {
|
||||||
if(LOG.isLoggable(INFO)) LOG.info("Expired");
|
|
||||||
Intent i = new Intent(this, ExpiredActivity.class);
|
|
||||||
i.setFlags(FLAG_ACTIVITY_NO_ANIMATION);
|
|
||||||
startActivity(i);
|
|
||||||
finish();
|
|
||||||
} else if(databaseConfig.getEncryptionKey() == null) {
|
|
||||||
if(LOG.isLoggable(INFO)) LOG.info("No password");
|
if(LOG.isLoggable(INFO)) LOG.info("No password");
|
||||||
Intent i = new Intent(this, PasswordActivity.class);
|
Intent i = new Intent(this, PasswordActivity.class);
|
||||||
i.setFlags(FLAG_ACTIVITY_NO_ANIMATION);
|
i.setFlags(FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.android;
|
package org.briarproject.android;
|
||||||
|
|
||||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||||
|
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
|
||||||
import static android.view.Gravity.CENTER;
|
import static android.view.Gravity.CENTER;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||||
@@ -14,6 +15,7 @@ import org.briarproject.api.db.DatabaseConfig;
|
|||||||
|
|
||||||
import roboguice.RoboGuice;
|
import roboguice.RoboGuice;
|
||||||
import roboguice.activity.RoboSplashActivity;
|
import roboguice.activity.RoboSplashActivity;
|
||||||
|
import android.app.Application;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -27,28 +29,34 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(SplashScreenActivity.class.getName());
|
Logger.getLogger(SplashScreenActivity.class.getName());
|
||||||
|
|
||||||
|
// This build expires on 7 February 2014
|
||||||
|
private static final long EXPIRY_DATE = 1391731200 * 1000L;
|
||||||
// Default log level - change this to OFF for release builds
|
// Default log level - change this to OFF for release builds
|
||||||
private static final Level DEFAULT_LOG_LEVEL = INFO;
|
private static final Level DEFAULT_LOG_LEVEL = INFO;
|
||||||
|
|
||||||
private long start = System.currentTimeMillis();
|
private long start = System.currentTimeMillis();
|
||||||
|
|
||||||
public SplashScreenActivity() {
|
public SplashScreenActivity() {
|
||||||
|
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||||
minDisplayMs = 500;
|
minDisplayMs = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
layout.setLayoutParams(MATCH_MATCH);
|
||||||
layout.setGravity(CENTER);
|
layout.setGravity(CENTER);
|
||||||
layout.setBackgroundColor(Color.WHITE);
|
layout.setBackgroundColor(Color.WHITE);
|
||||||
|
|
||||||
int pad = LayoutUtils.getLargeItemPadding(this);
|
int pad = LayoutUtils.getLargeItemPadding(this);
|
||||||
|
|
||||||
ImageView logo = new ImageView(this);
|
ImageView logo = new ImageView(this);
|
||||||
logo.setPadding(pad, pad, pad, pad);
|
logo.setPadding(pad, pad, pad, pad);
|
||||||
logo.setImageResource(R.drawable.briar_logo_large);
|
logo.setImageResource(R.drawable.briar_logo_large);
|
||||||
layout.addView(logo);
|
layout.addView(logo);
|
||||||
|
|
||||||
setContentView(layout);
|
setContentView(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,15 +64,23 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
long duration = System.currentTimeMillis() - start;
|
long duration = System.currentTimeMillis() - start;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
LOG.info("Guice startup took " + duration + " ms");
|
LOG.info("Guice startup took " + duration + " ms");
|
||||||
Injector guice = RoboGuice.getBaseApplicationInjector(getApplication());
|
if(System.currentTimeMillis() >= EXPIRY_DATE) {
|
||||||
if(guice.getInstance(DatabaseConfig.class).databaseExists()) {
|
if(LOG.isLoggable(INFO)) LOG.info("Expired");
|
||||||
Intent i = new Intent(this, DashboardActivity.class);
|
Intent i = new Intent(this, ExpiredActivity.class);
|
||||||
i.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
i.setFlags(FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
} else {
|
} else {
|
||||||
Intent i = new Intent(this, SetupActivity.class);
|
Application app = getApplication();
|
||||||
i.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
Injector guice = RoboGuice.getBaseApplicationInjector(app);
|
||||||
startActivity(i);
|
if(guice.getInstance(DatabaseConfig.class).databaseExists()) {
|
||||||
|
Intent i = new Intent(this, DashboardActivity.class);
|
||||||
|
i.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(i);
|
||||||
|
} else {
|
||||||
|
Intent i = new Intent(this, SetupActivity.class);
|
||||||
|
i.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user