diff --git a/briar-android/res/layout/fragment_dashboard.xml b/briar-android/res/layout/fragment_dashboard.xml deleted file mode 100644 index 1d73431f59b46c0699d6cef6895bdd8d54bafff1..0000000000000000000000000000000000000000 --- a/briar-android/res/layout/fragment_dashboard.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@color/dashboard_background" - > - - -</RelativeLayout> \ No newline at end of file diff --git a/briar-android/src/org/briarproject/android/ActivityComponent.java b/briar-android/src/org/briarproject/android/ActivityComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..4032d7bd7641457e6d065d3cd5240647d871c814 --- /dev/null +++ b/briar-android/src/org/briarproject/android/ActivityComponent.java @@ -0,0 +1,76 @@ +package org.briarproject.android; + +import android.app.Activity; +import android.os.Bundle; +import android.support.v4.app.Fragment; + +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.BaseFragment; +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 javax.inject.Named; + +import dagger.Component; +import dagger.Provides; + +@ActivityScope +@Component(modules = ActivityModule.class, + dependencies = AndroidComponent.class) +public interface ActivityComponent { + Activity activity(); + + void inject(SplashScreenActivity activity); + + void inject(SetupActivity activity); + + void inject(NavDrawerActivity activity); + + void inject(PasswordActivity 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(SettingsActivity activity); + + @Named("ContactListFragment") + BaseFragment newContactListFragment(); + + @Named("ForumListFragment") + BaseFragment newForumListFragment(); + +// void inject(ContactListFragment fragment); + +// void inject(ForumListFragment fragment); +} diff --git a/briar-android/src/org/briarproject/android/ActivityModule.java b/briar-android/src/org/briarproject/android/ActivityModule.java new file mode 100644 index 0000000000000000000000000000000000000000..8c1989a711e09e33a346030dd1a2e4e0e1338aaf --- /dev/null +++ b/briar-android/src/org/briarproject/android/ActivityModule.java @@ -0,0 +1,71 @@ +package org.briarproject.android; + +import android.app.Activity; +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.support.v4.app.Fragment; + +import org.briarproject.android.contact.ContactListFragment; +import org.briarproject.android.forum.ForumListFragment; +import org.briarproject.android.fragment.BaseFragment; +import org.briarproject.android.sdk.BriarHelper; +import org.briarproject.android.sdk.BriarHelperImp; + +import java.util.logging.Logger; + +import javax.inject.Named; + +import dagger.Module; +import dagger.Provides; + +@Module +public class ActivityModule { + + private final BaseActivity activity; + + public ActivityModule(BaseActivity activity) { + this.activity = activity; + } + + @ActivityScope + @Provides + Activity providesActivity() { + return activity; + } + + @ActivityScope + @Provides + BriarHelper provideBriarHelper(BriarHelperImp briarHelperImp) { + return briarHelperImp; + } + + @ActivityScope + Logger provideLogger(Activity activity) { + return Logger.getLogger(activity.getClass().getName()); + } + + @ActivityScope + @Provides + SharedPreferences provideSharedPreferences(Activity activity) { + return activity.getSharedPreferences("db", Context.MODE_PRIVATE); + } + + + @Provides + @Named("ForumListFragment") + BaseFragment provideForumListFragment( + ForumListFragment forumListFragment) { + forumListFragment.setArguments(new Bundle()); + return forumListFragment; + } + + @Provides + @Named("ContactListFragment") + BaseFragment provideContactListFragment( + ContactListFragment contactListFragment) { + contactListFragment.setArguments(new Bundle()); + return contactListFragment; + } + +} diff --git a/briar-android/src/org/briarproject/android/ActivityScope.java b/briar-android/src/org/briarproject/android/ActivityScope.java new file mode 100644 index 0000000000000000000000000000000000000000..a6ceb30ab7d9896edcf523aa2d6d22ed377b2fde --- /dev/null +++ b/briar-android/src/org/briarproject/android/ActivityScope.java @@ -0,0 +1,11 @@ +package org.briarproject.android; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.inject.Scope; + +@Scope +@Retention(RetentionPolicy.RUNTIME) +public @interface ActivityScope { +} diff --git a/briar-android/src/org/briarproject/android/AndroidComponent.java b/briar-android/src/org/briarproject/android/AndroidComponent.java index 8b2ac951ab65f8b7ed6e5565f850a054d06719bf..8766c4324e5b29ec854557ba625ddaff0f8df00d 100644 --- a/briar-android/src/org/briarproject/android/AndroidComponent.java +++ b/briar-android/src/org/briarproject/android/AndroidComponent.java @@ -2,6 +2,8 @@ package org.briarproject.android; import org.briarproject.CoreEagerSingletons; import org.briarproject.CoreModule; +import org.briarproject.android.api.AndroidNotificationManager; +import org.briarproject.android.api.ReferenceManager; import org.briarproject.android.contact.ContactListFragment; import org.briarproject.android.contact.ConversationActivity; import org.briarproject.android.forum.AvailableForumsActivity; @@ -23,10 +25,31 @@ import org.briarproject.android.keyagreement.KeyAgreementActivity; import org.briarproject.android.keyagreement.ShowQrCodeFragment; import org.briarproject.android.panic.PanicPreferencesActivity; import org.briarproject.android.panic.PanicResponderActivity; -import org.briarproject.android.util.BriarReportSender; +import org.briarproject.api.contact.ContactManager; +import org.briarproject.api.crypto.CryptoComponent; +import org.briarproject.api.crypto.CryptoExecutor; +import org.briarproject.api.crypto.PasswordStrengthEstimator; +import org.briarproject.api.db.DatabaseConfig; +import org.briarproject.api.db.DatabaseExecutor; +import org.briarproject.api.event.EventBus; +import org.briarproject.api.forum.ForumManager; +import org.briarproject.api.forum.ForumPostFactory; +import org.briarproject.api.forum.ForumSharingManager; +import org.briarproject.api.identity.AuthorFactory; +import org.briarproject.api.identity.IdentityManager; +import org.briarproject.api.invitation.InvitationTaskFactory; +import org.briarproject.api.lifecycle.LifecycleManager; +import org.briarproject.api.messaging.MessagingManager; +import org.briarproject.api.messaging.PrivateMessageFactory; +import org.briarproject.api.plugins.ConnectionRegistry; +import org.briarproject.api.plugins.PluginManager; +import org.briarproject.api.properties.TransportPropertyManager; +import org.briarproject.api.settings.SettingsManager; import org.briarproject.plugins.AndroidPluginsModule; import org.briarproject.system.AndroidSystemModule; +import java.util.concurrent.Executor; + import javax.inject.Singleton; import dagger.Component; @@ -39,16 +62,29 @@ import dagger.Component; AndroidSystemModule.class }) public interface AndroidComponent extends CoreEagerSingletons { - - void inject(DevReportActivity devReportActivity); - - void inject(SplashScreenActivity activity); - - void inject(SetupActivity activity); - - void inject(NavDrawerActivity activity); - - void inject(PasswordActivity activity); + // Exposed objects + @CryptoExecutor Executor cryptoExecutor(); + PasswordStrengthEstimator passwordStrengthIndicator(); + CryptoComponent cryptoComponent(); + DatabaseConfig databaseConfig(); + AuthorFactory authFactory(); + ReferenceManager referenceMangager(); + @DatabaseExecutor Executor databaseExecutor(); + LifecycleManager lifecycleManager(); + IdentityManager identityManager(); + PluginManager pluginManager(); + EventBus eventBus(); + InvitationTaskFactory invitationTaskFactory(); + AndroidNotificationManager androidNotificationManager(); + ConnectionRegistry connectionRegistry(); + ContactManager contactManager(); + MessagingManager messagingManager(); + PrivateMessageFactory privateMessageFactory(); + TransportPropertyManager transportPropertyManager(); + ForumManager forumManager(); + ForumSharingManager forumSharingManager(); + ForumPostFactory forumPostFactory(); + SettingsManager settingsManager(); void inject(BriarService activity); @@ -64,6 +100,8 @@ public interface AndroidComponent extends CoreEagerSingletons { void inject(CreateIdentityActivity activity); + void inject(TestingActivity activity); + void inject(AvailableForumsActivity activity); void inject(WriteForumPostActivity activity); diff --git a/briar-android/src/org/briarproject/android/BaseActivity.java b/briar-android/src/org/briarproject/android/BaseActivity.java index 1a93a006ec6b200e2522e8431c4168eefc1efdbc..9e602c9e55854d7a3154a3ab41cc6ad65c7d998c 100644 --- a/briar-android/src/org/briarproject/android/BaseActivity.java +++ b/briar-android/src/org/briarproject/android/BaseActivity.java @@ -1,12 +1,16 @@ package org.briarproject.android; +import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.os.Bundle; import android.os.IBinder; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.inputmethod.InputMethodManager; +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; @@ -17,17 +21,28 @@ public abstract class BaseActivity extends AppCompatActivity { public final static String PREF_DB_KEY = "key"; public final static String PREF_SEEN_WELCOME_MESSAGE = "welcome_message"; + protected ActivityComponent activityComponent; + + // TODO Shared prefs + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE); - BriarApplication application = (BriarApplication) getApplication(); - injectActivity(application.getApplicationComponent()); + AndroidComponent applicationComponent = + ((BriarApplication) getApplication()).getApplicationComponent(); + + activityComponent = DaggerActivityComponent.builder() + .androidComponent(applicationComponent) + .activityModule(new ActivityModule(this)) + .build(); + + injectActivity(activityComponent); } - public abstract void injectActivity(AndroidComponent component); + public abstract void injectActivity(ActivityComponent component); private SharedPreferences getSharedPrefs() { return getSharedPreferences(PREFS_NAME, MODE_PRIVATE); diff --git a/briar-android/src/org/briarproject/android/BriarFragmentActivity.java b/briar-android/src/org/briarproject/android/BriarFragmentActivity.java index 766a11e33044711faa87e978d22682d9ea4b2fe8..28f99232624ea7418515fc1bd6852e70cadc857a 100644 --- a/briar-android/src/org/briarproject/android/BriarFragmentActivity.java +++ b/briar-android/src/org/briarproject/android/BriarFragmentActivity.java @@ -10,7 +10,6 @@ import org.briarproject.R; import org.briarproject.android.contact.ContactListFragment; import org.briarproject.android.forum.ForumListFragment; import org.briarproject.android.fragment.BaseFragment; -import org.briarproject.android.fragment.DashboardFragment; /** * This class should be extended by classes that wish to utilise fragments in @@ -23,9 +22,7 @@ public abstract class BriarFragmentActivity extends BriarActivity { if (actionBar == null) return; - if (fragmentTag.equals(DashboardFragment.TAG)) { - actionBar.setTitle(R.string.dashboard_toolbar_header); - } else if (fragmentTag.equals(ContactListFragment.TAG)) { + if (fragmentTag.equals(ContactListFragment.TAG)) { actionBar.setTitle(R.string.contacts_toolbar_header); } else if (fragmentTag.equals(ForumListFragment.TAG)) { actionBar.setTitle(R.string.forums_toolbar_header); @@ -52,7 +49,8 @@ public abstract class BriarFragmentActivity extends BriarActivity { exiting. This models the typical Google navigation behaviour such as in Gmail/Inbox. */ - startFragment(ContactListFragment.newInstance()); + // FIXME +// startFragment(ContactListFragment.newInstance()); } else { super.onBackPressed(); diff --git a/briar-android/src/org/briarproject/android/NavDrawerActivity.java b/briar-android/src/org/briarproject/android/NavDrawerActivity.java index 367bb12ba16daf71f903ce4e1218e610850dad15..af98c88facb19a66ad9c5bacb565d3782fe9e6a6 100644 --- a/briar-android/src/org/briarproject/android/NavDrawerActivity.java +++ b/briar-android/src/org/briarproject/android/NavDrawerActivity.java @@ -68,9 +68,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements private Toolbar toolbar; private DrawerLayout drawerLayout; - private Button contactButton; - private Button forumsButton; - private Button settingsButton; private GridView transportsView; private TextView progressTitle; private ViewGroup progressViewGroup; @@ -85,14 +82,14 @@ public class NavDrawerActivity extends BriarFragmentActivity implements checkAuthorHandle(intent); clearBackStack(); if (intent.getBooleanExtra(INTENT_FORUMS, false)) - startFragment(ForumListFragment.newInstance()); + startFragment(activityComponent.newForumListFragment()); else if (intent.getBooleanExtra(INTENT_CONTACTS, false)) - startFragment(ContactListFragment.newInstance()); + startFragment(activityComponent.newContactListFragment()); } } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } @@ -108,9 +105,6 @@ public class NavDrawerActivity extends BriarFragmentActivity implements 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); @@ -133,7 +127,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements } }; drawerLayout.setDrawerListener(drawerToggle); - if (state == null) startFragment(ContactListFragment.newInstance()); + if (state == null) startFragment(activityComponent.newContactListFragment()); checkAuthorHandle(getIntent()); initializeTransports(getLayoutInflater()); @@ -217,10 +211,10 @@ public class NavDrawerActivity extends BriarFragmentActivity implements clearBackStack(); switch (view.getId()) { case R.id.nav_btn_contacts: - startFragment(ContactListFragment.newInstance()); + startFragment(activityComponent.newContactListFragment()); break; case R.id.nav_btn_forums: - startFragment(ForumListFragment.newInstance()); + startFragment(activityComponent.newForumListFragment()); break; case R.id.nav_btn_settings: startActivity(new Intent(this, SettingsActivity.class)); diff --git a/briar-android/src/org/briarproject/android/PasswordActivity.java b/briar-android/src/org/briarproject/android/PasswordActivity.java index 33f14f206b1b2c7ef29c640d061b3d1595dcd916..41c2459de32d0720dedf57e59f735418626c9b10 100644 --- a/briar-android/src/org/briarproject/android/PasswordActivity.java +++ b/briar-android/src/org/briarproject/android/PasswordActivity.java @@ -90,7 +90,7 @@ public class PasswordActivity extends BaseActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/SettingsActivity.java b/briar-android/src/org/briarproject/android/SettingsActivity.java index e270578a74065285f7ee43ee4f7dabc0ca8cffa2..bb783a06517004ff316d1d36763daafb61c8a0be 100644 --- a/briar-android/src/org/briarproject/android/SettingsActivity.java +++ b/briar-android/src/org/briarproject/android/SettingsActivity.java @@ -34,7 +34,7 @@ public class SettingsActivity extends BriarActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/SetupActivity.java b/briar-android/src/org/briarproject/android/SetupActivity.java index 6caf20e5acbaf686aed94603143eb980750689df..1ddb6dd58eb6edccc1daf69ab73cc713cfae6405 100644 --- a/briar-android/src/org/briarproject/android/SetupActivity.java +++ b/briar-android/src/org/briarproject/android/SetupActivity.java @@ -109,7 +109,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener, } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/SplashScreenActivity.java b/briar-android/src/org/briarproject/android/SplashScreenActivity.java index 0ba0d47b9479aa1b8e59432ce4f7993cf199c0f4..9a736d9163202c3d20123482657bb1027455ce39 100644 --- a/briar-android/src/org/briarproject/android/SplashScreenActivity.java +++ b/briar-android/src/org/briarproject/android/SplashScreenActivity.java @@ -56,7 +56,7 @@ public class SplashScreenActivity extends BaseActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/StartupFailureActivity.java b/briar-android/src/org/briarproject/android/StartupFailureActivity.java index 5180c33c27fe72a5b9fe4b1009f8597bfe7560bf..b258369391ff701b735b130d1ee901c46d22ccb7 100644 --- a/briar-android/src/org/briarproject/android/StartupFailureActivity.java +++ b/briar-android/src/org/briarproject/android/StartupFailureActivity.java @@ -20,7 +20,7 @@ public class StartupFailureActivity extends BaseActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { } diff --git a/briar-android/src/org/briarproject/android/contact/ContactListFragment.java b/briar-android/src/org/briarproject/android/contact/ContactListFragment.java index 82137d92ad531ebbcb49cca43c635d7d39abb961..62e1e349fde78b0d6dfcb31b45fb0b9f1647dbaa 100644 --- a/briar-android/src/org/briarproject/android/contact/ContactListFragment.java +++ b/briar-android/src/org/briarproject/android/contact/ContactListFragment.java @@ -13,12 +13,14 @@ 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.keyagreement.KeyAgreementActivity; import org.briarproject.android.util.BriarRecyclerView; import org.briarproject.api.contact.Contact; import org.briarproject.api.contact.ContactId; import org.briarproject.api.contact.ContactManager; +import org.briarproject.api.crypto.CryptoComponent; import org.briarproject.api.db.DbException; import org.briarproject.api.db.NoSuchContactException; import org.briarproject.api.event.ContactAddedEvent; @@ -28,6 +30,7 @@ import org.briarproject.api.event.ContactRemovedEvent; import org.briarproject.api.event.ContactStatusChangedEvent; import org.briarproject.api.event.Event; import org.briarproject.api.event.EventBus; +import org.briarproject.api.event.EventListener; import org.briarproject.api.event.MessageValidatedEvent; import org.briarproject.api.forum.ForumInvitationMessage; import org.briarproject.api.forum.ForumSharingManager; @@ -52,13 +55,14 @@ import static java.util.logging.Level.INFO; import static java.util.logging.Level.WARNING; import static org.briarproject.android.BriarActivity.GROUP_ID; -public class ContactListFragment extends BaseEventFragment { +public class ContactListFragment extends BaseFragment implements EventListener { private static final Logger LOG = Logger.getLogger(ContactListFragment.class.getName()); public final static String TAG = "ContactListFragment"; + /* public static ContactListFragment newInstance() { Bundle args = new Bundle(); @@ -67,6 +71,7 @@ public class ContactListFragment extends BaseEventFragment { fragment.setArguments(args); return fragment; } + */ @Override public String getUniqueTag() { @@ -92,9 +97,14 @@ public class ContactListFragment extends BaseEventFragment { @Inject protected volatile EventBus eventBus; - @Override - public void injectActivity(AndroidComponent component) { - component.inject(this); + +// @Override +// public void injectActivity(AndroidComponent component) { +// component.inject(this); +// } + @Inject + public ContactListFragment() { + } @Nullable @@ -155,7 +165,7 @@ public class ContactListFragment extends BaseEventFragment { @Override public void onResume() { super.onResume(); - + eventBus.addListener(this); loadContacts(); } @@ -163,6 +173,7 @@ public class ContactListFragment extends BaseEventFragment { public void onPause() { super.onPause(); adapter.clear(); + eventBus.removeListener(this); } private void loadContacts() { diff --git a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java index 5a62bef1f3c378449c2ce8e8ff1178d9aba76fa9..045c58e7f165e4b72ba16e08fa8ed05093624ac5 100644 --- a/briar-android/src/org/briarproject/android/contact/ConversationActivity.java +++ b/briar-android/src/org/briarproject/android/contact/ConversationActivity.java @@ -23,6 +23,7 @@ import android.widget.TextView; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.api.AndroidNotificationManager; @@ -157,7 +158,7 @@ public class ConversationActivity extends BriarActivity } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/forum/AvailableForumsActivity.java b/briar-android/src/org/briarproject/android/forum/AvailableForumsActivity.java index dd7a722e7518cdbf206f410a65b8e8e40f278c95..f1e1a7b9efb6cdee845c4338a0359ef6b122b487 100644 --- a/briar-android/src/org/briarproject/android/forum/AvailableForumsActivity.java +++ b/briar-android/src/org/briarproject/android/forum/AvailableForumsActivity.java @@ -5,6 +5,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.util.BriarRecyclerView; @@ -61,7 +62,7 @@ public class AvailableForumsActivity extends BriarActivity } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java b/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java index a35834c93aead75bb04298bae7c94ac1efbfbaee..fbb10650e834a08d2f288279aebd3febb0063253 100644 --- a/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java +++ b/briar-android/src/org/briarproject/android/forum/CreateForumActivity.java @@ -15,7 +15,7 @@ import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; import org.briarproject.R; -import org.briarproject.android.AndroidComponent; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.BriarActivity; import org.briarproject.api.db.DbException; import org.briarproject.api.forum.Forum; @@ -86,7 +86,7 @@ public class CreateForumActivity extends BriarActivity } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/forum/ForumActivity.java b/briar-android/src/org/briarproject/android/forum/ForumActivity.java index 9a2ec711d9233f87d2a60ad3d643433511de4419..1ea92c3c08b6c73d5c66def586d8796908042c0e 100644 --- a/briar-android/src/org/briarproject/android/forum/ForumActivity.java +++ b/briar-android/src/org/briarproject/android/forum/ForumActivity.java @@ -19,6 +19,7 @@ import android.widget.TextView; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.api.AndroidNotificationManager; @@ -127,7 +128,7 @@ public class ForumActivity extends BriarActivity implements EventListener, } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/forum/ForumListFragment.java b/briar-android/src/org/briarproject/android/forum/ForumListFragment.java index 4aa853bd7e42dc5d04db6037ac689543c41566fd..a6ba633f7a40b2d5cdd3ef64b01b1a1b54bff0d2 100644 --- a/briar-android/src/org/briarproject/android/forum/ForumListFragment.java +++ b/briar-android/src/org/briarproject/android/forum/ForumListFragment.java @@ -14,6 +14,7 @@ import android.view.View; import android.view.ViewGroup; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.fragment.BaseEventFragment; import org.briarproject.android.util.BriarRecyclerView; @@ -50,6 +51,7 @@ public class ForumListFragment extends BaseEventFragment implements private static final Logger LOG = Logger.getLogger(ForumListFragment.class.getName()); + /* public static ForumListFragment newInstance() { Bundle args = new Bundle(); @@ -58,6 +60,7 @@ public class ForumListFragment extends BaseEventFragment implements fragment.setArguments(args); return fragment; } + */ private BriarRecyclerView list; private ForumListAdapter adapter; @@ -67,6 +70,11 @@ public class ForumListFragment extends BaseEventFragment implements @Inject protected volatile ForumManager forumManager; @Inject protected volatile ForumSharingManager forumSharingManager; + @Inject + public ForumListFragment() { + + } + @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -99,10 +107,10 @@ public class ForumListFragment extends BaseEventFragment implements return TAG; } - @Override - public void injectActivity(AndroidComponent component) { - component.inject(this); - } +// @Override +// public void injectActivity(ActivityComponent component) { +// component.inject(this); +// } @Override public void onResume() { diff --git a/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java b/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java index f320ed6efd14a776d2f94c210846d53d82817438..cfc80ace2a4a4363327a4c88b3115bdc6cecbf64 100644 --- a/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java +++ b/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java @@ -12,6 +12,7 @@ import android.widget.ScrollView; import android.widget.TextView; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.util.AuthorView; @@ -168,7 +169,7 @@ implements OnClickListener { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/forum/ShareForumActivity.java b/briar-android/src/org/briarproject/android/forum/ShareForumActivity.java index 820e25666fdf0a26d0644a2ffa25cb0031aeb0dc..75a0bc676894b30c2d472a344b9e45c25e9653c0 100644 --- a/briar-android/src/org/briarproject/android/forum/ShareForumActivity.java +++ b/briar-android/src/org/briarproject/android/forum/ShareForumActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.view.View; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.fragment.BaseFragment; diff --git a/briar-android/src/org/briarproject/android/forum/WriteForumPostActivity.java b/briar-android/src/org/briarproject/android/forum/WriteForumPostActivity.java index 4087115e036c5598709903df94dd337e5959e5e2..d2185aa4630df3d1dcd024fd322a6c4bcdd154dd 100644 --- a/briar-android/src/org/briarproject/android/forum/WriteForumPostActivity.java +++ b/briar-android/src/org/briarproject/android/forum/WriteForumPostActivity.java @@ -16,6 +16,7 @@ import android.widget.TextView; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.identity.CreateIdentityActivity; @@ -161,7 +162,7 @@ implements OnItemSelectedListener, OnClickListener { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/fragment/BaseEventFragment.java b/briar-android/src/org/briarproject/android/fragment/BaseEventFragment.java index f353b6e08dddc6c4862fc21a531b0b591f14dcf1..69ceab43a6281a5a7ae1f0ad901697a6b2651d82 100644 --- a/briar-android/src/org/briarproject/android/fragment/BaseEventFragment.java +++ b/briar-android/src/org/briarproject/android/fragment/BaseEventFragment.java @@ -5,9 +5,6 @@ import org.briarproject.api.event.EventListener; import javax.inject.Inject; -/** - * Created by Ernir Erlingsson (ernir@ymirmobile.com) on 8.1.2016. - */ public abstract class BaseEventFragment extends BaseFragment implements EventListener { diff --git a/briar-android/src/org/briarproject/android/fragment/BaseFragment.java b/briar-android/src/org/briarproject/android/fragment/BaseFragment.java index 494f93c2dbfb2a74f2b4188a15ba96c8a1c7ef83..47f98f36606759b6b9a4e70bee9f6082a61c1037 100644 --- a/briar-android/src/org/briarproject/android/fragment/BaseFragment.java +++ b/briar-android/src/org/briarproject/android/fragment/BaseFragment.java @@ -28,15 +28,13 @@ public abstract class BaseFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - BriarApplication application = - (BriarApplication) getActivity().getApplication(); - injectActivity(application.getApplicationComponent()); +// 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(); @@ -45,4 +43,5 @@ public abstract class BaseFragment extends Fragment { void runOnDbThread(Runnable runnable); } + } diff --git a/briar-android/src/org/briarproject/android/fragment/DashboardFragment.java b/briar-android/src/org/briarproject/android/fragment/DashboardFragment.java deleted file mode 100644 index f98c16ab08336ebfc98b50e94fca9fa2dca5ef51..0000000000000000000000000000000000000000 --- a/briar-android/src/org/briarproject/android/fragment/DashboardFragment.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.briarproject.android.fragment; - - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -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; - -import java.util.logging.Logger; - -import javax.inject.Inject; - -public class DashboardFragment extends BaseEventFragment { - - public final static String TAG = "DashboardFragment"; - - private static final Logger LOG = - Logger.getLogger(DashboardFragment.class.getName()); - - @Inject - protected PluginManager pluginManager; - - public static DashboardFragment newInstance() { - - Bundle args = new Bundle(); - - DashboardFragment fragment = new DashboardFragment(); - fragment.setArguments(args); - return fragment; - } - - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View contentView = - inflater.inflate(R.layout.fragment_dashboard, container, false); - return contentView; - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - } - - @Override - public String getUniqueTag() { - return TAG; - } - - @Override - public void injectActivity(AndroidComponent component) { - - } - - @Override - public void eventOccurred(Event e) { - - } -} diff --git a/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java b/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java index d1d37f9facfcf74e757fba257fb2692755ec410d..b95ca581fcb5879bc198e345f0f25c07c2d8e53a 100644 --- a/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java +++ b/briar-android/src/org/briarproject/android/identity/CreateIdentityActivity.java @@ -14,6 +14,7 @@ import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.util.LayoutUtils; @@ -114,7 +115,7 @@ implements OnEditorActionListener, OnClickListener { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java b/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java index 2faf5f6193f074e43bc0c43d56794b42fb26365e..66a5c63eaa4730bbaf0b04904b2d70e549e54e22 100644 --- a/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java +++ b/briar-android/src/org/briarproject/android/invitation/AddContactActivity.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.api.ReferenceManager; @@ -145,7 +146,7 @@ implements InvitationListener { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/panic/ExitActivity.java b/briar-android/src/org/briarproject/android/panic/ExitActivity.java index 4417c1fe8f8500ea9c85fa46f748c984979dcc7d..7e85402018ee18a2c7bb901439cea1dfa7a5337f 100644 --- a/briar-android/src/org/briarproject/android/panic/ExitActivity.java +++ b/briar-android/src/org/briarproject/android/panic/ExitActivity.java @@ -3,6 +3,7 @@ package org.briarproject.android.panic; import android.os.Build; import android.os.Bundle; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BaseActivity; @@ -23,7 +24,7 @@ public class ExitActivity extends BaseActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { } } \ No newline at end of file diff --git a/briar-android/src/org/briarproject/android/panic/PanicPreferencesActivity.java b/briar-android/src/org/briarproject/android/panic/PanicPreferencesActivity.java index c25461c347476556401f09c57da3264b724112ec..f0645f3c2ed495066ab7d0b67cb536fc8f2c4e3e 100644 --- a/briar-android/src/org/briarproject/android/panic/PanicPreferencesActivity.java +++ b/briar-android/src/org/briarproject/android/panic/PanicPreferencesActivity.java @@ -5,6 +5,7 @@ import android.support.v7.app.ActionBar; import android.view.MenuItem; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; @@ -24,7 +25,7 @@ public class PanicPreferencesActivity extends BriarActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java b/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java index 87ba49e7023eada4ff2051e63baed477500d75a4..c57e44d03b15090f6cc17b944f0dca2fe44ac886 100644 --- a/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java +++ b/briar-android/src/org/briarproject/android/panic/PanicResponderActivity.java @@ -7,6 +7,7 @@ import android.os.Build; import android.os.Bundle; import android.support.v7.preference.PreferenceManager; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarActivity; import org.briarproject.android.api.AndroidExecutor; @@ -105,7 +106,7 @@ public class PanicResponderActivity extends BriarActivity { } @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } diff --git a/briar-android/src/org/briarproject/android/sdk/BriarHelper.java b/briar-android/src/org/briarproject/android/sdk/BriarHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..1cb8993ae8663620d4bb3b99141607c55a6b1e0a --- /dev/null +++ b/briar-android/src/org/briarproject/android/sdk/BriarHelper.java @@ -0,0 +1,4 @@ +package org.briarproject.android.sdk; + +public interface BriarHelper { +} diff --git a/briar-android/src/org/briarproject/android/sdk/BriarHelperImp.java b/briar-android/src/org/briarproject/android/sdk/BriarHelperImp.java new file mode 100644 index 0000000000000000000000000000000000000000..c83c33ac83f755abd14998b58b17abee1f7b4762 --- /dev/null +++ b/briar-android/src/org/briarproject/android/sdk/BriarHelperImp.java @@ -0,0 +1,13 @@ +package org.briarproject.android.sdk; + +import javax.inject.Inject; + +public class BriarHelperImp implements BriarHelper { + + + + @Inject + public BriarHelperImp() { + + } +}