Skip to content

Commit

Permalink
Merge pull request #4 from erikeelde/feature/androidx
Browse files Browse the repository at this point in the history
Feature/androidx
  • Loading branch information
erikeelde authored Mar 6, 2019
2 parents 9d4b728 + 12b997d commit 9cbc22e
Show file tree
Hide file tree
Showing 43 changed files with 533 additions and 517 deletions.
34 changes: 0 additions & 34 deletions app/build.gradle

This file was deleted.

39 changes: 39 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
plugins {
id("com.android.application")
kotlin("android")
kotlin("android.extensions")
}

android {
compileSdkVersion(28)

defaultConfig {
applicationId = "se.eelde.granter.app"
minSdkVersion(17)
targetSdkVersion(28)
versionCode = 2
versionName = "1.0.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

dependencies {
implementation("androidx.appcompat:appcompat:1.0.2")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
implementation(project(path = ":granter"))
implementation(embeddedKotlin("stdlib-jdk7"))
}

8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="se.eelde.granter.app">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Expand All @@ -9,12 +10,13 @@
<uses-permission android:name="android.permission.READ_CONTACTS" />

<application
android:allowBackup="true"
android:allowBackup="false"
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="GoogleAppIndexingWarning">
<activity android:name=".PermissionRequestingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -24,8 +26,6 @@
</activity>

<activity android:name=".RegularPermissionActivity" />

<activity android:name=".PermisoPermissionActivity" />
</application>

</manifest>
Binary file added app/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 0 additions & 26 deletions app/src/main/java/se/eelde/granter/app/DummyFragment.java

This file was deleted.

19 changes: 19 additions & 0 deletions app/src/main/java/se/eelde/granter/app/DummyFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package se.eelde.granter.app

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

class DummyFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_dummy, container, false)
}

companion object {
internal fun newInstance(): Fragment {
return DummyFragment()
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package se.eelde.granter.app

import android.Manifest
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_permission_requesting.*
import pub.devrel.easypermissions.AfterPermissionGranted
import pub.devrel.easypermissions.EasyPermissions
import se.eelde.granter.Granter

class PermissionRequestingActivity : AppCompatActivity(), EasyPermissions.PermissionCallbacks {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.activity_permission_requesting)

regular_permission.setOnClickListener { RegularPermissionActivity.start(this) }

permission_1_button.setOnClickListener {
Granter.Builder(this)
.requestCode(RC_CAMERA)
.addPermission(Manifest.permission.CAMERA)
.build()
.show()
}

permission_2_button.setOnClickListener {
Granter.Builder(this)
.requestCode(RC_2)
.addPermission(Manifest.permission.SEND_SMS)
.build()
.show()
}

permission_multiple_button.setOnClickListener {
Granter.Builder(this)
.requestCode(RC_multiple)
.addPermission(Manifest.permission.RECORD_AUDIO, Manifest.permission.ACCESS_FINE_LOCATION)
.rationale("This app neeeds access to audio and location!")
.build()
.show()
}

if (savedInstanceState == null) {
supportFragmentManager
.beginTransaction()
.replace(fragment_container.id, PermissionRequestingFragment.newInstance())
.commit()
}
}

@AfterPermissionGranted(RC_CAMERA)
fun rc1() {
Toast.makeText(this, "TODO: rc1 things", Toast.LENGTH_SHORT).show()

supportFragmentManager
.beginTransaction()
.replace(fragment_container.id, DummyFragment.newInstance())
.commit()
}

@AfterPermissionGranted(RC_2)
fun rc2() {
Toast.makeText(this, "TODO: rc2 things", Toast.LENGTH_SHORT).show()
}

@AfterPermissionGranted(RC_multiple)
fun rc_multiple() {
Toast.makeText(this, "TODO: rc_multiple things", Toast.LENGTH_SHORT).show()
}

override fun onPermissionsGranted(requestCode: Int, perms: List<String>) {
Log.d(TAG, "onPermissionsGranted:" + requestCode + ":" + perms.size)
}

override fun onPermissionsDenied(requestCode: Int, perms: List<String>) {
Log.d(TAG, "onPermissionsDenied:" + requestCode + ":" + perms.size)
}

companion object {
private const val TAG = "PermissionActivity"
private const val RC_CAMERA = 121
private const val RC_2 = 122
private const val RC_multiple = 123

}
}

This file was deleted.

Loading

0 comments on commit 9cbc22e

Please sign in to comment.