-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the dagger.android.support lib for compatibility with AppCompatActivity and support Fragment with minSdkVersion changed from 17 to 14. Closes #48 #49
Conversation
@@ -25,7 +25,7 @@ android { | |||
versionCode 1 | |||
versionName '1.0.0' | |||
|
|||
minSdkVersion 17 | |||
minSdkVersion 14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minSdkVersion
of 17 is the lowest version that our non-support setup in master supports due to Fragment.getChildFragmentManager()
and Fragment.onViewStateRestored
only being available starting at API level 17.
The minSdkVersion
14 is the lowest version that dagger.android.support API supports. See https://github.com/google/dagger/blob/master/java/dagger/android/support/AndroidManifest.xml#L18
@@ -21,7 +21,10 @@ | |||
<application | |||
android:name=".App" | |||
android:icon="@mipmap/ic_launcher" | |||
android:label="@string/app_name"> | |||
android:label="@string/app_name" | |||
android:theme="@style/Theme.AppCompat"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theme.AppCompat (or descendant) is required for AppCompatActivity
|
||
/** | ||
* Provides application-wide dependencies. | ||
*/ | ||
@Module(includes = AndroidInjectionModule.class) | ||
@Module(includes = AndroidSupportInjectionModule.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AndroidSupportInjectionModule
includes AndroidInjectionModule
implicitly.
…Activity and support Fragment with minSdkVersion changed from 17 to 14. Closes #48
12253ce
to
80140a8
Compare
AndroidInjection.inject(this); | ||
} | ||
// This is called even for API levels below 23. | ||
AndroidSupportInjection.inject(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now only invoked in onAttach(Context)
because the support Fragment
provides this method even to devices running API level 22 and below.
@@ -30,5 +30,9 @@ allprojects { | |||
repositories { | |||
jcenter() | |||
mavenCentral() | |||
// Required for dagger.android.support | |||
maven { | |||
url "https://maven.google.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required for dagger.android.support
This answers #48.
This feature branch will get merged into the master-support branch- not the master branch. I will be keeping the non-support and support setups separate to keep things as clean as possible.
Branches
Activity
andFragment
classes with aminSdkVersion
of 17.AppCompatActivity
and supportFragment
classes with aminSdkVersion
of 14.This branch is an extension of the master branch, containing all changes from master.
Take a look at PR Using the dagger.android.support lib for compatibility with AppCompatActivity and support Fragment with minSdkVersion changed from 17 to 14. Closes #48 #49 for the main diff from master.
Why is the
minSdkVersion
of the non-support setup in master 17? Can it be lower?There are 2 main reasons why the
minSdkVersion
of the non-support setup can only be as low as 17.Thus, the lowest
minSdkVersion
supported for the non-support setup in master is 17.It cannot be lower.
What about the
minSdkVersion
of the support setup in master-support? Can it be lower than 14?No. The dagger.android.support API only supports
minSdkVersion
as low as 14.
Changes
17
to14
Theme.AppCompat
AndroidSupportInjectionModule
instead ofAndroidInjectionModule
in AppModule includesBaseActivity
and module now usingAppCompatActivity
BaseFragment
and module now usingandroid.support.v4.app.Fragment
BaseFragment
now injecting withAndroidSupportInjection.inject(this)
in onlyonAttach(Context)
HasFragmentInjector
withHasSupportFragmentInjector
android.app.Fragment
withandroid.support.v4.app.Fragment
android.app.FragmentManager
withandroid.support.v4.app.FragmentManager