| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
I'm not sure how to unit test this change, as openFile will open another activity -- I don't see a similar test for ios. The test for android works (and opens a file chooser) but in doing so it puts the app into the background which makes subsequent tests fail... |
Sorry, something went wrong.
|
The cla-bot has been summoned, and re-checked this pull request! |
Sorry, something went wrong.
There was a problem hiding this comment.
@t3hmrman nice work implementing this and Kudos for all the checks and traceWrite!
About the test_openFile I think that it should be moved to the apps/app/ui-test-app/ in new page since we can automate it later and properly handle the new activity.
I have all these changes locally and if you are ok I could commit them to your PR?
Sorry, something went wrong.
|
Hey thanks for taking a look!
That looks good to me, please feel free to commit to the PR.
Thanks for all the hard work on Nativescript!
… On Mar 1, 2019, at 22:06, Alexander Djenkov ***@***.***> wrote:
@ADjenkov commented on this pull request.
@t3hmrman nice work implementing this and Kudos for all the checks and traceWrite!
About the test_openFile I think that it should be moved to the apps/app/ui-test-app/ in new page since we can automate it later and properly handle the new activity.
I have all these changes locally and if you are ok I could commit them to your PR?
In tns-core-modules/utils/utils.android.ts:
> + );
+ }
+
+ // Ensure external storage is available
+ if (isExternalStorageReadOnly()) {
+ traceWrite("External storage is read only", traceCategories.Error, traceMessageType.error);
+ }
+
+ // Determine file mimetype & start creating intent
+ const mimeType = getMimeTypeNameFromExtension(filePath);
+ const intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
+ const chooserIntent = android.content.Intent.createChooser(intent, "Open File...");
+
+ // Android SDK <28 only requires starting the chooser Intent straight forwardly
+ const sdkVersion = parseInt(device.sdkVersion, 10);
+ if (sdkVersion && sdkVersion < MIN_URI_SHARE_RESTRICTED_APK_VERSION) {
both:
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK); chooserIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
should be set when SDK<28 since there will be android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? exception thrown.
In tns-core-modules/utils/utils.android.ts:
> + try {
+ // Ensure external storage is available
+ if (!isExternalStorageAvailable()) {
+ traceWrite(
+ `
+External storage is unavailable (please check app permissions).
+Applications cannot access internal storage of other application on Android (see: https://developer.android.com/guide/topics/data/data-storage).
+`,
+ traceCategories.Error,
+ traceMessageType.error,
+ );
+ }
+
+ // Ensure external storage is available
+ if (isExternalStorageReadOnly()) {
+ traceWrite("External storage is read only", traceCategories.Error, traceMessageType.error);
consider return false; after the traceWrite
In tns-core-modules/utils/utils.android.ts:
> +
+ return mimeTypeMap.getMimeTypeFromExtension(extension);
+}
+
+/**
+ * Open a file
+ *
+ * @PARAM {string} filePath
+ * @returns {boolean} whether opening the file succeeded or not
+ */
+export function openFile(filePath: string): boolean {
+ const context = ad.getApplicationContext();
+ try {
+ // Ensure external storage is available
+ if (!isExternalStorageAvailable()) {
+ traceWrite(
consider return false; after the traceWrite
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry, something went wrong.
Small changes to openFile() method
|
test |
Sorry, something went wrong.
|
Hey what about the fact that the test causes the app to be unresponsive (since it opens the chooser)?
… On Mar 1, 2019, at 23:22, Alexander Djenkov ***@***.***> wrote:
test
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry, something went wrong.
@t3hmrman We'll later extend the test, with nativescript-dev-appium, to click on the appropriate icon from the chooser. |
Sorry, something went wrong.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Checklist
What is the current behavior?
No openFile functionality in android utils
What is the new behavior?
Adds openFile to utils android module.
Fixes/Implements/Closes #5661.