Commit 9d8e57e4 authored by Mark Murphy's avatar Mark Murphy

tweaks to support Q Beta 4

parent e67f44bc
......@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-Q'
compileSdkVersion 29
defaultConfig {
applicationId "com.commonsware.android.conferencevideos"
......
......@@ -18,11 +18,11 @@ package com.commonsware.android.conferencevideos
import android.Manifest
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.os.BuildCompat
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.*
import com.commonsware.android.conferencevideos.databinding.RowBinding
......@@ -32,8 +32,9 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
class MainActivity : AbstractPermissionActivity() {
private val motor: MainMotor by viewModel()
override val desiredPermissions = if (BuildCompat.isAtLeastQ()) arrayOf()
else arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
override val desiredPermissions =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) arrayOf()
else arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
override fun onPermissionDenied() {
Toast.makeText(this, getString(R.string.msg_toast), Toast.LENGTH_LONG)
......
......@@ -21,10 +21,10 @@ import android.content.ContentValues
import android.content.Context
import android.media.MediaScannerConnection
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import androidx.core.content.FileProvider
import androidx.core.os.BuildCompat
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
......@@ -40,7 +40,7 @@ private const val AUTHORITY = "${BuildConfig.APPLICATION_ID}.provider"
class VideoRepository(private val context: Context) {
private val ok = OkHttpClient()
private val collection =
if (BuildCompat.isAtLeastQ()) MediaStore.Video.Media.getContentUri(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) MediaStore.Video.Media.getContentUri(
MediaStore.VOLUME_EXTERNAL
) else MediaStore.Video.Media.EXTERNAL_CONTENT_URI
......@@ -63,7 +63,7 @@ class VideoRepository(private val context: Context) {
}
suspend fun download(filename: String): Uri =
if (BuildCompat.isAtLeastQ()) downloadQ(filename)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) downloadQ(filename)
else downloadLegacy(filename)
private suspend fun downloadQ(filename: String): Uri =
......@@ -74,6 +74,7 @@ class VideoRepository(private val context: Context) {
if (response.isSuccessful) {
val values = ContentValues().apply {
put(MediaStore.Video.Media.DISPLAY_NAME, filename)
put(MediaStore.Video.Media.RELATIVE_PATH, "Movies/ConferenceVideos")
put(MediaStore.Video.Media.MIME_TYPE, "video/mp4")
put(MediaStore.Video.Media.IS_PENDING, 1)
}
......
......@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-Q'
compileSdkVersion 29
defaultConfig {
applicationId "com.commonsware.android.q.exif"
......
......@@ -20,14 +20,13 @@ import android.Manifest
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.BuildCompat
import androidx.databinding.DataBindingUtil
import com.commonsware.android.q.exif.databinding.ActivityMainBinding
import org.koin.androidx.viewmodel.ext.android.viewModel
private const val REQUEST_OPEN = 1337
......@@ -103,7 +102,7 @@ class MainActivity : AppCompatActivity() {
}
private fun requestMediaPerm() {
val perms = if (BuildCompat.isAtLeastQ()) {
val perms = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_MEDIA_LOCATION
......
......@@ -19,9 +19,9 @@ package com.commonsware.android.q.exif
import android.content.Context
import android.media.MediaScannerConnection
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import androidx.core.os.BuildCompat
import androidx.exifinterface.media.ExifInterface
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
......@@ -45,7 +45,7 @@ class MainMotor(private val context: Context) : ViewModel() {
private val _countEvents = MutableLiveData<Event<Int>>()
val countEvents: LiveData<Event<Int>> = _countEvents
private val collection =
if (BuildCompat.isAtLeastQ()) MediaStore.Images.Media.getContentUri(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) MediaStore.Images.Media.getContentUri(
MediaStore.VOLUME_EXTERNAL
) else MediaStore.Images.Media.EXTERNAL_CONTENT_URI
......
......@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-Q'
compileSdkVersion 29
defaultConfig {
applicationId "com.commonsware.android.q.auth.checkfallback"
......
......@@ -23,12 +23,12 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import android.hardware.biometrics.BiometricPrompt
import android.os.Build
import android.os.Bundle
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.*
......@@ -64,7 +64,7 @@ class MainActivity : AppCompatActivity() {
.setDescription("This is the description")
.setSubtitle("This is the subtitle")
.apply {
if (BuildCompat.isAtLeastQ()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
setDeviceCredentialAllowed(true)
} else {
setNegativeButton(
......
......@@ -27,7 +27,7 @@
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
android:resource="@xml/share_targets" />
</activity>
<activity android:name=".ShareActivity">
<intent-filter>
......
......@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion "android-Q"
compileSdkVersion 29
defaultConfig {
applicationId "com.commonsware.android.storage"
......@@ -21,7 +21,7 @@ android {
}
}
flavorDimensions "target", "perm", "sandbox"
flavorDimensions "target", "perm", "legacy"
productFlavors {
p {
......@@ -32,8 +32,8 @@ android {
q {
dimension "target"
applicationIdSuffix ".q"
minSdkVersion "Q"
targetSdkVersion "Q"
minSdkVersion 29
targetSdkVersion 29
}
perm {
......@@ -48,16 +48,16 @@ android {
buildConfigField "boolean", "REQUEST_RUNTIME_PERMISSIONS", "false"
}
sandbox {
dimension "sandbox"
applicationIdSuffix ".sandbox"
resValue "bool", "useSandbox", "true"
}
normal {
dimension "sandbox"
dimension "legacy"
applicationIdSuffix ".normal"
resValue "bool", "useSandbox", "false"
resValue "bool", "useLegacy", "false"
}
legacy {
dimension "legacy"
applicationIdSuffix ".legacy"
resValue "bool", "useLegacy", "true"
}
}
}
......
......@@ -12,7 +12,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
android:allowExternalStorageSandbox="@bool/useSandbox">
android:requestLegacyExternalStorage="@bool/useLegacy">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -28,7 +28,6 @@ import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.core.os.BuildCompat
import androidx.core.view.GravityCompat
import androidx.documentfile.provider.DocumentFile
import androidx.drawerlayout.widget.DrawerLayout
......@@ -88,9 +87,9 @@ class MainActivity : AbstractPermissionActivity() {
navTo(R.id.nav_internal_files)
val msg =
if (BuildCompat.isAtLeastQ() && Environment.isExternalStorageSandboxed())
"This app has sandboxed external storage"
else "This app has normal external storage"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && Environment.isExternalStorageLegacy())
"This app has legacy external storage"
else "This app has Q-normal external storage"
Toast.makeText(this, msg, Toast.LENGTH_LONG).show()
}
......
......@@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-Q'
compileSdkVersion 29
defaultConfig {
applicationId "com.commonsware.android.q.typeinfo"
minSdkVersion 'Q'
targetSdkVersion 'Q'
minSdkVersion 29
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
......
......@@ -25,7 +25,7 @@ data class TypeRecord(
val description: CharSequence,
val icon: Icon
) {
constructor(type: String, typeInfo: ContentResolver.TypeInfo) : this(
constructor(type: String, typeInfo: ContentResolver.MimeTypeInfo) : this(
type,
typeInfo.label,
typeInfo.contentDescription,
......
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