[MM-21888] Don't use localPath when it's the share extension cache dir (#3845)

* Don't use localPath when it's the share extension cache dir

* Move android pasted images to cache image folder

* Use Files.move instead of FileInput / FileOutput stream

* Remove commented code and not needed imports
This commit is contained in:
Miguel Alatzar
2020-01-27 09:58:30 -07:00
committed by Amit Uttam
parent 7e7c652828
commit d25561bb83
5 changed files with 30 additions and 3 deletions

View File

@@ -39,6 +39,7 @@ public class ShareModule extends ReactContextBaseJavaModule {
private final OkHttpClient client = new OkHttpClient();
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
private final MainApplication mApplication;
public static final String CACHE_DIR_NAME = "mmShare";
public ShareModule(MainApplication application, ReactApplicationContext reactContext) {
super(reactContext);
@@ -67,6 +68,7 @@ public class ShareModule extends ReactContextBaseJavaModule {
@Override
public Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<>(1);
constants.put("cacheDirName", CACHE_DIR_NAME);
constants.put("isOpened", mApplication.sharedExtensionIsOpened);
mApplication.sharedExtensionIsOpened = false;
return constants;
@@ -133,7 +135,7 @@ public class ShareModule extends ReactContextBaseJavaModule {
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
this.tempFolder = new File(currentActivity.getCacheDir(), "mmShare");
this.tempFolder = new File(currentActivity.getCacheDir(), CACHE_DIR_NAME);
Intent intent = currentActivity.getIntent();
action = intent.getAction();
type = intent.getType();