apply plugin: 'com.android.application'

Properties properties = new Properties()
try {
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
} catch (Exception ex) {
    throw new GradleException("Missing local.properties file.");
}
def superpowered_sdk_path = properties.getProperty('superpowered.dir')


android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "at.ac.fhstp.sonicontrol"
        minSdkVersion 16 // more than 95% of all active Android devices (mid 2017)
        targetSdkVersion 28
        versionCode 24
        versionName "2.0.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' // these platforms cover 99% percent of all Android devices
        }

        externalNativeBuild {
            cmake {
                arguments '-DANDROID_PLATFORM=android-16', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_ARM_NEON=TRUE', '-DANDROID_STL=c++_static', "-DPATH_TO_SUPERPOWERED:STRING=${superpowered_sdk_path}"
                cFlags '-O3', '-fsigned-char' // full optimization, char data type is signed
                cppFlags '-fsigned-char', "-I${superpowered_sdk_path}"
            }
        }
    }
    buildTypes {
        debug {
            buildConfigField "String", "BASE_URL", "\"${properties.getProperty("baseUrl")}\""
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            buildConfigField "String", "BASE_URL", "\"${properties.getProperty("baseUrl")}\""
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['src/main/jni']
        }
    }
    externalNativeBuild {
        cmake {
            path 'src/main/jni/CMakeLists.txt'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'edu.emory.mathcs:JTransforms:2.4' // Used for FFT (noise generation and recognition)
    //Replaced by using JTransforms directly. implementation 'pl.edu.icm:JLargeArrays:1.6' // Better to have it here than in jar folder (see gitignore)
    //Not used anymore? implementation 'com.jjoe64:graphview:4.2.1'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'uk.me.berndporr:iirj:1.1' // Used for the high pass filtering

    implementation 'org.apache.commons:commons-lang3:3.8.1'
    implementation 'org.osmdroid:osmdroid-android:6.1.0'

    implementation 'com.github.MKergall:osmbonuspack:6.6.0'
    implementation 'androidx.multidex:multidex:2.0.0'
}
