-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd1faa7
commit 12b997d
Showing
15 changed files
with
364 additions
and
340 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
88 changes: 0 additions & 88 deletions
88
app/src/main/java/se/eelde/granter/app/PermissionRequestingActivity.java
This file was deleted.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
app/src/main/java/se/eelde/granter/app/PermissionRequestingActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
} | ||
|
46 changes: 0 additions & 46 deletions
46
app/src/main/java/se/eelde/granter/app/PermissionRequestingFragment.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
app/src/main/java/se/eelde/granter/app/PermissionRequestingFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package se.eelde.granter.app | ||
|
||
import android.Manifest | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.fragment.app.Fragment | ||
import kotlinx.android.synthetic.main.fragment_permission_requesting.view.* | ||
import pub.devrel.easypermissions.AfterPermissionGranted | ||
import se.eelde.granter.Granter | ||
|
||
/** | ||
* Created in [R.layout.activity_permission_requesting] | ||
*/ | ||
class PermissionRequestingFragment : Fragment() { | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_permission_requesting, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
view.fragment_permission_1_button.setOnClickListener { | ||
Granter.Builder(this) | ||
.requestCode(RC_READ_CONTACTS_PERM) | ||
.addPermission(Manifest.permission.READ_CONTACTS) | ||
.build() | ||
.show() | ||
} | ||
|
||
} | ||
|
||
@AfterPermissionGranted(RC_READ_CONTACTS_PERM) | ||
private fun contactsTask() { | ||
Toast.makeText(activity, "TODO: Read contacts things", Toast.LENGTH_LONG).show() | ||
} | ||
|
||
companion object { | ||
|
||
private const val RC_READ_CONTACTS_PERM = 122 | ||
|
||
internal fun newInstance(): Fragment { | ||
return PermissionRequestingFragment() | ||
} | ||
} | ||
} |
Oops, something went wrong.