mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 13:00:18 +03:00
decouples the flavor code / OSS licenses activity launching
This commit is contained in:
parent
0c61595ace
commit
ed3b73a989
6 changed files with 40 additions and 12 deletions
|
@ -27,6 +27,7 @@ import im.vector.app.core.services.GuardServiceStarter
|
||||||
import im.vector.app.fdroid.service.FDroidGuardServiceStarter
|
import im.vector.app.fdroid.service.FDroidGuardServiceStarter
|
||||||
import im.vector.app.features.home.NightlyProxy
|
import im.vector.app.features.home.NightlyProxy
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
|
import im.vector.app.features.settings.legals.FlavourLegals
|
||||||
import im.vector.app.push.fcm.FdroidFcmHelper
|
import im.vector.app.push.fcm.FdroidFcmHelper
|
||||||
|
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
|
@ -45,6 +46,15 @@ abstract class FlavorModule {
|
||||||
// no op
|
// no op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun providesFlavorLegals() = object : FlavourLegals {
|
||||||
|
override fun hasThirdPartyNotices() = false
|
||||||
|
|
||||||
|
override fun navigateToThirdPartyNotices(context: Context) {
|
||||||
|
// no op
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 New Vector Ltd
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,5 +19,15 @@ package im.vector.app
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
|
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
|
||||||
|
import im.vector.app.features.settings.legals.FlavourLegals
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
fun openOssLicensesMenuActivity(context: Context) = context.startActivity(Intent(context, OssLicensesMenuActivity::class.java))
|
class GoogleFlavorLegals @Inject constructor() : FlavourLegals {
|
||||||
|
|
||||||
|
override fun hasThirdPartyNotices() = true
|
||||||
|
|
||||||
|
override fun navigateToThirdPartyNotices(context: Context) {
|
||||||
|
// See https://developers.google.com/android/guides/opensource
|
||||||
|
context.startActivity(Intent(context, OssLicensesMenuActivity::class.java))
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,9 +21,11 @@ import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import im.vector.app.GoogleFlavorLegals
|
||||||
import im.vector.app.core.pushers.FcmHelper
|
import im.vector.app.core.pushers.FcmHelper
|
||||||
import im.vector.app.core.services.GuardServiceStarter
|
import im.vector.app.core.services.GuardServiceStarter
|
||||||
import im.vector.app.features.home.NightlyProxy
|
import im.vector.app.features.home.NightlyProxy
|
||||||
|
import im.vector.app.features.settings.legals.FlavourLegals
|
||||||
import im.vector.app.nightly.FirebaseNightlyProxy
|
import im.vector.app.nightly.FirebaseNightlyProxy
|
||||||
import im.vector.app.push.fcm.GoogleFcmHelper
|
import im.vector.app.push.fcm.GoogleFcmHelper
|
||||||
|
|
||||||
|
@ -43,4 +45,8 @@ abstract class FlavorModule {
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindsFcmHelper(fcmHelper: GoogleFcmHelper): FcmHelper
|
abstract fun bindsFcmHelper(fcmHelper: GoogleFcmHelper): FcmHelper
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
abstract fun bindsFlavorLegals(legals: GoogleFlavorLegals): FlavourLegals
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 New Vector Ltd
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -14,9 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package im.vector.app
|
package im.vector.app.features.settings.legals
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
|
||||||
// No op
|
interface FlavourLegals {
|
||||||
fun openOssLicensesMenuActivity(@Suppress("UNUSED_PARAMETER") context: Context) = Unit
|
fun hasThirdPartyNotices(): Boolean
|
||||||
|
fun navigateToThirdPartyNotices(context: Context)
|
||||||
|
}
|
|
@ -38,7 +38,8 @@ class LegalsController @Inject constructor(
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val resources: Resources,
|
private val resources: Resources,
|
||||||
private val elementLegals: ElementLegals,
|
private val elementLegals: ElementLegals,
|
||||||
private val errorFormatter: ErrorFormatter
|
private val errorFormatter: ErrorFormatter,
|
||||||
|
private val flavourLegals: FlavourLegals,
|
||||||
) : TypedEpoxyController<LegalsState>() {
|
) : TypedEpoxyController<LegalsState>() {
|
||||||
|
|
||||||
var listener: Listener? = null
|
var listener: Listener? = null
|
||||||
|
@ -134,7 +135,7 @@ class LegalsController @Inject constructor(
|
||||||
clickListener { host.listener?.openThirdPartyNotice() }
|
clickListener { host.listener?.openThirdPartyNotice() }
|
||||||
}
|
}
|
||||||
// Only on Gplay
|
// Only on Gplay
|
||||||
if (resources.getBoolean(R.bool.isGplay)) {
|
if (flavourLegals.hasThirdPartyNotices()) {
|
||||||
discoveryPolicyItem {
|
discoveryPolicyItem {
|
||||||
id("eltpn2")
|
id("eltpn2")
|
||||||
name(host.stringProvider.getString(R.string.settings_other_third_party_notices))
|
name(host.stringProvider.getString(R.string.settings_other_third_party_notices))
|
||||||
|
|
|
@ -33,11 +33,11 @@ import im.vector.app.databinding.FragmentGenericRecyclerBinding
|
||||||
import im.vector.app.features.analytics.plan.MobileScreen
|
import im.vector.app.features.analytics.plan.MobileScreen
|
||||||
import im.vector.app.features.discovery.ServerPolicy
|
import im.vector.app.features.discovery.ServerPolicy
|
||||||
import im.vector.app.features.settings.VectorSettingsUrls
|
import im.vector.app.features.settings.VectorSettingsUrls
|
||||||
import im.vector.app.openOssLicensesMenuActivity
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LegalsFragment @Inject constructor(
|
class LegalsFragment @Inject constructor(
|
||||||
private val controller: LegalsController
|
private val controller: LegalsController,
|
||||||
|
private val flavourLegals: FlavourLegals,
|
||||||
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
|
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
|
||||||
LegalsController.Listener {
|
LegalsController.Listener {
|
||||||
|
|
||||||
|
@ -100,8 +100,7 @@ class LegalsFragment @Inject constructor(
|
||||||
|
|
||||||
override fun openThirdPartyNoticeGplay() {
|
override fun openThirdPartyNoticeGplay() {
|
||||||
if (firstThrottler.canHandle() is FirstThrottler.CanHandlerResult.Yes) {
|
if (firstThrottler.canHandle() is FirstThrottler.CanHandlerResult.Yes) {
|
||||||
// See https://developers.google.com/android/guides/opensource
|
flavourLegals.navigateToThirdPartyNotices(requireContext())
|
||||||
openOssLicensesMenuActivity(requireActivity())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue