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"> + +