UI code cleanup.

This commit is contained in:
akwizgran
2016-05-11 13:37:32 +01:00
parent 7a3bcc58ae
commit 6873dbc493
70 changed files with 524 additions and 531 deletions

View File

@@ -28,6 +28,7 @@ import dagger.Component;
@Component(modules = ActivityModule.class, @Component(modules = ActivityModule.class,
dependencies = AndroidComponent.class) dependencies = AndroidComponent.class)
public interface ActivityComponent { public interface ActivityComponent {
Activity activity(); Activity activity();
void inject(SplashScreenActivity activity); void inject(SplashScreenActivity activity);
@@ -64,23 +65,8 @@ public interface ActivityComponent {
void inject(SettingsActivity activity); void inject(SettingsActivity activity);
/*
void inject(ContactListFragment fragment);
void inject(ForumListFragment fragment);
void inject(ShowQrCodeFragment fragment);
*/
void inject(IntroductionActivity activity); void inject(IntroductionActivity activity);
/*
void inject(ContactChooserFragment fragment);
void inject(introductionmessagefragment fragment);
*/
@Named("ContactListFragment") @Named("ContactListFragment")
BaseFragment newContactListFragment(); BaseFragment newContactListFragment();

View File

@@ -49,6 +49,7 @@ import dagger.Component;
AndroidSystemModule.class AndroidSystemModule.class
}) })
public interface AndroidComponent extends CoreEagerSingletons { public interface AndroidComponent extends CoreEagerSingletons {
// Exposed objects // Exposed objects
@CryptoExecutor @CryptoExecutor
Executor cryptoExecutor(); Executor cryptoExecutor();

View File

@@ -19,12 +19,13 @@ public abstract class BaseActivity extends AppCompatActivity {
protected ActivityComponent activityComponent; protected ActivityComponent activityComponent;
private List<ActivityLifecycleController> lifecycleControllers = private final List<ActivityLifecycleController> lifecycleControllers =
new ArrayList<ActivityLifecycleController>(); new ArrayList<>();
public void addLifecycleController( public abstract void injectActivity(ActivityComponent component);
ActivityLifecycleController lifecycleController) {
this.lifecycleControllers.add(lifecycleController); public void addLifecycleController(ActivityLifecycleController alc) {
lifecycleControllers.add(alc);
} }
@Override @Override
@@ -77,9 +78,7 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
} }
public abstract void injectActivity(ActivityComponent component); public void showSoftKeyboard(View view) {
protected void showSoftKeyboard(View view) {
Object o = getSystemService(INPUT_METHOD_SERVICE); Object o = getSystemService(INPUT_METHOD_SERVICE);
((InputMethodManager) o).showSoftInput(view, SHOW_IMPLICIT); ((InputMethodManager) o).showSoftInput(view, SHOW_IMPLICIT);
} }
@@ -89,5 +88,4 @@ public abstract class BaseActivity extends AppCompatActivity {
Object o = getSystemService(INPUT_METHOD_SERVICE); Object o = getSystemService(INPUT_METHOD_SERVICE);
((InputMethodManager) o).hideSoftInputFromWindow(token, 0); ((InputMethodManager) o).hideSoftInputFromWindow(token, 0);
} }
} }

View File

@@ -69,14 +69,13 @@ public abstract class BriarActivity extends BaseActivity {
} }
private void startExitActivity() { private void startExitActivity() {
Intent intent = new Intent(BriarActivity.this, Intent i = new Intent(this, ExitActivity.class);
ExitActivity.class); i.addFlags(FLAG_ACTIVITY_NEW_TASK
intent.addFlags(FLAG_ACTIVITY_NEW_TASK
| FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| FLAG_ACTIVITY_NO_ANIMATION); | FLAG_ACTIVITY_NO_ANIMATION);
if (Build.VERSION.SDK_INT >= 11) if (Build.VERSION.SDK_INT >= 11)
intent.addFlags(FLAG_ACTIVITY_CLEAR_TASK); i.addFlags(FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent); startActivity(i);
} }
private void finishAndExit() { private void finishAndExit() {
@@ -94,6 +93,7 @@ public abstract class BriarActivity extends BaseActivity {
@Deprecated @Deprecated
protected void finishOnUiThread() { protected void finishOnUiThread() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
finish(); finish();
} }

View File

@@ -22,7 +22,8 @@ import java.util.logging.Logger;
resDialogOkToast = R.string.dev_report_saved, resDialogOkToast = R.string.dev_report_saved,
deleteOldUnsentReportsOnApplicationStart = false deleteOldUnsentReportsOnApplicationStart = false
) )
public class BriarApplicationImpl extends Application implements BriarApplication { public class BriarApplicationImpl extends Application
implements BriarApplication {
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(BriarApplicationImpl.class.getName()); Logger.getLogger(BriarApplicationImpl.class.getName());
@@ -50,6 +51,7 @@ public class BriarApplicationImpl extends Application implements BriarApplicatio
AndroidEagerSingletons.initEagerSingletons(applicationComponent); AndroidEagerSingletons.initEagerSingletons(applicationComponent);
} }
@Override
public AndroidComponent getApplicationComponent() { public AndroidComponent getApplicationComponent() {
return applicationComponent; return applicationComponent;
} }

View File

@@ -58,9 +58,8 @@ public abstract class BriarFragmentActivity extends BriarActivity {
protected void startFragment(BaseFragment fragment) { protected void startFragment(BaseFragment fragment) {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) if (getSupportFragmentManager().getBackStackEntryCount() == 0)
this.startFragment(fragment, false); startFragment(fragment, false);
else else startFragment(fragment, true);
this.startFragment(fragment, true);
} }
protected void showMessageDialog(int titleStringId, int msgStringId) { protected void showMessageDialog(int titleStringId, int msgStringId) {
@@ -76,7 +75,7 @@ public abstract class BriarFragmentActivity extends BriarActivity {
protected void startFragment(BaseFragment fragment, protected void startFragment(BaseFragment fragment,
boolean isAddedToBackStack) { boolean isAddedToBackStack) {
this.startFragment(fragment, 0, 0, isAddedToBackStack); startFragment(fragment, 0, 0, isAddedToBackStack);
} }
protected void startFragment(BaseFragment fragment, protected void startFragment(BaseFragment fragment,
@@ -94,5 +93,4 @@ public abstract class BriarFragmentActivity extends BriarActivity {
trans.commit(); trans.commit();
updateToolbarTitle(fragment.getUniqueTag()); updateToolbarTitle(fragment.getUniqueTag());
} }
} }

View File

@@ -16,7 +16,6 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import org.acra.ACRA; import org.acra.ACRA;
import org.acra.ACRAConstants;
import org.acra.ReportField; import org.acra.ReportField;
import org.acra.collector.CrashReportData; import org.acra.collector.CrashReportData;
import org.acra.dialog.BaseCrashReportDialog; import org.acra.dialog.BaseCrashReportDialog;
@@ -24,7 +23,6 @@ import org.acra.file.CrashReportPersister;
import org.acra.prefs.SharedPreferencesFactory; import org.acra.prefs.SharedPreferencesFactory;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.util.UserFeedback; import org.briarproject.android.util.UserFeedback;
import org.briarproject.api.reporting.DevReporter;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -34,12 +32,12 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.inject.Inject; import static android.content.DialogInterface.BUTTON_POSITIVE;
import static android.view.View.GONE; import static android.view.View.GONE;
import static android.view.View.INVISIBLE; import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import static org.acra.ACRAConstants.EXTRA_REPORT_FILE;
import static org.acra.ReportField.ANDROID_VERSION; import static org.acra.ReportField.ANDROID_VERSION;
import static org.acra.ReportField.APP_VERSION_CODE; import static org.acra.ReportField.APP_VERSION_CODE;
import static org.acra.ReportField.APP_VERSION_NAME; import static org.acra.ReportField.APP_VERSION_NAME;
@@ -68,9 +66,6 @@ public class DevReportActivity extends BaseCrashReportDialog
requiredFields.add(STACK_TRACE); requiredFields.add(STACK_TRACE);
} }
@Inject
protected DevReporter reporter;
private SharedPreferencesFactory sharedPreferencesFactory; private SharedPreferencesFactory sharedPreferencesFactory;
private Set<ReportField> excludedFields; private Set<ReportField> excludedFields;
private EditText userCommentView = null; private EditText userCommentView = null;
@@ -86,17 +81,15 @@ public class DevReportActivity extends BaseCrashReportDialog
super.onCreate(state); super.onCreate(state);
setContentView(R.layout.activity_dev_report); setContentView(R.layout.activity_dev_report);
((BriarApplication) getApplication()).getApplicationComponent() BriarApplication app = (BriarApplication) getApplication();
.inject(this); app.getApplicationComponent().inject(this);
sharedPreferencesFactory = new SharedPreferencesFactory(
sharedPreferencesFactory = getApplicationContext(), getConfig());
new SharedPreferencesFactory(getApplicationContext(),
getConfig());
final SharedPreferences prefs = sharedPreferencesFactory.create(); final SharedPreferences prefs = sharedPreferencesFactory.create();
excludedFields = new HashSet<>(); excludedFields = new HashSet<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= 11) {
for (String name : prefs.getStringSet(PREF_EXCLUDED_FIELDS, for (String name : prefs.getStringSet(PREF_EXCLUDED_FIELDS,
new HashSet<String>())) { new HashSet<String>())) {
excludedFields.add(ReportField.valueOf(name)); excludedFields.add(ReportField.valueOf(name));
@@ -163,11 +156,8 @@ public class DevReportActivity extends BaseCrashReportDialog
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) { if (which == BUTTON_POSITIVE) dialog.dismiss();
dialog.dismiss(); else dialog.cancel();
} else {
dialog.cancel();
}
} }
@Override @Override
@@ -179,10 +169,8 @@ public class DevReportActivity extends BaseCrashReportDialog
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ReportField field = (ReportField) buttonView.getTag(); ReportField field = (ReportField) buttonView.getTag();
if (field != null) { if (field != null) {
if (isChecked) if (isChecked) excludedFields.remove(field);
excludedFields.remove(field); else excludedFields.add(field);
else
excludedFields.add(field);
} }
} }
@@ -214,7 +202,7 @@ public class DevReportActivity extends BaseCrashReportDialog
@Override @Override
protected CrashReportData doInBackground(Void... args) { protected CrashReportData doInBackground(Void... args) {
File reportFile = (File) getIntent().getSerializableExtra( File reportFile = (File) getIntent().getSerializableExtra(
ACRAConstants.EXTRA_REPORT_FILE); EXTRA_REPORT_FILE);
final CrashReportPersister persister = final CrashReportPersister persister =
new CrashReportPersister(); new CrashReportPersister();
try { try {
@@ -272,7 +260,7 @@ public class DevReportActivity extends BaseCrashReportDialog
@Override @Override
protected Boolean doInBackground(Void... args) { protected Boolean doInBackground(Void... args) {
File reportFile = (File) getIntent().getSerializableExtra( File reportFile = (File) getIntent().getSerializableExtra(
ACRAConstants.EXTRA_REPORT_FILE); EXTRA_REPORT_FILE);
CrashReportPersister persister = new CrashReportPersister(); CrashReportPersister persister = new CrashReportPersister();
try { try {
CrashReportData data = persister.load(reportFile); CrashReportData data = persister.load(reportFile);
@@ -303,7 +291,7 @@ public class DevReportActivity extends BaseCrashReportDialog
protected void onPostExecute(Boolean success) { protected void onPostExecute(Boolean success) {
final SharedPreferences prefs = final SharedPreferences prefs =
sharedPreferencesFactory.create(); sharedPreferencesFactory.create();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= 11) {
final SharedPreferences.Editor prefEditor = final SharedPreferences.Editor prefEditor =
prefs.edit(); prefs.edit();
Set<String> fields = new HashSet<>(); Set<String> fields = new HashSet<>();

View File

@@ -6,7 +6,6 @@ import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
@@ -33,6 +32,11 @@ import java.util.logging.Logger;
import javax.inject.Inject; import javax.inject.Inject;
import static android.support.v4.view.GravityCompat.START;
import static android.support.v4.widget.DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
import static android.support.v4.widget.DrawerLayout.LOCK_MODE_UNLOCKED;
import static android.view.View.INVISIBLE;
public class NavDrawerActivity extends BriarFragmentActivity implements public class NavDrawerActivity extends BriarFragmentActivity implements
BaseFragment.BaseFragmentListener, TransportStateListener { BaseFragment.BaseFragmentListener, TransportStateListener {
@@ -51,7 +55,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
private Toolbar toolbar; private Toolbar toolbar;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private GridView transportsView;
private TextView progressTitle; private TextView progressTitle;
private ViewGroup progressViewGroup; private ViewGroup progressViewGroup;
@@ -88,7 +91,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
transportsView = (GridView) findViewById(R.id.transportsView); GridView transportsView = (GridView) findViewById(R.id.transportsView);
progressTitle = (TextView) findViewById(R.id.title_progress_bar); progressTitle = (TextView) findViewById(R.id.title_progress_bar);
progressViewGroup = (ViewGroup) findViewById(R.id.container_progress); progressViewGroup = (ViewGroup) findViewById(R.id.container_progress);
@@ -98,19 +101,10 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
R.string.nav_drawer_open_description, R.string.nav_drawer_open_description,
R.string.nav_drawer_close_description R.string.nav_drawer_close_description);
) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
};
drawerLayout.setDrawerListener(drawerToggle); drawerLayout.setDrawerListener(drawerToggle);
if (state == null) startFragment(activityComponent.newContactListFragment()); if (state == null)
startFragment(activityComponent.newContactListFragment());
checkAuthorHandle(getIntent()); checkAuthorHandle(getIntent());
initializeTransports(getLayoutInflater()); initializeTransports(getLayoutInflater());
@@ -156,18 +150,17 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
return false; return false;
} }
private void storeLocalAuthor(final LocalAuthor a) { private void storeLocalAuthor(LocalAuthor a) {
controller.storeLocalAuthor(a, controller.storeLocalAuthor(a, new UiResultHandler<Void>(this) {
new UiResultHandler<Void>(this) { @Override
@Override public void onResultUi(Void result) {
public void onResultUi(Void result) { hideLoadingScreen();
hideLoadingScreen(); }
} });
});
} }
public void onNavigationClick(View view) { public void onNavigationClick(View view) {
drawerLayout.closeDrawer(GravityCompat.START); drawerLayout.closeDrawer(START);
clearBackStack(); clearBackStack();
switch (view.getId()) { switch (view.getId()) {
case R.id.nav_btn_contacts: case R.id.nav_btn_contacts:
@@ -189,8 +182,8 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0 if (getSupportFragmentManager().getBackStackEntryCount() == 0
&& drawerLayout.isDrawerOpen(GravityCompat.START)) { && drawerLayout.isDrawerOpen(START)) {
drawerLayout.closeDrawer(GravityCompat.START); drawerLayout.closeDrawer(START);
return; return;
} }
super.onBackPressed(); super.onBackPressed();
@@ -218,8 +211,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
public void showLoadingScreen(boolean isBlocking, int stringId) { public void showLoadingScreen(boolean isBlocking, int stringId) {
if (isBlocking) { if (isBlocking) {
// Disable navigation drawer slide to open // Disable navigation drawer slide to open
drawerLayout drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED);
.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
CustomAnimations.animateHeight(toolbar, false, 250); CustomAnimations.animateHeight(toolbar, false, 250);
} }
progressTitle.setText(stringId); progressTitle.setText(stringId);
@@ -228,14 +220,13 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
@Override @Override
public void hideLoadingScreen() { public void hideLoadingScreen() {
drawerLayout drawerLayout.setDrawerLockMode(LOCK_MODE_UNLOCKED);
.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
CustomAnimations.animateHeight(toolbar, true, 250); CustomAnimations.animateHeight(toolbar, true, 250);
progressViewGroup.setVisibility(View.INVISIBLE); progressViewGroup.setVisibility(INVISIBLE);
} }
private void initializeTransports(final LayoutInflater inflater) { private void initializeTransports(final LayoutInflater inflater) {
transports = new ArrayList<Transport>(3); transports = new ArrayList<>(3);
Transport tor = new Transport(); Transport tor = new Transport();
tor.id = new TransportId("tor"); tor.id = new TransportId("tor");
@@ -277,8 +268,8 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
@Override @Override
public View getView(int position, View convertView, public View getView(int position, View convertView,
ViewGroup parent) { ViewGroup parent) {
ViewGroup view = (ViewGroup) inflater ViewGroup view = (ViewGroup) inflater.inflate(
.inflate(R.layout.list_item_transport, parent, false); R.layout.list_item_transport, parent, false);
Transport t = getItem(position); Transport t = getItem(position);
Resources r = getResources(); Resources r = getResources();
@@ -304,6 +295,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
private void setTransport(final TransportId id, final boolean enabled) { private void setTransport(final TransportId id, final boolean enabled) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
if (transports == null || transportsAdapter == null) return; if (transports == null || transportsAdapter == null) return;
for (Transport t : transports) { for (Transport t : transports) {
@@ -331,9 +323,10 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
} }
private static class Transport { private static class Transport {
TransportId id;
boolean enabled; private TransportId id;
int iconId; private boolean enabled;
int textId; private int iconId;
private int textId;
} }
} }

View File

@@ -30,20 +30,20 @@ import static android.view.View.VISIBLE;
public class PasswordActivity extends BaseActivity { public class PasswordActivity extends BaseActivity {
@Inject
protected PasswordController passwordController;
private Button signInButton; private Button signInButton;
private ProgressBar progress; private ProgressBar progress;
private TextInputLayout input; private TextInputLayout input;
private EditText password; private EditText password;
@Inject
PasswordController passwordController;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
super.onCreate(state); super.onCreate(state);
if (!passwordController.initialized()) { if (!passwordController.accountExists()) {
clearSharedPrefsAndDeleteEverything(); deleteAccount();
return; return;
} }
@@ -61,6 +61,7 @@ public class PasswordActivity extends BaseActivity {
} }
}); });
password.addTextChangedListener(new TextWatcher() { password.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, public void beforeTextChanged(CharSequence s, int start, int count,
int after) { int after) {
@@ -91,9 +92,8 @@ public class PasswordActivity extends BaseActivity {
startActivity(intent); startActivity(intent);
} }
private void clearSharedPrefsAndDeleteEverything() { private void deleteAccount() {
passwordController.clearPrefs(); passwordController.deleteAccount(this);
AndroidUtils.deleteAppData(this);
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
startActivity(new Intent(this, SetupActivity.class)); startActivity(new Intent(this, SetupActivity.class));
finish(); finish();
@@ -114,7 +114,7 @@ public class PasswordActivity extends BaseActivity {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
clearSharedPrefsAndDeleteEverything(); deleteAccount();
} }
}); });
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();
@@ -140,8 +140,7 @@ public class PasswordActivity extends BaseActivity {
} }
private void tryAgain() { private void tryAgain() {
AndroidUtils.setError(input, getString(R.string.try_again), AndroidUtils.setError(input, getString(R.string.try_again), true);
true);
signInButton.setVisibility(VISIBLE); signInButton.setVisibility(VISIBLE);
progress.setVisibility(INVISIBLE); progress.setVisibility(INVISIBLE);
password.setText(""); password.setText("");
@@ -149,5 +148,4 @@ public class PasswordActivity extends BaseActivity {
// show the keyboard again // show the keyboard again
showSoftKeyboard(password); showSoftKeyboard(password);
} }
} }

View File

@@ -27,8 +27,6 @@ import javax.inject.Inject;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.view.View.INVISIBLE; import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK; import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH; import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
@@ -38,15 +36,15 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
@Inject @Inject
protected SetupController setupController; protected SetupController setupController;
TextInputLayout nicknameEntryWrapper; private TextInputLayout nicknameEntryWrapper;
TextInputLayout passwordEntryWrapper; private TextInputLayout passwordEntryWrapper;
TextInputLayout passwordConfirmationWrapper; private TextInputLayout passwordConfirmationWrapper;
EditText nicknameEntry; private EditText nicknameEntry;
EditText passwordEntry; private EditText passwordEntry;
EditText passwordConfirmation; private EditText passwordConfirmation;
StrengthMeter strengthMeter; private StrengthMeter strengthMeter;
Button createAccountButton; private Button createAccountButton;
ProgressBar progress; private ProgressBar progress;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
@@ -66,9 +64,8 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
createAccountButton = (Button) findViewById(R.id.create_account); createAccountButton = (Button) findViewById(R.id.create_account);
progress = (ProgressBar) findViewById(R.id.progress_wheel); progress = (ProgressBar) findViewById(R.id.progress_wheel);
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
TextWatcher tw = new TextWatcher() { TextWatcher tw = new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, public void beforeTextChanged(CharSequence s, int start, int count,
int after) { int after) {
@@ -107,7 +104,8 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
String firstPassword = passwordEntry.getText().toString(); String firstPassword = passwordEntry.getText().toString();
String secondPassword = passwordConfirmation.getText().toString(); String secondPassword = passwordConfirmation.getText().toString();
boolean passwordsMatch = firstPassword.equals(secondPassword); boolean passwordsMatch = firstPassword.equals(secondPassword);
float strength = setupController.estimatePasswordStrength(firstPassword); float strength =
setupController.estimatePasswordStrength(firstPassword);
strengthMeter.setStrength(strength); strengthMeter.setStrength(strength);
AndroidUtils.setError(nicknameEntryWrapper, AndroidUtils.setError(nicknameEntryWrapper,
getString(R.string.name_too_long), getString(R.string.name_too_long),
@@ -123,18 +121,19 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
&& passwordsMatch && strength >= WEAK); && passwordsMatch && strength >= WEAK);
} }
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
hideSoftKeyboard(v); hideSoftKeyboard(v);
return true; return true;
} }
@Override
public void onClick(View view) { public void onClick(View view) {
// Replace the button with a progress bar // Replace the button with a progress bar
createAccountButton.setVisibility(INVISIBLE); createAccountButton.setVisibility(INVISIBLE);
progress.setVisibility(VISIBLE); progress.setVisibility(VISIBLE);
final String nickname = nicknameEntry.getText().toString(); String nickname = nicknameEntry.getText().toString();
final String password = passwordEntry.getText().toString(); String password = passwordEntry.getText().toString();
setupController.createIdentity(nickname, password, setupController.createIdentity(nickname, password,
new UiResultHandler<Long>(this) { new UiResultHandler<Long>(this) {
@Override @Override
@@ -145,8 +144,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
} }
private void showMain(final long handle) { private void showMain(final long handle) {
Intent i = new Intent(SetupActivity.this, Intent i = new Intent(this, NavDrawerActivity.class);
NavDrawerActivity.class);
i.putExtra(BriarActivity.KEY_LOCAL_AUTHOR_HANDLE, handle); i.putExtra(BriarActivity.KEY_LOCAL_AUTHOR_HANDLE, handle);
i.setFlags(FLAG_ACTIVITY_NEW_TASK); i.setFlags(FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);

View File

@@ -11,7 +11,6 @@ import android.support.v7.preference.PreferenceManager;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.api.AndroidExecutor; import org.briarproject.android.api.AndroidExecutor;
import org.briarproject.android.controller.ConfigController; import org.briarproject.android.controller.ConfigController;
import org.briarproject.android.util.AndroidUtils;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -29,7 +28,7 @@ public class SplashScreenActivity extends BaseActivity {
private static final long EXPIRY_DATE = 1464735600 * 1000L; private static final long EXPIRY_DATE = 1464735600 * 1000L;
@Inject @Inject
ConfigController configController; protected ConfigController configController;
@Inject @Inject
protected AndroidExecutor androidExecutor; protected AndroidExecutor androidExecutor;
@@ -65,12 +64,10 @@ public class SplashScreenActivity extends BaseActivity {
LOG.info("Expired"); LOG.info("Expired");
startActivity(new Intent(this, ExpiredActivity.class)); startActivity(new Intent(this, ExpiredActivity.class));
} else { } else {
if (configController.initialized()) { if (configController.accountExists()) {
startActivity(new Intent(this, NavDrawerActivity.class)); startActivity(new Intent(this, NavDrawerActivity.class));
} else { } else {
configController.clearPrefs(); configController.deleteAccount(this);
// TODO replace this static call with a controller method
AndroidUtils.deleteAppData(this);
startActivity(new Intent(this, SetupActivity.class)); startActivity(new Intent(this, SetupActivity.class));
} }
} }
@@ -91,6 +88,7 @@ public class SplashScreenActivity extends BaseActivity {
private void setPreferencesDefaults() { private void setPreferencesDefaults() {
androidExecutor.execute(new Runnable() { androidExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
PreferenceManager.setDefaultValues(SplashScreenActivity.this, PreferenceManager.setDefaultValues(SplashScreenActivity.this,
R.xml.panic_preferences, false); R.xml.panic_preferences, false);

View File

@@ -25,15 +25,15 @@ public abstract class BaseContactListAdapter<VH extends BaseContactListAdapter.B
protected final OnItemClickListener listener; protected final OnItemClickListener listener;
protected Context ctx; protected Context ctx;
public BaseContactListAdapter(Context context, OnItemClickListener listener) { public BaseContactListAdapter(Context ctx, OnItemClickListener listener) {
this.ctx = context; this.ctx = ctx;
this.listener = listener; this.listener = listener;
this.contacts = new SortedList<>(ContactListItem.class, this.contacts = new SortedList<>(ContactListItem.class,
new SortedListCallBacks()); new SortedListCallBacks());
} }
@Override @Override
public void onBindViewHolder(final VH ui, final int position) { public void onBindViewHolder(final VH ui, int position) {
final ContactListItem item = getItem(position); final ContactListItem item = getItem(position);
Author author = item.getContact().getAuthor(); Author author = item.getContact().getAuthor();
@@ -96,6 +96,7 @@ public abstract class BaseContactListAdapter<VH extends BaseContactListAdapter.B
} }
public static class BaseContactHolder extends RecyclerView.ViewHolder { public static class BaseContactHolder extends RecyclerView.ViewHolder {
public final ViewGroup layout; public final ViewGroup layout;
public final ImageView avatar; public final ImageView avatar;
public final TextView name; public final TextView name;
@@ -132,7 +133,8 @@ public abstract class BaseContactListAdapter<VH extends BaseContactListAdapter.B
return 0; return 0;
} }
protected class SortedListCallBacks extends SortedList.Callback<ContactListItem> { protected class SortedListCallBacks
extends SortedList.Callback<ContactListItem> {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
@@ -185,5 +187,4 @@ public abstract class BaseContactListAdapter<VH extends BaseContactListAdapter.B
public interface OnItemClickListener { public interface OnItemClickListener {
void onItemClick(View view, ContactListItem item); void onItemClick(View view, ContactListItem item);
} }
} }

View File

@@ -20,17 +20,17 @@ public class ContactListAdapter
@Override @Override
public ContactHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public ContactHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()) View v = LayoutInflater.from(viewGroup.getContext()).inflate(
.inflate(R.layout.list_item_contact, viewGroup, false); R.layout.list_item_contact, viewGroup, false);
return new ContactHolder(v); return new ContactHolder(v);
} }
@Override @Override
public void onBindViewHolder(final ContactHolder ui, final int position) { public void onBindViewHolder(ContactHolder ui, int position) {
super.onBindViewHolder(ui, position); super.onBindViewHolder(ui, position);
final ContactListItem item = getItem(position); ContactListItem item = getItem(position);
// name and unread count // name and unread count
String contactName = item.getContact().getAuthor().getName(); String contactName = item.getContact().getAuthor().getName();
@@ -84,5 +84,4 @@ public class ContactListAdapter
public int compareContactListItems(ContactListItem c1, ContactListItem c2) { public int compareContactListItems(ContactListItem c1, ContactListItem c2) {
return compareByTime(c1, c2); return compareByTime(c1, c2);
} }
} }

View File

@@ -54,18 +54,16 @@ import static org.briarproject.android.BriarActivity.GROUP_ID;
public class ContactListFragment extends BaseFragment implements EventListener { public class ContactListFragment extends BaseFragment implements EventListener {
public final static String TAG = "ContactListFragment";
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(ContactListFragment.class.getName()); Logger.getLogger(ContactListFragment.class.getName());
public final static String TAG = "ContactListFragment";
@Override
public String getUniqueTag() {
return TAG;
}
@Inject @Inject
protected ConnectionRegistry connectionRegistry; protected ConnectionRegistry connectionRegistry;
@Inject
protected EventBus eventBus;
private ContactListAdapter adapter = null; private ContactListAdapter adapter = null;
private BriarRecyclerView list = null; private BriarRecyclerView list = null;
@@ -80,15 +78,17 @@ public class ContactListFragment extends BaseFragment implements EventListener {
protected volatile IntroductionManager introductionManager; protected volatile IntroductionManager introductionManager;
@Inject @Inject
protected volatile ForumSharingManager forumSharingManager; protected volatile ForumSharingManager forumSharingManager;
@Inject
protected volatile EventBus eventBus;
@Inject @Inject
public ContactListFragment() { public ContactListFragment() {
} }
@Override
public String getUniqueTag() {
return TAG;
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -160,11 +160,11 @@ public class ContactListFragment extends BaseFragment implements EventListener {
private void loadContacts() { private void loadContacts() {
listener.runOnDbThread(new Runnable() { listener.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
List<ContactListItem> contacts = List<ContactListItem> contacts = new ArrayList<>();
new ArrayList<ContactListItem>();
for (Contact c : contactManager.getActiveContacts()) { for (Contact c : contactManager.getActiveContacts()) {
try { try {
ContactId id = c.getId(); ContactId id = c.getId();
@@ -196,6 +196,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
private void displayContacts(final List<ContactListItem> contacts) { private void displayContacts(final List<ContactListItem> contacts) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
if (contacts.size() == 0) list.showData(); if (contacts.size() == 0) list.showData();
else adapter.addAll(contacts); else adapter.addAll(contacts);
@@ -203,9 +204,10 @@ public class ContactListFragment extends BaseFragment implements EventListener {
}); });
} }
@Override
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if (e instanceof ContactAddedEvent) { if (e instanceof ContactAddedEvent) {
if(((ContactAddedEvent) e).isActive()) { if (((ContactAddedEvent) e).isActive()) {
LOG.info("Contact added as active, reloading"); LOG.info("Contact added as active, reloading");
loadContacts(); loadContacts();
} }
@@ -233,6 +235,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
private void reloadConversation(final GroupId g) { private void reloadConversation(final GroupId g) {
listener.runOnDbThread(new Runnable() { listener.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
ContactId c = messagingManager.getContactId(g); ContactId c = messagingManager.getContactId(g);
@@ -252,6 +255,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
private void updateItem(final ContactId c, private void updateItem(final ContactId c,
final Collection<ConversationItem> messages) { final Collection<ConversationItem> messages) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
int position = adapter.findItemPosition(c); int position = adapter.findItemPosition(c);
ContactListItem item = adapter.getItem(position); ContactListItem item = adapter.getItem(position);
@@ -265,6 +269,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
private void removeItem(final ContactId c) { private void removeItem(final ContactId c) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
int position = adapter.findItemPosition(c); int position = adapter.findItemPosition(c);
ContactListItem item = adapter.getItem(position); ContactListItem item = adapter.getItem(position);
@@ -275,6 +280,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
private void setConnected(final ContactId c, final boolean connected) { private void setConnected(final ContactId c, final boolean connected) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
int position = adapter.findItemPosition(c); int position = adapter.findItemPosition(c);
ContactListItem item = adapter.getItem(position); ContactListItem item = adapter.getItem(position);
@@ -286,14 +292,13 @@ public class ContactListFragment extends BaseFragment implements EventListener {
}); });
} }
/** This needs to be called from the DbThread */ // This needs to be called from the DB thread
private Collection<ConversationItem> getMessages(ContactId id) private Collection<ConversationItem> getMessages(ContactId id)
throws DbException { throws DbException {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
Collection<ConversationItem> messages = Collection<ConversationItem> messages = new ArrayList<>();
new ArrayList<ConversationItem>();
Collection<PrivateMessageHeader> headers = Collection<PrivateMessageHeader> headers =
messagingManager.getMessageHeaders(id); messagingManager.getMessageHeaders(id);

View File

@@ -24,12 +24,12 @@ import android.widget.Toast;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
import org.briarproject.android.api.AndroidNotificationManager; import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.introduction.IntroductionActivity; import org.briarproject.android.introduction.IntroductionActivity;
import org.briarproject.android.util.BriarRecyclerView; import org.briarproject.android.util.BriarRecyclerView;
import org.briarproject.api.FormatException; import org.briarproject.api.FormatException;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactId;
import org.briarproject.api.contact.ContactManager; import org.briarproject.api.contact.ContactManager;
@@ -55,7 +55,6 @@ import org.briarproject.api.introduction.IntroductionManager;
import org.briarproject.api.introduction.IntroductionMessage; import org.briarproject.api.introduction.IntroductionMessage;
import org.briarproject.api.introduction.IntroductionRequest; import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.introduction.IntroductionResponse; import org.briarproject.api.introduction.IntroductionResponse;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.messaging.MessagingManager; import org.briarproject.api.messaging.MessagingManager;
import org.briarproject.api.messaging.PrivateMessage; import org.briarproject.api.messaging.PrivateMessage;
import org.briarproject.api.messaging.PrivateMessageFactory; import org.briarproject.api.messaging.PrivateMessageFactory;
@@ -95,25 +94,37 @@ public class ConversationActivity extends BriarActivity
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(ConversationActivity.class.getName()); Logger.getLogger(ConversationActivity.class.getName());
@Inject protected AndroidNotificationManager notificationManager; @Inject
@Inject protected ConnectionRegistry connectionRegistry; protected AndroidNotificationManager notificationManager;
@Inject @CryptoExecutor protected Executor cryptoExecutor; @Inject
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>(); protected ConnectionRegistry connectionRegistry;
private ConversationAdapter adapter = null; @Inject
@CryptoExecutor
protected Executor cryptoExecutor;
private Map<MessageId, byte[]> bodyCache = new HashMap<>();
private ConversationAdapter adapter;
private CircleImageView toolbarAvatar; private CircleImageView toolbarAvatar;
private ImageView toolbarStatus; private ImageView toolbarStatus;
private TextView toolbarTitle; private TextView toolbarTitle;
private BriarRecyclerView list = null; private BriarRecyclerView list;
private EditText content = null; private EditText content;
private ImageButton sendButton = null; private ImageButton sendButton;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject protected volatile ContactManager contactManager; @Inject
@Inject protected volatile MessagingManager messagingManager; protected volatile ContactManager contactManager;
@Inject protected volatile EventBus eventBus; @Inject
@Inject protected volatile PrivateMessageFactory privateMessageFactory; protected volatile MessagingManager messagingManager;
@Inject protected volatile IntroductionManager introductionManager; @Inject
@Inject protected volatile ForumSharingManager forumSharingManager; protected volatile EventBus eventBus;
@Inject
protected volatile PrivateMessageFactory privateMessageFactory;
@Inject
protected volatile IntroductionManager introductionManager;
@Inject
protected volatile ForumSharingManager forumSharingManager;
private volatile GroupId groupId = null; private volatile GroupId groupId = null;
private volatile ContactId contactId = null; private volatile ContactId contactId = null;
private volatile String contactName = null; private volatile String contactName = null;
@@ -218,6 +229,7 @@ public class ConversationActivity extends BriarActivity
private void loadData() { private void loadData() {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -248,6 +260,7 @@ public class ConversationActivity extends BriarActivity
private void displayContactDetails() { private void displayContactDetails() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
toolbarAvatar.setImageDrawable( toolbarAvatar.setImageDrawable(
new IdenticonDrawable(contactIdenticonKey)); new IdenticonDrawable(contactIdenticonKey));
@@ -273,6 +286,7 @@ public class ConversationActivity extends BriarActivity
private void loadMessages() { private void loadMessages() {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -304,6 +318,7 @@ public class ConversationActivity extends BriarActivity
final Collection<IntroductionMessage> introductions, final Collection<IntroductionMessage> introductions,
final Collection<ForumInvitationMessage> invitations) { final Collection<ForumInvitationMessage> invitations) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
sendButton.setEnabled(true); sendButton.setEnabled(true);
if (headers.isEmpty() && introductions.isEmpty() && if (headers.isEmpty() && introductions.isEmpty() &&
@@ -312,8 +327,7 @@ public class ConversationActivity extends BriarActivity
// so let the list know to hide progress bar // so let the list know to hide progress bar
list.showData(); list.showData();
} else { } else {
List<ConversationItem> items = List<ConversationItem> items = new ArrayList<>();
new ArrayList<ConversationItem>();
for (PrivateMessageHeader h : headers) { for (PrivateMessageHeader h : headers) {
ConversationMessageItem item = ConversationMessageItem item =
(ConversationMessageItem) ConversationItem (ConversationMessageItem) ConversationItem
@@ -350,6 +364,7 @@ public class ConversationActivity extends BriarActivity
private void loadMessageBody(final PrivateMessageHeader h) { private void loadMessageBody(final PrivateMessageHeader h) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -370,6 +385,7 @@ public class ConversationActivity extends BriarActivity
private void displayMessageBody(final MessageId m, final byte[] body) { private void displayMessageBody(final MessageId m, final byte[] body) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
bodyCache.put(m, body); bodyCache.put(m, body);
SparseArray<ConversationMessageItem> messages = SparseArray<ConversationMessageItem> messages =
@@ -399,9 +415,8 @@ public class ConversationActivity extends BriarActivity
} }
private void markMessagesRead() { private void markMessagesRead() {
List<MessageId> unread = new ArrayList<MessageId>(); List<MessageId> unread = new ArrayList<>();
SparseArray<IncomingItem> list = SparseArray<IncomingItem> list = adapter.getIncomingMessages();
adapter.getIncomingMessages();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
IncomingItem item = list.valueAt(i); IncomingItem item = list.valueAt(i);
if (!item.isRead()) unread.add(item.getId()); if (!item.isRead()) unread.add(item.getId());
@@ -414,6 +429,7 @@ public class ConversationActivity extends BriarActivity
private void markMessagesRead(final Collection<MessageId> unread) { private void markMessagesRead(final Collection<MessageId> unread) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -432,6 +448,7 @@ public class ConversationActivity extends BriarActivity
}); });
} }
@Override
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if (e instanceof ContactRemovedEvent) { if (e instanceof ContactRemovedEvent) {
ContactRemovedEvent c = (ContactRemovedEvent) e; ContactRemovedEvent c = (ContactRemovedEvent) e;
@@ -501,6 +518,7 @@ public class ConversationActivity extends BriarActivity
private void markMessageReadIfNew(final Message m) { private void markMessageReadIfNew(final Message m) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
ConversationItem item = adapter.getLastItem(); ConversationItem item = adapter.getLastItem();
if (item != null) { if (item != null) {
@@ -519,6 +537,7 @@ public class ConversationActivity extends BriarActivity
private void markNewMessageRead(final Message m) { private void markNewMessageRead(final Message m) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
messagingManager.setReadFlag(m.getId(), true); messagingManager.setReadFlag(m.getId(), true);
@@ -534,10 +553,10 @@ public class ConversationActivity extends BriarActivity
private void markMessages(final Collection<MessageId> messageIds, private void markMessages(final Collection<MessageId> messageIds,
final boolean sent, final boolean seen) { final boolean sent, final boolean seen) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
Set<MessageId> messages = new HashSet<MessageId>(messageIds); Set<MessageId> messages = new HashSet<>(messageIds);
SparseArray<OutgoingItem> list = SparseArray<OutgoingItem> list = adapter.getOutgoingMessages();
adapter.getOutgoingMessages();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
OutgoingItem item = list.valueAt(i); OutgoingItem item = list.valueAt(i);
if (messages.contains(item.getId())) { if (messages.contains(item.getId())) {
@@ -550,6 +569,7 @@ public class ConversationActivity extends BriarActivity
}); });
} }
@Override
public void onClick(View view) { public void onClick(View view) {
markMessagesRead(); markMessagesRead();
String message = content.getText().toString(); String message = content.getText().toString();
@@ -569,6 +589,7 @@ public class ConversationActivity extends BriarActivity
private void createMessage(final byte[] body, final long timestamp) { private void createMessage(final byte[] body, final long timestamp) {
cryptoExecutor.execute(new Runnable() { cryptoExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
try { try {
storeMessage(privateMessageFactory.createPrivateMessage( storeMessage(privateMessageFactory.createPrivateMessage(
@@ -582,6 +603,7 @@ public class ConversationActivity extends BriarActivity
private void storeMessage(final PrivateMessage m) { private void storeMessage(final PrivateMessage m) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -617,6 +639,7 @@ public class ConversationActivity extends BriarActivity
private void removeContact() { private void removeContact() {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
// make sure contactId is initialised // make sure contactId is initialised
@@ -648,6 +671,7 @@ public class ConversationActivity extends BriarActivity
private void hideIntroductionActionWhenOneContact(final MenuItem item) { private void hideIntroductionActionWhenOneContact(final MenuItem item) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
if (contactManager.getActiveContacts().size() < 2) { if (contactManager.getActiveContacts().size() < 2) {
@@ -689,11 +713,7 @@ public class ConversationActivity extends BriarActivity
timestamp); timestamp);
} }
loadMessages(); loadMessages();
} catch (DbException e) { } catch (DbException | FormatException e) {
introductionResponseError();
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
} catch (FormatException e) {
introductionResponseError(); introductionResponseError();
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e); LOG.log(WARNING, e.toString(), e);

View File

@@ -41,6 +41,7 @@ class ConversationAdapter extends RecyclerView.Adapter {
private final SortedList<ConversationItem> items = private final SortedList<ConversationItem> items =
new SortedList<>(ConversationItem.class, new ListCallbacks()); new SortedList<>(ConversationItem.class, new ListCallbacks());
private Context ctx; private Context ctx;
private IntroductionHandler intro; private IntroductionHandler intro;
private String contactName; private String contactName;
@@ -67,44 +68,38 @@ class ConversationAdapter extends RecyclerView.Adapter {
// outgoing message (local) // outgoing message (local)
if (type == MSG_OUT) { if (type == MSG_OUT) {
v = LayoutInflater.from(viewGroup.getContext()) v = LayoutInflater.from(viewGroup.getContext()).inflate(
.inflate(R.layout.list_item_msg_out, viewGroup, false); R.layout.list_item_msg_out, viewGroup, false);
return new MessageHolder(v, type); return new MessageHolder(v, type);
} } else if (type == INTRODUCTION_IN) {
else if (type == INTRODUCTION_IN) { v = LayoutInflater.from(viewGroup.getContext()).inflate(
v = LayoutInflater.from(viewGroup.getContext()) R.layout.list_item_introduction_in, viewGroup, false);
.inflate(R.layout.list_item_introduction_in, viewGroup, false);
return new IntroductionHolder(v, type); return new IntroductionHolder(v, type);
} } else if (type == INTRODUCTION_OUT) {
else if (type == INTRODUCTION_OUT) { v = LayoutInflater.from(viewGroup.getContext()).inflate(
v = LayoutInflater.from(viewGroup.getContext()) R.layout.list_item_introduction_out, viewGroup, false);
.inflate(R.layout.list_item_introduction_out, viewGroup, false);
return new IntroductionHolder(v, type); return new IntroductionHolder(v, type);
} } else if (type == NOTICE_IN) {
else if (type == NOTICE_IN) { v = LayoutInflater.from(viewGroup.getContext()).inflate(
v = LayoutInflater.from(viewGroup.getContext()) R.layout.list_item_notice_in, viewGroup, false);
.inflate(R.layout.list_item_notice_in, viewGroup, false);
return new NoticeHolder(v, type); return new NoticeHolder(v, type);
} } else if (type == NOTICE_OUT) {
else if (type == NOTICE_OUT) { v = LayoutInflater.from(viewGroup.getContext()).inflate(
v = LayoutInflater.from(viewGroup.getContext()) R.layout.list_item_notice_out, viewGroup, false);
.inflate(R.layout.list_item_notice_out, viewGroup, false);
return new NoticeHolder(v, type); return new NoticeHolder(v, type);
} } else if (type == FORUM_INVITATION_IN) {
else if (type == FORUM_INVITATION_IN) { v = LayoutInflater.from(viewGroup.getContext()).inflate(
v = LayoutInflater.from(viewGroup.getContext()) R.layout.list_item_forum_invitation_in, viewGroup, false);
.inflate(R.layout.list_item_forum_invitation_in, viewGroup, false);
return new InvitationHolder(v, type); return new InvitationHolder(v, type);
} } else if (type == FORUM_INVITATION_OUT) {
else if (type == FORUM_INVITATION_OUT) { v = LayoutInflater.from(viewGroup.getContext()).inflate(
v = LayoutInflater.from(viewGroup.getContext()) R.layout.list_item_forum_invitation_out, viewGroup, false);
.inflate(R.layout.list_item_forum_invitation_out, viewGroup, false);
return new InvitationHolder(v, type); return new InvitationHolder(v, type);
} }
// incoming message (non-local) // incoming message (non-local)
else { else {
v = LayoutInflater.from(viewGroup.getContext()) v = LayoutInflater.from(viewGroup.getContext()).inflate(
.inflate(R.layout.list_item_msg_in, viewGroup, false); R.layout.list_item_msg_in, viewGroup, false);
return new MessageHolder(v, type); return new MessageHolder(v, type);
} }
} }
@@ -126,10 +121,10 @@ class ConversationAdapter extends RecyclerView.Adapter {
bindNotice((NoticeHolder) ui, (ConversationNoticeInItem) item); bindNotice((NoticeHolder) ui, (ConversationNoticeInItem) item);
} else if (item instanceof ConversationForumInvitationOutItem) { } else if (item instanceof ConversationForumInvitationOutItem) {
bindInvitation((InvitationHolder) ui, bindInvitation((InvitationHolder) ui,
(ConversationForumInvitationOutItem) item, position); (ConversationForumInvitationOutItem) item);
} else if (item instanceof ConversationForumInvitationInItem) { } else if (item instanceof ConversationForumInvitationInItem) {
bindInvitation((InvitationHolder) ui, bindInvitation((InvitationHolder) ui,
(ConversationForumInvitationInItem) item, position); (ConversationForumInvitationInItem) item);
} else { } else {
throw new IllegalArgumentException("Unhandled Conversation Item"); throw new IllegalArgumentException("Unhandled Conversation Item");
} }
@@ -200,13 +195,16 @@ class ConversationAdapter extends RecyclerView.Adapter {
(ConversationIntroductionOutItem) item; (ConversationIntroductionOutItem) item;
if (i.isSeen()) { if (i.isSeen()) {
ui.status.setImageResource(R.drawable.message_delivered); ui.status.setImageResource(R.drawable.message_delivered);
ui.message.status.setImageResource(R.drawable.message_delivered_white); ui.message.status.setImageResource(
R.drawable.message_delivered_white);
} else if (i.isSent()) { } else if (i.isSent()) {
ui.status.setImageResource(R.drawable.message_sent); ui.status.setImageResource(R.drawable.message_sent);
ui.message.status.setImageResource(R.drawable.message_sent_white); ui.message.status.setImageResource(
R.drawable.message_sent_white);
} else { } else {
ui.status.setImageResource(R.drawable.message_stored); ui.status.setImageResource(R.drawable.message_stored);
ui.message.status.setImageResource(R.drawable.message_stored_white); ui.message.status.setImageResource(
R.drawable.message_stored_white);
} }
} }
// Incoming Introduction Request (Answered) // Incoming Introduction Request (Answered)
@@ -279,7 +277,7 @@ class ConversationAdapter extends RecyclerView.Adapter {
} }
private void bindInvitation(InvitationHolder ui, private void bindInvitation(InvitationHolder ui,
final ConversationForumInvitationItem item, final int position) { final ConversationForumInvitationItem item) {
ForumInvitationMessage fim = item.getForumInvitationMessage(); ForumInvitationMessage fim = item.getForumInvitationMessage();
@@ -301,13 +299,16 @@ class ConversationAdapter extends RecyclerView.Adapter {
(ConversationForumInvitationOutItem) item; (ConversationForumInvitationOutItem) item;
if (i.isSeen()) { if (i.isSeen()) {
ui.status.setImageResource(R.drawable.message_delivered); ui.status.setImageResource(R.drawable.message_delivered);
ui.message.status.setImageResource(R.drawable.message_delivered_white); ui.message.status.setImageResource(
R.drawable.message_delivered_white);
} else if (i.isSent()) { } else if (i.isSent()) {
ui.status.setImageResource(R.drawable.message_sent); ui.status.setImageResource(R.drawable.message_sent);
ui.message.status.setImageResource(R.drawable.message_sent_white); ui.message.status.setImageResource(
R.drawable.message_sent_white);
} else { } else {
ui.status.setImageResource(R.drawable.message_stored); ui.status.setImageResource(R.drawable.message_stored);
ui.message.status.setImageResource(R.drawable.message_stored_white); ui.message.status.setImageResource(
R.drawable.message_stored_white);
} }
} }
// Incoming Invitation // Incoming Invitation
@@ -321,9 +322,8 @@ class ConversationAdapter extends RecyclerView.Adapter {
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = Intent intent = new Intent(ctx,
new Intent(ctx, AvailableForumsActivity.class);
AvailableForumsActivity.class);
ctx.startActivity(intent); ctx.startActivity(intent);
} }
}); });
@@ -380,7 +380,7 @@ class ConversationAdapter extends RecyclerView.Adapter {
} }
public SparseArray<ConversationMessageItem> getPrivateMessages() { public SparseArray<ConversationMessageItem> getPrivateMessages() {
SparseArray<ConversationMessageItem> messages = new SparseArray<>(); SparseArray<ConversationMessageItem> messages = new SparseArray<>();
for (int i = 0; i < items.size(); i++) { for (int i = 0; i < items.size(); i++) {
ConversationItem item = items.get(i); ConversationItem item = items.get(i);
@@ -426,19 +426,17 @@ class ConversationAdapter extends RecyclerView.Adapter {
private static class IntroductionHolder extends RecyclerView.ViewHolder { private static class IntroductionHolder extends RecyclerView.ViewHolder {
final private ViewGroup layout; private final View messageLayout;
final private View messageLayout; private final MessageHolder message;
final private MessageHolder message; private final TextView text;
final private TextView text; private final Button acceptButton;
final private Button acceptButton; private final Button declineButton;
final private Button declineButton; private final TextView date;
final private TextView date; private final ImageView status;
final private ImageView status;
public IntroductionHolder(View v, int type) { public IntroductionHolder(View v, int type) {
super(v); super(v);
layout = (ViewGroup) v.findViewById(R.id.introductionLayout);
messageLayout = v.findViewById(R.id.messageLayout); messageLayout = v.findViewById(R.id.messageLayout);
message = new MessageHolder(messageLayout, message = new MessageHolder(messageLayout,
type == INTRODUCTION_IN ? MSG_IN : MSG_OUT); type == INTRODUCTION_IN ? MSG_IN : MSG_OUT);
@@ -457,15 +455,13 @@ class ConversationAdapter extends RecyclerView.Adapter {
private static class NoticeHolder extends RecyclerView.ViewHolder { private static class NoticeHolder extends RecyclerView.ViewHolder {
final private ViewGroup layout; private final TextView text;
final private TextView text; private final TextView date;
final private TextView date; private final ImageView status;
final private ImageView status;
public NoticeHolder(View v, int type) { public NoticeHolder(View v, int type) {
super(v); super(v);
layout = (ViewGroup) v.findViewById(R.id.noticeLayout);
text = (TextView) v.findViewById(R.id.noticeText); text = (TextView) v.findViewById(R.id.noticeText);
date = (TextView) v.findViewById(R.id.noticeTime); date = (TextView) v.findViewById(R.id.noticeTime);
@@ -479,18 +475,16 @@ class ConversationAdapter extends RecyclerView.Adapter {
private static class InvitationHolder extends RecyclerView.ViewHolder { private static class InvitationHolder extends RecyclerView.ViewHolder {
final private ViewGroup layout; private final View messageLayout;
final private View messageLayout; private final MessageHolder message;
final private MessageHolder message; private final TextView text;
final private TextView text; private final Button showForumsButton;
final private Button showForumsButton; private final TextView date;
final private TextView date; private final ImageView status;
final private ImageView status;
public InvitationHolder(View v, int type) { public InvitationHolder(View v, int type) {
super(v); super(v);
layout = (ViewGroup) v.findViewById(R.id.introductionLayout);
messageLayout = v.findViewById(R.id.messageLayout); messageLayout = v.findViewById(R.id.messageLayout);
message = new MessageHolder(messageLayout, message = new MessageHolder(messageLayout,
type == FORUM_INVITATION_IN ? MSG_IN : MSG_OUT); type == FORUM_INVITATION_IN ? MSG_IN : MSG_OUT);
@@ -507,6 +501,7 @@ class ConversationAdapter extends RecyclerView.Adapter {
} }
private class ListCallbacks extends SortedList.Callback<ConversationItem> { private class ListCallbacks extends SortedList.Callback<ConversationItem> {
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
notifyItemRangeInserted(position, count); notifyItemRangeInserted(position, count);
@@ -551,8 +546,6 @@ class ConversationAdapter extends RecyclerView.Adapter {
} }
public interface IntroductionHandler { public interface IntroductionHandler {
void respondToIntroduction(final SessionId sessionId, void respondToIntroduction(SessionId sessionId, boolean accept);
final boolean accept);
} }
} }

View File

@@ -29,5 +29,4 @@ public class ConversationForumInvitationInItem
public void setRead(boolean read) { public void setRead(boolean read) {
this.read = read; this.read = read;
} }
} }

View File

@@ -4,7 +4,7 @@ import org.briarproject.api.forum.ForumInvitationMessage;
abstract class ConversationForumInvitationItem extends ConversationItem { abstract class ConversationForumInvitationItem extends ConversationItem {
private ForumInvitationMessage fim; private final ForumInvitationMessage fim;
public ConversationForumInvitationItem(ForumInvitationMessage fim) { public ConversationForumInvitationItem(ForumInvitationMessage fim) {
super(fim.getId(), fim.getTimestamp()); super(fim.getId(), fim.getTimestamp());
@@ -15,5 +15,4 @@ abstract class ConversationForumInvitationItem extends ConversationItem {
public ForumInvitationMessage getForumInvitationMessage() { public ForumInvitationMessage getForumInvitationMessage() {
return fim; return fim;
} }
} }

View File

@@ -6,7 +6,7 @@ import org.briarproject.api.forum.ForumInvitationMessage;
* This class is needed and can not be replaced by an ConversationNoticeOutItem, * This class is needed and can not be replaced by an ConversationNoticeOutItem,
* because it carries the optional invitation message * because it carries the optional invitation message
* to be displayed as a regular private message. * to be displayed as a regular private message.
* * <p/>
* This class is not thread-safe * This class is not thread-safe
*/ */
public class ConversationForumInvitationOutItem public class ConversationForumInvitationOutItem
@@ -45,5 +45,4 @@ public class ConversationForumInvitationOutItem
public void setSeen(boolean seen) { public void setSeen(boolean seen) {
this.seen = seen; this.seen = seen;
} }
} }

View File

@@ -1,7 +1,6 @@
package org.briarproject.android.contact; package org.briarproject.android.contact;
import org.briarproject.api.introduction.IntroductionRequest; import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
public class ConversationIntroductionInItem extends ConversationIntroductionItem public class ConversationIntroductionInItem extends ConversationIntroductionItem
@@ -29,5 +28,4 @@ public class ConversationIntroductionInItem extends ConversationIntroductionItem
public void setRead(boolean read) { public void setRead(boolean read) {
this.read = read; this.read = read;
} }
} }

View File

@@ -2,9 +2,10 @@ package org.briarproject.android.contact;
import org.briarproject.api.introduction.IntroductionRequest; import org.briarproject.api.introduction.IntroductionRequest;
// This class is not thread-safe
abstract class ConversationIntroductionItem extends ConversationItem { abstract class ConversationIntroductionItem extends ConversationItem {
private IntroductionRequest ir; private final IntroductionRequest ir;
private boolean answered; private boolean answered;
public ConversationIntroductionItem(IntroductionRequest ir) { public ConversationIntroductionItem(IntroductionRequest ir) {
@@ -25,5 +26,4 @@ abstract class ConversationIntroductionItem extends ConversationItem {
public void setAnswered(boolean answered) { public void setAnswered(boolean answered) {
this.answered = answered; this.answered = answered;
} }
} }

View File

@@ -45,5 +45,4 @@ public class ConversationIntroductionOutItem
public void setSeen(boolean seen) { public void setSeen(boolean seen) {
this.seen = seen; this.seen = seen;
} }
} }

View File

@@ -103,8 +103,9 @@ public abstract class ConversationItem {
} }
} }
/** This method should not be used to get user-facing objects, /**
* Its purpose is to provider data for the contact list. * This method should not be used to get user-facing objects,
* Its purpose is to provider data for the contact list.
*/ */
public static ConversationItem from(IntroductionMessage im) { public static ConversationItem from(IntroductionMessage im) {
if (im.isLocal()) if (im.isLocal())
@@ -115,17 +116,24 @@ public abstract class ConversationItem {
} }
protected interface OutgoingItem { protected interface OutgoingItem {
MessageId getId(); MessageId getId();
boolean isSent(); boolean isSent();
void setSent(boolean sent); void setSent(boolean sent);
boolean isSeen(); boolean isSeen();
void setSeen(boolean seen); void setSeen(boolean seen);
} }
protected interface IncomingItem { protected interface IncomingItem {
MessageId getId(); MessageId getId();
boolean isRead(); boolean isRead();
void setRead(boolean read); void setRead(boolean read);
} }
} }

View File

@@ -28,5 +28,4 @@ public class ConversationMessageInItem extends ConversationMessageItem
public void setRead(boolean read) { public void setRead(boolean read) {
this.read = read; this.read = read;
} }
} }

View File

@@ -26,5 +26,4 @@ abstract class ConversationMessageItem extends ConversationItem {
void setBody(byte[] body) { void setBody(byte[] body) {
this.body = body; this.body = body;
} }
} }

View File

@@ -39,5 +39,4 @@ public class ConversationMessageOutItem extends ConversationMessageItem
public void setSeen(boolean seen) { public void setSeen(boolean seen) {
this.seen = seen; this.seen = seen;
} }
} }

View File

@@ -3,8 +3,8 @@ package org.briarproject.android.contact;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
public class ConversationNoticeInItem extends ConversationNoticeItem implements public class ConversationNoticeInItem extends ConversationNoticeItem
ConversationItem.IncomingItem { implements ConversationItem.IncomingItem {
private boolean read; private boolean read;
@@ -29,5 +29,4 @@ public class ConversationNoticeInItem extends ConversationNoticeItem implements
public void setRead(boolean read) { public void setRead(boolean read) {
this.read = read; this.read = read;
} }
} }

View File

@@ -4,7 +4,7 @@ import org.briarproject.api.sync.MessageId;
abstract class ConversationNoticeItem extends ConversationItem { abstract class ConversationNoticeItem extends ConversationItem {
private String text; private final String text;
public ConversationNoticeItem(MessageId id, String text, long time) { public ConversationNoticeItem(MessageId id, String text, long time) {
super(id, time); super(id, time);
@@ -15,5 +15,4 @@ abstract class ConversationNoticeItem extends ConversationItem {
public String getText() { public String getText() {
return text; return text;
} }
} }

View File

@@ -3,14 +3,13 @@ package org.briarproject.android.contact;
import org.briarproject.api.sync.MessageId; import org.briarproject.api.sync.MessageId;
// This class is not thread-safe // This class is not thread-safe
public class ConversationNoticeOutItem extends ConversationNoticeItem implements public class ConversationNoticeOutItem extends ConversationNoticeItem
ConversationItem.OutgoingItem { implements ConversationItem.OutgoingItem {
private boolean sent, seen; private boolean sent, seen;
public ConversationNoticeOutItem(MessageId id, String text, long time, public ConversationNoticeOutItem(MessageId id, String text, long time,
boolean sent, boolean seen) { boolean sent, boolean seen) {
super(id, text, time); super(id, text, time);
this.sent = sent; this.sent = sent;
@@ -41,5 +40,4 @@ public class ConversationNoticeOutItem extends ConversationNoticeItem implements
public void setSeen(boolean seen) { public void setSeen(boolean seen) {
this.seen = seen; this.seen = seen;
} }
} }

View File

@@ -1,9 +1,9 @@
package org.briarproject.android.controller; package org.briarproject.android.controller;
import org.briarproject.android.controller.handler.ResultHandler; import org.briarproject.android.controller.handler.ResultHandler;
public interface BriarController extends ActivityLifecycleController { public interface BriarController extends ActivityLifecycleController {
void runOnDbThread(final Runnable task); void runOnDbThread(final Runnable task);
void startAndBindService(); void startAndBindService();

View File

@@ -26,14 +26,15 @@ public class BriarControllerImpl implements BriarController {
protected BriarServiceConnection serviceConnection; protected BriarServiceConnection serviceConnection;
@Inject @Inject
protected DatabaseConfig databaseConfig; protected DatabaseConfig databaseConfig;
@Inject
protected Activity activity;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject @Inject
@DatabaseExecutor @DatabaseExecutor
protected volatile Executor dbExecutor; protected volatile Executor dbExecutor;
@Inject @Inject
protected volatile LifecycleManager lifecycleManager; protected volatile LifecycleManager lifecycleManager;
@Inject
protected Activity activity;
private boolean bound = false; private boolean bound = false;
@@ -64,6 +65,7 @@ public class BriarControllerImpl implements BriarController {
unbindService(); unbindService();
} }
@Override
public void startAndBindService() { public void startAndBindService() {
activity.startService(new Intent(activity, BriarService.class)); activity.startService(new Intent(activity, BriarService.class));
bound = activity.bindService(new Intent(activity, BriarService.class), bound = activity.bindService(new Intent(activity, BriarService.class),
@@ -83,7 +85,8 @@ public class BriarControllerImpl implements BriarController {
try { try {
// Wait for the service to finish starting up // Wait for the service to finish starting up
IBinder binder = serviceConnection.waitForBinder(); IBinder binder = serviceConnection.waitForBinder();
BriarService service = ((BriarService.BriarBinder) binder).getService(); BriarService service =
((BriarService.BriarBinder) binder).getService();
service.waitForStartup(); service.waitForStartup();
// Shut down the service and wait for it to shut down // Shut down the service and wait for it to shut down
LOG.info("Shutting down service"); LOG.info("Shutting down service");
@@ -101,8 +104,10 @@ public class BriarControllerImpl implements BriarController {
if (bound) activity.unbindService(serviceConnection); if (bound) activity.unbindService(serviceConnection);
} }
@Override
public void runOnDbThread(final Runnable task) { public void runOnDbThread(final Runnable task) {
dbExecutor.execute(new Runnable() { dbExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
try { try {
lifecycleManager.waitForDatabase(); lifecycleManager.waitForDatabase();
@@ -114,5 +119,4 @@ public class BriarControllerImpl implements BriarController {
} }
}); });
} }
} }

View File

@@ -1,9 +1,12 @@
package org.briarproject.android.controller; package org.briarproject.android.controller;
import android.content.Context;
public interface ConfigController { public interface ConfigController {
String getEncryptedDatabaseKey(); String getEncryptedDatabaseKey();
void clearPrefs(); void deleteAccount(Context ctx);
boolean initialized(); boolean accountExists();
} }

View File

@@ -1,14 +1,16 @@
package org.briarproject.android.controller; package org.briarproject.android.controller;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import org.briarproject.android.util.AndroidUtils;
import org.briarproject.api.db.DatabaseConfig; import org.briarproject.api.db.DatabaseConfig;
import javax.inject.Inject; import javax.inject.Inject;
public class ConfigControllerImpl implements ConfigController { public class ConfigControllerImpl implements ConfigController {
private final static String PREF_DB_KEY = "key"; private static final String PREF_DB_KEY = "key";
@Inject @Inject
protected SharedPreferences briarPrefs; protected SharedPreferences briarPrefs;
@@ -20,22 +22,22 @@ public class ConfigControllerImpl implements ConfigController {
} }
@Override
public String getEncryptedDatabaseKey() { public String getEncryptedDatabaseKey() {
return briarPrefs.getString(PREF_DB_KEY, null); return briarPrefs.getString(PREF_DB_KEY, null);
} }
public void clearPrefs() { @Override
public void deleteAccount(Context ctx) {
SharedPreferences.Editor editor = briarPrefs.edit(); SharedPreferences.Editor editor = briarPrefs.edit();
editor.clear(); editor.clear();
editor.apply(); editor.apply();
AndroidUtils.deleteAppData(ctx);
} }
@Override @Override
public boolean initialized() { public boolean accountExists() {
String hex = getEncryptedDatabaseKey(); String hex = getEncryptedDatabaseKey();
if (hex != null && databaseConfig.databaseExists()) { return hex != null && databaseConfig.databaseExists();
return true;
}
return false;
} }
} }

View File

@@ -5,6 +5,7 @@ import org.briarproject.api.TransportId;
import org.briarproject.api.identity.LocalAuthor; import org.briarproject.api.identity.LocalAuthor;
public interface NavDrawerController extends BriarController { public interface NavDrawerController extends BriarController {
void setTransportListener(TransportStateListener transportListener); void setTransportListener(TransportStateListener transportListener);
boolean isTransportRunning(TransportId transportId); boolean isTransportRunning(TransportId transportId);

View File

@@ -16,8 +16,6 @@ import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.plugins.Plugin; import org.briarproject.api.plugins.Plugin;
import org.briarproject.api.plugins.PluginManager; import org.briarproject.api.plugins.PluginManager;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.inject.Inject; import javax.inject.Inject;
@@ -34,15 +32,15 @@ public class NavDrawerControllerImpl extends BriarControllerImpl
@Inject @Inject
protected ReferenceManager referenceManager; protected ReferenceManager referenceManager;
@Inject @Inject
protected volatile IdentityManager identityManager;
@Inject
protected PluginManager pluginManager; protected PluginManager pluginManager;
@Inject @Inject
protected EventBus eventBus; protected EventBus eventBus;
@Inject @Inject
protected Activity activity; protected Activity activity;
private List<Plugin> transports = new ArrayList<Plugin>(); // Fields that are accessed from background threads must be volatile
@Inject
protected volatile IdentityManager identityManager;
private TransportStateListener transportStateListener; private TransportStateListener transportStateListener;
@@ -112,6 +110,7 @@ public class NavDrawerControllerImpl extends BriarControllerImpl
public void storeLocalAuthor(final LocalAuthor author, public void storeLocalAuthor(final LocalAuthor author,
final UiResultHandler<Void> resultHandler) { final UiResultHandler<Void> resultHandler) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -130,7 +129,6 @@ public class NavDrawerControllerImpl extends BriarControllerImpl
@Override @Override
public LocalAuthor removeAuthorHandle(long handle) { public LocalAuthor removeAuthorHandle(long handle) {
return referenceManager.removeReference(handle, return referenceManager.removeReference(handle, LocalAuthor.class);
LocalAuthor.class);
} }
} }

View File

@@ -3,6 +3,7 @@ package org.briarproject.android.controller;
import org.briarproject.android.controller.handler.ResultHandler; import org.briarproject.android.controller.handler.ResultHandler;
public interface PasswordController extends ConfigController { public interface PasswordController extends ConfigController {
void validatePassword(String password, void validatePassword(String password,
ResultHandler<Boolean> resultHandler); ResultHandler<Boolean> resultHandler);
} }

View File

@@ -33,6 +33,7 @@ public class PasswordControllerImpl extends ConfigControllerImpl
final ResultHandler<Boolean> resultHandler) { final ResultHandler<Boolean> resultHandler) {
final byte[] encrypted = getEncryptedKey(); final byte[] encrypted = getEncryptedKey();
cryptoExecutor.execute(new Runnable() { cryptoExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
byte[] key = crypto.decryptWithPassword(encrypted, password); byte[] key = crypto.decryptWithPassword(encrypted, password);
if (key == null) { if (key == null) {
@@ -48,7 +49,7 @@ public class PasswordControllerImpl extends ConfigControllerImpl
private byte[] getEncryptedKey() { private byte[] getEncryptedKey() {
String hex = getEncryptedDatabaseKey(); String hex = getEncryptedDatabaseKey();
if (hex == null) if (hex == null)
throw new IllegalStateException("Encrypted database key is null."); throw new IllegalStateException("Encrypted database key is null");
return StringUtils.fromHexString(hex); return StringUtils.fromHexString(hex);
} }
} }

View File

@@ -3,6 +3,7 @@ package org.briarproject.android.controller;
import org.briarproject.android.controller.handler.ResultHandler; import org.briarproject.android.controller.handler.ResultHandler;
public interface SetupController { public interface SetupController {
float estimatePasswordStrength(String password); float estimatePasswordStrength(String password);
void createIdentity(String nickname, String password, void createIdentity(String nickname, String password,

View File

@@ -34,6 +34,10 @@ public class SetupControllerImpl implements SetupController {
protected Executor cryptoExecutor; protected Executor cryptoExecutor;
@Inject @Inject
protected PasswordStrengthEstimator strengthEstimator; protected PasswordStrengthEstimator strengthEstimator;
@Inject
protected Activity activity;
@Inject
protected SharedPreferences briarPrefs;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject @Inject
@@ -44,10 +48,6 @@ public class SetupControllerImpl implements SetupController {
protected volatile AuthorFactory authorFactory; protected volatile AuthorFactory authorFactory;
@Inject @Inject
protected volatile ReferenceManager referenceManager; protected volatile ReferenceManager referenceManager;
@Inject
protected Activity activity;
@Inject
protected SharedPreferences briarPrefs;
@Inject @Inject
public SetupControllerImpl() { public SetupControllerImpl() {
@@ -85,6 +85,7 @@ public class SetupControllerImpl implements SetupController {
public void createIdentity(final String nickname, final String password, public void createIdentity(final String nickname, final String password,
final ResultHandler<Long> resultHandler) { final ResultHandler<Long> resultHandler) {
cryptoExecutor.execute(new Runnable() { cryptoExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
SecretKey key = crypto.generateSecretKey(); SecretKey key = crypto.generateSecretKey();
databaseConfig.setEncryptionKey(key); databaseConfig.setEncryptionKey(key);
@@ -98,10 +99,9 @@ public class SetupControllerImpl implements SetupController {
}); });
} }
private void storeEncryptedDatabaseKey(final String hex) { private void storeEncryptedDatabaseKey(String hex) {
SharedPreferences.Editor editor = briarPrefs.edit(); SharedPreferences.Editor editor = briarPrefs.edit();
editor.putString(PREF_DB_KEY, hex); editor.putString(PREF_DB_KEY, hex);
editor.apply(); editor.apply();
} }
} }

View File

@@ -3,5 +3,6 @@ package org.briarproject.android.controller;
import org.briarproject.api.TransportId; import org.briarproject.api.TransportId;
public interface TransportStateListener { public interface TransportStateListener {
void stateUpdate(TransportId id, boolean enabled); void stateUpdate(TransportId id, boolean enabled);
} }

View File

@@ -1,6 +1,8 @@
package org.briarproject.android.controller.handler; package org.briarproject.android.controller.handler;
public interface ResultExceptionHandler<R, E extends Exception> { public interface ResultExceptionHandler<R, E extends Exception> {
void onResult(R result); void onResult(R result);
void onException(E exception); void onException(E exception);
} }

View File

@@ -1,5 +1,6 @@
package org.briarproject.android.controller.handler; package org.briarproject.android.controller.handler;
public interface ResultHandler<R> { public interface ResultHandler<R> {
void onResult(R result); void onResult(R result);
} }

View File

@@ -11,16 +11,20 @@ public abstract class UiResultExceptionHandler<R, E extends Exception>
this.activity = activity; this.activity = activity;
} }
@Override
public void onResult(final R result) { public void onResult(final R result) {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
onResultUi(result); onResultUi(result);
} }
}); });
} }
@Override
public void onException(final E exception) { public void onException(final E exception) {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
onExceptionUi(exception); onExceptionUi(exception);
} }

View File

@@ -10,8 +10,10 @@ public abstract class UiResultHandler<R> implements ResultHandler<R> {
this.activity = activity; this.activity = activity;
} }
@Override
public void onResult(final R result) { public void onResult(final R result) {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
onResultUi(result); onResultUi(result);
} }

View File

@@ -6,7 +6,6 @@ import android.widget.Toast;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
import org.briarproject.android.util.BriarRecyclerView; import org.briarproject.android.util.BriarRecyclerView;
import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.Contact;
@@ -44,9 +43,12 @@ public class AvailableForumsActivity extends BriarActivity
private AvailableForumsAdapter adapter; private AvailableForumsAdapter adapter;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject protected volatile ForumManager forumManager; @Inject
@Inject protected volatile ForumSharingManager forumSharingManager; protected volatile ForumManager forumManager;
@Inject protected volatile EventBus eventBus; @Inject
protected volatile ForumSharingManager forumSharingManager;
@Inject
protected volatile EventBus eventBus;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
@@ -75,6 +77,7 @@ public class AvailableForumsActivity extends BriarActivity
private void loadForums() { private void loadForums() {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
Collection<ForumContacts> available = new ArrayList<>(); Collection<ForumContacts> available = new ArrayList<>();
@@ -102,6 +105,7 @@ public class AvailableForumsActivity extends BriarActivity
private void displayForums(final Collection<ForumContacts> available) { private void displayForums(final Collection<ForumContacts> available) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
if (available.isEmpty()) { if (available.isEmpty()) {
LOG.info("No forums available, finishing"); LOG.info("No forums available, finishing");
@@ -124,6 +128,7 @@ public class AvailableForumsActivity extends BriarActivity
eventBus.removeListener(this); eventBus.removeListener(this);
} }
@Override
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if (e instanceof ContactRemovedEvent) { if (e instanceof ContactRemovedEvent) {
LOG.info("Contact removed, reloading"); LOG.info("Contact removed, reloading");
@@ -146,6 +151,7 @@ public class AvailableForumsActivity extends BriarActivity
} }
} }
@Override
public void onItemClick(AvailableForumsItem item, boolean accept) { public void onItemClick(AvailableForumsItem item, boolean accept) {
respondToInvitation(item.getForum(), accept); respondToInvitation(item.getForum(), accept);
@@ -157,6 +163,7 @@ public class AvailableForumsActivity extends BriarActivity
private void respondToInvitation(final Forum f, final boolean accept) { private void respondToInvitation(final Forum f, final boolean accept) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
forumSharingManager.respondToInvitation(f, accept); forumSharingManager.respondToInvitation(f, accept);
@@ -168,5 +175,4 @@ public class AvailableForumsActivity extends BriarActivity
} }
}); });
} }
} }

View File

@@ -25,9 +25,7 @@ class AvailableForumsAdapter extends
new SortedList<>(AvailableForumsItem.class, new SortedList<>(AvailableForumsItem.class,
new SortedListCallBacks()); new SortedListCallBacks());
AvailableForumsAdapter(Context ctx, AvailableForumsAdapter(Context ctx, AvailableForumClickListener listener) {
AvailableForumClickListener listener) {
this.ctx = ctx; this.ctx = ctx;
this.listener = listener; this.listener = listener;
} }
@@ -90,16 +88,14 @@ class AvailableForumsAdapter extends
protected static class AvailableForumViewHolder protected static class AvailableForumViewHolder
extends RecyclerView.ViewHolder { extends RecyclerView.ViewHolder {
public final ViewGroup layout; private final TextView name;
public final TextView name; private final TextView sharedBy;
public final TextView sharedBy; private final Button accept;
public final Button accept; private final Button decline;
public final Button decline;
public AvailableForumViewHolder(View v) { public AvailableForumViewHolder(View v) {
super(v); super(v);
layout = (ViewGroup) v;
name = (TextView) v.findViewById(R.id.forumNameView); name = (TextView) v.findViewById(R.id.forumNameView);
sharedBy = (TextView) v.findViewById(R.id.sharedByView); sharedBy = (TextView) v.findViewById(R.id.sharedByView);
accept = (Button) v.findViewById(R.id.acceptButton); accept = (Button) v.findViewById(R.id.acceptButton);
@@ -156,5 +152,4 @@ class AvailableForumsAdapter extends
interface AvailableForumClickListener { interface AvailableForumClickListener {
void onItemClick(AvailableForumsItem item, boolean accept); void onItemClick(AvailableForumsItem item, boolean accept);
} }
} }

View File

@@ -20,8 +20,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
public class ContactSelectorAdapter public class ContactSelectorAdapter
extends extends BaseContactListAdapter<ContactSelectorAdapter.SelectableContactHolder> {
BaseContactListAdapter<ContactSelectorAdapter.SelectableContactHolder> {
public ContactSelectorAdapter(Context context, public ContactSelectorAdapter(Context context,
OnItemClickListener listener) { OnItemClickListener listener) {
@@ -32,19 +31,17 @@ public class ContactSelectorAdapter
@Override @Override
public SelectableContactHolder onCreateViewHolder(ViewGroup viewGroup, public SelectableContactHolder onCreateViewHolder(ViewGroup viewGroup,
int i) { int i) {
View v = LayoutInflater.from(ctx) View v = LayoutInflater.from(ctx).inflate(
.inflate(R.layout.list_item_selectable_contact, viewGroup, R.layout.list_item_selectable_contact, viewGroup, false);
false);
return new SelectableContactHolder(v); return new SelectableContactHolder(v);
} }
@Override @Override
public void onBindViewHolder(final SelectableContactHolder ui, public void onBindViewHolder(SelectableContactHolder ui, int position) {
final int position) {
super.onBindViewHolder(ui, position); super.onBindViewHolder(ui, position);
final SelectableContactListItem item = SelectableContactListItem item =
(SelectableContactListItem) getItem(position); (SelectableContactListItem) getItem(position);
if (item.isSelected()) { if (item.isSelected()) {
@@ -90,7 +87,7 @@ public class ContactSelectorAdapter
} }
private void grayOutItem(final SelectableContactHolder ui) { private void grayOutItem(final SelectableContactHolder ui) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= 11) {
float alpha = 0.25f; float alpha = 0.25f;
ui.avatar.setAlpha(alpha); ui.avatar.setAlpha(alpha);
ui.name.setAlpha(alpha); ui.name.setAlpha(alpha);
@@ -103,5 +100,4 @@ public class ContactSelectorAdapter
ui.checkBox.setEnabled(false); ui.checkBox.setEnabled(false);
} }
} }
} }

View File

@@ -44,17 +44,17 @@ public class ContactSelectorFragment extends BaseFragment implements
BaseContactListAdapter.OnItemClickListener { BaseContactListAdapter.OnItemClickListener {
public final static String TAG = "ContactSelectorFragment"; public final static String TAG = "ContactSelectorFragment";
private static final Logger LOG =
Logger.getLogger(ContactSelectorFragment.class.getName());
private ShareForumActivity shareForumActivity; private ShareForumActivity shareForumActivity;
private Menu menu; private Menu menu;
private BriarRecyclerView list; private BriarRecyclerView list;
private ContactSelectorAdapter adapter; private ContactSelectorAdapter adapter;
private Collection<ContactId> selectedContacts; private Collection<ContactId> selectedContacts;
private static final Logger LOG =
Logger.getLogger(ContactSelectorFragment.class.getName());
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
protected volatile GroupId groupId;
@Inject @Inject
protected volatile ContactManager contactManager; protected volatile ContactManager contactManager;
@Inject @Inject
@@ -62,6 +62,8 @@ public class ContactSelectorFragment extends BaseFragment implements
@Inject @Inject
protected volatile ForumSharingManager forumSharingManager; protected volatile ForumSharingManager forumSharingManager;
protected volatile GroupId groupId;
public void initBundle(GroupId groupId) { public void initBundle(GroupId groupId) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putByteArray(GROUP_ID, groupId.getBytes()); bundle.putByteArray(GROUP_ID, groupId.getBytes());
@@ -97,11 +99,10 @@ public class ContactSelectorFragment extends BaseFragment implements
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View contentView = View contentView = inflater.inflate(
inflater.inflate(R.layout.introduction_contact_chooser, R.layout.introduction_contact_chooser, container, false);
container, false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= 21) {
setExitTransition(new Fade()); setExitTransition(new Fade());
} }
@@ -116,7 +117,8 @@ public class ContactSelectorFragment extends BaseFragment implements
if (savedInstanceState != null) { if (savedInstanceState != null) {
ArrayList<Integer> intContacts = ArrayList<Integer> intContacts =
savedInstanceState.getIntegerArrayList(CONTACTS); savedInstanceState.getIntegerArrayList(CONTACTS);
selectedContacts = ShareForumActivity.getContactsFromIntegers(intContacts); selectedContacts = ShareForumActivity.getContactsFromIntegers(
intContacts);
} }
return contentView; return contentView;
@@ -126,11 +128,9 @@ public class ContactSelectorFragment extends BaseFragment implements
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (selectedContacts != null) { if (selectedContacts != null)
loadContacts(Collections.unmodifiableCollection(selectedContacts)); loadContacts(Collections.unmodifiableCollection(selectedContacts));
} else { else loadContacts(null);
loadContacts(null);
}
} }
@Override @Override
@@ -182,11 +182,11 @@ public class ContactSelectorFragment extends BaseFragment implements
private void loadContacts(final Collection<ContactId> selection) { private void loadContacts(final Collection<ContactId> selection) {
shareForumActivity.runOnDbThread(new Runnable() { shareForumActivity.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
List<ContactListItem> contacts = List<ContactListItem> contacts = new ArrayList<>();
new ArrayList<>();
for (Contact c : contactManager.getActiveContacts()) { for (Contact c : contactManager.getActiveContacts()) {
LocalAuthor localAuthor = identityManager LocalAuthor localAuthor = identityManager
@@ -197,9 +197,8 @@ public class ContactSelectorFragment extends BaseFragment implements
// do we have already some sharing with that contact? // do we have already some sharing with that contact?
boolean disabled = boolean disabled =
!forumSharingManager.canBeShared(groupId, c); !forumSharingManager.canBeShared(groupId, c);
contacts.add( contacts.add(new SelectableContactListItem(c,
new SelectableContactListItem(c, localAuthor, localAuthor, groupId, selected, disabled));
groupId, selected, disabled));
} }
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO)) if (LOG.isLoggable(INFO))
@@ -216,12 +215,10 @@ public class ContactSelectorFragment extends BaseFragment implements
private void displayContacts(final List<ContactListItem> contacts) { private void displayContacts(final List<ContactListItem> contacts) {
shareForumActivity.runOnUiThread(new Runnable() { shareForumActivity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
if (!contacts.isEmpty()) { if (!contacts.isEmpty()) adapter.addAll(contacts);
adapter.addAll(contacts); else list.showData();
} else {
list.showData();
}
updateMenuItem(); updateMenuItem();
} }
}); });
@@ -239,5 +236,4 @@ public class ContactSelectorFragment extends BaseFragment implements
item.setVisible(false); item.setVisible(false);
} }
} }
} }

View File

@@ -40,10 +40,10 @@ public class CreateForumActivity extends BriarActivity
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(CreateForumActivity.class.getName()); Logger.getLogger(CreateForumActivity.class.getName());
private EditText nameEntry = null; private EditText nameEntry;
private Button createForumButton = null; private Button createForumButton;
private ProgressBar progress = null; private ProgressBar progress;
private TextView feedback = null; private TextView feedback;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject @Inject
@@ -95,6 +95,7 @@ public class CreateForumActivity extends BriarActivity
createForumButton.setEnabled(validateName()); createForumButton.setEnabled(validateName());
} }
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) { public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
hideSoftKeyboard(textView); hideSoftKeyboard(textView);
return true; return true;
@@ -111,6 +112,7 @@ public class CreateForumActivity extends BriarActivity
return length > 0; return length > 0;
} }
@Override
public void onClick(View view) { public void onClick(View view) {
if (view == createForumButton) { if (view == createForumButton) {
hideSoftKeyboard(view); hideSoftKeyboard(view);
@@ -123,6 +125,7 @@ public class CreateForumActivity extends BriarActivity
private void storeForum(final String name) { private void storeForum(final String name) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -143,6 +146,7 @@ public class CreateForumActivity extends BriarActivity
private void displayForum(final Forum f) { private void displayForum(final Forum f) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
Intent i = new Intent(CreateForumActivity.this, Intent i = new Intent(CreateForumActivity.this,
ForumActivity.class); ForumActivity.class);

View File

@@ -26,6 +26,7 @@ public class ForumListAdapter extends
private SortedList<ForumListItem> forums = new SortedList<>( private SortedList<ForumListItem> forums = new SortedList<>(
ForumListItem.class, new SortedList.Callback<ForumListItem>() { ForumListItem.class, new SortedList.Callback<ForumListItem>() {
@Override @Override
public int compare(ForumListItem a, ForumListItem b) { public int compare(ForumListItem a, ForumListItem b) {
if (a == b) return 0; if (a == b) return 0;
@@ -71,6 +72,7 @@ public class ForumListAdapter extends
return a.getForum().equals(b.getForum()); return a.getForum().equals(b.getForum());
} }
}); });
private final Context ctx; private final Context ctx;
public ForumListAdapter(Context ctx) { public ForumListAdapter(Context ctx) {
@@ -78,11 +80,9 @@ public class ForumListAdapter extends
} }
@Override @Override
public ForumViewHolder onCreateViewHolder(ViewGroup parent, public ForumViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int viewType) { View v = LayoutInflater.from(ctx).inflate(
R.layout.list_item_forum, parent, false);
View v = LayoutInflater.from(ctx)
.inflate(R.layout.list_item_forum, parent, false);
return new ForumViewHolder(v); return new ForumViewHolder(v);
} }
@@ -175,10 +175,10 @@ public class ForumListAdapter extends
protected static class ForumViewHolder extends RecyclerView.ViewHolder { protected static class ForumViewHolder extends RecyclerView.ViewHolder {
public final ViewGroup layout; private final ViewGroup layout;
public final TextView name; private final TextView name;
public final TextView unread; private final TextView unread;
public final TextView date; private final TextView date;
public ForumViewHolder(View v) { public ForumViewHolder(View v) {
super(v); super(v);
@@ -189,5 +189,4 @@ public class ForumListAdapter extends
date = (TextView) v.findViewById(R.id.dateView); date = (TextView) v.findViewById(R.id.dateView);
} }
} }
} }

View File

@@ -134,6 +134,7 @@ public class ForumListFragment extends BaseEventFragment implements
private void loadForumHeaders() { private void loadForumHeaders() {
listener.runOnDbThread(new Runnable() { listener.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
// load forums // load forums
@@ -162,6 +163,7 @@ public class ForumListFragment extends BaseEventFragment implements
private void displayForumHeaders(final Collection<ForumListItem> forums) { private void displayForumHeaders(final Collection<ForumListItem> forums) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
if (forums.size() > 0) adapter.addAll(forums); if (forums.size() > 0) adapter.addAll(forums);
else list.showData(); else list.showData();
@@ -171,6 +173,7 @@ public class ForumListFragment extends BaseEventFragment implements
private void loadAvailableForums() { private void loadAvailableForums() {
listener.runOnDbThread(new Runnable() { listener.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -190,6 +193,7 @@ public class ForumListFragment extends BaseEventFragment implements
private void displayAvailableForums(final int availableCount) { private void displayAvailableForums(final int availableCount) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
if (availableCount == 0) { if (availableCount == 0) {
snackbar.dismiss(); snackbar.dismiss();
@@ -203,6 +207,7 @@ public class ForumListFragment extends BaseEventFragment implements
}); });
} }
@Override
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if (e instanceof ContactRemovedEvent) { if (e instanceof ContactRemovedEvent) {
LOG.info("Contact removed, reloading available forums"); LOG.info("Contact removed, reloading available forums");
@@ -235,6 +240,7 @@ public class ForumListFragment extends BaseEventFragment implements
private void loadForumHeaders(final GroupId g) { private void loadForumHeaders(final GroupId g) {
listener.runOnDbThread(new Runnable() { listener.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -272,9 +278,9 @@ public class ForumListFragment extends BaseEventFragment implements
}); });
} }
@Override
public void onClick(View view) { public void onClick(View view) {
// snackbar click // snackbar click
startActivity(new Intent(getContext(), AvailableForumsActivity.class)); startActivity(new Intent(getContext(), AvailableForumsActivity.class));
} }
} }

View File

@@ -16,7 +16,8 @@ public class SelectableContactListItem extends ContactListItem {
public SelectableContactListItem(Contact contact, LocalAuthor localAuthor, public SelectableContactListItem(Contact contact, LocalAuthor localAuthor,
GroupId groupId, boolean selected, boolean disabled) { GroupId groupId, boolean selected, boolean disabled) {
super(contact, localAuthor, false, groupId, Collections.<ConversationItem>emptyList()); super(contact, localAuthor, false, groupId,
Collections.<ConversationItem>emptyList());
this.selected = selected; this.selected = selected;
this.disabled = disabled; this.disabled = disabled;
@@ -37,5 +38,4 @@ public class SelectableContactListItem extends ContactListItem {
public boolean isDisabled() { public boolean isDisabled() {
return disabled; return disabled;
} }
} }

View File

@@ -9,7 +9,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.briarproject.R; import org.briarproject.R;
@@ -25,6 +24,7 @@ import java.util.logging.Logger;
import javax.inject.Inject; import javax.inject.Inject;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import static org.briarproject.android.forum.ShareForumActivity.CONTACTS; import static org.briarproject.android.forum.ShareForumActivity.CONTACTS;
import static org.briarproject.android.forum.ShareForumActivity.getContactsFromIds; import static org.briarproject.android.forum.ShareForumActivity.getContactsFromIds;
@@ -32,15 +32,17 @@ import static org.briarproject.api.forum.ForumConstants.GROUP_ID;
public class ShareForumMessageFragment extends BaseFragment { public class ShareForumMessageFragment extends BaseFragment {
public final static String TAG = "IntroductionMessageFragment";
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(ShareForumMessageFragment.class.getName()); Logger.getLogger(ShareForumMessageFragment.class.getName());
public final static String TAG = "IntroductionMessageFragment";
private ShareForumActivity shareForumActivity; private ShareForumActivity shareForumActivity;
private ViewHolder ui; private ViewHolder ui;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject protected volatile ForumSharingManager forumSharingManager; @Inject
protected volatile ForumSharingManager forumSharingManager;
private volatile GroupId groupId; private volatile GroupId groupId;
private volatile Collection<ContactId> contacts; private volatile Collection<ContactId> contacts;
@@ -81,9 +83,8 @@ public class ShareForumMessageFragment extends BaseFragment {
setHasOptionsMenu(true); setHasOptionsMenu(true);
// inflate view // inflate view
View v = View v = inflater.inflate(R.layout.share_forum_message, container,
inflater.inflate(R.layout.share_forum_message, container, false);
false);
ui = new ViewHolder(v); ui = new ViewHolder(v);
ui.button.setOnClickListener(new View.OnClickListener() { ui.button.setOnClickListener(new View.OnClickListener() {
@Override @Override
@@ -131,11 +132,12 @@ public class ShareForumMessageFragment extends BaseFragment {
private void shareForum(final String msg) { private void shareForum(final String msg) {
shareForumActivity.runOnDbThread(new Runnable() { shareForumActivity.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
for (ContactId c : contacts) { for (ContactId c : contacts) {
forumSharingManager forumSharingManager.sendForumInvitation(groupId, c,
.sendForumInvitation(groupId, c, msg); msg);
} }
} catch (DbException e) { } catch (DbException e) {
sharingError(); sharingError();
@@ -148,21 +150,20 @@ public class ShareForumMessageFragment extends BaseFragment {
private void sharingError() { private void sharingError() {
shareForumActivity.runOnUiThread(new Runnable() { shareForumActivity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
Toast.makeText(shareForumActivity, Toast.makeText(shareForumActivity,
R.string.introduction_error, Toast.LENGTH_SHORT) R.string.introduction_error, LENGTH_SHORT).show();
.show();
} }
}); });
} }
private static class ViewHolder { private static class ViewHolder {
final private TextView text;
final private EditText message; private final EditText message;
final private Button button; private final Button button;
ViewHolder(View v) { ViewHolder(View v) {
text = (TextView) v.findViewById(R.id.introductionText);
message = (EditText) v.findViewById(R.id.invitationMessageView); message = (EditText) v.findViewById(R.id.invitationMessageView);
button = (Button) v.findViewById(R.id.shareForumButton); button = (Button) v.findViewById(R.id.shareForumButton);
} }

View File

@@ -6,10 +6,10 @@ import android.support.v4.app.Fragment;
public abstract class BaseFragment extends Fragment { public abstract class BaseFragment extends Fragment {
public abstract String getUniqueTag();
protected BaseFragmentListener listener; protected BaseFragmentListener listener;
public abstract String getUniqueTag();
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);
@@ -27,6 +27,7 @@ public abstract class BaseFragment extends Fragment {
} }
public interface BaseFragmentListener { public interface BaseFragmentListener {
void showLoadingScreen(boolean isBlocking, int stringId); void showLoadingScreen(boolean isBlocking, int stringId);
void hideLoadingScreen(); void hideLoadingScreen();
@@ -35,5 +36,4 @@ public abstract class BaseFragment extends Fragment {
void runOnDbThread(Runnable runnable); void runOnDbThread(Runnable runnable);
} }
} }

View File

@@ -15,7 +15,6 @@ import android.widget.Toast;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
import org.briarproject.android.util.LayoutUtils; import org.briarproject.android.util.LayoutUtils;
import org.briarproject.api.crypto.CryptoComponent; import org.briarproject.api.crypto.CryptoComponent;
@@ -47,21 +46,27 @@ import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH; import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
public class CreateIdentityActivity extends BriarActivity public class CreateIdentityActivity extends BriarActivity
implements OnEditorActionListener, OnClickListener { implements OnEditorActionListener, OnClickListener {
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(CreateIdentityActivity.class.getName()); Logger.getLogger(CreateIdentityActivity.class.getName());
@Inject @CryptoExecutor protected Executor cryptoExecutor; @Inject
private EditText nicknameEntry = null; @CryptoExecutor
private Button createIdentityButton = null; protected Executor cryptoExecutor;
private ProgressBar progress = null;
private TextView feedback = null; private EditText nicknameEntry;
private Button createIdentityButton;
private ProgressBar progress;
private TextView feedback;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject protected volatile CryptoComponent crypto; @Inject
@Inject protected volatile AuthorFactory authorFactory; protected volatile CryptoComponent crypto;
@Inject protected volatile IdentityManager identityManager; @Inject
protected volatile AuthorFactory authorFactory;
@Inject
protected volatile IdentityManager identityManager;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
@@ -124,6 +129,7 @@ implements OnEditorActionListener, OnClickListener {
createIdentityButton.setEnabled(validateNickname()); createIdentityButton.setEnabled(validateNickname());
} }
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) { public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
hideSoftKeyboard(textView); hideSoftKeyboard(textView);
return true; return true;
@@ -140,6 +146,7 @@ implements OnEditorActionListener, OnClickListener {
return length > 0; return length > 0;
} }
@Override
public void onClick(View view) { public void onClick(View view) {
hideSoftKeyboard(view); hideSoftKeyboard(view);
if (!validateNickname()) return; if (!validateNickname()) return;
@@ -149,6 +156,7 @@ implements OnEditorActionListener, OnClickListener {
// Create the identity in a background thread // Create the identity in a background thread
final String nickname = nicknameEntry.getText().toString(); final String nickname = nicknameEntry.getText().toString();
cryptoExecutor.execute(new Runnable() { cryptoExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
KeyPair keyPair = crypto.generateSignatureKeyPair(); KeyPair keyPair = crypto.generateSignatureKeyPair();
final byte[] publicKey = keyPair.getPublic().getEncoded(); final byte[] publicKey = keyPair.getPublic().getEncoded();
@@ -162,6 +170,7 @@ implements OnEditorActionListener, OnClickListener {
private void storeLocalAuthor(final LocalAuthor a) { private void storeLocalAuthor(final LocalAuthor a) {
runOnDbThread(new Runnable() { runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -180,6 +189,7 @@ implements OnEditorActionListener, OnClickListener {
private void setResultAndFinish(final LocalAuthor a) { private void setResultAndFinish(final LocalAuthor a) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
Intent i = new Intent(); Intent i = new Intent();
i.putExtra("briar.LOCAL_AUTHOR_ID", a.getId().getBytes()); i.putExtra("briar.LOCAL_AUTHOR_ID", a.getId().getBytes());

View File

@@ -55,7 +55,7 @@ public class ContactChooserAdapter extends ContactListAdapter {
} }
private void grayOutItem(final ContactHolder ui) { private void grayOutItem(final ContactHolder ui) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= 11) {
float alpha = 0.25f; float alpha = 0.25f;
ui.bulb.setAlpha(alpha); ui.bulb.setAlpha(alpha);
ui.avatar.setAlpha(alpha); ui.avatar.setAlpha(alpha);

View File

@@ -44,14 +44,15 @@ import static java.util.logging.Level.WARNING;
public class ContactChooserFragment extends BaseFragment { public class ContactChooserFragment extends BaseFragment {
public final static String TAG = "ContactChooserFragment"; public final static String TAG = "ContactChooserFragment";
private static final Logger LOG =
Logger.getLogger(ContactChooserFragment.class.getName());
private IntroductionActivity introductionActivity; private IntroductionActivity introductionActivity;
private BriarRecyclerView list; private BriarRecyclerView list;
private ContactChooserAdapter adapter; private ContactChooserAdapter adapter;
private int contactId; private int contactId;
private static final Logger LOG =
Logger.getLogger(ContactChooserFragment.class.getName());
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
protected volatile Contact c1; protected volatile Contact c1;
@Inject @Inject
@@ -76,7 +77,7 @@ public class ContactChooserFragment extends BaseFragment {
try { try {
introductionActivity = (IntroductionActivity) context; introductionActivity = (IntroductionActivity) context;
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new java.lang.InstantiationError( throw new InstantiationError(
"This fragment is only meant to be attached to the IntroductionActivity"); "This fragment is only meant to be attached to the IntroductionActivity");
} }
} }
@@ -90,7 +91,7 @@ public class ContactChooserFragment extends BaseFragment {
container, false); container, false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= 21) {
setExitTransition(new Fade()); setExitTransition(new Fade());
} }
@@ -99,14 +100,15 @@ public class ContactChooserFragment extends BaseFragment {
@Override @Override
public void onItemClick(View view, ContactListItem item) { public void onItemClick(View view, ContactListItem item) {
if (c1 == null) { if (c1 == null) {
throw new RuntimeException("c1 not initialized"); throw new RuntimeException("c1 not accountExists");
} }
Contact c2 = item.getContact(); Contact c2 = item.getContact();
if (!c1.getLocalAuthorId() if (!c1.getLocalAuthorId()
.equals(c2.getLocalAuthorId())) { .equals(c2.getLocalAuthorId())) {
warnAboutDifferentIdentities(view, c1, c2); warnAboutDifferentIdentities(view, c1, c2);
} else { } else {
introductionActivity.showMessageScreen(view, c1, c2); introductionActivity.showMessageScreen(view, c1,
c2);
} }
} }
}; };
@@ -142,11 +144,11 @@ public class ContactChooserFragment extends BaseFragment {
private void loadContacts() { private void loadContacts() {
introductionActivity.runOnDbThread(new Runnable() { introductionActivity.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
List<ContactListItem> contacts = List<ContactListItem> contacts = new ArrayList<>();
new ArrayList<ContactListItem>(); AuthorId localAuthorId = null;
AuthorId localAuthorId= null;
for (Contact c : contactManager.getActiveContacts()) { for (Contact c : contactManager.getActiveContacts()) {
if (c.getId().getInt() == contactId) { if (c.getId().getInt() == contactId) {
c1 = c; c1 = c;
@@ -177,6 +179,7 @@ public class ContactChooserFragment extends BaseFragment {
private void displayContacts(final AuthorId localAuthorId, private void displayContacts(final AuthorId localAuthorId,
final List<ContactListItem> contacts) { final List<ContactListItem> contacts) {
introductionActivity.runOnUiThread(new Runnable() { introductionActivity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
adapter.setLocalAuthor(localAuthorId); adapter.setLocalAuthor(localAuthorId);
if (contacts.size() == 0) list.showData(); if (contacts.size() == 0) list.showData();
@@ -206,14 +209,15 @@ public class ContactChooserFragment extends BaseFragment {
builder.show(); builder.show();
} }
/** This needs to be called from the DbThread */ /**
* This needs to be called from the DbThread
*/
private Collection<ConversationItem> getMessages(ContactId id) private Collection<ConversationItem> getMessages(ContactId id)
throws DbException { throws DbException {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
Collection<ConversationItem> messages = Collection<ConversationItem> messages = new ArrayList<>();
new ArrayList<ConversationItem>();
Collection<PrivateMessageHeader> headers = Collection<PrivateMessageHeader> headers =
messagingManager.getMessageHeaders(id); messagingManager.getMessageHeaders(id);
@@ -237,5 +241,4 @@ public class ContactChooserFragment extends BaseFragment {
return messages; return messages;
} }
} }

View File

@@ -3,7 +3,6 @@ package org.briarproject.android.introduction;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.transition.ChangeBounds; import android.transition.ChangeBounds;
import android.transition.Fade; import android.transition.Fade;
@@ -20,6 +19,7 @@ public class IntroductionActivity extends BriarActivity implements
BaseFragment.BaseFragmentListener { BaseFragment.BaseFragmentListener {
public static final String CONTACT_ID = "briar.CONTACT_ID"; public static final String CONTACT_ID = "briar.CONTACT_ID";
private int contactId; private int contactId;
@Override @Override
@@ -34,7 +34,8 @@ public class IntroductionActivity extends BriarActivity implements
setContentView(R.layout.activity_introduction); setContentView(R.layout.activity_introduction);
if (savedInstanceState == null) { if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction() getSupportFragmentManager()
.beginTransaction()
.add(R.id.introductionContainer, .add(R.id.introductionContainer,
activityComponent.newContactChooserFragment()) activityComponent.newContactChooserFragment())
.commit(); .commit();
@@ -82,21 +83,21 @@ public class IntroductionActivity extends BriarActivity implements
return contactId; return contactId;
} }
public void showMessageScreen(final View view, final Contact c1, public void showMessageScreen(View view, Contact c1, Contact c2) {
final Contact c2) {
IntroductionMessageFragment messageFragment = IntroductionMessageFragment messageFragment =
activityComponent.newIntroductionMessageFragment(); activityComponent.newIntroductionMessageFragment();
messageFragment.initBundle(c1.getId().getInt(), c2.getId().getInt()); messageFragment.initBundle(c1.getId().getInt(), c2.getId().getInt());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= 21) {
messageFragment.setSharedElementEnterTransition(new ChangeBounds()); messageFragment.setSharedElementEnterTransition(new ChangeBounds());
messageFragment.setEnterTransition(new Fade()); messageFragment.setEnterTransition(new Fade());
messageFragment messageFragment.setSharedElementReturnTransition(
.setSharedElementReturnTransition(new ChangeBounds()); new ChangeBounds());
} }
getSupportFragmentManager().beginTransaction() getSupportFragmentManager()
.beginTransaction()
.setCustomAnimations(android.R.anim.fade_in, .setCustomAnimations(android.R.anim.fade_in,
android.R.anim.fade_out, android.R.anim.fade_out,
android.R.anim.slide_in_left, android.R.anim.slide_in_left,
@@ -107,5 +108,4 @@ public class IntroductionActivity extends BriarActivity implements
.addToBackStack(null) .addToBackStack(null)
.commit(); .commit();
} }
} }

View File

@@ -28,19 +28,22 @@ import javax.inject.Inject;
import de.hdodenhof.circleimageview.CircleImageView; import de.hdodenhof.circleimageview.CircleImageView;
import im.delight.android.identicons.IdenticonDrawable; import im.delight.android.identicons.IdenticonDrawable;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
public class IntroductionMessageFragment extends BaseFragment { public class IntroductionMessageFragment extends BaseFragment {
private static final Logger LOG =
Logger.getLogger(IntroductionMessageFragment.class.getName());
public final static String TAG = "IntroductionMessageFragment"; public final static String TAG = "IntroductionMessageFragment";
private IntroductionActivity introductionActivity;
private ViewHolder ui;
private final static String CONTACT_ID_1 = "contact1"; private final static String CONTACT_ID_1 = "contact1";
private final static String CONTACT_ID_2 = "contact2"; private final static String CONTACT_ID_2 = "contact2";
private static final Logger LOG =
Logger.getLogger(IntroductionMessageFragment.class.getName());
private IntroductionActivity introductionActivity;
private ViewHolder ui;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject @Inject
@@ -83,13 +86,12 @@ public class IntroductionMessageFragment extends BaseFragment {
} }
// inflate view // inflate view
View v = View v = inflater.inflate(R.layout.introduction_message, container,
inflater.inflate(R.layout.introduction_message, container, false);
false);
// show progress bar until contacts have been loaded // show progress bar until contacts have been loaded
ui = new ViewHolder(v); ui = new ViewHolder(v);
ui.text.setVisibility(View.GONE); ui.text.setVisibility(GONE);
ui.button.setEnabled(false); ui.button.setEnabled(false);
// get contact IDs from fragment arguments // get contact IDs from fragment arguments
@@ -114,12 +116,13 @@ public class IntroductionMessageFragment extends BaseFragment {
private void prepareToSetUpViews(final int contactId1, private void prepareToSetUpViews(final int contactId1,
final int contactId2) { final int contactId2) {
introductionActivity.runOnDbThread(new Runnable() { introductionActivity.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
Contact c1 = contactManager Contact c1 = contactManager.getContact(
.getContact(new ContactId(contactId1)); new ContactId(contactId1));
Contact c2 = contactManager Contact c2 = contactManager.getContact(
.getContact(new ContactId(contactId2)); new ContactId(contactId2));
setUpViews(c1, c2); setUpViews(c1, c2);
} catch (DbException e) { } catch (DbException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
@@ -131,6 +134,7 @@ public class IntroductionMessageFragment extends BaseFragment {
private void setUpViews(final Contact c1, final Contact c2) { private void setUpViews(final Contact c1, final Contact c2) {
introductionActivity.runOnUiThread(new Runnable() { introductionActivity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
// set avatars // set avatars
ui.avatar1.setImageDrawable(new IdenticonDrawable( ui.avatar1.setImageDrawable(new IdenticonDrawable(
@@ -152,8 +156,8 @@ public class IntroductionMessageFragment extends BaseFragment {
}); });
// hide progress bar and show views // hide progress bar and show views
ui.progressBar.setVisibility(View.GONE); ui.progressBar.setVisibility(GONE);
ui.text.setVisibility(View.VISIBLE); ui.text.setVisibility(VISIBLE);
ui.button.setEnabled(true); ui.button.setEnabled(true);
} }
}); });
@@ -174,17 +178,14 @@ public class IntroductionMessageFragment extends BaseFragment {
private void makeIntroduction(final Contact c1, final Contact c2, private void makeIntroduction(final Contact c1, final Contact c2,
final String msg) { final String msg) {
introductionActivity.runOnDbThread(new Runnable() { introductionActivity.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
// actually make the introduction // actually make the introduction
try { try {
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
introductionManager introductionManager.makeIntroduction(c1, c2, msg,
.makeIntroduction(c1, c2, msg, timestamp); timestamp);
} catch (DbException e) { } catch (DbException | FormatException e) {
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
introductionError();
} catch (FormatException e) {
if (LOG.isLoggable(WARNING)) if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e); LOG.log(WARNING, e.toString(), e);
introductionError(); introductionError();
@@ -195,26 +196,24 @@ public class IntroductionMessageFragment extends BaseFragment {
private void introductionError() { private void introductionError() {
introductionActivity.runOnUiThread(new Runnable() { introductionActivity.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
Toast.makeText(introductionActivity, Toast.makeText(introductionActivity,
R.string.introduction_error, Toast.LENGTH_SHORT) R.string.introduction_error, LENGTH_SHORT).show();
.show();
} }
}); });
} }
private static class ViewHolder { private static class ViewHolder {
ProgressBar progressBar;
ViewGroup header; private final ProgressBar progressBar;
CircleImageView avatar1; private final CircleImageView avatar1, avatar2;
CircleImageView avatar2; private final TextView text;
TextView text; private final EditText message;
EditText message; private final Button button;
Button button;
ViewHolder(View v) { ViewHolder(View v) {
progressBar = (ProgressBar) v.findViewById(R.id.progressBar); progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
header = (ViewGroup) v.findViewById(R.id.introductionHeader);
avatar1 = (CircleImageView) v.findViewById(R.id.avatarContact1); avatar1 = (CircleImageView) v.findViewById(R.id.avatarContact1);
avatar2 = (CircleImageView) v.findViewById(R.id.avatarContact2); avatar2 = (CircleImageView) v.findViewById(R.id.avatarContact2);
text = (TextView) v.findViewById(R.id.introductionText); text = (TextView) v.findViewById(R.id.introductionText);

View File

@@ -13,8 +13,6 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Spinner; import android.widget.Spinner;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.fragment.BaseFragment; import org.briarproject.android.fragment.BaseFragment;
import org.briarproject.android.identity.CreateIdentityActivity; import org.briarproject.android.identity.CreateIdentityActivity;
import org.briarproject.android.identity.LocalAuthorItem; import org.briarproject.android.identity.LocalAuthorItem;
@@ -42,18 +40,17 @@ public class ChooseIdentityFragment extends BaseFragment
void identitySelected(AuthorId localAuthorId); void identitySelected(AuthorId localAuthorId);
} }
public static final String TAG = "ChooseIdentityFragment";
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(ChooseIdentityFragment.class.getName()); Logger.getLogger(ChooseIdentityFragment.class.getName());
public static final String TAG = "ChooseIdentityFragment";
private static final int REQUEST_CREATE_IDENTITY = 1; private static final int REQUEST_CREATE_IDENTITY = 1;
private IdentitySelectedListener lsnr; private IdentitySelectedListener lsnr;
private LocalAuthorSpinnerAdapter adapter; private LocalAuthorSpinnerAdapter adapter;
private Spinner spinner; private Spinner spinner;
private View button; private View button;
private AuthorId localAuthorId; private AuthorId localAuthorId;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@@ -112,6 +109,7 @@ public class ChooseIdentityFragment extends BaseFragment
private void loadLocalAuthors() { private void loadLocalAuthors() {
listener.runOnDbThread(new Runnable() { listener.runOnDbThread(new Runnable() {
@Override
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -157,6 +155,7 @@ public class ChooseIdentityFragment extends BaseFragment
button.setEnabled(localAuthorId != null); button.setEnabled(localAuthorId != null);
} }
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) { long id) {
LocalAuthorItem item = adapter.getItem(position); LocalAuthorItem item = adapter.getItem(position);
@@ -169,6 +168,7 @@ public class ChooseIdentityFragment extends BaseFragment
} }
} }
@Override
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
setLocalAuthorId(null); setLocalAuthorId(null);
} }

View File

@@ -8,7 +8,6 @@ import android.widget.Toast;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarFragmentActivity; import org.briarproject.android.BriarFragmentActivity;
import org.briarproject.android.fragment.BaseFragment; import org.briarproject.android.fragment.BaseFragment;
import org.briarproject.android.util.CustomAnimations; import org.briarproject.android.util.CustomAnimations;
@@ -24,7 +23,6 @@ import org.briarproject.api.identity.AuthorId;
import org.briarproject.api.identity.IdentityManager; import org.briarproject.api.identity.IdentityManager;
import org.briarproject.api.identity.LocalAuthor; import org.briarproject.api.identity.LocalAuthor;
import org.briarproject.api.keyagreement.KeyAgreementResult; import org.briarproject.api.keyagreement.KeyAgreementResult;
import org.briarproject.api.settings.SettingsManager;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -49,8 +47,6 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
@Inject @Inject
protected EventBus eventBus; protected EventBus eventBus;
@Inject
protected SettingsManager settingsManager;
private Toolbar toolbar; private Toolbar toolbar;
private View progressContainer; private View progressContainer;
@@ -58,6 +54,7 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
private AuthorId localAuthorId; private AuthorId localAuthorId;
// Fields that are accessed from background threads must be volatile
@Inject @Inject
protected volatile ContactExchangeTask contactExchangeTask; protected volatile ContactExchangeTask contactExchangeTask;
@Inject @Inject
@@ -193,6 +190,7 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
@Override @Override
public void contactExchangeSucceeded(final Author remoteAuthor) { public void contactExchangeSucceeded(final Author remoteAuthor) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
String contactName = remoteAuthor.getName(); String contactName = remoteAuthor.getName();
String format = getString(R.string.contact_added_toast); String format = getString(R.string.contact_added_toast);
@@ -207,6 +205,7 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
@Override @Override
public void duplicateContact(final Author remoteAuthor) { public void duplicateContact(final Author remoteAuthor) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
String contactName = remoteAuthor.getName(); String contactName = remoteAuthor.getName();
String format = getString(R.string.contact_already_exists); String format = getString(R.string.contact_already_exists);
@@ -221,6 +220,7 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements
@Override @Override
public void contactExchangeFailed() { public void contactExchangeFailed() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
Toast.makeText(KeyAgreementActivity.this, Toast.makeText(KeyAgreementActivity.this,
R.string.contact_exchange_failed, LENGTH_LONG).show(); R.string.contact_exchange_failed, LENGTH_LONG).show();

View File

@@ -57,11 +57,11 @@ import static java.util.logging.Level.WARNING;
public class ShowQrCodeFragment extends BaseEventFragment public class ShowQrCodeFragment extends BaseEventFragment
implements QrCodeDecoder.ResultCallback { implements QrCodeDecoder.ResultCallback {
public static final String TAG = "ShowQrCodeFragment";
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(ShowQrCodeFragment.class.getName()); Logger.getLogger(ShowQrCodeFragment.class.getName());
public static final String TAG = "ShowQrCodeFragment";
@Inject @Inject
protected KeyAgreementTaskFactory keyAgreementTaskFactory; protected KeyAgreementTaskFactory keyAgreementTaskFactory;
@Inject @Inject
@@ -138,6 +138,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
if (adapter != null && !adapter.isEnabled()) { if (adapter != null && !adapter.isEnabled()) {
waitingForBluetooth = true; waitingForBluetooth = true;
androidExecutor.execute(new Runnable() { androidExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
adapter.enable(); adapter.enable();
} }
@@ -342,6 +343,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
@Override @Override
public void handleResult(final Result result) { public void handleResult(final Result result) {
listener.runOnUiThread(new Runnable() { listener.runOnUiThread(new Runnable() {
@Override
public void run() { public void run() {
LOG.info("Got result from decoder"); LOG.info("Got result from decoder");
if (!gotRemotePayload) { if (!gotRemotePayload) {

View File

@@ -4,7 +4,6 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BaseActivity; import org.briarproject.android.BaseActivity;
import java.util.logging.Logger; import java.util.logging.Logger;

View File

@@ -6,7 +6,6 @@ import android.view.MenuItem;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.ActivityComponent; import org.briarproject.android.ActivityComponent;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
public class PanicPreferencesActivity extends BriarActivity { public class PanicPreferencesActivity extends BriarActivity {
@@ -29,6 +28,7 @@ public class PanicPreferencesActivity extends BriarActivity {
component.inject(this); component.inject(this);
} }
@Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) { if (item.getItemId() == android.R.id.home) {
onBackPressed(); onBackPressed();
@@ -36,5 +36,4 @@ public class PanicPreferencesActivity extends BriarActivity {
} }
return false; return false;
} }
} }

View File

@@ -11,7 +11,6 @@ import org.briarproject.android.ActivityComponent;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
import org.briarproject.android.api.AndroidExecutor; import org.briarproject.android.api.AndroidExecutor;
import org.briarproject.android.controller.ConfigController; import org.briarproject.android.controller.ConfigController;
import org.briarproject.android.util.AndroidUtils;
import org.iilab.IilabEngineeringRSA2048Pin; import org.iilab.IilabEngineeringRSA2048Pin;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -32,7 +31,9 @@ public class PanicResponderActivity extends BriarActivity {
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(PanicResponderActivity.class.getName()); Logger.getLogger(PanicResponderActivity.class.getName());
@Inject protected ConfigController configController;
@Inject
protected ConfigController configController;
@Inject @Inject
protected AndroidExecutor androidExecutor; protected AndroidExecutor androidExecutor;
@@ -76,8 +77,6 @@ public class PanicResponderActivity extends BriarActivity {
LOG.info("Signing out..."); LOG.info("Signing out...");
signOut(true); signOut(true);
} }
// TODO send a pre-defined message to certain contacts (#212)
} }
// Performing non-destructive default panic response // Performing non-destructive default panic response
else if (sharedPref.getBoolean(KEY_LOCK, true)) { else if (sharedPref.getBoolean(KEY_LOCK, true)) {
@@ -109,11 +108,10 @@ public class PanicResponderActivity extends BriarActivity {
private void deleteAllData() { private void deleteAllData() {
androidExecutor.execute(new Runnable() { androidExecutor.execute(new Runnable() {
@Override
public void run() { public void run() {
configController.clearPrefs(); configController.deleteAccount(PanicResponderActivity.this);
// TODO somehow delete/shred the database more thoroughly // TODO somehow delete/shred the database more thoroughly
// TODO replace this static call with a controller method
AndroidUtils.deleteAppData(PanicResponderActivity.this);
PanicResponder.deleteAllAppData(PanicResponderActivity.this); PanicResponder.deleteAllAppData(PanicResponderActivity.this);
// nothing left to do after everything is deleted, // nothing left to do after everything is deleted,

View File

@@ -4,67 +4,61 @@ import android.animation.Animator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Build; import android.os.Build;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import static android.view.View.GONE;
import static android.view.View.MeasureSpec.UNSPECIFIED;
import static android.view.View.VISIBLE;
public class CustomAnimations { public class CustomAnimations {
public static void animateHeight( public static void animateHeight(ViewGroup viewGroup, boolean isExtending,
final ViewGroup viewGroup, final boolean isExtending,
int duration) { int duration) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT >= 11) {
animateHeightPostGingerbread(viewGroup, isExtending, duration); animateHeightPostGingerbread(viewGroup, isExtending, duration);
} else { } else {
animateHeightGingerbread(viewGroup, isExtending, duration); animateHeightGingerbread(viewGroup, isExtending);
} }
} }
private static void animateHeightGingerbread(final ViewGroup viewGroup, private static void animateHeightGingerbread(ViewGroup viewGroup,
final boolean isExtending, int duration) { boolean isExtending) {
// No animations for Gingerbread // No animations for Gingerbread
if (isExtending) { if (isExtending) viewGroup.setVisibility(VISIBLE);
viewGroup.setVisibility(View.VISIBLE); else viewGroup.setVisibility(GONE);
} else {
viewGroup.setVisibility(View.GONE);
}
} }
@SuppressLint("NewApi") @SuppressLint("NewApi")
private static void animateHeightPostGingerbread( private static void animateHeightPostGingerbread(final ViewGroup viewGroup,
final ViewGroup viewGroup, final boolean isExtending, int duration) {
final boolean isExtending,
int duration) {
ValueAnimator anim; ValueAnimator anim;
if (isExtending) { if (isExtending) {
viewGroup.setVisibility(View.VISIBLE); viewGroup.setVisibility(VISIBLE);
viewGroup.measure(View.MeasureSpec.UNSPECIFIED, viewGroup.measure(UNSPECIFIED, UNSPECIFIED);
View.MeasureSpec.UNSPECIFIED);
anim = ValueAnimator.ofInt(0, viewGroup.getMeasuredHeight()); anim = ValueAnimator.ofInt(0, viewGroup.getMeasuredHeight());
} else { } else {
anim = ValueAnimator.ofInt(viewGroup.getHeight(), 0); anim = ValueAnimator.ofInt(viewGroup.getHeight(), 0);
} }
anim.addListener(new Animator.AnimatorListener() { anim.addListener(new Animator.AnimatorListener() {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
} }
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
if (!isExtending) { if (!isExtending) {
viewGroup.setVisibility(View.GONE); viewGroup.setVisibility(GONE);
} }
} }
@Override @Override
public void onAnimationCancel(Animator animation) { public void onAnimationCancel(Animator animation) {
} }
@Override @Override
public void onAnimationRepeat(Animator animation) { public void onAnimationRepeat(Animator animation) {
} }
}); });
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@@ -76,7 +70,6 @@ public class CustomAnimations {
layoutParams.height = val; layoutParams.height = val;
viewGroup.setLayoutParams(layoutParams); viewGroup.setLayoutParams(layoutParams);
} }
}); });
anim.setDuration(duration); anim.setDuration(duration);
anim.start(); anim.start();

View File

@@ -8,7 +8,6 @@ import android.provider.Settings;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Logger;
import javax.inject.Inject; import javax.inject.Inject;
@@ -16,9 +15,6 @@ import static android.provider.Settings.Secure.ANDROID_ID;
class AndroidSeedProvider extends LinuxSeedProvider { class AndroidSeedProvider extends LinuxSeedProvider {
private static final Logger LOG =
Logger.getLogger(LinuxSeedProvider.class.getName());
private final Context appContext; private final Context appContext;
@Inject @Inject
@@ -34,10 +30,8 @@ class AndroidSeedProvider extends LinuxSeedProvider {
if (Build.FINGERPRINT != null) out.writeUTF(Build.FINGERPRINT); if (Build.FINGERPRINT != null) out.writeUTF(Build.FINGERPRINT);
if (Build.SERIAL != null) out.writeUTF(Build.SERIAL); if (Build.SERIAL != null) out.writeUTF(Build.SERIAL);
ContentResolver contentResolver = appContext.getContentResolver(); ContentResolver contentResolver = appContext.getContentResolver();
String str = Settings.Secure.getString(contentResolver, ANDROID_ID); String id = Settings.Secure.getString(contentResolver, ANDROID_ID);
if (str != null) { if (id != null) out.writeUTF(id);
out.writeUTF(str);
}
super.writeToEntropyPool(out); super.writeToEntropyPool(out);
} }
} }

View File

@@ -48,23 +48,23 @@ import static org.robolectric.Shadows.shadowOf;
@RunWith(RobolectricGradleTestRunner.class) @RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, @Config(constants = BuildConfig.class, sdk = 21,
application = TestBriarApplicationImp.class) application = TestBriarApplication.class)
public class SetupActivityTest { public class SetupActivityTest {
TestSetupActivity setupActivity; private TestSetupActivity setupActivity;
TextInputLayout nicknameEntryWrapper; private TextInputLayout nicknameEntryWrapper;
TextInputLayout passwordEntryWrapper; private TextInputLayout passwordEntryWrapper;
TextInputLayout passwordConfirmationWrapper; private TextInputLayout passwordConfirmationWrapper;
EditText nicknameEntry; private EditText nicknameEntry;
EditText passwordEntry; private EditText passwordEntry;
EditText passwordConfirmation; private EditText passwordConfirmation;
StrengthMeter strengthMeter; private StrengthMeter strengthMeter;
Button createAccountButton; private Button createAccountButton;
@Mock @Mock
SetupController setupController; private SetupController setupController;
@Captor @Captor
ArgumentCaptor<ResultHandler<Long>> resultCaptor; private ArgumentCaptor<ResultHandler<Long>> resultCaptor;
@Before @Before
public void setUp() { public void setUp() {
@@ -225,5 +225,4 @@ public class SetupActivityTest {
Mockito.verify(mockedController, Mockito.times(1)) Mockito.verify(mockedController, Mockito.times(1))
.estimatePasswordStrength(eq("empty")); .estimatePasswordStrength(eq("empty"));
} }
} }

View File

@@ -12,13 +12,13 @@ import org.briarproject.android.DaggerAndroidComponent;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* This Class only exists to get around ACRA * This class only exists to avoid static initialisation of ACRA
*/ */
public class TestBriarApplicationImp extends Application implements public class TestBriarApplication extends Application
BriarApplication{ implements BriarApplication {
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(TestBriarApplicationImp.class.getName()); Logger.getLogger(TestBriarApplication.class.getName());
private AndroidComponent applicationComponent; private AndroidComponent applicationComponent;
@@ -37,6 +37,7 @@ public class TestBriarApplicationImp extends Application implements
AndroidEagerSingletons.initEagerSingletons(applicationComponent); AndroidEagerSingletons.initEagerSingletons(applicationComponent);
} }
@Override
public AndroidComponent getApplicationComponent() { public AndroidComponent getApplicationComponent() {
return applicationComponent; return applicationComponent;
} }

View File

@@ -10,11 +10,10 @@ import org.briarproject.android.controller.SetupController;
public class TestSetupActivity extends SetupActivity { public class TestSetupActivity extends SetupActivity {
public SetupController getController() { public SetupController getController() {
return this.setupController; return setupController;
} }
public void setController(SetupController setupController) { public void setController(SetupController setupController) {
this.setupController = setupController; this.setupController = setupController;
} }
} }