-
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.
Merge pull request #4 from erikeelde/feature/androidx
Feature/androidx
- Loading branch information
Showing
43 changed files
with
533 additions
and
517 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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() | ||
} | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
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 | ||
|
||
} | ||
} | ||
|
44 changes: 0 additions & 44 deletions
44
app/src/main/java/se/eelde/granter/app/PermissionRequestingFragment.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.