aboutsummaryrefslogtreecommitdiff
path: root/app/build.gradle
blob: b7c55000b47b42395d866b4731983279132007c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
repositories {
    mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 33

    defaultConfig {
        applicationId "dev.equestria.notifications"
        minSdkVersion 21
        targetSdkVersion 33

        versionCode 135
        versionName "1.6.0"
        buildConfigField 'String', "NTFY_VERSION", '"1.16.0"'

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        /* Required for Room schema migrations */
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            debuggable true
        }
    }

    flavorDimensions "store"
    productFlavors {
        play {
            buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'true'
            buildConfigField 'boolean', 'RATE_APP_AVAILABLE', 'true'
            buildConfigField 'boolean', 'INSTALL_PACKAGES_AVAILABLE', 'false'
        }
        fdroid {
            buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'false'
            buildConfigField 'boolean', 'RATE_APP_AVAILABLE', 'false'
            buildConfigField 'boolean', 'INSTALL_PACKAGES_AVAILABLE', 'true'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
        freeCompilerArgs += [
            '-Xjvm-default=all-compatibility' // https://stackoverflow.com/a/71234042/1440785
        ]
    }
}

// Disables GoogleServices tasks for F-Droid variant
android.applicationVariants.all { variant ->
    def shouldProcessGoogleServices = variant.flavorName == "play"
    def googleTask = tasks.findByName("process${variant.name.capitalize()}GoogleServices")
    googleTask.enabled = shouldProcessGoogleServices
}

// Strips out REQUEST_INSTALL_PACKAGES permission for Google Play variant
android.applicationVariants.all { variant ->
    def shouldStripInstallPermission = variant.flavorName == "play"
    if (shouldStripInstallPermission) {
        variant.outputs.each { output ->
            def processManifest = output.getProcessManifestProvider().get()
            processManifest.doLast { task ->
                def outputDir = task.getMultiApkManifestOutputDirectory().get().asFile
                def manifestOutFile = file("$outputDir/AndroidManifest.xml")
                def newFileContents = manifestOutFile.collect { s -> s.contains("android.permission.REQUEST_INSTALL_PACKAGES") ? "" : s }.join("\n")
                manifestOutFile.write(newFileContents, 'UTF-8')
            }
        }
    }
}

dependencies {
    // AndroidX, The Basics
    implementation "androidx.appcompat:appcompat:1.5.1"
    implementation "androidx.core:core-ktx:1.9.0"
    implementation "androidx.constraintlayout:constraintlayout:2.1.4"
    implementation "androidx.activity:activity-ktx:1.6.1"
    implementation "androidx.fragment:fragment-ktx:1.5.4"
    implementation "androidx.work:work-runtime-ktx:2.7.1"
    implementation 'androidx.preference:preference-ktx:1.2.0'

    // JSON serialization
    implementation 'com.google.code.gson:gson:2.10'

    // Room (SQLite)
    def room_version = "2.4.3"
    implementation "androidx.room:room-ktx:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    // OkHttp (HTTP library)
    implementation 'com.squareup.okhttp3:okhttp:4.10.0'

    // Firebase, sigh ... (only Google Play)
    playImplementation 'com.google.firebase:firebase-messaging:23.1.0'

    // RecyclerView
    implementation "androidx.recyclerview:recyclerview:1.3.0-rc01"

    // Swipe down to refresh
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

    // Material design
    implementation "com.google.android.material:material:1.6.1"

    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    // Image viewer
    implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
}