mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Moved lifecycle management into briar-core and reconfigured executors.
CryptoExecutor and DatabaseExecutor now use bounded thread pools with unbounded queues, since running too many tasks in parallel is likely to harm performance; IncomingConnectionExecutor, PluginExecutor and ReliabilityExecutor use unbounded thread pools with direct handoff, since their tasks may run indefinitely. There are no longer any bounded executors, and all executors discard tasks when shutting down, which fixes issue #3612189. Responsibility for starting and stopping services has been moved from BriarService in briar-android to LifecycleManagerImpl in briar-core. However, BriarService is still responsible for stopping the Android-specific executors, which is ugly. It would be better if executors registered themselves with LifecycleManager.
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package net.sf.briar.android;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import net.sf.briar.api.android.AndroidExecutor;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
@@ -34,15 +39,22 @@ public class AndroidModule extends AbstractModule {
|
||||
bind(AndroidExecutor.class).to(AndroidExecutorImpl.class);
|
||||
bind(ReferenceManager.class).to(ReferenceManagerImpl.class).in(
|
||||
Singleton.class);
|
||||
// Use a single thread so DB accesses from the UI don't overlap, with
|
||||
// an unbounded queue so submissions don't block
|
||||
bind(Executor.class).annotatedWith(DatabaseUiExecutor.class).toInstance(
|
||||
Executors.newSingleThreadExecutor());
|
||||
// The queue is unbounded, so tasks can be dependent
|
||||
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
|
||||
// Discard tasks that are submitted during shutdown
|
||||
RejectedExecutionHandler policy =
|
||||
new ThreadPoolExecutor.DiscardPolicy();
|
||||
// Use a single thread so DB accesses from the UI don't overlap
|
||||
ExecutorService e = new ThreadPoolExecutor(1, 1, 60, SECONDS, queue,
|
||||
policy);
|
||||
bind(Executor.class).annotatedWith(
|
||||
DatabaseUiExecutor.class).toInstance(e);
|
||||
bind(ExecutorService.class).annotatedWith(
|
||||
DatabaseUiExecutor.class).toInstance(e);
|
||||
}
|
||||
|
||||
@Provides
|
||||
SimplexPluginConfig getSimplexPluginConfig(
|
||||
@PluginExecutor ExecutorService pluginExecutor) {
|
||||
SimplexPluginConfig getSimplexPluginConfig() {
|
||||
return new SimplexPluginConfig() {
|
||||
public Collection<SimplexPluginFactory> getFactories() {
|
||||
return Collections.emptyList();
|
||||
@@ -52,7 +64,7 @@ public class AndroidModule extends AbstractModule {
|
||||
|
||||
@Provides
|
||||
DuplexPluginConfig getDuplexPluginConfig(
|
||||
@PluginExecutor ExecutorService pluginExecutor,
|
||||
@PluginExecutor Executor pluginExecutor,
|
||||
AndroidExecutor androidExecutor, Context appContext,
|
||||
CryptoComponent crypto, ShutdownManager shutdownManager) {
|
||||
DuplexPluginFactory droidtooth = new DroidtoothPluginFactory(
|
||||
|
||||
@@ -3,18 +3,15 @@ package net.sf.briar.android;
|
||||
import static android.app.PendingIntent.FLAG_ONE_SHOT;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.api.crypto.KeyManager;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DatabaseConfig;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.plugins.PluginManager;
|
||||
import net.sf.briar.api.android.AndroidExecutor;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import roboguice.service.RoboService;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
@@ -31,15 +28,12 @@ public class BriarService extends RoboService {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BriarService.class.getName());
|
||||
|
||||
private final CountDownLatch dbLatch = new CountDownLatch(1);
|
||||
private final CountDownLatch startupLatch = new CountDownLatch(1);
|
||||
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||
private final Binder binder = new BriarBinder();
|
||||
|
||||
@Inject private DatabaseConfig databaseConfig = null;
|
||||
@Inject private DatabaseComponent db = null;
|
||||
@Inject private KeyManager keyManager = null;
|
||||
@Inject private PluginManager pluginManager = null;
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
@Inject private volatile AndroidExecutor androidExecutor;
|
||||
@Inject @DatabaseUiExecutor private volatile ExecutorService dbUiExecutor;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -63,7 +57,7 @@ public class BriarService extends RoboService {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
startServices();
|
||||
lifecycleManager.startServices();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@@ -71,11 +65,11 @@ public class BriarService extends RoboService {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Started");
|
||||
return START_STICKY;
|
||||
return START_NOT_STICKY; // Don't restart automatically if killed
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Bound");
|
||||
return binder;
|
||||
}
|
||||
|
||||
@@ -87,71 +81,38 @@ public class BriarService extends RoboService {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
stopServices();
|
||||
// FIXME: This is ugly - executors should register themselves
|
||||
// with the lifecycle manager
|
||||
androidExecutor.shutdown();
|
||||
dbUiExecutor.shutdown();
|
||||
lifecycleManager.stopServices();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private void startServices() {
|
||||
if(databaseConfig.getEncryptionKey() == null)
|
||||
throw new IllegalStateException();
|
||||
try {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Starting");
|
||||
boolean reopened = db.open();
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
if(reopened) LOG.info("Database reopened");
|
||||
else LOG.info("Database created");
|
||||
}
|
||||
dbLatch.countDown();
|
||||
keyManager.start();
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Key manager started");
|
||||
int pluginsStarted = pluginManager.start();
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info(pluginsStarted + " plugins started");
|
||||
startupLatch.countDown();
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopServices() {
|
||||
try {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Shutting down");
|
||||
int pluginsStopped = pluginManager.stop();
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info(pluginsStopped + " plugins stopped");
|
||||
keyManager.stop();
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Key manager stopped");
|
||||
db.close();
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Database closed");
|
||||
shutdownLatch.countDown();
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/** Waits for the database to be opened before returning. */
|
||||
public void waitForDatabase() throws InterruptedException {
|
||||
dbLatch.await();
|
||||
lifecycleManager.waitForDatabase();
|
||||
}
|
||||
|
||||
/** Waits for all services to start before returning. */
|
||||
public void waitForStartup() throws InterruptedException {
|
||||
startupLatch.await();
|
||||
lifecycleManager.waitForStartup();
|
||||
}
|
||||
|
||||
/** Waits for all services to stop before returning. */
|
||||
public void waitForShutdown() throws InterruptedException {
|
||||
shutdownLatch.await();
|
||||
lifecycleManager.waitForShutdown();
|
||||
}
|
||||
|
||||
/** Starts the shutdown process. */
|
||||
public void shutdown() {
|
||||
stopSelf();
|
||||
stopSelf(); // This will call onDestroy()
|
||||
}
|
||||
|
||||
public class BriarBinder extends Binder {
|
||||
|
||||
/** Returns the bound service. */
|
||||
public BriarService getService() {
|
||||
return BriarService.this;
|
||||
}
|
||||
@@ -170,19 +131,10 @@ public class BriarService extends RoboService {
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {}
|
||||
|
||||
/** Waits for the service to connect and returns its binder. */
|
||||
public IBinder waitForBinder() throws InterruptedException {
|
||||
binderLatch.await();
|
||||
return binder;
|
||||
}
|
||||
|
||||
public void waitForDatabase() throws InterruptedException {
|
||||
waitForBinder();
|
||||
((BriarBinder) binder).getService().waitForDatabase();
|
||||
}
|
||||
|
||||
public void waitForStartup() throws InterruptedException {
|
||||
waitForBinder();
|
||||
((BriarBinder) binder).getService().waitForStartup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.sf.briar.api.crypto.CryptoExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DatabaseConfig;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.util.StringUtils;
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
@@ -70,18 +71,19 @@ public class HomeScreenActivity extends RoboActivity {
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private ReferenceManager referenceManager = null;
|
||||
@Inject private DatabaseConfig databaseConfig = null;
|
||||
@Inject @DatabaseUiExecutor private Executor dbUiExecutor = null;
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor = null;
|
||||
@Inject private ReferenceManager referenceManager;
|
||||
@Inject private DatabaseConfig databaseConfig;
|
||||
@Inject @DatabaseUiExecutor private Executor dbUiExecutor;
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
private boolean bound = false;
|
||||
private TextView enterPassword = null;
|
||||
private Button continueButton = null;
|
||||
private ProgressBar progress = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db = null;
|
||||
@Inject private volatile CryptoComponent crypto = null;
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -136,7 +138,7 @@ public class HomeScreenActivity extends RoboActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Wait for the service to be bound and started
|
||||
// Wait for the service to finish starting up
|
||||
IBinder binder = serviceConnection.waitForBinder();
|
||||
BriarService service = ((BriarBinder) binder).getService();
|
||||
service.waitForStartup();
|
||||
@@ -146,7 +148,7 @@ public class HomeScreenActivity extends RoboActivity {
|
||||
service.waitForShutdown();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while waiting for database");
|
||||
LOG.info("Interrupted while waiting for service");
|
||||
}
|
||||
// Finish the activity and kill the JVM
|
||||
runOnUiThread(new Runnable() {
|
||||
@@ -164,7 +166,7 @@ public class HomeScreenActivity extends RoboActivity {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.addLocalAuthor(a);
|
||||
db.setRating(a.getId(), GOOD);
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.AscendingHeaderComparator;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
import net.sf.briar.api.Author;
|
||||
@@ -33,6 +31,7 @@ import net.sf.briar.api.db.event.GroupMessageAddedEvent;
|
||||
import net.sf.briar.api.db.event.MessageExpiredEvent;
|
||||
import net.sf.briar.api.db.event.RatingChangedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionRemovedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
import android.content.Intent;
|
||||
@@ -53,9 +52,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BlogActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private String groupName = null;
|
||||
private boolean postable = false;
|
||||
private BlogAdapter adapter = null;
|
||||
@@ -65,6 +61,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile GroupId groupId = null;
|
||||
|
||||
@Override
|
||||
@@ -107,10 +104,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
layout.addView(composeButton);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +117,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<GroupMessageHeader> headers =
|
||||
db.getGroupMessageHeaders(groupId);
|
||||
@@ -196,12 +189,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof GroupMessageAddedEvent) {
|
||||
GroupMessageAddedEvent g = (GroupMessageAddedEvent) e;
|
||||
|
||||
@@ -21,8 +21,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
@@ -38,6 +36,7 @@ import net.sf.briar.api.db.event.MessageExpiredEvent;
|
||||
import net.sf.briar.api.db.event.RemoteSubscriptionsUpdatedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionAddedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionRemovedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.GroupStatus;
|
||||
@@ -61,9 +60,6 @@ OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BlogListActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private BlogListAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
@@ -73,6 +69,7 @@ OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -126,10 +123,6 @@ OnItemClickListener {
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,7 +137,7 @@ OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Set<GroupId> local = new HashSet<GroupId>();
|
||||
for(Group g : db.getLocalGroups()) local.add(g.getId());
|
||||
@@ -252,12 +245,6 @@ OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof GroupMessageAddedEvent) {
|
||||
Group g = ((GroupMessageAddedEvent) e).getGroup();
|
||||
@@ -292,7 +279,7 @@ OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<GroupMessageHeader> headers =
|
||||
db.getGroupMessageHeaders(g.getId());
|
||||
@@ -333,7 +320,7 @@ OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
int available = 0;
|
||||
long now = System.currentTimeMillis();
|
||||
for(GroupStatus s : db.getAvailableGroups()) {
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.contact.SelectContactsDialog;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import net.sf.briar.android.messages.NoContactsDialog;
|
||||
@@ -25,6 +23,7 @@ import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
@@ -48,9 +47,6 @@ SelectContactsDialog.Listener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConfigureBlogActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private boolean subscribed = false;
|
||||
private CheckBox subscribeCheckBox = null;
|
||||
private RadioGroup radioGroup = null;
|
||||
@@ -61,6 +57,7 @@ SelectContactsDialog.Listener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile Group group = null;
|
||||
private volatile Collection<ContactId> selected = Collections.emptyList();
|
||||
|
||||
@@ -127,16 +124,6 @@ SelectContactsDialog.Listener {
|
||||
layout.addView(progress);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
@@ -164,7 +151,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Contact> contacts = db.getContacts();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -208,7 +195,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
if(subscribe) {
|
||||
if(!wasSubscribed) db.subscribe(group);
|
||||
|
||||
@@ -21,8 +21,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.contact.SelectContactsDialog;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import net.sf.briar.android.messages.NoContactsDialog;
|
||||
@@ -33,6 +31,7 @@ import net.sf.briar.api.crypto.CryptoComponent;
|
||||
import net.sf.briar.api.crypto.CryptoExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.GroupFactory;
|
||||
import net.sf.briar.api.messaging.LocalGroup;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
@@ -60,9 +59,6 @@ SelectContactsDialog.Listener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CreateBlogActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
private EditText nameEntry = null;
|
||||
private RadioGroup radioGroup = null;
|
||||
@@ -75,6 +71,7 @@ SelectContactsDialog.Listener {
|
||||
@Inject private volatile GroupFactory groupFactory;
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile Collection<ContactId> selected = Collections.emptyList();
|
||||
|
||||
@Override
|
||||
@@ -135,10 +132,6 @@ SelectContactsDialog.Listener {
|
||||
layout.addView(progress);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
private void enableOrDisableCreateButton() {
|
||||
@@ -149,12 +142,6 @@ SelectContactsDialog.Listener {
|
||||
createButton.setEnabled(nameNotEmpty && visibilitySelected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
||||
validateName();
|
||||
return true;
|
||||
@@ -197,7 +184,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Contact> contacts = db.getContacts();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -240,7 +227,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.addLocalGroup(g);
|
||||
db.subscribe(g);
|
||||
|
||||
@@ -13,8 +13,6 @@ import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
@@ -24,6 +22,7 @@ import net.sf.briar.api.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.db.event.RemoteSubscriptionsUpdatedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionAddedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionRemovedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupStatus;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
@@ -42,9 +41,6 @@ implements DatabaseListener, OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ManageBlogsActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private ManageBlogsAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
@@ -52,6 +48,7 @@ implements DatabaseListener, OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -66,10 +63,6 @@ implements DatabaseListener, OnItemClickListener {
|
||||
// Show a progress bar while the list is loading
|
||||
loading = new ListLoadingProgressBar(this);
|
||||
setContentView(loading);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +76,7 @@ implements DatabaseListener, OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
List<GroupStatus> available = new ArrayList<GroupStatus>();
|
||||
for(GroupStatus s : db.getAvailableGroups())
|
||||
@@ -125,12 +118,6 @@ implements DatabaseListener, OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof RemoteSubscriptionsUpdatedEvent) {
|
||||
if(LOG.isLoggable(INFO))
|
||||
|
||||
@@ -19,14 +19,13 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.db.NoSuchMessageException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
import net.sf.briar.api.messaging.Rating;
|
||||
@@ -55,9 +54,6 @@ implements OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ReadBlogPostActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private GroupId groupId = null;
|
||||
private boolean postable = false;
|
||||
private Rating rating = UNRATED;
|
||||
@@ -70,6 +66,7 @@ implements OnClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile MessageId messageId = null;
|
||||
|
||||
@Override
|
||||
@@ -196,17 +193,13 @@ implements OnClickListener {
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
private void setReadInDatabase(final boolean read) {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.setReadFlag(messageId, read);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -239,7 +232,7 @@ implements OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
byte[] body = db.getMessageBody(messageId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -278,12 +271,6 @@ implements OnClickListener {
|
||||
state.putBoolean("net.sf.briar.READ", read);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if(view == readButton) {
|
||||
setReadInDatabase(!read);
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.identity.CreateIdentityActivity;
|
||||
import net.sf.briar.android.identity.LocalAuthorItem;
|
||||
import net.sf.briar.android.identity.LocalAuthorItemComparator;
|
||||
@@ -31,6 +29,7 @@ import net.sf.briar.api.crypto.CryptoComponent;
|
||||
import net.sf.briar.api.crypto.KeyParser;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.LocalGroup;
|
||||
import net.sf.briar.api.messaging.Message;
|
||||
@@ -58,9 +57,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(WriteBlogPostActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private MessageFactory messageFactory;
|
||||
private LocalAuthorSpinnerAdapter fromAdapter = null;
|
||||
@@ -74,6 +70,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile LocalAuthor localAuthor = null;
|
||||
private volatile LocalGroup localGroup = null;
|
||||
private volatile MessageId parentId = null;
|
||||
@@ -152,10 +149,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
layout.addView(content);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,7 +162,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<LocalAuthor> localAuthors = db.getLocalAuthors();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -216,7 +209,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<LocalGroup> groups = db.getLocalGroups();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -269,12 +262,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
if(parent == fromSpinner) {
|
||||
@@ -350,7 +337,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.addLocalGroupMessage(m);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
|
||||
@@ -22,8 +22,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||
@@ -37,6 +35,7 @@ import net.sf.briar.api.db.event.ContactAddedEvent;
|
||||
import net.sf.briar.api.db.event.ContactRemovedEvent;
|
||||
import net.sf.briar.api.db.event.DatabaseEvent;
|
||||
import net.sf.briar.api.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.transport.ConnectionListener;
|
||||
import net.sf.briar.api.transport.ConnectionRegistry;
|
||||
import roboguice.activity.RoboActivity;
|
||||
@@ -60,9 +59,6 @@ ConnectionListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ContactListActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private ConnectionRegistry connectionRegistry;
|
||||
private ContactListAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
@@ -72,6 +68,7 @@ ConnectionListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -118,10 +115,6 @@ ConnectionListener {
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,7 +129,7 @@ ConnectionListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Contact> contacts = db.getContacts();
|
||||
Map<ContactId, Long> times = db.getLastConnected();
|
||||
@@ -182,12 +175,6 @@ ConnectionListener {
|
||||
connectionRegistry.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if(view == addContactButton) {
|
||||
startActivity(new Intent(this, AddContactActivity.class));
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.contact.SelectContactsDialog;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import net.sf.briar.android.messages.NoContactsDialog;
|
||||
@@ -25,6 +23,7 @@ import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
@@ -48,9 +47,6 @@ SelectContactsDialog.Listener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConfigureGroupActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private boolean subscribed = false;
|
||||
private CheckBox subscribeCheckBox = null;
|
||||
private RadioGroup radioGroup = null;
|
||||
@@ -61,6 +57,7 @@ SelectContactsDialog.Listener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile Group group = null;
|
||||
private volatile Collection<ContactId> selected = Collections.emptyList();
|
||||
|
||||
@@ -125,16 +122,6 @@ SelectContactsDialog.Listener {
|
||||
layout.addView(progress);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
@@ -162,7 +149,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Contact> contacts = db.getContacts();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -206,7 +193,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
if(subscribe) {
|
||||
if(!wasSubscribed) db.subscribe(group);
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.contact.SelectContactsDialog;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import net.sf.briar.android.messages.NoContactsDialog;
|
||||
@@ -30,6 +28,7 @@ import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupFactory;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
@@ -57,9 +56,6 @@ SelectContactsDialog.Listener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CreateGroupActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private EditText nameEntry = null;
|
||||
private RadioGroup radioGroup = null;
|
||||
private RadioButton visibleToAll = null, visibleToSome = null;
|
||||
@@ -70,6 +66,7 @@ SelectContactsDialog.Listener {
|
||||
@Inject private volatile GroupFactory groupFactory;
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile Collection<ContactId> selected = Collections.emptyList();
|
||||
|
||||
@Override
|
||||
@@ -129,10 +126,6 @@ SelectContactsDialog.Listener {
|
||||
layout.addView(progress);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
private void enableOrDisableCreateButton() {
|
||||
@@ -143,12 +136,6 @@ SelectContactsDialog.Listener {
|
||||
createButton.setEnabled(nameNotEmpty && visibilitySelected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
||||
validateName();
|
||||
return true;
|
||||
@@ -172,7 +159,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
Group g = groupFactory.createGroup(name);
|
||||
long now = System.currentTimeMillis();
|
||||
db.subscribe(g);
|
||||
@@ -206,7 +193,7 @@ SelectContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Contact> contacts = db.getContacts();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.AscendingHeaderComparator;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
import net.sf.briar.api.Author;
|
||||
@@ -33,6 +31,7 @@ import net.sf.briar.api.db.event.GroupMessageAddedEvent;
|
||||
import net.sf.briar.api.db.event.MessageExpiredEvent;
|
||||
import net.sf.briar.api.db.event.RatingChangedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionRemovedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
@@ -53,9 +52,6 @@ OnClickListener, OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(GroupActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private String groupName = null;
|
||||
private GroupAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
@@ -64,6 +60,7 @@ OnClickListener, OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile GroupId groupId = null;
|
||||
|
||||
@Override
|
||||
@@ -105,10 +102,6 @@ OnClickListener, OnItemClickListener {
|
||||
layout.addView(composeButton);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,7 +115,7 @@ OnClickListener, OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<GroupMessageHeader> headers =
|
||||
db.getGroupMessageHeaders(groupId);
|
||||
@@ -194,12 +187,6 @@ OnClickListener, OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof GroupMessageAddedEvent) {
|
||||
GroupMessageAddedEvent g = (GroupMessageAddedEvent) e;
|
||||
|
||||
@@ -19,8 +19,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
@@ -36,6 +34,7 @@ import net.sf.briar.api.db.event.MessageExpiredEvent;
|
||||
import net.sf.briar.api.db.event.RemoteSubscriptionsUpdatedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionAddedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionRemovedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.GroupStatus;
|
||||
@@ -59,9 +58,6 @@ OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(GroupListActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private GroupListAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
@@ -71,6 +67,7 @@ OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -124,10 +121,6 @@ OnItemClickListener {
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +135,7 @@ OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
int available = 0;
|
||||
long now = System.currentTimeMillis();
|
||||
for(GroupStatus s : db.getAvailableGroups()) {
|
||||
@@ -247,12 +240,6 @@ OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof GroupMessageAddedEvent) {
|
||||
Group g = ((GroupMessageAddedEvent) e).getGroup();
|
||||
@@ -287,7 +274,7 @@ OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<GroupMessageHeader> headers =
|
||||
db.getGroupMessageHeaders(g.getId());
|
||||
@@ -327,7 +314,7 @@ OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
int available = 0;
|
||||
long now = System.currentTimeMillis();
|
||||
for(GroupStatus s : db.getAvailableGroups()) {
|
||||
|
||||
@@ -13,8 +13,6 @@ import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
@@ -24,6 +22,7 @@ import net.sf.briar.api.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.db.event.RemoteSubscriptionsUpdatedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionAddedEvent;
|
||||
import net.sf.briar.api.db.event.SubscriptionRemovedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupStatus;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
@@ -42,9 +41,6 @@ implements DatabaseListener, OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ManageGroupsActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private ManageGroupsAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
@@ -52,6 +48,7 @@ implements DatabaseListener, OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -66,10 +63,6 @@ implements DatabaseListener, OnItemClickListener {
|
||||
// Show a progress bar while the list is loading
|
||||
loading = new ListLoadingProgressBar(this);
|
||||
setContentView(loading);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +76,7 @@ implements DatabaseListener, OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
List<GroupStatus> available = new ArrayList<GroupStatus>();
|
||||
for(GroupStatus s : db.getAvailableGroups())
|
||||
@@ -125,12 +118,6 @@ implements DatabaseListener, OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof RemoteSubscriptionsUpdatedEvent) {
|
||||
if(LOG.isLoggable(INFO))
|
||||
|
||||
@@ -19,8 +19,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||
import net.sf.briar.api.AuthorId;
|
||||
@@ -28,6 +26,7 @@ import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.db.NoSuchMessageException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
import net.sf.briar.api.messaging.Rating;
|
||||
@@ -56,9 +55,6 @@ implements OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ReadGroupPostActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private GroupId groupId = null;
|
||||
private Rating rating = UNRATED;
|
||||
private boolean read;
|
||||
@@ -71,6 +67,7 @@ implements OnClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile MessageId messageId = null;
|
||||
private volatile AuthorId authorId = null;
|
||||
|
||||
@@ -220,17 +217,13 @@ implements OnClickListener {
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
private void setReadInDatabase(final boolean read) {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.setReadFlag(messageId, read);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -263,7 +256,7 @@ implements OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
byte[] body = db.getMessageBody(messageId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -302,12 +295,6 @@ implements OnClickListener {
|
||||
state.putBoolean("net.sf.briar.READ", read);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if(view == goodButton) {
|
||||
if(rating == BAD) setRatingInDatabase(UNRATED);
|
||||
@@ -337,7 +324,7 @@ implements OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.setRating(authorId, r);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.identity.CreateIdentityActivity;
|
||||
import net.sf.briar.android.identity.LocalAuthorItem;
|
||||
import net.sf.briar.android.identity.LocalAuthorItemComparator;
|
||||
@@ -34,6 +32,7 @@ import net.sf.briar.api.crypto.CryptoComponent;
|
||||
import net.sf.briar.api.crypto.KeyParser;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.Message;
|
||||
@@ -61,9 +60,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(WriteGroupPostActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private MessageFactory messageFactory;
|
||||
private LocalAuthorSpinnerAdapter fromAdapter = null;
|
||||
@@ -77,6 +73,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile LocalAuthor localAuthor = null;
|
||||
private volatile Group group = null;
|
||||
private volatile MessageId parentId = null;
|
||||
@@ -155,10 +152,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
layout.addView(content);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,7 +165,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<LocalAuthor> localAuthors = db.getLocalAuthors();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -219,7 +212,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
long now = System.currentTimeMillis();
|
||||
for(Group g : db.getSubscriptions())
|
||||
@@ -274,12 +267,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
if(parent == fromSpinner) {
|
||||
@@ -352,7 +339,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.addLocalGroupMessage(m);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.api.AuthorFactory;
|
||||
import net.sf.briar.api.LocalAuthor;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
@@ -29,8 +27,8 @@ import net.sf.briar.api.crypto.CryptoComponent;
|
||||
import net.sf.briar.api.crypto.CryptoExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -51,9 +49,6 @@ implements OnEditorActionListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CreateIdentityActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
private EditText nicknameEntry = null;
|
||||
private Button createButton = null;
|
||||
@@ -64,6 +59,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
@Inject private volatile AuthorFactory authorFactory;
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -109,16 +105,6 @@ implements OnEditorActionListener, OnClickListener {
|
||||
layout.addView(progress);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
|
||||
@@ -154,7 +140,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.addLocalAuthor(a);
|
||||
db.setRating(a.getId(), GOOD);
|
||||
|
||||
@@ -12,8 +12,6 @@ import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.identity.LocalAuthorItem;
|
||||
import net.sf.briar.android.identity.LocalAuthorItemComparator;
|
||||
import net.sf.briar.android.identity.LocalAuthorSpinnerAdapter;
|
||||
@@ -28,6 +26,7 @@ import net.sf.briar.api.invitation.InvitationListener;
|
||||
import net.sf.briar.api.invitation.InvitationState;
|
||||
import net.sf.briar.api.invitation.InvitationTask;
|
||||
import net.sf.briar.api.invitation.InvitationTaskFactory;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -46,9 +45,6 @@ implements InvitationListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AddContactActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private InvitationTaskFactory invitationTaskFactory;
|
||||
@Inject private ReferenceManager referenceManager;
|
||||
@@ -69,6 +65,7 @@ implements InvitationListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -159,10 +156,6 @@ implements InvitationListener {
|
||||
if(info.getNetworkId() != -1) networkName = info.getSSID();
|
||||
}
|
||||
view.wifiStateChanged();
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,7 +183,6 @@ implements InvitationListener {
|
||||
super.onDestroy();
|
||||
if(task != null) task.removeListener(this);
|
||||
unregisterReceiver(receiver);
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
void setView(AddContactView view) {
|
||||
@@ -216,7 +208,7 @@ implements InvitationListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<LocalAuthor> localAuthors = db.getLocalAuthors();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.AscendingHeaderComparator;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
import net.sf.briar.api.AuthorId;
|
||||
@@ -31,6 +29,7 @@ import net.sf.briar.api.db.event.DatabaseEvent;
|
||||
import net.sf.briar.api.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.db.event.MessageExpiredEvent;
|
||||
import net.sf.briar.api.db.event.PrivateMessageAddedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -50,9 +49,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private String contactName = null;
|
||||
private ConversationAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
@@ -61,6 +57,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile ContactId contactId = null;
|
||||
private volatile AuthorId localAuthorId = null;
|
||||
|
||||
@@ -106,10 +103,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
layout.addView(composeButton);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +116,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<PrivateMessageHeader> headers =
|
||||
db.getPrivateMessageHeaders(contactId);
|
||||
@@ -196,12 +189,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof ContactRemovedEvent) {
|
||||
ContactRemovedEvent c = (ContactRemovedEvent) e;
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.ListLoadingProgressBar;
|
||||
@@ -32,6 +30,7 @@ import net.sf.briar.api.db.event.DatabaseEvent;
|
||||
import net.sf.briar.api.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.db.event.MessageExpiredEvent;
|
||||
import net.sf.briar.api.db.event.PrivateMessageAddedEvent;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import roboguice.activity.RoboFragmentActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -49,9 +48,6 @@ implements OnClickListener, DatabaseListener, NoContactsDialog.Listener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationListActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private ConversationListAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
@@ -59,6 +55,7 @@ implements OnClickListener, DatabaseListener, NoContactsDialog.Listener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -90,10 +87,6 @@ implements OnClickListener, DatabaseListener, NoContactsDialog.Listener {
|
||||
layout.addView(composeButton);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +101,7 @@ implements OnClickListener, DatabaseListener, NoContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
for(Contact c : db.getContacts()) {
|
||||
try {
|
||||
@@ -191,12 +184,6 @@ implements OnClickListener, DatabaseListener, NoContactsDialog.Listener {
|
||||
db.removeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if(adapter.isEmpty()) {
|
||||
NoContactsDialog dialog = new NoContactsDialog();
|
||||
@@ -225,7 +212,7 @@ implements OnClickListener, DatabaseListener, NoContactsDialog.Listener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Contact contact = db.getContact(c);
|
||||
Collection<PrivateMessageHeader> headers =
|
||||
|
||||
@@ -19,8 +19,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
import net.sf.briar.android.widgets.HorizontalSpace;
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -28,6 +26,7 @@ import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.db.NoSuchMessageException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
import net.sf.briar.api.messaging.Rating;
|
||||
import roboguice.activity.RoboActivity;
|
||||
@@ -55,9 +54,6 @@ implements OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ReadPrivateMessageActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private ContactId contactId = null;
|
||||
private Rating rating = UNRATED;
|
||||
private boolean read;
|
||||
@@ -68,6 +64,7 @@ implements OnClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
private volatile MessageId messageId = null;
|
||||
|
||||
@Override
|
||||
@@ -190,17 +187,13 @@ implements OnClickListener {
|
||||
layout.addView(footer);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
private void setReadInDatabase(final boolean read) {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
db.setReadFlag(messageId, read);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -233,7 +226,7 @@ implements OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
byte[] body = db.getMessageBody(messageId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -272,12 +265,6 @@ implements OnClickListener {
|
||||
state.putBoolean("net.sf.briar.READ", read);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if(view == readButton) {
|
||||
setReadInDatabase(!read);
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.contact.ContactItem;
|
||||
import net.sf.briar.android.contact.ContactItemComparator;
|
||||
import net.sf.briar.android.contact.ContactSpinnerAdapter;
|
||||
@@ -31,6 +29,7 @@ import net.sf.briar.api.LocalAuthor;
|
||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Message;
|
||||
import net.sf.briar.api.messaging.MessageFactory;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
@@ -56,9 +55,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(WritePrivateMessageActivity.class.getName());
|
||||
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
private TextView from = null;
|
||||
private ContactSpinnerAdapter adapter = null;
|
||||
private Spinner spinner = null;
|
||||
@@ -68,6 +64,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
@Inject private volatile MessageFactory messageFactory;
|
||||
private volatile LocalAuthor localAuthor = null;
|
||||
private volatile ContactId contactId = null;
|
||||
@@ -139,10 +136,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
layout.addView(content);
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
// Bind to the service so we can wait for it to start
|
||||
bindService(new Intent(BriarService.class.getName()),
|
||||
serviceConnection, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,7 +148,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Contact> contacts = db.getContacts();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -201,12 +194,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
state.putInt("net.sf.briar.CONTACT_ID", contactId.getInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbindService(serviceConnection);
|
||||
}
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
ContactItem item = adapter.getItem(position);
|
||||
@@ -227,7 +214,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
localAuthor = db.getLocalAuthor(a);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
@@ -277,7 +264,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
serviceConnection.waitForDatabase();
|
||||
lifecycleManager.waitForDatabase();
|
||||
Message m = messageFactory.createPrivateMessage(parentId,
|
||||
"text/plain", body);
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
Reference in New Issue
Block a user