mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Switched Roboguice/Guice out for Dagger 2
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import org.briarproject.android.contact.ContactListFragment;
|
||||
import org.briarproject.android.contact.ConversationActivity;
|
||||
import org.briarproject.android.forum.AvailableForumsActivity;
|
||||
import org.briarproject.android.forum.CreateForumActivity;
|
||||
import org.briarproject.android.forum.ForumActivity;
|
||||
import org.briarproject.android.forum.ForumListFragment;
|
||||
import org.briarproject.android.forum.ReadForumPostActivity;
|
||||
import org.briarproject.android.forum.ShareForumActivity;
|
||||
import org.briarproject.android.forum.WriteForumPostActivity;
|
||||
import org.briarproject.android.fragment.SettingsFragment;
|
||||
import org.briarproject.android.identity.CreateIdentityActivity;
|
||||
import org.briarproject.android.invitation.AddContactActivity;
|
||||
import org.briarproject.android.panic.PanicPreferencesActivity;
|
||||
import org.briarproject.android.panic.PanicResponderActivity;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.forum.ForumModule;
|
||||
import org.briarproject.identity.IdentityModule;
|
||||
import org.briarproject.invitation.InvitationModule;
|
||||
import org.briarproject.lifecycle.LifecycleModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.plugins.AndroidPluginsModule;
|
||||
import org.briarproject.properties.PropertiesModule;
|
||||
import org.briarproject.reliability.ReliabilityModule;
|
||||
import org.briarproject.settings.SettingsModule;
|
||||
import org.briarproject.sync.SyncModule;
|
||||
import org.briarproject.system.AndroidSystemModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import dagger.Component;
|
||||
@Singleton
|
||||
@Component(
|
||||
modules = {AppModule.class, AndroidModule.class, DatabaseModule.class,
|
||||
CryptoModule.class, LifecycleModule.class,
|
||||
ReliabilityModule.class, MessagingModule.class,
|
||||
InvitationModule.class, ForumModule.class, IdentityModule.class,
|
||||
EventModule.class, DataModule.class, ContactModule.class,
|
||||
AndroidSystemModule.class, AndroidPluginsModule.class,
|
||||
PropertiesModule.class, TransportModule.class, SyncModule.class,
|
||||
SettingsModule.class})
|
||||
public interface AndroidComponent {
|
||||
void inject(SplashScreenActivity activity);
|
||||
void inject(SetupActivity activity);
|
||||
void inject(NavDrawerActivity activity);
|
||||
void inject(PasswordActivity activity);
|
||||
void inject(BriarService activity);
|
||||
void inject(PanicResponderActivity activity);
|
||||
void inject(PanicPreferencesActivity activity);
|
||||
void inject(AddContactActivity activity);
|
||||
void inject(ConversationActivity activity);
|
||||
void inject(CreateIdentityActivity activity);
|
||||
void inject(TestingActivity activity);
|
||||
void inject(AvailableForumsActivity activity);
|
||||
void inject(WriteForumPostActivity activity);
|
||||
void inject(CreateForumActivity activity);
|
||||
void inject(ShareForumActivity activity);
|
||||
void inject(ReadForumPostActivity activity);
|
||||
void inject(ForumActivity activity);
|
||||
void inject(ContactListFragment fragment);
|
||||
void inject(SettingsFragment fragment);
|
||||
void inject(ForumListFragment fragment);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
@@ -18,9 +17,13 @@ import java.io.File;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
public class AndroidModule extends AbstractModule {
|
||||
@Module
|
||||
public class AndroidModule {
|
||||
|
||||
private final UiCallback uiCallback;
|
||||
|
||||
@@ -42,17 +45,27 @@ public class AndroidModule extends AbstractModule {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AndroidExecutor.class).to(AndroidExecutorImpl.class).in(
|
||||
Singleton.class);
|
||||
bind(ReferenceManager.class).to(ReferenceManagerImpl.class).in(
|
||||
Singleton.class);
|
||||
bind(UiCallback.class).toInstance(uiCallback);
|
||||
@Provides
|
||||
UiCallback provideUICallback() {
|
||||
return uiCallback;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
DatabaseConfig getDatabaseConfig(final Application app) {
|
||||
@Provides
|
||||
@Singleton
|
||||
ReferenceManager provideReferenceManager() {
|
||||
return new ReferenceManagerImpl();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AndroidExecutor provideAndroidExecutor(
|
||||
AndroidExecutorImpl androidExecutor) {
|
||||
return androidExecutor;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
DatabaseConfig provideDatabaseConfig(final Application app) {
|
||||
final File dir = app.getApplicationContext().getDir("db", MODE_PRIVATE);
|
||||
return new DatabaseConfig() {
|
||||
|
||||
@@ -80,12 +93,15 @@ public class AndroidModule extends AbstractModule {
|
||||
};
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
AndroidNotificationManager getAndroidNotificationManager(
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AndroidNotificationManager provideAndroidNotificationManager(
|
||||
LifecycleManager lifecycleManager, EventBus eventBus,
|
||||
AndroidNotificationManagerImpl notificationManager) {
|
||||
lifecycleManager.register(notificationManager);
|
||||
eventBus.addListener(notificationManager);
|
||||
return notificationManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
25
briar-android/src/org/briarproject/android/AppModule.java
Normal file
25
briar-android/src/org/briarproject/android/AppModule.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class AppModule {
|
||||
|
||||
Application application;
|
||||
|
||||
public AppModule(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Application providesApplication() {
|
||||
return application;
|
||||
}
|
||||
}
|
||||
@@ -9,125 +9,31 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Key;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
import roboguice.activity.event.OnActivityResultEvent;
|
||||
import roboguice.activity.event.OnConfigurationChangedEvent;
|
||||
import roboguice.activity.event.OnContentChangedEvent;
|
||||
import roboguice.activity.event.OnCreateEvent;
|
||||
import roboguice.activity.event.OnDestroyEvent;
|
||||
import roboguice.activity.event.OnNewIntentEvent;
|
||||
import roboguice.activity.event.OnPauseEvent;
|
||||
import roboguice.activity.event.OnRestartEvent;
|
||||
import roboguice.activity.event.OnResumeEvent;
|
||||
import roboguice.activity.event.OnStartEvent;
|
||||
import roboguice.activity.event.OnStopEvent;
|
||||
import roboguice.event.EventManager;
|
||||
import roboguice.inject.RoboInjector;
|
||||
import roboguice.util.RoboContext;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
|
||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity
|
||||
implements RoboContext {
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
public final static String PREFS_NAME = "db";
|
||||
public final static String PREF_DB_KEY = "key";
|
||||
public final static String PREF_SEEN_WELCOME_MESSAGE = "welcome_message";
|
||||
|
||||
private final HashMap<Key<?>, Object> scopedObjects =
|
||||
new HashMap<Key<?>, Object>();
|
||||
|
||||
@Inject private EventManager eventManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
RoboInjector injector = RoboGuice.getInjector(this);
|
||||
injector.injectMembersWithoutViews(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
eventManager.fire(new OnCreateEvent(savedInstanceState));
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
AndroidComponent component =
|
||||
((BriarApplication) getApplication()).getApplicationComponent();
|
||||
injectActivity(component);
|
||||
}
|
||||
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
eventManager.fire(new OnRestartEvent());
|
||||
}
|
||||
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
eventManager.fire(new OnStartEvent());
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
eventManager.fire(new OnResumeEvent());
|
||||
}
|
||||
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
eventManager.fire(new OnPauseEvent());
|
||||
}
|
||||
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
eventManager.fire(new OnNewIntentEvent());
|
||||
}
|
||||
|
||||
protected void onStop() {
|
||||
try {
|
||||
eventManager.fire(new OnStopEvent());
|
||||
} finally {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void onDestroy() {
|
||||
try {
|
||||
eventManager.fire(new OnDestroyEvent());
|
||||
} finally {
|
||||
try {
|
||||
RoboGuice.destroyInjector(this);
|
||||
} finally {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
Configuration currentConfig = getResources().getConfiguration();
|
||||
super.onConfigurationChanged(newConfig);
|
||||
eventManager.fire(new OnConfigurationChangedEvent(currentConfig,
|
||||
newConfig));
|
||||
}
|
||||
|
||||
public void onContentChanged() {
|
||||
super.onContentChanged();
|
||||
RoboGuice.getInjector(this).injectViewMembers(this);
|
||||
eventManager.fire(new OnContentChangedEvent());
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode,
|
||||
Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
eventManager.fire(new OnActivityResultEvent(requestCode, resultCode,
|
||||
data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Key<?>, Object> getScopedObjectMap() {
|
||||
return scopedObjects;
|
||||
}
|
||||
public abstract void injectActivity(AndroidComponent component);
|
||||
|
||||
private SharedPreferences getSharedPrefs() {
|
||||
return getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
|
||||
|
||||
@@ -27,7 +27,8 @@ import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
@SuppressLint("Registered")
|
||||
public abstract class BriarActivity extends BaseActivity {
|
||||
|
||||
public static final String KEY_LOCAL_AUTHOR_HANDLE = "briar.LOCAL_AUTHOR_HANDLE";
|
||||
public static final String KEY_LOCAL_AUTHOR_HANDLE =
|
||||
"briar.LOCAL_AUTHOR_HANDLE";
|
||||
public static final String KEY_STARTUP_FAILED = "briar.STARTUP_FAILED";
|
||||
|
||||
public static final int REQUEST_PASSWORD = 1;
|
||||
@@ -38,16 +39,21 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private DatabaseConfig databaseConfig;
|
||||
@Inject
|
||||
DatabaseConfig databaseConfig;
|
||||
private boolean bound = false;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject @DatabaseExecutor private volatile Executor dbExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
@Inject
|
||||
@DatabaseExecutor
|
||||
protected volatile Executor dbExecutor;
|
||||
@Inject
|
||||
protected volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (databaseConfig.getEncryptionKey() != null) startAndBindService();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ public class BriarApplication extends Application {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BriarApplication.class.getName());
|
||||
|
||||
private AndroidComponent applicationComponent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@@ -20,5 +22,14 @@ public class BriarApplication extends Application {
|
||||
Context ctx = getApplicationContext();
|
||||
CrashHandler newHandler = new CrashHandler(ctx, oldHandler);
|
||||
Thread.setDefaultUncaughtExceptionHandler(newHandler);
|
||||
|
||||
applicationComponent = DaggerAndroidComponent.builder()
|
||||
.appModule(new AppModule(this))
|
||||
.androidModule(new AndroidModule())
|
||||
.build();
|
||||
}
|
||||
|
||||
public AndroidComponent getApplicationComponent() {
|
||||
return applicationComponent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.android;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
@@ -22,8 +23,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.service.RoboService;
|
||||
|
||||
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
@@ -34,7 +33,7 @@ import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.ALREADY_RUNNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.SUCCESS;
|
||||
|
||||
public class BriarService extends RoboService {
|
||||
public class BriarService extends Service {
|
||||
|
||||
private static final int ONGOING_NOTIFICATION_ID = 1;
|
||||
private static final int FAILURE_NOTIFICATION_ID = 2;
|
||||
@@ -45,16 +44,20 @@ public class BriarService extends RoboService {
|
||||
private final AtomicBoolean created = new AtomicBoolean(false);
|
||||
private final Binder binder = new BriarBinder();
|
||||
|
||||
@Inject private DatabaseConfig databaseConfig;
|
||||
@Inject protected DatabaseConfig databaseConfig;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
@Inject private volatile AndroidExecutor androidExecutor;
|
||||
@Inject protected volatile LifecycleManager lifecycleManager;
|
||||
@Inject protected volatile AndroidExecutor androidExecutor;
|
||||
private volatile boolean started = false;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
((BriarApplication) this.getApplication())
|
||||
.getApplicationComponent().inject(this);
|
||||
|
||||
LOG.info("Created");
|
||||
if (created.getAndSet(true)) {
|
||||
LOG.info("Already created");
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -42,9 +43,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
import roboguice.inject.InjectView;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
@@ -60,33 +58,23 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
||||
@Inject
|
||||
private ReferenceManager referenceManager;
|
||||
protected ReferenceManager referenceManager;
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
private volatile IdentityManager identityManager;
|
||||
protected volatile IdentityManager identityManager;
|
||||
@Inject
|
||||
private PluginManager pluginManager;
|
||||
protected PluginManager pluginManager;
|
||||
@Inject
|
||||
protected volatile EventBus eventBus;
|
||||
|
||||
@InjectView(R.id.toolbar)
|
||||
private Toolbar toolbar;
|
||||
@InjectView(R.id.drawer_layout)
|
||||
private DrawerLayout drawerLayout;
|
||||
@InjectView(R.id.nav_btn_contacts)
|
||||
private AppCompatButton contactButton;
|
||||
@InjectView(R.id.nav_btn_contacts)
|
||||
private AppCompatButton forumsButton;
|
||||
@InjectView(R.id.nav_btn_contacts)
|
||||
private AppCompatButton settingsButton;
|
||||
@InjectView(R.id.nav_menu_header)
|
||||
private TextView menuHeader;
|
||||
@InjectView(R.id.title_progress_bar)
|
||||
private TextView progressTitle;
|
||||
@InjectView(R.id.container_progress)
|
||||
ViewGroup progressViewGroup;
|
||||
@InjectView(R.id.transportsView)
|
||||
private Button contactButton;
|
||||
private Button forumsButton;
|
||||
private Button settingsButton;
|
||||
private GridView transportsView;
|
||||
private TextView progressTitle;
|
||||
private ViewGroup progressViewGroup;
|
||||
|
||||
private List<Transport> transports;
|
||||
private BaseAdapter transportsAdapter;
|
||||
@@ -104,6 +92,11 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -112,9 +105,16 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
if (isStartupFailed(getIntent()))
|
||||
return;
|
||||
|
||||
// TODO inflate and inject with @ContentView with RoboGuice 3.0 and later
|
||||
setContentView(R.layout.activity_nav_drawer);
|
||||
RoboGuice.getInjector(this).injectViewMembers(this);
|
||||
|
||||
toolbar = (Toolbar)findViewById(R.id.toolbar);
|
||||
drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
|
||||
contactButton = (Button)findViewById(R.id.nav_btn_contacts);
|
||||
forumsButton = (Button)findViewById(R.id.nav_btn_forums);
|
||||
settingsButton = (Button)findViewById(R.id.nav_btn_settings);
|
||||
transportsView = (GridView)findViewById(R.id.transportsView);
|
||||
progressTitle = (TextView)findViewById(R.id.title_progress_bar);
|
||||
progressViewGroup = (ViewGroup)findViewById(R.id.container_progress);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@@ -34,7 +34,7 @@ import static android.view.View.VISIBLE;
|
||||
|
||||
public class PasswordActivity extends BaseActivity {
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private Button signInButton;
|
||||
private ProgressBar progress;
|
||||
private TextInputLayout input;
|
||||
@@ -43,8 +43,8 @@ public class PasswordActivity extends BaseActivity {
|
||||
private byte[] encrypted;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile DatabaseConfig databaseConfig;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
@Inject protected volatile DatabaseConfig databaseConfig;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -74,7 +74,8 @@ public class PasswordActivity extends BaseActivity {
|
||||
password.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
int after) {}
|
||||
int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before,
|
||||
@@ -83,10 +84,16 @@ public class PasswordActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// Show the home screen rather than another password prompt
|
||||
|
||||
@@ -33,8 +33,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.inject.InjectView;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
@@ -50,29 +48,40 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SetupActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject private PasswordStrengthEstimator strengthEstimator;
|
||||
@InjectView(R.id.nickname_entry_wrapper) TextInputLayout nicknameEntryWrapper;
|
||||
@InjectView(R.id.password_entry_wrapper) TextInputLayout passwordEntryWrapper;
|
||||
@InjectView(R.id.password_confirm_wrapper) TextInputLayout passwordConfirmationWrapper;
|
||||
@InjectView(R.id.nickname_entry) EditText nicknameEntry;
|
||||
@InjectView(R.id.password_entry) EditText passwordEntry;
|
||||
@InjectView(R.id.password_confirm) EditText passwordConfirmation;
|
||||
@InjectView(R.id.strength_meter) StrengthMeter strengthMeter;
|
||||
@InjectView(R.id.create_account) Button createAccountButton;
|
||||
@InjectView(R.id.progress_wheel) ProgressBar progress;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
@Inject protected PasswordStrengthEstimator strengthEstimator;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile DatabaseConfig databaseConfig;
|
||||
@Inject private volatile AuthorFactory authorFactory;
|
||||
@Inject private volatile ReferenceManager referenceManager;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
@Inject protected volatile DatabaseConfig databaseConfig;
|
||||
@Inject protected volatile AuthorFactory authorFactory;
|
||||
@Inject protected volatile ReferenceManager referenceManager;
|
||||
|
||||
TextInputLayout nicknameEntryWrapper;
|
||||
TextInputLayout passwordEntryWrapper;
|
||||
TextInputLayout passwordConfirmationWrapper;
|
||||
EditText nicknameEntry;
|
||||
EditText passwordEntry;
|
||||
EditText passwordConfirmation;
|
||||
StrengthMeter strengthMeter;
|
||||
Button createAccountButton;
|
||||
ProgressBar progress;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.activity_setup);
|
||||
|
||||
nicknameEntryWrapper = (TextInputLayout)findViewById(R.id.nickname_entry_wrapper);
|
||||
passwordEntryWrapper = (TextInputLayout)findViewById(R.id.password_entry_wrapper);
|
||||
passwordConfirmationWrapper = (TextInputLayout)findViewById(R.id.password_confirm_wrapper);
|
||||
nicknameEntry = (EditText)findViewById(R.id.nickname_entry);
|
||||
passwordEntry = (EditText)findViewById(R.id.password_entry);
|
||||
passwordConfirmation = (EditText)findViewById(R.id.password_confirm);
|
||||
strengthMeter = (StrengthMeter)findViewById(R.id.strength_meter);
|
||||
createAccountButton = (Button)findViewById(R.id.create_account);
|
||||
progress = (ProgressBar)findViewById(R.id.progress_wheel);
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
TextWatcher tw = new TextWatcher() {
|
||||
@@ -99,6 +108,11 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
createAccountButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void enableOrDisableContinueButton() {
|
||||
if (progress == null) return; // Not created yet
|
||||
if (passwordEntry.getText().length() > 0 && passwordEntry.hasFocus())
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.StrictMode;
|
||||
import android.os.StrictMode.ThreadPolicy;
|
||||
import android.os.StrictMode.VmPolicy;
|
||||
@@ -11,29 +13,22 @@ import android.support.v7.preference.PreferenceManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.AndroidUtils;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.ui.UiCallback;
|
||||
import org.briarproject.util.FileUtils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
import roboguice.activity.RoboSplashActivity;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static org.briarproject.android.BaseActivity.PREFS_NAME;
|
||||
import static org.briarproject.android.BaseActivity.PREF_DB_KEY;
|
||||
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||
import static org.briarproject.android.TestingConstants.TESTING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
public class SplashScreenActivity extends RoboSplashActivity {
|
||||
public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SplashScreenActivity.class.getName());
|
||||
@@ -43,18 +38,18 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
|
||||
private long now = System.currentTimeMillis();
|
||||
|
||||
@Inject
|
||||
DatabaseConfig dbConfig;
|
||||
|
||||
public SplashScreenActivity() {
|
||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||
enableStrictMode();
|
||||
minDisplayMs = 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setLayoutParams(MATCH_MATCH);
|
||||
layout.setGravity(CENTER);
|
||||
@@ -70,28 +65,36 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
setPreferencesDefaults();
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startNextActivity();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
protected void startNextActivity() {
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Guice startup took " + duration + " ms");
|
||||
if (System.currentTimeMillis() >= EXPIRY_DATE) {
|
||||
LOG.info("Expired");
|
||||
startActivity(new Intent(this, ExpiredActivity.class));
|
||||
} else {
|
||||
SharedPreferences prefs = getSharedPreferences(PREFS_NAME,
|
||||
MODE_PRIVATE);
|
||||
String hex = prefs.getString(PREF_DB_KEY, null);
|
||||
Injector i = RoboGuice.getBaseApplicationInjector(getApplication());
|
||||
DatabaseConfig databaseConfig = i.getInstance(DatabaseConfig.class);
|
||||
if (hex != null && databaseConfig.databaseExists()) {
|
||||
startActivity(new Intent(this, NavDrawerActivity.class));
|
||||
} else {
|
||||
prefs.edit().clear().apply();
|
||||
AndroidUtils.deleteAppData(this);
|
||||
startActivity(new Intent(this, SetupActivity.class));
|
||||
String hex = getEncryptedDatabaseKey();
|
||||
|
||||
if (dbConfig != null) {
|
||||
if (hex != null && dbConfig.databaseExists()) {
|
||||
startActivity(new Intent(this, NavDrawerActivity.class));
|
||||
} else {
|
||||
clearSharedPrefs();
|
||||
FileUtils.deleteFileOrDir(
|
||||
dbConfig.getDatabaseDirectory());
|
||||
startActivity(new Intent(this, SetupActivity.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,7 +117,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
PreferenceManager.setDefaultValues(SplashScreenActivity.this,
|
||||
R.xml.panic_preferences, false);
|
||||
R.xml.panic_preferences, false);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ public class StartupFailureActivity extends BaseActivity {
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
|
||||
}
|
||||
|
||||
private void handleIntent(Intent i) {
|
||||
StartResult result = (StartResult) i.getSerializableExtra("briar.START_RESULT");
|
||||
int notificationId = i.getIntExtra("briar.FAILURE_NOTIFICATION_ID", -1);
|
||||
|
||||
@@ -75,9 +75,9 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(TestingActivity.class.getName());
|
||||
|
||||
@Inject private PluginManager pluginManager;
|
||||
@Inject private LifecycleManager lifecycleManager;
|
||||
@Inject private TransportPropertyManager transportPropertyManager;
|
||||
@Inject protected PluginManager pluginManager;
|
||||
@Inject protected LifecycleManager lifecycleManager;
|
||||
@Inject protected TransportPropertyManager transportPropertyManager;
|
||||
private ScrollView scroll = null;
|
||||
private ListLoadingProgressBar progress = null;
|
||||
private LinearLayout status = null;
|
||||
@@ -137,6 +137,11 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarApplication;
|
||||
import org.briarproject.android.fragment.BaseEventFragment;
|
||||
import org.briarproject.android.invitation.AddContactActivity;
|
||||
import org.briarproject.android.util.BriarRecyclerView;
|
||||
@@ -64,19 +66,29 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private CryptoComponent crypto;
|
||||
protected CryptoComponent crypto;
|
||||
@Inject
|
||||
private ConnectionRegistry connectionRegistry;
|
||||
protected ConnectionRegistry connectionRegistry;
|
||||
private ContactListAdapter adapter = null;
|
||||
private BriarRecyclerView list = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
private volatile ContactManager contactManager;
|
||||
protected volatile ContactManager contactManager;
|
||||
@Inject
|
||||
private volatile MessagingManager messagingManager;
|
||||
protected volatile MessagingManager messagingManager;
|
||||
@Inject
|
||||
private volatile EventBus eventBus;
|
||||
protected volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.BriarRecyclerView;
|
||||
import org.briarproject.api.FormatException;
|
||||
@@ -71,10 +72,10 @@ public class ConversationActivity extends BriarActivity
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationActivity.class.getName());
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private AndroidNotificationManager notificationManager;
|
||||
@Inject private ConnectionRegistry connectionRegistry;
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject protected CryptoComponent crypto;
|
||||
@Inject protected AndroidNotificationManager notificationManager;
|
||||
@Inject protected ConnectionRegistry connectionRegistry;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
||||
private ConversationAdapter adapter = null;
|
||||
private BriarRecyclerView list = null;
|
||||
@@ -82,10 +83,10 @@ public class ConversationActivity extends BriarActivity
|
||||
private ImageButton sendButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ContactManager contactManager;
|
||||
@Inject private volatile MessagingManager messagingManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@Inject private volatile PrivateMessageFactory privateMessageFactory;
|
||||
@Inject protected volatile ContactManager contactManager;
|
||||
@Inject protected volatile MessagingManager messagingManager;
|
||||
@Inject protected volatile EventBus eventBus;
|
||||
@Inject protected volatile PrivateMessageFactory privateMessageFactory;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile ContactId contactId = null;
|
||||
private volatile String contactName = null;
|
||||
@@ -115,6 +116,11 @@ public class ConversationActivity extends BriarActivity
|
||||
sendButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
@@ -47,9 +48,9 @@ implements EventListener, OnItemClickListener {
|
||||
private ListView list = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -66,6 +67,11 @@ implements EventListener, OnItemClickListener {
|
||||
setContentView(loading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DbException;
|
||||
@@ -51,7 +52,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
private TextView feedback = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -102,6 +103,11 @@ implements OnEditorActionListener, OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void enableOrDisableCreateButton() {
|
||||
if (progress == null) return; // Not created yet
|
||||
createForumButton.setEnabled(validateName());
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
@@ -62,7 +63,7 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ForumActivity.class.getName());
|
||||
|
||||
@Inject private AndroidNotificationManager notificationManager;
|
||||
@Inject protected AndroidNotificationManager notificationManager;
|
||||
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
||||
private TextView empty = null;
|
||||
private ForumAdapter adapter = null;
|
||||
@@ -71,8 +72,8 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
private ImageButton composeButton = null, shareButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile EventBus eventBus;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile Forum forum = null;
|
||||
|
||||
@@ -139,6 +140,11 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.fragment.BaseEventFragment;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
@@ -83,8 +84,8 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
private ImageButton newForumButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -152,6 +153,11 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
@@ -59,7 +60,7 @@ implements OnClickListener {
|
||||
private int position = -1;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
private volatile MessageId messageId = null;
|
||||
|
||||
@Override
|
||||
@@ -164,6 +165,11 @@ implements OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.contact.SelectContactsDialog;
|
||||
import org.briarproject.android.invitation.AddContactActivity;
|
||||
@@ -51,8 +52,8 @@ SelectContactsDialog.Listener {
|
||||
private boolean changed = false;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ContactManager contactManager;
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile ContactManager contactManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile Collection<Contact> contacts = null;
|
||||
private volatile Collection<ContactId> selected = null;
|
||||
@@ -109,6 +110,11 @@ SelectContactsDialog.Listener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if (view == shareWithAll) {
|
||||
changed = true;
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.identity.CreateIdentityActivity;
|
||||
import org.briarproject.android.identity.LocalAuthorItem;
|
||||
@@ -67,7 +68,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(WriteForumPostActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private LocalAuthorSpinnerAdapter adapter = null;
|
||||
private Spinner spinner = null;
|
||||
private ImageButton sendButton = null;
|
||||
@@ -76,10 +77,10 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private GroupId groupId = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile ForumPostFactory forumPostFactory;
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject protected volatile IdentityManager identityManager;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumPostFactory forumPostFactory;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
private volatile MessageId parentId = null;
|
||||
private volatile long minTimestamp = -1;
|
||||
private volatile LocalAuthor localAuthor = null;
|
||||
@@ -157,6 +158,11 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package org.briarproject.android.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.BriarApplication;
|
||||
|
||||
import roboguice.fragment.RoboFragment;
|
||||
|
||||
public abstract class BaseFragment extends RoboFragment {
|
||||
public abstract class BaseFragment extends Fragment {
|
||||
|
||||
public abstract String getUniqueTag();
|
||||
|
||||
@@ -25,10 +27,25 @@ public abstract class BaseFragment extends RoboFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndroidComponent component =
|
||||
((BriarApplication) getActivity().getApplication())
|
||||
.getApplicationComponent();
|
||||
injectActivity(component);
|
||||
}
|
||||
|
||||
public abstract void injectActivity(AndroidComponent component);
|
||||
|
||||
public interface BaseFragmentListener {
|
||||
void showLoadingScreen(boolean isBlocking, int stringId);
|
||||
|
||||
void hideLoadingScreen();
|
||||
|
||||
void runOnUiThread(Runnable runnable);
|
||||
|
||||
void runOnDbThread(Runnable runnable);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.GridView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.plugins.PluginManager;
|
||||
|
||||
@@ -16,8 +17,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.inject.InjectView;
|
||||
|
||||
public class DashboardFragment extends BaseEventFragment {
|
||||
|
||||
public final static String TAG = "DashboardFragment";
|
||||
@@ -26,10 +25,7 @@ public class DashboardFragment extends BaseEventFragment {
|
||||
Logger.getLogger(DashboardFragment.class.getName());
|
||||
|
||||
@Inject
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@InjectView(R.id.transportsView)
|
||||
private GridView transportsView;
|
||||
protected PluginManager pluginManager;
|
||||
|
||||
public static DashboardFragment newInstance() {
|
||||
|
||||
@@ -59,6 +55,11 @@ public class DashboardFragment extends BaseEventFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventOccurred(Event e) {
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -50,16 +51,16 @@ implements OnEditorActionListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CreateIdentityActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private EditText nicknameEntry = null;
|
||||
private Button createIdentityButton = null;
|
||||
private ProgressBar progress = null;
|
||||
private TextView feedback = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile AuthorFactory authorFactory;
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
@Inject protected volatile AuthorFactory authorFactory;
|
||||
@Inject protected volatile IdentityManager identityManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -112,6 +113,11 @@ implements OnEditorActionListener, OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void enableOrDisableCreateButton() {
|
||||
if (progress == null) return; // Not created yet
|
||||
createIdentityButton.setEnabled(validateNickname());
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -38,9 +39,9 @@ implements InvitationListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AddContactActivity.class.getName());
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private InvitationTaskFactory invitationTaskFactory;
|
||||
@Inject private ReferenceManager referenceManager;
|
||||
@Inject protected CryptoComponent crypto;
|
||||
@Inject protected InvitationTaskFactory invitationTaskFactory;
|
||||
@Inject protected ReferenceManager referenceManager;
|
||||
private AddContactView view = null;
|
||||
private InvitationTask task = null;
|
||||
private long taskHandle = -1;
|
||||
@@ -53,7 +54,7 @@ implements InvitationListener {
|
||||
private String contactName = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject protected volatile IdentityManager identityManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -138,6 +139,11 @@ implements InvitationListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void showToastAndFinish() {
|
||||
String format = getString(R.string.contact_added_toast);
|
||||
String text = String.format(format, contactName);
|
||||
|
||||
@@ -24,8 +24,6 @@ import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
|
||||
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
|
||||
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
|
||||
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
||||
@@ -35,7 +33,7 @@ import static org.briarproject.android.invitation.AddContactActivity.REQUEST_CRE
|
||||
class ChooseIdentityView extends AddContactView
|
||||
implements OnItemSelectedListener, OnClickListener {
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject protected CryptoComponent crypto;
|
||||
private LocalAuthorSpinnerAdapter adapter = null;
|
||||
private Spinner spinner = null;
|
||||
|
||||
@@ -46,7 +44,8 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
void populate() {
|
||||
removeAllViews();
|
||||
Context ctx = getContext();
|
||||
RoboGuice.injectMembers(ctx, this);
|
||||
// TODO
|
||||
// RoboGuice.injectMembers(ctx, this);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService
|
||||
(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.briarproject.android.panic;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BaseActivity;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
@@ -20,4 +21,9 @@ public class ExitActivity extends BaseActivity {
|
||||
LOG.info("Exiting");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.support.v7.app.ActionBar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
|
||||
public class PanicPreferencesActivity extends BriarActivity {
|
||||
@@ -22,6 +23,11 @@ public class PanicPreferencesActivity extends BriarActivity {
|
||||
setContentView(R.layout.activity_panic_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
|
||||
@@ -7,12 +7,16 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.AndroidUtils;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.util.FileUtils;
|
||||
import org.iilab.IilabEngineeringRSA2048Pin;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.guardianproject.GuardianProjectRSA4096;
|
||||
import info.guardianproject.panic.Panic;
|
||||
import info.guardianproject.panic.PanicResponder;
|
||||
@@ -26,6 +30,7 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(PanicResponderActivity.class.getName());
|
||||
@Inject protected DatabaseConfig databaseConfig;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -95,13 +100,20 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void deleteAllData() {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
clearSharedPrefs();
|
||||
// TODO somehow delete/shred the database more thoroughly
|
||||
AndroidUtils.deleteAppData(PanicResponderActivity.this);
|
||||
FileUtils
|
||||
.deleteFileOrDir(
|
||||
databaseConfig.getDatabaseDirectory());
|
||||
PanicResponder.deleteAllAppData(PanicResponderActivity.this);
|
||||
|
||||
// nothing left to do after everything is deleted,
|
||||
|
||||
@@ -16,11 +16,10 @@ import org.briarproject.api.identity.AuthorId;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import im.delight.android.identicons.IdenticonDrawable;
|
||||
import roboguice.RoboGuice;
|
||||
|
||||
public class AuthorView extends FrameLayout {
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject protected CryptoComponent crypto;
|
||||
private ImageView avatarView;
|
||||
private TextView nameView;
|
||||
private ImageView statusView;
|
||||
@@ -45,7 +44,6 @@ public class AuthorView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
if (isInEditMode())
|
||||
return;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.briarproject.plugins;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
@@ -24,6 +23,10 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class AndroidPluginsModule extends PluginsModule {
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -6,13 +6,13 @@ import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.system.LocationUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.content.Context.TELEPHONY_SERVICE;
|
||||
|
||||
class AndroidLocationUtils implements LocationUtils {
|
||||
|
||||
@@ -1,18 +1,37 @@
|
||||
package org.briarproject.system;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.api.system.LocationUtils;
|
||||
import org.briarproject.api.system.SeedProvider;
|
||||
import org.briarproject.api.system.Timer;
|
||||
|
||||
public class AndroidSystemModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
protected void configure() {
|
||||
bind(Clock.class).to(SystemClock.class);
|
||||
bind(Timer.class).to(SystemTimer.class);
|
||||
bind(SeedProvider.class).to(AndroidSeedProvider.class);
|
||||
bind(LocationUtils.class).to(AndroidLocationUtils.class);
|
||||
@Module
|
||||
public class AndroidSystemModule {
|
||||
|
||||
@Provides
|
||||
Clock provideClock() {
|
||||
return new SystemClock();
|
||||
}
|
||||
|
||||
@Provides
|
||||
Timer provideTimer() {
|
||||
return new SystemTimer();
|
||||
}
|
||||
|
||||
@Provides
|
||||
SeedProvider provideSeedProvider(final Application app) {
|
||||
return new AndroidSeedProvider(app);
|
||||
}
|
||||
|
||||
@Provides
|
||||
LocationUtils provideLocationUtils(final Application app) {
|
||||
return new AndroidLocationUtils(app);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user