Skip to content

Commit

Permalink
Merge pull request #43 from tgpetrov/master
Browse files Browse the repository at this point in the history
fix: make the plugin androidx compatible
  • Loading branch information
EddyVerbruggen authored May 14, 2019
2 parents e5153b3 + 37f001a commit 6f70651
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/social-share.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as platform from "tns-core-modules/platform";

var context;
var numberOfImagesCreated = 0;
declare var global: any;
const FileProviderPackageName = useAndroidX() ? global.androidx.core.content : android.support.v4.content;

function getIntent(type) {
var intent = new android.content.Intent(android.content.Intent.ACTION_SEND);
Expand All @@ -17,6 +19,9 @@ function share(intent, subject) {
shareIntent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(shareIntent);
}
function useAndroidX () {
return global.androidx && global.androidx.appcompat;
}

export function shareImage(image, subject) {
numberOfImagesCreated ++;
Expand All @@ -40,7 +45,7 @@ export function shareImage(image, subject) {
var shareableFileUri;
var sdkVersionInt = parseInt(platform.device.sdkVersion);
if (sdkVersionInt >= 21) {
shareableFileUri = android.support.v4.content.FileProvider.getUriForFile(context, application.android.nativeApp.getPackageName() + ".provider", newFile);
shareableFileUri = FileProviderPackageName.FileProvider.getUriForFile(context, application.android.nativeApp.getPackageName() + ".provider", newFile);
} else {
shareableFileUri = android.net.Uri.fromFile(newFile);
}
Expand Down

0 comments on commit 6f70651

Please sign in to comment.