mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
Created switches for disabling alpha/beta testing code.
This commit is contained in:
@@ -4,6 +4,7 @@ import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
|
|||||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
||||||
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -42,7 +43,7 @@ public class BriarActivity extends RoboActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
getWindow().setFlags(FLAG_SECURE, FLAG_SECURE);
|
if(PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||||
if(databaseConfig.getEncryptionKey() != null) startAndBindService();
|
if(databaseConfig.getEncryptionKey() != null) startAndBindService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.briarproject.android;
|
|||||||
|
|
||||||
import static android.view.Gravity.CENTER;
|
import static android.view.Gravity.CENTER;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
@@ -18,7 +19,7 @@ public class ExpiredActivity extends Activity {
|
|||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
getWindow().setFlags(FLAG_SECURE, FLAG_SECURE);
|
if(PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
layout.setLayoutParams(MATCH_MATCH);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import static android.view.View.VISIBLE;
|
|||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
||||||
import static android.widget.LinearLayout.VERTICAL;
|
import static android.widget.LinearLayout.VERTICAL;
|
||||||
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ public class PasswordActivity extends RoboActivity {
|
|||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
getWindow().setFlags(FLAG_SECURE, FLAG_SECURE);
|
if(PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||||
|
|
||||||
SharedPreferences prefs = getSharedPreferences("db", MODE_PRIVATE);
|
SharedPreferences prefs = getSharedPreferences("db", MODE_PRIVATE);
|
||||||
String hex = prefs.getString("key", null);
|
String hex = prefs.getString("key", null);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import static android.view.View.VISIBLE;
|
|||||||
import static android.widget.LinearLayout.VERTICAL;
|
import static android.widget.LinearLayout.VERTICAL;
|
||||||
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 org.briarproject.android.TestingConstants.SHOW_TESTING_ACTIVITY;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||||
|
|
||||||
@@ -168,16 +169,18 @@ OnClickListener {
|
|||||||
|
|
||||||
layout.addView(new HorizontalBorder(this));
|
layout.addView(new HorizontalBorder(this));
|
||||||
|
|
||||||
LinearLayout footer = new LinearLayout(this);
|
if(SHOW_TESTING_ACTIVITY) {
|
||||||
footer.setLayoutParams(MATCH_WRAP);
|
LinearLayout footer = new LinearLayout(this);
|
||||||
footer.setGravity(CENTER);
|
footer.setLayoutParams(MATCH_WRAP);
|
||||||
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
|
footer.setGravity(CENTER);
|
||||||
testingButton = new ImageButton(this);
|
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
|
||||||
testingButton.setBackgroundResource(0);
|
testingButton = new ImageButton(this);
|
||||||
testingButton.setImageResource(R.drawable.action_about);
|
testingButton.setBackgroundResource(0);
|
||||||
testingButton.setOnClickListener(this);
|
testingButton.setImageResource(R.drawable.action_about);
|
||||||
footer.addView(testingButton);
|
testingButton.setOnClickListener(this);
|
||||||
layout.addView(footer);
|
footer.addView(testingButton);
|
||||||
|
layout.addView(footer);
|
||||||
|
}
|
||||||
|
|
||||||
setContentView(layout);
|
setContentView(layout);
|
||||||
}
|
}
|
||||||
@@ -246,7 +249,7 @@ OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(testingButton == null) return; // Not created yet
|
if(progress == null) return; // Not created yet
|
||||||
if(view == testingButton) {
|
if(view == testingButton) {
|
||||||
startActivity(new Intent(this, TestingActivity.class));
|
startActivity(new Intent(this, TestingActivity.class));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import static android.view.View.VISIBLE;
|
|||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static android.widget.LinearLayout.VERTICAL;
|
import static android.widget.LinearLayout.VERTICAL;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||||
import static org.briarproject.api.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
import static org.briarproject.api.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
@@ -75,7 +76,7 @@ public class SetupActivity extends RoboActivity implements OnClickListener {
|
|||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
getWindow().setFlags(FLAG_SECURE, FLAG_SECURE);
|
if(PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
layout.setLayoutParams(MATCH_MATCH);
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ package org.briarproject.android;
|
|||||||
import static android.view.Gravity.CENTER;
|
import static android.view.Gravity.CENTER;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
||||||
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
@@ -31,8 +32,6 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
|
|
||||||
// This build expires on 10 May 2014
|
// This build expires on 10 May 2014
|
||||||
private static final long EXPIRY_DATE = 1399680000 * 1000L;
|
private static final long EXPIRY_DATE = 1399680000 * 1000L;
|
||||||
// Default log level - change this to OFF for release builds
|
|
||||||
private static final Level DEFAULT_LOG_LEVEL = INFO;
|
|
||||||
|
|
||||||
private long now = System.currentTimeMillis();
|
private long now = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
getWindow().setFlags(FLAG_SECURE, FLAG_SECURE);
|
if(PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
layout.setLayoutParams(MATCH_MATCH);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.briarproject.android;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
interface TestingConstants {
|
||||||
|
|
||||||
|
/** Default log level - this should be OFF for release builds. */
|
||||||
|
Level DEFAULT_LOG_LEVEL = INFO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to prevent screenshots from being taken. This should be true for
|
||||||
|
* release builds, to prevent Recent Apps from storing screenshots of
|
||||||
|
* private information. Unfortunately this also prevents the user from
|
||||||
|
* taking screenshots intentionally.
|
||||||
|
*/
|
||||||
|
boolean PREVENT_SCREENSHOTS = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to allow TestingActivity to be launched from SettingsActivity.
|
||||||
|
* This should be false for release builds.
|
||||||
|
*/
|
||||||
|
boolean SHOW_TESTING_ACTIVITY = true;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user