diff --git a/.gitignore b/.gitignore index 8ab99ec..54b905a 100644 --- a/.gitignore +++ b/.gitignore @@ -64,9 +64,6 @@ release.properties # Ignore Gradle GUI config gradle-app.setting -# Properties -gradle.properties - # Mobile Tools for Java (J2ME) .mtj.tmp/ diff --git a/app/build.gradle b/app/build.gradle index 8f8d837..b0d5939 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,28 +14,13 @@ * limitations under the License. */ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: '../dependencies.gradle' - android { - compileSdk versions.compileSdk - defaultConfig { - minSdk versions.minSdk - targetSdk versions.targetSdk - applicationId "github.nisrulz.projectqreader" versionCode versions.appVersionCode versionName versions.appVersionName testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } buildFeatures { // Enabled View Binding @@ -44,7 +29,6 @@ android { } dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') // Support implementation androidX diff --git a/app/src/main/java/github/nisrulz/projectqreader/MainActivity.kt b/app/src/main/java/github/nisrulz/projectqreader/MainActivity.kt index ddeae88..a5fd03e 100644 --- a/app/src/main/java/github/nisrulz/projectqreader/MainActivity.kt +++ b/app/src/main/java/github/nisrulz/projectqreader/MainActivity.kt @@ -148,13 +148,13 @@ class MainActivity : AppCompatActivity() { internal fun readQRCodeFromDrawable(resID: Int) { qrEader = QREader.Builder(this, object : QRDataListener { - override fun onDetected(data: String) { + override fun onDetected(data: String?) { Log.d("QREader", "Value : $data") binding.txtQrCodeInfo.post { binding.txtQrCodeInfo.text = data } } - override fun onReadQrError(exception: Exception) { - Toast.makeText(this@MainActivity, exception.localizedMessage, Toast.LENGTH_LONG) + override fun onReadQrError(exception: Exception?) { + Toast.makeText(this@MainActivity, exception?.localizedMessage, Toast.LENGTH_LONG) .show() } }).build() @@ -167,12 +167,12 @@ class MainActivity : AppCompatActivity() { // Init QREader // ------------ qrEader = QREader.Builder(this, object : QRDataListener { - override fun onDetected(data: String) { + override fun onDetected(data: String?) { Log.d("QREader", "Value : $data") binding.txtQrCodeInfo.post { binding.txtQrCodeInfo.text = data } } - override fun onReadQrError(exception: Exception) { + override fun onReadQrError(exception: Exception?) { Toast.makeText(this@MainActivity, "Cannot open camera", Toast.LENGTH_LONG).show() } diff --git a/build.gradle b/build.gradle index f49f8dd..a262f84 100644 --- a/build.gradle +++ b/build.gradle @@ -15,11 +15,10 @@ */ // Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { // Gradle will not find vars defined in an external file when referring to them // in the buildscript block, unless you link it from the buildscript block, too. - apply from: 'dependencies.gradle' + apply from: "${rootDir}/configs/dependencies.gradle" repositories { google() @@ -31,13 +30,5 @@ buildscript { } } -allprojects { - repositories { - google() - mavenCentral() - } -} -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file +apply from: "${rootDir}/configs/all_projects.gradle" \ No newline at end of file diff --git a/configs/all_projects.gradle b/configs/all_projects.gradle new file mode 100644 index 0000000..52bb7be --- /dev/null +++ b/configs/all_projects.gradle @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +allprojects { + repositories { + google() + mavenCentral() + } + + switch (project.name) { + case "app": apply plugin: 'com.android.application'; break + default: apply plugin: 'com.android.library'; break + } + apply plugin: 'kotlin-android' + + android { + compileSdk versions.compileSdk + } + + apply from: "${rootDir}/configs/dependencies.gradle" + apply from: "${rootDir}/configs/android.gradle" +} diff --git a/configs/android.gradle b/configs/android.gradle new file mode 100644 index 0000000..fc9fdb6 --- /dev/null +++ b/configs/android.gradle @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +android { + defaultConfig { + minSdk versions.minSdk + targetSdk versions.targetSdk + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') +} \ No newline at end of file diff --git a/configs/dependencies.gradle b/configs/dependencies.gradle new file mode 100644 index 0000000..f47f410 --- /dev/null +++ b/configs/dependencies.gradle @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ext { + versions = [ + appVersionCode : 2, + appVersionName : '1.0.1', + + minSdk : 21, + targetSdk : 31, + compileSdk : 31, + + appcompat : '1.0.2', + annotation : '1.2.0', + lifeycle_runtime: '2.3.1', + + vision : '21.0.0', + + ] + + visionDeps = "com.google.firebase:firebase-ml-vision:$versions.vision" + + androidXDeps = [ + appcompat : "androidx.appcompat:appcompat:$versions.appcompat", + annotation : "androidx.annotation:annotation:$versions.annotation", + lifecycle_runtime: "androidx.lifecycle:lifecycle-runtime-ktx:$versions.lifeycle_runtime" + ] + + gradlePlug = [ + android : "com.android.tools.build:gradle:7.0.3", + kotlin : "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31", + nexus_plugin: "com.vanniktech:gradle-maven-publish-plugin:0.18.0", + ] + + gradlePlugins = gradlePlug.values() + androidX = androidXDeps.values() +} diff --git a/configs/library.gradle b/configs/library.gradle new file mode 100644 index 0000000..6f54a76 --- /dev/null +++ b/configs/library.gradle @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2016 Nishant Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// To publish to the local maven repository on your machine (~/.m2/repository), +// run: ./gradlew publishToMavenLocal +apply plugin: "com.vanniktech.maven.publish" + +final versionCode = 13 +final versionName = "2.2.0" + +android { + defaultConfig { + // define version + buildConfigField 'int', 'VERSION_CODE', "${versionCode}" + buildConfigField 'String', 'VERSION_NAME', "\"${versionName}\"" + + consumerProguardFiles 'consumer-proguard-rules.pro' + } +} + +dependencies { + implementation androidXDeps.annotation + api visionDeps +} \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle deleted file mode 100644 index 6308cf1..0000000 --- a/dependencies.gradle +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2017 Nishant Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -ext { - versions = [ - appVersionCode : 2, - appVersionName : '1.0.1', - - minSdk : 21, - targetSdk : 31, - compileSdk : 31, - - androidGradlePlugin: '7.0.3', - kotlinVersion : '1.5.31', - - appcompat : '1.0.2', - annotation : '1.2.0', - - lifeycle_runtime : '2.3.1', - vision : '21.0.0', - - ] - - - visionDeps = [vision: "com.google.firebase:firebase-ml-vision:$versions.vision"] - - - lifecycle = [ - 'runtime': "androidx.lifecycle:lifecycle-runtime-ktx:$versions.lifeycle_runtime" - ] - - androidXDeps = [ - appcompat : "androidx.appcompat:appcompat:$versions.appcompat", - annotation: "androidx.annotation:annotation:$versions.annotation" - ] - - gradlePlug = [ - android: "com.android.tools.build:gradle:$versions.androidGradlePlugin", - kotlin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion", - ] - - gradlePlugins = gradlePlug.values() - androidX = androidXDeps.values() - vision = visionDeps.values() -} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..1cc482d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,27 @@ +android.enableJetifier=true +android.useAndroidX=true + +# Disable signing for generating an unsigned build +# RELEASE_SIGNING_ENABLED=false + +# QReader Configs +GROUP=com.github.nisrulz +POM_ARTIFACT_ID=qreader +VERSION_NAME=2.2.0 + +POM_NAME=QReader +POM_DESCRIPTION=Android library that uses google\'s mobile vision api and simplify the QR code reading process. +POM_INCEPTION_YEAR=2016 +POM_URL=https://github.com/nisrulz/qreader + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENSE_DIST=repo + +POM_SCM_URL=https://github.com/nisrulz/qreader +POM_SCM_CONNECTION=scm:git:git://github.com/nisrulz/qreader.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/nisrulz/qreader.git + +POM_DEVELOPER_ID=nisrulz +POM_DEVELOPER_NAME=Nishant Srivastava +POM_DEVELOPER_URL=https://github.com/nisrulz/ \ No newline at end of file diff --git a/libconfig.gradle b/libconfig.gradle deleted file mode 100644 index 9595725..0000000 --- a/libconfig.gradle +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2017 Nishant Srivastava - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// Replace nisrulz with -final group = "com.github.nisrulz" -final artifact = "qreader" -final versionCode = 13 -final versionName = "2.2.0" - -android { - defaultConfig { - // define version - buildConfigField 'int', 'VERSION_CODE', "${versionCode}" - buildConfigField 'String', 'VERSION_NAME', "\"${versionName}\"" - } -} - - -ext { - libConfig = [ - versionCode : 13, - versionName : '2.2.0', - pomUrl : 'https://github.com/nisrulz/qreader', - githubRepo : 'nisrulz/qreader', - - moduleName : 'qreader', - moduleDesc : 'Android library that uses google\'s mobile vision api and simplify the QR code reading process.', - bintrayName : 'com.github.nisrulz:qreader', - - publishedGroupId: GROUP, - developerId : POM_DEVELOPER_ID, - developerName : POM_DEVELOPER_NAME, - developerEmail : POM_DEVELOPER_EMAILID, - licenseName : POM_LICENCE_NAME, - licenseUrl : POM_LICENCE_URL, - allLicenses : [POM_ALL_LICENCES], - ] - - bintray = [ - user : BINTRAY_USER, - apikey: BINTRAY_APIKEY - ] -} \ No newline at end of file diff --git a/qreader/build.gradle b/qreader/build.gradle index 77e1a93..222157a 100644 --- a/qreader/build.gradle +++ b/qreader/build.gradle @@ -14,30 +14,4 @@ * limitations under the License. */ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply from: '../dependencies.gradle' -//apply from: '../libconfig.gradle' - -android { - compileSdk versions.compileSdk - - defaultConfig { - minSdk versions.minSdk - targetSdk versions.targetSdk - - consumerProguardFiles 'consumer-proguard-rules.pro' - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation androidXDeps.annotation - api vision -} +apply from: "${rootDir}/configs/library.gradle"