Merge pull request #6788 from vector-im/feature/adm/app-level-variant-v2

`:vector-app` level variants
This commit is contained in:
Adam Brown 2022-09-16 10:36:58 +01:00 committed by GitHub
commit b05d52bb6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 121 additions and 123 deletions

1
changelog.d/6779.misc Normal file
View File

@ -0,0 +1 @@
[Modules] Lifts the application variants to the app module

View File

@ -81,11 +81,11 @@ task generateCoverageReport(type: JacocoReport) {
task unitTestsWithCoverage(type: GradleBuild) {
// the 7.1.3 android gradle plugin has a bug where enableTestCoverage generates invalid coverage
startParameter.projectProperties.coverage = [enableTestCoverage: false]
tasks = [':vector:testGplayDebugUnitTest', ':matrix-sdk-android:testDebugUnitTest']
tasks = ['testDebugUnitTest']
}
task instrumentationTestsWithCoverage(type: GradleBuild) {
startParameter.projectProperties.coverage = [enableTestCoverage: true]
startParameter.projectProperties['android.testInstrumentationRunnerArguments.notPackage'] = 'im.vector.app.ui'
tasks = [':vector-app:connectedGplayDebugAndroidTest', ':vector:connectedGplayDebugAndroidTest', 'matrix-sdk-android:connectedDebugAndroidTest']
tasks = [':vector-app:connectedGplayDebugAndroidTest', ':vector:connectedDebugAndroidTest', 'matrix-sdk-android:connectedDebugAndroidTest']
}

View File

@ -12,6 +12,7 @@ org.gradle.jvmargs=-Xmx4g -Xms512M -XX:MaxPermSize=2048m -XX:MaxMetaspaceSize=1g
org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.vfs.watch=true
org.gradle.caching=true
# Android Settings
android.enableJetifier=true

View File

@ -291,6 +291,12 @@ android {
}
}
sourceSets {
nightly {
java.srcDirs += "src/release/java"
}
}
flavorDimensions "store"
productFlavors {
@ -340,16 +346,48 @@ android {
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
]
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation project(':vector')
implementation project(':vector-config')
debugImplementation project(':library:ui-styles')
implementation libs.dagger.hilt
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.sharetarget:sharetarget:1.1.0"
// Flipper, debug builds only
debugImplementation(libs.flipper.flipper) {
exclude group: 'com.facebook.fbjni', module: 'fbjni'
}
debugImplementation(libs.flipper.flipperNetworkPlugin) {
exclude group: 'com.facebook.fbjni', module: 'fbjni'
}
debugImplementation 'com.facebook.soloader:soloader:0.10.4'
debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0"
gplayImplementation "com.google.android.gms:play-services-location:16.0.0"
// UnifiedPush gplay flavor only
gplayImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.1.2') {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}
// Nightly
// API-only library
gplayImplementation libs.google.appdistributionApi
// Full SDK implementation
gplayImplementation libs.google.appdistribution
// OSS License, gplay flavor only
gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
kapt libs.dagger.hiltCompiler
kapt libs.airbnb.epoxyProcessor
androidTestImplementation libs.androidx.testCore
androidTestImplementation libs.androidx.testRunner
@ -374,5 +412,6 @@ dependencies {
androidTestImplementation libs.androidx.fragmentTesting
androidTestImplementation "org.jetbrains.kotlin:kotlin-reflect:1.7.10"
debugImplementation libs.androidx.fragmentTesting
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name="im.vector.app.features.debug.TestLinkifyActivity" />
<activity android:name="im.vector.app.features.debug.DebugPermissionActivity" />
<activity android:name="im.vector.app.features.debug.analytics.DebugAnalyticsActivity" />
<activity android:name="im.vector.app.features.debug.settings.DebugPrivateSettingsActivity" />
<activity android:name="im.vector.app.features.debug.sas.DebugSasEmojiActivity" />
<activity android:name="im.vector.app.features.debug.features.DebugFeaturesSettingsActivity" />
<activity android:name="im.vector.app.features.debug.DebugMenuActivity" />
<activity android:name="im.vector.app.features.debug.leak.DebugMemoryLeaksActivity" />
<activity
android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true" />
</application>
</manifest>

View File

@ -34,13 +34,13 @@ import im.vector.app.core.utils.PERMISSIONS_FOR_TAKING_PHOTO
import im.vector.app.core.utils.checkPermissions
import im.vector.app.core.utils.registerForPermissionsResult
import im.vector.app.core.utils.toast
import im.vector.app.databinding.ActivityDebugMenuBinding
import im.vector.app.features.debug.analytics.DebugAnalyticsActivity
import im.vector.app.features.debug.features.DebugFeaturesSettingsActivity
import im.vector.app.features.debug.leak.DebugMemoryLeaksActivity
import im.vector.app.features.debug.sas.DebugSasEmojiActivity
import im.vector.app.features.debug.settings.DebugPrivateSettingsActivity
import im.vector.app.features.qrcode.QrCodeScannerActivity
import im.vector.application.databinding.ActivityDebugMenuBinding
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkDefaultActivity
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkTestActivity
import im.vector.lib.ui.styles.debug.DebugMaterialThemeDarkVectorActivity

View File

@ -23,13 +23,13 @@ import android.widget.Toast
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.utils.checkPermissions
import im.vector.app.core.utils.onPermissionDeniedDialog
import im.vector.app.core.utils.onPermissionDeniedSnackbar
import im.vector.app.core.utils.registerForPermissionsResult
import im.vector.app.databinding.ActivityDebugPermissionBinding
import im.vector.application.R
import im.vector.application.databinding.ActivityDebugPermissionBinding
import timber.log.Timber
@AndroidEntryPoint

View File

@ -20,9 +20,9 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import im.vector.app.R
import im.vector.app.databinding.ActivityTestLinkifyBinding
import im.vector.app.databinding.ItemTestLinkifyBinding
import im.vector.application.R
import im.vector.application.databinding.ActivityTestLinkifyBinding
import im.vector.application.databinding.ItemTestLinkifyBinding
class TestLinkifyActivity : AppCompatActivity() {

View File

@ -25,7 +25,7 @@ import com.airbnb.mvrx.withState
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.extensions.toOnOff
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentDebugAnalyticsBinding
import im.vector.application.databinding.FragmentDebugAnalyticsBinding
import me.gujun.android.span.span
class DebugAnalyticsFragment : VectorBaseFragment<FragmentDebugAnalyticsBinding>() {

View File

@ -23,9 +23,9 @@ import android.widget.Spinner
import android.widget.TextView
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.application.R
@EpoxyModelClass
abstract class BooleanFeatureItem : VectorEpoxyModel<BooleanFeatureItem.Holder>(R.layout.item_feature) {
@ -70,8 +70,8 @@ abstract class BooleanFeatureItem : VectorEpoxyModel<BooleanFeatureItem.Holder>(
}
class Holder : VectorEpoxyHolder() {
val label by bind<TextView>(im.vector.app.R.id.feature_label)
val optionsSpinner by bind<Spinner>(im.vector.app.R.id.feature_options)
val label by bind<TextView>(R.id.feature_label)
val optionsSpinner by bind<Spinner>(R.id.feature_options)
}
interface Listener {

View File

@ -66,13 +66,13 @@ class DebugVectorOverrides(private val context: Context) : VectorOverrides {
suspend fun setHomeserverCapabilities(block: HomeserverCapabilitiesOverride.() -> HomeserverCapabilitiesOverride) {
val capabilitiesOverride = block(forceHomeserverCapabilities.firstOrNull() ?: HomeserverCapabilitiesOverride(null, null))
context.dataStore.edit { settings ->
when (capabilitiesOverride.canChangeDisplayName) {
when (val canChangeDisplayName = capabilitiesOverride.canChangeDisplayName) {
null -> settings.remove(forceCanChangeDisplayName)
else -> settings[forceCanChangeDisplayName] = capabilitiesOverride.canChangeDisplayName
else -> settings[forceCanChangeDisplayName] = canChangeDisplayName
}
when (capabilitiesOverride.canChangeAvatar) {
when (val canChangeAvatar = capabilitiesOverride.canChangeAvatar) {
null -> settings.remove(forceCanChangeAvatar)
else -> settings[forceCanChangeAvatar] = capabilitiesOverride.canChangeAvatar
else -> settings[forceCanChangeAvatar] = canChangeAvatar
}
}
}

View File

@ -23,9 +23,9 @@ import android.widget.Spinner
import android.widget.TextView
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.application.R
@EpoxyModelClass
abstract class EnumFeatureItem : VectorEpoxyModel<EnumFeatureItem.Holder>(R.layout.item_feature) {
@ -70,8 +70,8 @@ abstract class EnumFeatureItem : VectorEpoxyModel<EnumFeatureItem.Holder>(R.layo
}
class Holder : VectorEpoxyHolder() {
val label by bind<TextView>(im.vector.app.R.id.feature_label)
val optionsSpinner by bind<Spinner>(im.vector.app.R.id.feature_options)
val label by bind<TextView>(R.id.feature_label)
val optionsSpinner by bind<Spinner>(R.id.feature_options)
}
interface Listener {

View File

@ -25,7 +25,7 @@ import com.airbnb.mvrx.withState
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.epoxy.onClick
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentDebugMemoryLeaksBinding
import im.vector.application.databinding.FragmentDebugMemoryLeaksBinding
@AndroidEntryPoint
class DebugMemoryLeaksFragment :

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 New Vector Ltd
* 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.

View File

@ -21,9 +21,9 @@ import android.widget.TextView
import androidx.core.content.ContextCompat
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.application.R
import me.gujun.android.span.image
import me.gujun.android.span.span
import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentation

View File

@ -25,8 +25,8 @@ import android.view.ViewGroup
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentDebugPrivateSettingsBinding
import im.vector.app.features.home.room.list.home.release.ReleaseNotesActivity
import im.vector.application.databinding.FragmentDebugPrivateSettingsBinding
class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSettingsBinding>() {

View File

@ -24,7 +24,7 @@ import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.LinearLayout
import im.vector.app.databinding.ViewBooleanDropdownBinding
import im.vector.application.databinding.ViewBooleanDropdownBinding
class OverrideDropdownView @JvmOverloads constructor(
context: Context,

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="im.vector.app">
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
@ -15,7 +14,7 @@
<application>
<receiver
android:name=".fdroid.receiver.OnApplicationUpgradeOrRebootReceiver"
android:name="im.vector.app.fdroid.receiver.OnApplicationUpgradeOrRebootReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
@ -24,12 +23,12 @@
</receiver>
<receiver
android:name=".fdroid.receiver.AlarmSyncBroadcastReceiver"
android:name="im.vector.app.fdroid.receiver.AlarmSyncBroadcastReceiver"
android:enabled="true"
android:exported="false" />
<service
android:name=".fdroid.service.GuardAndroidService"
android:name="im.vector.app.fdroid.service.GuardAndroidService"
android:exported="false"
tools:ignore="Instantiatable" />

View File

@ -16,6 +16,7 @@
package im.vector.app.fdroid.receiver
import android.annotation.SuppressLint
import android.app.AlarmManager
import android.app.PendingIntent
import android.content.BroadcastReceiver
@ -65,6 +66,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() {
companion object {
private const val REQUEST_CODE = 0
@SuppressLint("WrongConstant") // PendingIntentCompat.FLAG_IMMUTABLE is a false positive
fun scheduleAlarm(context: Context, sessionId: String, delayInSeconds: Int, clock: Clock) {
// Reschedule
Timber.v("## Sync: Scheduling alarm for background sync in $delayInSeconds seconds")
@ -87,6 +89,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() {
}
}
@SuppressLint("WrongConstant") // PendingIntentCompat.FLAG_IMMUTABLE is a false positive
fun cancelAlarm(context: Context) {
Timber.v("## Sync: Cancel alarm for background sync")
val intent = Intent(context, AlarmSyncBroadcastReceiver::class.java)

View File

@ -18,6 +18,24 @@
tools:ignore="UnusedAttribute"
tools:replace="android:allowBackup">
<!-- Activity alias for the launcher Activity (must be declared after the Activity it targets) -->
<!-- exported="true" is required to launch application -->
<activity-alias
android:name=".features.Alias"
android:exported="true"
android:targetActivity="im.vector.app.features.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity-alias>
<!-- Providers -->
<!-- Remove WorkManagerInitializer Provider because we are using on-demand initialization of WorkManager-->

View File

@ -66,23 +66,6 @@ android {
testCoverageEnabled = coverage.enableTestCoverage
}
}
nightly {
initWith release
matchingFallbacks = ['release']
}
release
}
flavorDimensions "store"
productFlavors {
gplay {
dimension "store"
}
fdroid {
dimension "store"
}
}
compileOptions {
@ -111,10 +94,6 @@ android {
test {
java.srcDirs += "src/sharedTest/java"
}
// Add sourceSets for `release` version when building `nightly`
nightly {
java.srcDirs += "src/release/java"
}
}
buildFeatures {
@ -183,12 +162,6 @@ dependencies {
// Snap Helper https://github.com/rubensousa/GravitySnapHelper
api 'com.github.rubensousa:gravitysnaphelper:2.2.2'
// Nightly
// API-only library
gplayImplementation libs.google.appdistributionApi
// Full SDK implementation
gplayImplementation libs.google.appdistribution
// Work
api libs.androidx.work
@ -204,7 +177,7 @@ dependencies {
// UI
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation libs.google.material
implementation 'me.gujun.android:span:1.7'
api 'me.gujun.android:span:1.7'
implementation libs.markwon.core
implementation libs.markwon.extLatex
implementation libs.markwon.inlineParser
@ -256,15 +229,6 @@ dependencies {
// UnifiedPush
implementation 'com.github.UnifiedPush:android-connector:2.0.1'
// UnifiedPush gplay flavor only
gplayImplementation('com.google.firebase:firebase-messaging:23.0.8') {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}
// OSS License, gplay flavor only
gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation "androidx.emoji2:emoji2:1.1.0"
@ -300,14 +264,12 @@ dependencies {
implementation 'commons-codec:commons-codec:1.15'
// MapTiler
fdroidApi(libs.maplibre.androidSdk) {
api(libs.maplibre.androidSdk) {
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
fdroidApi(libs.maplibre.pluginAnnotation) {
api(libs.maplibre.pluginAnnotation) {
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
gplayApi libs.maplibre.androidSdk
gplayApi libs.maplibre.pluginAnnotation
// TESTS
testImplementation libs.tests.junit
@ -320,19 +282,6 @@ dependencies {
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}
// Flipper, debug builds only
debugImplementation(libs.flipper.flipper) {
exclude group: 'com.facebook.fbjni', module: 'fbjni'
}
debugImplementation(libs.flipper.flipperNetworkPlugin) {
exclude group: 'com.facebook.fbjni', module: 'fbjni'
}
debugImplementation 'com.facebook.soloader:soloader:0.10.4'
debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0"
// Activate when you want to check for leaks, from time to time.
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
androidTestImplementation libs.androidx.testCore
androidTestImplementation libs.androidx.testRunner
androidTestImplementation libs.androidx.testRules

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name="im.vector.app.features.pin.lockscreen.tests.LockScreenTestActivity" />
</application>
</manifest>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="im.vector.app">
<application>
<activity android:name=".features.debug.TestLinkifyActivity" />
<activity android:name=".features.debug.DebugPermissionActivity" />
<activity android:name=".features.debug.analytics.DebugAnalyticsActivity" />
<activity android:name=".features.debug.settings.DebugPrivateSettingsActivity" />
<activity android:name=".features.debug.sas.DebugSasEmojiActivity" />
<activity android:name=".features.debug.features.DebugFeaturesSettingsActivity" />
<activity android:name=".features.debug.DebugMenuActivity" />
<activity android:name=".features.debug.leak.DebugMemoryLeaksActivity" />
<activity
android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true" />
<!-- Used for UI tests to display the BiometricPrompt. It's normal that it appears as an error. -->
<activity android:exported="false" android:name=".features.pin.lockscreen.tests.LockScreenTestActivity" />
</application>
</manifest>

View File

@ -90,23 +90,6 @@
android:name=".features.MainActivity"
android:theme="@style/Theme.Vector.Launcher" />
<!-- Activity alias for the launcher Activity (must be declared after the Activity it targets) -->
<!-- exported="true" is required to launch application -->
<activity-alias
android:name=".features.Alias"
android:exported="true"
android:targetActivity=".features.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity-alias>
<activity android:name=".features.home.HomeActivity" />
<activity