diff --git a/.travis.yml b/.travis.yml
index ab003b9..28697e4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ jdk:
install:
# Let's use the new command 'sdkmanager' to install Android SDK components
-- yes | sdkmanager "build-tools;28.0.2"
+- yes | sdkmanager "build-tools;28.0.3"
- yes | sdkmanager "platform-tools"
- yes | sdkmanager "tools"
- yes | sdkmanager "platforms;android-28"
diff --git a/app/build.gradle b/app/build.gradle
index 3afea6c..413ed43 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,19 +1,16 @@
apply plugin: 'com.android.application'
-
apply plugin: 'kotlin-android'
-
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.crisolutions.commonlibrarysample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 3
- versionName "1.2.0"
+ versionName "1.3.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2a8824b..9cb078a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,6 +1,10 @@
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.crisolutions.commonlibrarysample">
+
+
+
+ android:theme="@style/AppTheme"
+ tools:ignore="AllowBackup,GoogleAppIndexingWarning">
+
-
+
-
+
-
-
\ No newline at end of file
+
diff --git a/app/src/main/java/com/crisolutions/commonlibrarysample/MainActivity.kt b/app/src/main/java/com/crisolutions/commonlibrarysample/MainActivity.kt
index c34a965..42fb2c5 100644
--- a/app/src/main/java/com/crisolutions/commonlibrarysample/MainActivity.kt
+++ b/app/src/main/java/com/crisolutions/commonlibrarysample/MainActivity.kt
@@ -1,9 +1,15 @@
package com.crisolutions.commonlibrarysample
+import android.Manifest.permission.CAMERA
+import android.os.Build
import android.os.Bundle
+import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
+import androidx.core.content.PermissionChecker.PERMISSION_GRANTED
+import com.crisolutions.commonlib.utils.permissions.PermissionCheckerUtil
import com.crisolutions.commonlibrarysample.Samples.SampleJ
import com.crisolutions.commonlibrarysample.Samples.SampleKt
+import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
@@ -22,5 +28,28 @@ class MainActivity : AppCompatActivity() {
sampleK.capitalizeWords()
sampleJ.capitalizeWords()
+
+ button_request_permission.setOnClickListener {
+ if (PermissionCheckerUtil.hasPermission(CAMERA, this)) {
+ Toast.makeText(this, "Camera Permission has been granted", Toast.LENGTH_SHORT).show()
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ requestPermissions(arrayOf(CAMERA), REQUEST_CODE_CAMERA_PERMISSION)
+ }
+ }
+ }
+
+ override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ if (requestCode == REQUEST_CODE_CAMERA_PERMISSION) {
+ if (grantResults[0] == PERMISSION_GRANTED) {
+ Toast.makeText(this, "Camera Permission granted", Toast.LENGTH_SHORT).show()
+ } else {
+ Toast.makeText(this, "Camera Permission denied", Toast.LENGTH_SHORT).show()
+ }
+ }
+ }
+
+ companion object {
+ private const val REQUEST_CODE_CAMERA_PERMISSION: Int = 4
}
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 99cd5d3..285dcf9 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -3,10 +3,19 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical"
tools:context="com.crisolutions.commonlibrarysample.MainActivity">
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7dbda16..00c236e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,4 @@
Solutions Common Library
+ Request Camera Permission
diff --git a/build.gradle b/build.gradle
index 4970d65..ba3f8d5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,11 +1,11 @@
buildscript {
- ext.kotlinVersion = '1.3.0'
+ ext.kotlinVersion = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.0'
+ classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
@@ -18,8 +18,6 @@ allprojects {
}
ext {
- supportLibraryVersion = '28.0.0'
- buildToolsVersion = '28.0.2'
daggerVersion = '2.17'
timberVersion = '4.7.1'
retrofitVersion = '2.4.0'
@@ -44,7 +42,6 @@ ext {
}
ext.deps = [
-
'base' :
[
dagger : "com.google.dagger:dagger:${daggerVersion}",
@@ -54,7 +51,6 @@ ext.deps = [
stdlibKt: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
],
- // Test Dependencies
'test' :
[
junit : "junit:junit:$junitVersion",
diff --git a/commonlib/build.gradle b/commonlib/build.gradle
index ec263a5..c6ab7ca 100644
--- a/commonlib/build.gradle
+++ b/commonlib/build.gradle
@@ -1,8 +1,8 @@
apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
@@ -29,9 +29,10 @@ dependencies {
implementation deps.androidx.exif
implementation deps.base.dagger
- implementation deps.base.timber
implementation deps.base.retrofit
implementation deps.base.rxjava
+ implementation deps.base.stdlibKt
+ implementation deps.base.timber
testImplementation deps.test.junit
androidTestImplementation deps.test.androidTestRunner
diff --git a/commonlib/src/main/java/com/crisolutions/commonlib/utils/permissions/PermissionCheckerUtil.kt b/commonlib/src/main/java/com/crisolutions/commonlib/utils/permissions/PermissionCheckerUtil.kt
new file mode 100644
index 0000000..f4387ea
--- /dev/null
+++ b/commonlib/src/main/java/com/crisolutions/commonlib/utils/permissions/PermissionCheckerUtil.kt
@@ -0,0 +1,21 @@
+package com.crisolutions.commonlib.utils.permissions
+
+import android.annotation.TargetApi
+import android.content.Context
+import android.os.Build
+import androidx.core.content.PermissionChecker
+import androidx.core.content.PermissionChecker.PERMISSION_GRANTED
+
+object PermissionCheckerUtil {
+ @TargetApi(Build.VERSION_CODES.M)
+ @JvmStatic
+ fun hasPermission(
+ permissionString: String,
+ context: Context?
+ ) = when {
+ Build.VERSION.SDK_INT < Build.VERSION_CODES.M -> true
+ context != null ->
+ PermissionChecker.checkSelfPermission(context, permissionString) == PERMISSION_GRANTED
+ else -> false
+ }
+}
diff --git a/commonlibktx/build.gradle b/commonlibktx/build.gradle
index d7c9bf5..d3e657c 100644
--- a/commonlibktx/build.gradle
+++ b/commonlibktx/build.gradle
@@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index bd24854..b10568f 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip