Commit 0bb4b645 authored by Mark Murphy's avatar Mark Murphy

updated samples for Q Beta 2, new dependencies, etc.

parent 3c46f7ab
......@@ -59,7 +59,7 @@ class MainActivity : AppCompatActivity() {
.setDescription("This is the description")
.setSubtitle("This is the subtitle")
.setRequireConfirmation(true)
.setEnableFallback(true)
.setAllowDeviceCredential(true)
.build()
fingerprint.apply {
......
......@@ -28,6 +28,7 @@ import android.os.CancellationSignal
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.os.BuildCompat
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import kotlinx.android.synthetic.main.activity_main.*
......@@ -63,8 +64,8 @@ class MainActivity : AppCompatActivity() {
.setDescription("This is the description")
.setSubtitle("This is the subtitle")
.apply {
if (resources.getBoolean(R.bool.isQ)) {
setEnableFallback(true)
if (BuildCompat.isAtLeastQ()) {
setAllowDeviceCredential(true)
} else {
setNegativeButton(
"Ick!",
......
......@@ -47,6 +47,15 @@ android {
buildConfigField "boolean", "REQUEST_RUNTIME_PERMISSIONS", "false"
buildConfigField "String", "ROLE", "android.app.role.RoleManager.ROLE_GALLERY"
}
qperm {
dimension "scenario"
applicationId "com.commonsware.android.storage.qperm"
minSdkVersion "Q"
targetSdkVersion "Q"
buildConfigField "boolean", "REQUEST_RUNTIME_PERMISSIONS", "true"
buildConfigField "String", "ROLE", "null"
}
}
}
......
......@@ -16,7 +16,6 @@
package com.commonsware.android.storage
import android.Manifest
import android.annotation.TargetApi
import android.app.Activity
import android.app.role.RoleManager
......@@ -39,8 +38,11 @@ private const val ASSET_VIDEO = "sample.mp4"
private const val REQUEST_ROLE = 1337
class MainActivity : AbstractPermissionActivity() {
override val desiredPermissions =
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
override val desiredPermissions: Array<String> by lazy {
resources.getStringArray(
R.array.permissions
)
}
private val roleManager: RoleManager
by lazy { getSystemService(RoleManager::class.java) }
private val viewModel: TopViewModel by viewModel()
......@@ -67,7 +69,7 @@ class MainActivity : AbstractPermissionActivity() {
return super.onCreateOptionsMenu(menu)
}
@TargetApi(Build.VERSION_CODES.P)
@TargetApi(Build.VERSION_CODES.Q)
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when {
item.itemId == R.id.requestRole -> {
......@@ -83,7 +85,7 @@ class MainActivity : AbstractPermissionActivity() {
return super.onOptionsItemSelected(item)
}
@TargetApi(Build.VERSION_CODES.P)
@TargetApi(Build.VERSION_CODES.Q)
override fun onActivityResult(
requestCode: Int,
resultCode: Int,
......@@ -95,6 +97,7 @@ class MainActivity : AbstractPermissionActivity() {
}
}
@TargetApi(Build.VERSION_CODES.Q)
private fun allowRoleRequest() = resources.getBoolean(R.bool.isQ)
&& BuildConfig.ROLE != null
&& roleManager.isRoleAvailable(BuildConfig.ROLE)
......
......@@ -75,21 +75,24 @@ class ContentSource(
) {
withContext(Dispatchers.IO) {
val child = root.createFile(mimeType, name)
val uri = child!!.uri
ctxt.contentResolver.openOutputStream(uri).use {
creator(
it!!
)
}
child?.let {
val uri = child.uri
if (uri.scheme == ContentResolver.SCHEME_FILE) {
MediaScannerConnection.scanFile(
ctxt,
arrayOf(uri.path),
arrayOf(mimeType),
null
)
ctxt.contentResolver.openOutputStream(uri).use {
creator(
it!!
)
}
if (uri.scheme == ContentResolver.SCHEME_FILE) {
MediaScannerConnection.scanFile(
ctxt,
arrayOf(uri.path),
arrayOf(mimeType),
null
)
}
}
}
}
......@@ -114,8 +117,8 @@ class MediaSource(
generateSequence { if (cursor.moveToNext()) cursor else null }
.map {
StorageItem(
it.getString(nameColumn),
it.getString(typeColumn)
it.getString(nameColumn) ?: "Name not provided",
it.getString(typeColumn) ?: "unknown"
)
}
.toList()
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="permissions">
<item>android.permission.WRITE_EXTERNAL_STORAGE</item>
</string-array>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools"
package="com.commonsware.android.storage"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<application tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.APP_MUSIC" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="permissions">
<item>android.permission.READ_MEDIA_AUDIO</item>
<item>android.permission.READ_MEDIA_IMAGES</item>
<item>android.permission.READ_MEDIA_VIDEO</item>
</string-array>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">QPerm Storage Explorer</string>
</resources>
\ No newline at end of file
buildscript {
ext.kotlin_version = '1.3.21'
ext.kotlin_version = '1.3.30'
repositories {
google()
......@@ -29,11 +29,14 @@ task clean(type: Delete) {
ext {
appcompat_version = "1.0.2"
cardview_version = "1.0.0"
constraintlayout_version = "1.1.3"
coroutines_version = "1.1.0"
koin_version = "1.0.2"
lifecycle_version = "2.1.0-alpha03"
lifecycle_version = "2.1.0-alpha04"
recyclerview_version = "1.0.0"
sharetarget_version = "1.0.0-alpha01"
slice_version = "1.0.0"
viewpager_version = "1.0.0"
work_version = "2.0.0"
}
include ':StorageExplorer', ':ConditionalFile', ':PayAttention', ':SecureCheq',
':SecureCheqFallback'
\ No newline at end of file
include ':StorageExplorer', ':ConditionalFile', ':PayAttention', ':SecureCheq', ':TypeInfo', ':BasicBubble', ':ShareSomething', ':ShareTargets',
':SecureCheqFallback', ':SlicedBubble'
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment