-
Notifications
You must be signed in to change notification settings - Fork 739
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
Decouple :vector
variants/build types
#6783
Changes from 11 commits
e02cf61
19c8b2a
8156a64
02286b9
f605e0c
0c61595
ed3b73a
045398d
319ec6f
d794930
6526cf3
439224e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Decouples the variant logic from the vector module |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.debug.di | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import im.vector.app.core.debug.DebugNavigator | ||
import im.vector.app.core.debug.DebugReceiver | ||
import im.vector.app.core.debug.FlipperProxy | ||
import im.vector.app.features.debug.DebugMenuActivity | ||
import im.vector.app.flipper.VectorFlipperProxy | ||
import im.vector.app.receivers.VectorDebugReceiver | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
abstract class DebugModule { | ||
|
||
companion object { | ||
|
||
@Provides | ||
fun providesDebugNavigator() = object : DebugNavigator { | ||
override fun openDebugMenu(context: Context) { | ||
context.startActivity(Intent(context, DebugMenuActivity::class.java)) | ||
} | ||
} | ||
} | ||
|
||
@Binds | ||
abstract fun bindsDebugReceiver(receiver: VectorDebugReceiver): DebugReceiver | ||
|
||
@Binds | ||
abstract fun bindsFlipperProxy(flipperProxy: VectorFlipperProxy): FlipperProxy | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,20 +17,46 @@ | |
package im.vector.app.di | ||
|
||
import android.content.Context | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import im.vector.app.core.pushers.FcmHelper | ||
import im.vector.app.core.services.GuardServiceStarter | ||
import im.vector.app.fdroid.service.FDroidGuardServiceStarter | ||
import im.vector.app.features.home.NightlyProxy | ||
import im.vector.app.features.settings.VectorPreferences | ||
import im.vector.app.features.settings.legals.FlavourLegals | ||
import im.vector.app.push.fcm.FdroidFcmHelper | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@Module | ||
object FlavorModule { | ||
abstract class FlavorModule { | ||
|
||
@Provides | ||
fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter { | ||
return FDroidGuardServiceStarter(preferences, appContext) | ||
companion object { | ||
@Provides | ||
fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it is a detail but could we rename the provide methods using the prefix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good to me! |
||
return FDroidGuardServiceStarter(preferences, appContext) | ||
} | ||
|
||
@Provides | ||
fun provideNightlyProxy() = object : NightlyProxy { | ||
override fun onHomeResumed() { | ||
// no op | ||
} | ||
} | ||
|
||
@Provides | ||
fun providesFlavorLegals() = object : FlavourLegals { | ||
override fun hasThirdPartyNotices() = false | ||
|
||
override fun navigateToThirdPartyNotices(context: Context) { | ||
// no op | ||
} | ||
} | ||
} | ||
|
||
@Binds | ||
abstract fun bindsFcmHelper(fcmHelper: FdroidFcmHelper): FcmHelper | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ActivityComponent | ||
import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory | ||
import im.vector.app.push.fcm.FdroidNotificationTroubleshootTestManagerFactory | ||
|
||
@InstallIn(ActivityComponent::class) | ||
@Module | ||
abstract class NotificationTestModule { | ||
@Binds | ||
abstract fun bindsNotificationTestFactory(factory: FdroidNotificationTroubleshootTestManagerFactory): NotificationTroubleshootTestManagerFactory | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity | ||
import im.vector.app.features.settings.legals.FlavourLegals | ||
import javax.inject.Inject | ||
|
||
class GoogleFlavorLegals @Inject constructor() : FlavourLegals { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
override fun hasThirdPartyNotices() = true | ||
|
||
override fun navigateToThirdPartyNotices(context: Context) { | ||
// See https://developers.google.com/android/guides/opensource | ||
context.startActivity(Intent(context, OssLicensesMenuActivity::class.java)) | ||
} | ||
} |
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.
instead of relying on file overrides with the variants we can provide variant unique modules to the dagger graph and provide different implementations
the variant logic could also be extracted to their own modules in the future if wanted