Skip to content

Commit

Permalink
NTV-85: Target Android 12 (#1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadia committed Dec 7, 2021
1 parent 430a715 commit 3e27a16
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 80 deletions.
79 changes: 7 additions & 72 deletions app/build.gradle
Expand Up @@ -17,6 +17,7 @@ apply plugin: 'kotlin-parcelize'
apply plugin: 'com.apollographql.apollo'
apply plugin: 'jacoco'
apply from: 'quality.gradle'
apply from: "$project.rootDir/jacoco.gradle"

def externalPrivateVersion = new File(project.rootDir.path + "/app/external_version_code.txt").text.trim().toInteger()
def externalPublicVersion = new File(project.rootDir.path + "/app/external_version_name.txt").text.trim()
Expand All @@ -37,77 +38,15 @@ if (file('signing.gradle').exists()) {
apply from: 'signing.gradle'
}

jacoco {
toolVersion = "$jacoco_version"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}

// Creates tasks based on the application build variant (productFlavor + buildType = variant)
android.applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
def autoGenerated = ['**/R.class',
'**/R$*.class',
'**/Manifest*.*',
'android/**/*.*',
'**/BuildConfig.*',
'**/*$ViewBinder*.*',
'**/*$ViewInjector*.*',
'**/Lambda$*.class',
'**/Lambda.class',
'**/*Lambda.class',
'**/*Lambda*.class',
'**/*Dagger*.*',
'**/*_MembersInjector.class',
'**/Dagger*Component*.class',
'**/Dagger*Subcomponent*.class',
'**/*Subcomponent$Builder.class',
'**/*Module_*Factory.class',
'**/KSApplication.*',
'**/ApplicationModule.*',
'**/*Activity*.*',
'**/*Fragment*.*',
'**/*ViewHolder*.*',
'**/*Toolbar*.*',
'**/*Dialog*.*',
'**/ui/*.*',
'**/ui/views/*.*',
'**/databinding/*.*',
'**/mock/*.*',
'**/services/*.*',
'**/firebase/*.*',
'**/fragment/*.*']

/**
* Generates Jacoco coverage reports based off the unit tests.
*/
task("jacoco${variantName}Report", type: JacocoReport, dependsOn: "test${variantName}UnitTest") {
group 'Reporting'
description "Generate ${variantName} Jacoco coverage reports."

reports {
xml.enabled = true
html.enabled = true
}

// variant.javaCompile.source does not work
// traverses from starting point
sourceDirectories.from = files(android.sourceSets.main.java.srcDirs)
executionData.from = files("${buildDir}/jacoco/test${variantName}UnitTest.exec")
classDirectories.from = fileTree(dir: variant.javaCompileProvider.get().destinationDir, excludes: autoGenerated)
}

}

android {
compileSdkVersion 30
compileSdkVersion 31

defaultConfig {
applicationId "com.kickstarter"
minSdkVersion 23
targetSdkVersion 30
targetSdkVersion 31
testApplicationId "com.kickstarter.internal.debug.test"
testInstrumentationRunner "com.kickstarter.screenshoot.testing.KSScreenShotTestRunner"

Expand Down Expand Up @@ -190,6 +129,7 @@ android {

buildFeatures {
compose false
viewBinding true
}

lintOptions {
Expand All @@ -215,10 +155,6 @@ android {
}
}

buildFeatures {
viewBinding true
}

variantFilter { variant ->
def names = variant.flavors*.name
if( names.contains("regression")) {
Expand Down Expand Up @@ -253,7 +189,6 @@ apollo {
repositories {
// This is the only reference we cannot remove yet as it has not been migrated to mavenCentral() or google()
// see - https://github.com/google/flexbox-layout/issues/566
jcenter()
maven {
url 'https://maven.google.com'
}
Expand All @@ -268,7 +203,7 @@ dependencies {
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.work:work-runtime-ktx:2.6.0-beta01'
implementation 'androidx.work:work-runtime-ktx:2.7.0-alpha05'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
implementation 'com.apollographql.apollo:apollo-runtime:2.5.10'
implementation 'com.facebook.android:facebook-android-sdk:12.0.1'
Expand All @@ -279,8 +214,8 @@ dependencies {
kapt "com.github.frankiesardo:auto-parcel-processor:$auto_parcel_version"
implementation "com.google.android.gms:play-services-wallet:18.1.3"
implementation "com.google.android.exoplayer:exoplayer:2.15.1"
implementation 'com.google.android:flexbox:1.1.0'
implementation 'com.google.android.material:material:1.5.0-alpha01'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation 'com.google.android.material:material:1.5.0-alpha02'
final dagger_version = "2.39"
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
Expand Down
3 changes: 2 additions & 1 deletion app/src/internal/AndroidManifest.xml
Expand Up @@ -3,14 +3,15 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<application>
<application android:icon="@mipmap/ic_launcher">
<activity android:name=".ui.activities.InternalToolsActivity" />
<activity android:name=".ui.activities.FeatureFlagsActivity"/>
<activity android:name=".ui.activities.PlaygroundActivity" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="no" />
<provider
android:exported="false"
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="${applicationId}.firebaseinitprovider"
tools:node="remove"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Expand Up @@ -66,6 +66,7 @@
<activity
android:name=".ui.activities.DiscoveryActivity"
android:label="@string/app_name"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/DiscoveryActivity">
<intent-filter android:autoVerify="true">
Expand Down Expand Up @@ -189,6 +190,7 @@
android:name=".ui.activities.ProjectActivity"
android:parentActivityName=".ui.activities.DiscoveryActivity"
android:theme="@style/ProjectActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -249,7 +251,9 @@
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity android:name=".ui.activities.DeepLinkActivity" android:theme="@style/Theme.AppCompat.Translucent">
<activity android:name=".ui.activities.DeepLinkActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.Translucent">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/kickstarter/libs/PushNotifications.java
Expand Up @@ -341,7 +341,7 @@ private void displayNotificationFromUpdateActivity(final @NonNull PushNotificati
final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this.context)
.addNextIntentWithParentStack(messageThreadIntent);

return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_IMMUTABLE);
}

@VisibleForTesting
Expand All @@ -355,7 +355,7 @@ private void displayNotificationFromUpdateActivity(final @NonNull PushNotificati
final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this.context)
.addNextIntentWithParentStack(this.messageThreadIntent);

return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_IMMUTABLE);
}

private @NonNull NotificationCompat.Builder notificationBuilder(final @NonNull String title,
Expand All @@ -376,7 +376,7 @@ private void displayNotificationFromUpdateActivity(final @NonNull PushNotificati
final TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this.context)
.addNextIntentWithParentStack(projectIntent);

return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_IMMUTABLE);
}

private @NonNull PendingIntent projectUpdateContentIntent(final @NonNull PushNotificationEnvelope envelope,
Expand All @@ -395,7 +395,7 @@ private void displayNotificationFromUpdateActivity(final @NonNull PushNotificati
.addNextIntentWithParentStack(projectIntent)
.addNextIntent(updateIntent);

return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_IMMUTABLE);
}

private @NonNull PendingIntent surveyResponseContentIntent(final @NonNull PushNotificationEnvelope envelope,
Expand All @@ -410,7 +410,7 @@ private void displayNotificationFromUpdateActivity(final @NonNull PushNotificati
.addNextIntentWithParentStack(activityFeedIntent)
.addNextIntent(surveyResponseIntent);

return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_UPDATE_CURRENT);
return taskStackBuilder.getPendingIntent(envelope.signature(), PendingIntent.FLAG_IMMUTABLE);
}

private @Nullable Bitmap fetchBitmap(final @Nullable String url, final boolean transformIntoCircle) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
@@ -1,6 +1,6 @@
buildscript {
ext.kotlin_version = '1.5.21'
ext.jacoco_version = '0.8.5'
ext.jacoco_version = '0.8.7'

repositories {
google()
Expand Down
65 changes: 65 additions & 0 deletions jacoco.gradle
@@ -0,0 +1,65 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = "$jacoco_version"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}

// Creates tasks based on the application build variant (productFlavor + buildType = variant)
android.applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
def autoGenerated = ['**/R.class',
'**/R$*.class',
'**/Manifest*.*',
'android/**/*.*',
'**/BuildConfig.*',
'**/*$ViewBinder*.*',
'**/*$ViewInjector*.*',
'**/Lambda$*.class',
'**/Lambda.class',
'**/*Lambda.class',
'**/*Lambda*.class',
'**/*Dagger*.*',
'**/*_MembersInjector.class',
'**/Dagger*Component*.class',
'**/Dagger*Subcomponent*.class',
'**/*Subcomponent$Builder.class',
'**/*Module_*Factory.class',
'**/KSApplication.*',
'**/ApplicationModule.*',
'**/*Activity*.*',
'**/*Fragment*.*',
'**/*ViewHolder*.*',
'**/*Toolbar*.*',
'**/*Dialog*.*',
'**/ui/*.*',
'**/ui/views/*.*',
'**/databinding/*.*',
'**/mock/*.*',
'**/services/*.*',
'**/firebase/*.*',
'**/fragment/*.*']

/**
* Generates Jacoco coverage reports based off the unit tests.
*/
task("jacoco${variantName}Report", type: JacocoReport, dependsOn: "test${variantName}UnitTest") {
group 'Reporting'
description "Generate ${variantName} Jacoco coverage reports."

reports {
xml.enabled = true
html.enabled = true
}

// variant.javaCompile.source does not work
// traverses from starting point
sourceDirectories.from = files(android.sourceSets.main.java.srcDirs)
executionData.from = files("${buildDir}/jacoco/test${variantName}UnitTest.exec")
classDirectories.from = fileTree(dir: variant.javaCompileProvider.get().destinationDir, excludes: autoGenerated)
}

}

0 comments on commit 3e27a16

Please sign in to comment.