From 47eabbfffc79a40362c7ff7f07373627b22ace9b Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 11 Aug 2016 19:44:46 -0500 Subject: [PATCH] Fix dagger warnings --- .../java/com/todoroo/astrid/test/DatabaseTestCase.java | 6 +++--- .../java/org/tasks/injection/InjectingTestCase.java | 4 +++- .../java/org/tasks/injection/TestComponent.java | 3 +++ .../java/org/tasks/injection/ActivityComponent.java | 1 + .../java/org/tasks/injection/BaseActivityComponent.java | 3 +++ .../org/tasks/injection/InjectingPreferenceActivity.java | 6 ++---- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/androidTest/java/com/todoroo/astrid/test/DatabaseTestCase.java b/src/androidTest/java/com/todoroo/astrid/test/DatabaseTestCase.java index 4b55c4b27..3b4303687 100644 --- a/src/androidTest/java/com/todoroo/astrid/test/DatabaseTestCase.java +++ b/src/androidTest/java/com/todoroo/astrid/test/DatabaseTestCase.java @@ -9,16 +9,16 @@ import com.todoroo.astrid.dao.Database; import org.tasks.injection.InjectingTestCase; -import javax.inject.Inject; - public abstract class DatabaseTestCase extends InjectingTestCase { - @Inject protected Database database; + protected Database database; @Override protected void setUp() { super.setUp(); + database = component.getDatabase(); + database.close(); getContext().deleteDatabase(database.getName()); database.openForWriting(); diff --git a/src/androidTest/java/org/tasks/injection/InjectingTestCase.java b/src/androidTest/java/org/tasks/injection/InjectingTestCase.java index 3e5c24245..13a4f3a4f 100644 --- a/src/androidTest/java/org/tasks/injection/InjectingTestCase.java +++ b/src/androidTest/java/org/tasks/injection/InjectingTestCase.java @@ -6,11 +6,13 @@ import static org.tasks.TestUtilities.initializeMockito; public abstract class InjectingTestCase extends AndroidTestCase { + protected TestComponent component; + @Override protected void setUp() { initializeMockito(getContext()); - TestComponent component = DaggerTestComponent.builder() + component = DaggerTestComponent.builder() .testModule(new TestModule(getContext())) .build(); inject(component); diff --git a/src/androidTestGoogleplay/java/org/tasks/injection/TestComponent.java b/src/androidTestGoogleplay/java/org/tasks/injection/TestComponent.java index b274bc1c4..95c13d760 100644 --- a/src/androidTestGoogleplay/java/org/tasks/injection/TestComponent.java +++ b/src/androidTestGoogleplay/java/org/tasks/injection/TestComponent.java @@ -1,5 +1,6 @@ package org.tasks.injection; +import com.todoroo.astrid.dao.Database; import com.todoroo.astrid.gtasks.GtasksIndentActionTest; import com.todoroo.astrid.gtasks.GtasksListServiceTest; import com.todoroo.astrid.gtasks.GtasksMetadataServiceTest; @@ -14,6 +15,8 @@ import dagger.Component; @Component(modules = TestModule.class) public interface TestComponent extends BaseTestComponent { + Database getDatabase(); + GtasksMetadataServiceTest.GtasksMetadataServiceTestComponent plus(GtasksMetadataServiceTest.GtasksMetadataServiceTestModule gtasksMetadataServiceTestModule); void inject(GtasksIndentActionTest gtasksIndentActionTest); diff --git a/src/googleplay/java/org/tasks/injection/ActivityComponent.java b/src/googleplay/java/org/tasks/injection/ActivityComponent.java index 3196f70ab..f4a29a438 100644 --- a/src/googleplay/java/org/tasks/injection/ActivityComponent.java +++ b/src/googleplay/java/org/tasks/injection/ActivityComponent.java @@ -13,6 +13,7 @@ import dagger.Subcomponent; @Singleton @Subcomponent(modules = ActivityModule.class) public interface ActivityComponent extends BaseActivityComponent { + void inject(GtasksPreferences gtasksPreferences); void inject(TaskerSettingsActivity taskerSettingsActivity); diff --git a/src/main/java/org/tasks/injection/BaseActivityComponent.java b/src/main/java/org/tasks/injection/BaseActivityComponent.java index e9624d657..4cb91501d 100644 --- a/src/main/java/org/tasks/injection/BaseActivityComponent.java +++ b/src/main/java/org/tasks/injection/BaseActivityComponent.java @@ -34,12 +34,15 @@ import org.tasks.preferences.MiscellaneousPreferences; import org.tasks.reminders.MissedCallActivity; import org.tasks.reminders.NotificationActivity; import org.tasks.reminders.SnoozeActivity; +import org.tasks.themes.Theme; import org.tasks.voice.VoiceCommandActivity; import org.tasks.widget.ShortcutConfigActivity; import org.tasks.widget.WidgetConfigActivity; public interface BaseActivityComponent { + Theme getTheme(); + FragmentComponent plus(FragmentModule module); DialogFragmentComponent plus(DialogFragmentModule dialogFragmentModule); diff --git a/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java b/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java index 84ee21f9b..4e8adc8a8 100644 --- a/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java +++ b/src/main/java/org/tasks/injection/InjectingPreferenceActivity.java @@ -17,8 +17,6 @@ import org.tasks.preferences.AppCompatPreferenceActivity; import org.tasks.themes.Theme; import org.tasks.ui.MenuColorizer; -import javax.inject.Inject; - import timber.log.Timber; public abstract class InjectingPreferenceActivity extends AppCompatPreferenceActivity implements InjectingActivity { @@ -27,8 +25,6 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct protected Toolbar toolbar; - @Inject Theme theme; - public InjectingPreferenceActivity() { Locale.getInstance(this).applyOverrideConfiguration(this); } @@ -40,6 +36,8 @@ public abstract class InjectingPreferenceActivity extends AppCompatPreferenceAct .plus(new ActivityModule(this)); inject(activityComponent); + Theme theme = activityComponent.getTheme(); + theme.applyThemeAndStatusBarColor(this, getDelegate()); super.onCreate(savedInstanceState);