Skip to content

Commit

Permalink
feature: Add support for Android API versions 16 through 22. Closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
rpander93 committed May 3, 2021
1 parent a3fcc3a commit 0fcf93a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.reactnativedocumentopener

import android.content.ClipData
import android.content.Intent
import androidx.core.content.FileProvider
import com.facebook.react.bridge.*
Expand All @@ -18,6 +19,9 @@ class DocumentOpenerModule(reactContext: ReactApplicationContext) : ReactContext

val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndType(uri, resolvedType)
// Support versions between Android 4.1 (API level 16) and Android 5.1 (API level 22)
// @see https://developer.android.com/reference/androidx/core/content/FileProvider#include-the-permission-in-an-intent
clipData = ClipData.newRawUri("", uri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
Expand Down
9 changes: 7 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
addUnimodulesDependencies()

addUnimodulesDependencies(exclude: [
"expo-constants",
"expo-image-loader",
"expo-permissions"
])

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
Expand All @@ -205,7 +210,7 @@ dependencies {
implementation jscFlavor
}

implementation project(':reactnativedocumentopener')
implementation project(':react-native-document-opener')
}

// Run this once to be able to run the application with BUCK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
public class BasePackageList {
public List<Package> getPackageList() {
return Arrays.<Package>asList(
new expo.modules.constants.ConstantsPackage(),
new expo.modules.filesystem.FileSystemPackage(),
new expo.modules.imageloader.ImageLoaderPackage(),
new expo.modules.permissions.PermissionsPackage()
new expo.modules.filesystem.FileSystemPackage()
);
}
}
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
Expand Down
4 changes: 2 additions & 2 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ apply from: '../node_modules/react-native-unimodules/gradle.groovy'; includeUnim
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

include ':reactnativedocumentopener'
project(':reactnativedocumentopener').projectDir = new File(rootProject.projectDir, '../../android')
include ':react-native-document-opener'
project(':react-native-document-opener').projectDir = new File(rootProject.projectDir, '../../android')
4 changes: 3 additions & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
platform :ios, '11.0'

target 'DocumentOpenerExample' do
use_unimodules!
use_unimodules!(exclude: [
"expo-permissions"
])
config = use_native_modules!

use_react_native!(:path => config["reactNativePath"])
Expand Down

0 comments on commit 0fcf93a

Please sign in to comment.