2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-22 09:58:08 +00:00
kdeconnect-android/build.gradle

237 lines
9.1 KiB
Groovy
Raw Normal View History

2020-04-29 18:59:00 +00:00
import com.android.build.gradle.AppExtension
import com.android.build.gradle.api.ApkVariantOutput
import com.android.build.gradle.api.ApplicationVariant
2021-01-12 04:04:28 +00:00
import com.github.jk1.license.render.TextReportRenderer
2018-01-23 00:18:43 +01:00
buildscript {
2023-05-20 14:00:41 +02:00
ext.kotlin_version = '1.8.21'
dependencies {
2023-05-28 11:45:29 +02:00
classpath 'com.android.tools.build:gradle:8.0.2'
2020-07-07 19:03:02 +05:30
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
2021-01-12 04:04:28 +00:00
plugins {
id 'com.github.jk1.dependency-license-report' version '1.16'
}
def licenseResDir = new File("$projectDir/build/dependency-license-res")
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
2023-04-25 23:37:31 +02:00
namespace 'org.kde.kdeconnect_tp'
compileSdkVersion 33
2016-05-19 09:38:24 -07:00
defaultConfig {
[SMS Plugin] Change android-smsmms to in-house build until upstream supports SDK31 ## Summary Android apps which target SDK 31+ require specifying the mutability of any PENDING_INTENT. This is not supported in the upstream android-smsmms library: https://github.com/klinker41/android-smsmms/pull/193 Until the above PR is merged, we need a solution. I have pulled the code into https://invent.kde.org/sredman/android-smsmms and published the package in the Maven repository in gitlab. BUG: 464392 ## Test Plan ### Before: Attempting to send an SMS or MMS message using kdeconnect-sms results in no message being sent, and an error being logged: > V/Sending message: Sending new SMS > E/Sending message: Exception > java.lang.IllegalArgumentException: org.kde.kdeconnect_tp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. > Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. > at android.app.PendingIntent.checkFlags(PendingIntent.java:382) > at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673) > at android.app.PendingIntent.getBroadcast(PendingIntent.java:660) > at com.klinker.android.send_message.Transaction.sendSmsMessage(Transaction.java:267) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:158) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:172) > at org.kde.kdeconnect.Plugins.SMSPlugin.SmsMmsUtils.sendMessage(SmsMmsUtils.java:188) > at org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin.onPacketReceived(SMSPlugin.java:414) > at org.kde.kdeconnect.Device.onPacketReceived(Device.java:570) > <snipped for brevity> ### After: SMS and MMS sends normally.
2023-01-23 22:02:01 +00:00
minSdkVersion 21
targetSdkVersion 32
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
2020-07-08 05:01:35 +05:30
buildFeatures {
viewBinding true
compose true
2020-07-08 05:01:35 +05:30
}
composeOptions {
2023-05-20 14:00:41 +02:00
kotlinCompilerExtensionVersion = "1.4.7"
}
2016-05-19 09:38:24 -07:00
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
2020-07-01 07:25:02 +05:30
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
}
2020-07-07 19:03:02 +05:30
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['resources']
res.srcDirs = [licenseResDir, 'res']
assets.srcDirs = ['assets']
}
test {
java.srcDirs = ['tests']
}
}
2014-01-10 23:26:32 +01:00
packagingOptions {
2022-03-03 23:58:23 +01:00
resources {
merges += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE']
}
}
signingConfigs {
debug {
storeFile file("debug.keystore")
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
2016-06-16 23:47:11 +02:00
debug {
minifyEnabled true
2020-08-02 06:31:33 +00:00
shrinkResources true
signingConfig signingConfigs.debug
2016-06-16 23:47:11 +02:00
}
// keep minifyEnabled false above for faster builds; set to 'true'
// when testing to make sure ProGuard/R8 is not deleting important stuff
release {
minifyEnabled true
2020-08-02 06:31:33 +00:00
shrinkResources true
}
}
2022-03-03 23:58:23 +01:00
lint {
abortOnError false
checkReleaseBuilds false
}
testOptions {
unitTests.all {
jvmArgs += [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.security=ALL-UNNAMED",
"--add-opens", "java.base/sun.security.rsa=ALL-UNNAMED",
"--add-opens", "java.base/sun.security.x509=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED"
]
}
}
}
2020-04-29 18:59:00 +00:00
/**
* This is a special on-demand Gradle object.
*
* Its value will not be determined until someone calls one of the gitHashProvider.getXXX() methods.
*
* If it does not encounter an explicit 'return' statement, getHashProvider.isPresent() will return false.
*/
Provider<String> gitHashProvider = project.provider {
Process gitCommand = null
try {
// This invokes 'git' immediately, but does not wait for it to finish
gitCommand = 'git rev-parse --short HEAD'.execute([], project.rootDir)
} catch (IOException ignored) {
}
if (gitCommand == null) {
logger.log(LogLevel.WARN, "Could not make use of the 'git' command-line tool. Output filenames will not be customized.")
} else if (gitCommand.waitFor() == 0) {
// This call to '::getText' (using the 'text' Groovy accessor syntax) collects the
// output stream
return '-' + gitCommand.text.trim()
} else {
logger.log(
LogLevel.WARN,
"Could not determine which commit is currently checked out -" +
" did you download this code without the .git directory?"
)
}
}
// We know we can safely cast the 'android' type to the 'AppExtension' class because
// we used the 'com.android.application' plugin at the top of the file.
//
// Note the use of the '::all' extension method; unlike '::each', it can detect every
// object added to the collection, no matter in which build phase that happens.
(android as AppExtension).applicationVariants.all { ApplicationVariant v ->
logger.log(LogLevel.INFO, "Found a variant called '${v.name}'.")
if (v.buildType.debuggable) {
// We're looking at variants made from android.buildTypes.debug! This one
// might have multiple outputs, but only one output will be an APK file.
v.outputs.matching { it instanceof ApkVariantOutput }.all {
// Default output filename is "${project.name}-${v.name}.apk". We want
// the Git commit short-hash to be added onto that default filename.
(it as ApkVariantOutput).outputFileName = "${project.name}-${v.name}${gitHashProvider.getOrElse("")}.apk"
}
}
}
2020-07-07 19:03:02 +05:30
ext {
2023-03-17 18:34:53 +01:00
coroutines_version = '1.6.4'
2020-07-07 19:03:02 +05:30
}
dependencies {
2023-04-13 18:37:27 +02:00
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
2020-07-01 07:25:02 +05:30
2023-05-20 14:00:41 +02:00
implementation 'androidx.compose.material3:material3:1.1.0'
implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3'
2023-05-31 13:40:29 +02:00
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'com.google.accompanist:accompanist-themeadapter-material3:0.31.0-alpha'
implementation 'androidx.constraintlayout:constraintlayout-compose:1.0.1'
2023-05-31 13:40:29 +02:00
implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3'
debugImplementation 'androidx.compose.ui:ui-tooling:1.4.3'
implementation 'androidx.media:media:1.6.0'
2023-03-04 16:04:22 +01:00
implementation 'androidx.appcompat:appcompat:1.6.1'
2023-05-20 14:00:41 +02:00
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.preference:preference-ktx:1.2.0'
2023-03-17 18:34:53 +01:00
implementation 'androidx.recyclerview:recyclerview:1.3.0'
2020-09-09 17:34:41 +05:30
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
2023-04-13 18:37:27 +02:00
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
2023-04-13 18:37:27 +02:00
implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.1'
2020-03-27 20:23:02 +01:00
implementation 'androidx.gridlayout:gridlayout:1.0.0'
2023-05-20 14:00:41 +02:00
implementation 'com.google.android.material:material:1.9.0'
implementation 'com.jakewharton:disklrucache:2.0.2' //For caching album art bitmaps
2018-11-02 13:02:49 +01:00
implementation 'org.apache.sshd:sshd-core:0.14.0'
implementation 'org.apache.mina:mina-core:2.0.19' //For some reason, makes sshd-core:0.14.0 work without NIO, which isn't available until Android 8 (api 26)
Use Storage Access Framework on SDK >= 21 (Lollipop and above) Summary: Use Storage Access Framework on Android running SDK >= 21 so writing to sdcard will work again |{F6546802}|{F6546803}|{F6546804}| |API 21+|API 19-|Edit| Test Plan: Install patch on Android phone with Build.Version < 19 (Kitkat) - Without a sdcard: Verify that dolphin displays an "All Files" entry that is empty - With a sdcard and with "Add camera folder shortcut" turned off: Verify that dolphin displays the configured display name of the sdcard - With a sdcard and with "Add camera folder shortcut" turned on: Verify that dolphin displays the configured display name of the sdcard and also lists a "Camera pictures" shortcut - With a sdcard: Verify that when changing the display name or the "Add camera folder shortcut" preference dolphin displays the updated items (after pressing F5) - With a sdcard: Verify that files can be read and written to/from the sdcard Install patch on Android phone with Build.Version < 19 (Kitkat) - Repeat the above tests except for the read/write test: Verify that files can be read from the sdcard Install patch on Android phone with Build.Version > 21 (Lollipop) - Without any configured storage locations: Verify dolphin displays an "All Files" entry that is empty - With configured storage locations: Verify dolphin displays the display names of the configured storage locations and that entering a location displays the correct directory entries - Make one or several changes to the configured storage locations: Verify dolphin displays the display names of the configured storage locations (after pressing F5) and that entering a location displays the correct directory entries Reviewers: #kde_connect, albertvaka, sredman Reviewed By: #kde_connect, albertvaka, sredman Subscribers: albertvaka, sredman, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D18212
2019-03-08 13:44:54 +01:00
//implementation('com.github.bright:slf4android:0.1.6') { transitive = true } // For org.apache.sshd debugging
implementation 'org.bouncycastle:bcpkix-jdk15on:1.70' //For SSL certificate generation
2016-06-12 21:07:01 +02:00
2023-03-17 18:34:53 +01:00
implementation 'org.atteo.classindex:classindex:3.13'
annotationProcessor 'org.atteo.classindex:classindex:3.13'
[SMS Plugin] Change android-smsmms to in-house build until upstream supports SDK31 ## Summary Android apps which target SDK 31+ require specifying the mutability of any PENDING_INTENT. This is not supported in the upstream android-smsmms library: https://github.com/klinker41/android-smsmms/pull/193 Until the above PR is merged, we need a solution. I have pulled the code into https://invent.kde.org/sredman/android-smsmms and published the package in the Maven repository in gitlab. BUG: 464392 ## Test Plan ### Before: Attempting to send an SMS or MMS message using kdeconnect-sms results in no message being sent, and an error being logged: > V/Sending message: Sending new SMS > E/Sending message: Exception > java.lang.IllegalArgumentException: org.kde.kdeconnect_tp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. > Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. > at android.app.PendingIntent.checkFlags(PendingIntent.java:382) > at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673) > at android.app.PendingIntent.getBroadcast(PendingIntent.java:660) > at com.klinker.android.send_message.Transaction.sendSmsMessage(Transaction.java:267) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:158) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:172) > at org.kde.kdeconnect.Plugins.SMSPlugin.SmsMmsUtils.sendMessage(SmsMmsUtils.java:188) > at org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin.onPacketReceived(SMSPlugin.java:414) > at org.kde.kdeconnect.Device.onPacketReceived(Device.java:570) > <snipped for brevity> ### After: SMS and MMS sends normally.
2023-01-23 22:02:01 +00:00
// The android-smsmms library is the only way I know to handle MMS in Android
// (Shouldn't a phone OS make phone things easy?)
// This library was originally authored as com.klinkerapps at https://github.com/klinker41/android-smsmms.
// However, that version is under-loved. I have therefore made "some fixes" and published it.
// Please see https://invent.kde.org/sredman/android-smsmms/-/tree/master
implementation 'org.kde.invent.sredman:android-smsmms:kdeconnect-1-21-0'
[SMS Plugin] Change android-smsmms to in-house build until upstream supports SDK31 ## Summary Android apps which target SDK 31+ require specifying the mutability of any PENDING_INTENT. This is not supported in the upstream android-smsmms library: https://github.com/klinker41/android-smsmms/pull/193 Until the above PR is merged, we need a solution. I have pulled the code into https://invent.kde.org/sredman/android-smsmms and published the package in the Maven repository in gitlab. BUG: 464392 ## Test Plan ### Before: Attempting to send an SMS or MMS message using kdeconnect-sms results in no message being sent, and an error being logged: > V/Sending message: Sending new SMS > E/Sending message: Exception > java.lang.IllegalArgumentException: org.kde.kdeconnect_tp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. > Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. > at android.app.PendingIntent.checkFlags(PendingIntent.java:382) > at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673) > at android.app.PendingIntent.getBroadcast(PendingIntent.java:660) > at com.klinker.android.send_message.Transaction.sendSmsMessage(Transaction.java:267) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:158) > at com.klinker.android.send_message.Transaction.sendNewMessage(Transaction.java:172) > at org.kde.kdeconnect.Plugins.SMSPlugin.SmsMmsUtils.sendMessage(SmsMmsUtils.java:188) > at org.kde.kdeconnect.Plugins.SMSPlugin.SMSPlugin.onPacketReceived(SMSPlugin.java:414) > at org.kde.kdeconnect.Device.onPacketReceived(Device.java:570) > <snipped for brevity> ### After: SMS and MMS sends normally.
2023-01-23 22:02:01 +00:00
implementation 'com.klinkerapps:logger:1.0.3'
2023-03-20 00:06:16 +01:00
implementation 'commons-io:commons-io:2.11.0'
2020-07-10 04:41:44 +05:30
implementation 'org.apache.commons:commons-collections4:4.4'
2023-01-02 21:58:18 +01:00
implementation 'org.apache.commons:commons-lang3:3.12.0'
2020-07-10 04:41:44 +05:30
implementation 'com.univocity:univocity-parsers:2.9.1'
2020-07-07 19:03:02 +05:30
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
2016-06-12 21:07:01 +02:00
// Testing
2022-12-30 23:56:21 +01:00
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.powermock:powermock-core:2.0.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0'
2023-01-02 21:58:18 +01:00
testImplementation 'org.mockito:mockito-core:3.12.4' // powermock isn't compatible with mockito 4
testImplementation 'org.skyscreamer:jsonassert:1.5.1'
// For device controls
implementation 'org.reactivestreams:reactive-streams:1.0.4'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
}
2020-03-27 20:23:02 +01:00
2021-01-12 04:04:28 +00:00
licenseReport {
configurations = ALL
renderers = [new TextReportRenderer()]
}
generateLicenseReport.doLast {
def target = new File(licenseResDir, "raw/license")
target.parentFile.mkdirs()
target.text =
files("COPYING", "$projectDir/build/reports/dependency-license/THIRD-PARTY-NOTICES.txt")
.collect { it.getText() }.join('\n')
}
preBuild.dependsOn(generateLicenseReport)