Skip to content

Commit

Permalink
Merge pull request #27 from crisolutions/dev
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
benwicks authored Apr 11, 2019
2 parents 79fa18c + a57bf9b commit 2b10549
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}

Expand Down
17 changes: 11 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.crisolutions.commonlibrarysample">
xmlns:tools="http://schemas.android.com/tools"
package="com.crisolutions.commonlibrarysample">

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -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() {

Expand All @@ -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<out String>, 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
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>

<Button
android:id="@+id/button_request_permission"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:text="@string/request_camera_permission"/>
</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Solutions Common Library</string>
<string name="request_camera_permission">Request Camera Permission</string>
</resources>
8 changes: 2 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
}
Expand All @@ -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'
Expand All @@ -44,7 +42,6 @@ ext {
}

ext.deps = [

'base' :
[
dagger : "com.google.dagger:dagger:${daggerVersion}",
Expand All @@ -54,7 +51,6 @@ ext.deps = [
stdlibKt: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

],
// Test Dependencies
'test' :
[
junit : "junit:junit:$junitVersion",
Expand Down
5 changes: 3 additions & 2 deletions commonlib/build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 0 additions & 1 deletion commonlibktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apply plugin: 'kotlin-android'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2b10549

Please sign in to comment.