[jira] [Commented] (CB-285) Add property returning root path of PhoneGap files
[ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13571437#comment-13571437 ] Andrew Grieve commented on CB-285: -- I like the idea of switching PERSISTENT to be internal-only. The W3C spec intends this area to be sandboxed to the app, so shouldn't be on the sdcard. I think we need more than just an APP constant though, as there are many places where an app might want to put things. For iOS, You'd minimally want: 1. Application bundle, 2. Application_Home The other locations are all subdirectories of Application_Home, so not a big deal if we don't have constants for them For Android, You'd minimally want: 1. Assets directory (seems like a parallel to iOS Application Bundle) 2. Application data on internal storage (/data/data/$PACKAGE_NAME/files) 3. Application cache on internal storage (/data/data/$PACKAGE_NAME/cache) 4. External root: (/sdcard) We could maybe combine #2 and #3 into a single one that gave you /data/data/$PACKAGE_NAME, and document that Android wants files in the files and cache directories. The Ideal iOS constants: 1. PERSISTENT changes from Application_Home/Documents -- Application_Home/Library/CdvPersistentStorage 2. TEMPORARY changes from Application_Home/tmp -- Application_Home/tmp/CdvTemporaryStorage 3. APP_ASSETS -- Application bundle 4. APP_DATA -- Application_Home The main reason for changing #1 is that iCloud treats Documents directory specially The main reason for adding subdirs under Library/tmp is that it keeps the storage areas separate from the rest of the app (apps that have native components won't interfere with the webview's storage area). The ideal Android constants: 1. PERSISTENT -- /data/data/$PACKAGE_NAME/files/CdvPersistentStorage 2. TEMPORARY -- /data/data/$PACKAGE_NAME/cache/CdvTemporaryStorage 3. APP_ASSETS -- assets directory 4. APP_DATA -- /data/data/$PACKAGE_NAME 5. EXTERNAL_APP_DATA -- /sdcard/Android/data/$PACKAGE_NAME 6. EXTERNAL_ROOT -- /sdcard I even think there would be merit in adding more constants (e.g. DOCUMENTS, android resources) going forward, but one step at a time... == Transitioning to these new constants == TEMPORARY: Use the new path right away. No need to transition since the files there are temporary anyways. PERSISTENT (iOS): - If new location directory exists, use that. - Else, if any files exist in the legacy location, use the legacy location - Else, use the new path. PERSISTENT (Android): - PERSISTENT is currently /sdcard, so files will always exist :( In both cases, add a PERSISTENT_NEW constant to allow them to move their files over. In Cordova 3.0, change PERSISTENT to be PERSISTENT_NEW, and add PERSISTENT_LEGACY (in case apps have still not switched). Side issue: The spec says PERSISTENT and TEMPORARY are constants on the window object (ugh). So far though, Cordova has exposed them not as globals, but instead as LocalFileSystem.PERSISTENT and LocalFileSystem.TEMPORARY. I like the idea of exposing them on LocalFileSystem, but we should also put PERSISTENT and TEMPORARY on the window. Add property returning root path of PhoneGap files -- Key: CB-285 URL: https://issues.apache.org/jira/browse/CB-285 Project: Apache Cordova Issue Type: Improvement Components: CordovaJS Affects Versions: 1.4.0 Environment: Both PhoneGap SDK and PhoneGap Build Reporter: Ashley Gullen Assignee: Andrew Grieve Labels: features There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in). For example, if I add 'music.mp3' to my project, in Android it will be located in: /android_asset/www/music.mp3 On iOS after being built with PhoneGap Build it will be located in some path like this: /var/mobile/Applications/app_ID/name.app/www/music.mp3 However, there does not appear to be a programmatic way to determine both app_ID and name.app. This has two side effects: 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient. 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap. Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path. This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator. Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain. This PhoneGap Support thread led to this issue:
[jira] [Commented] (CB-285) Add property returning root path of PhoneGap files
[ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13571647#comment-13571647 ] Becky Gibson commented on CB-285: - For iOS I'm not sure that I understand why you want to change the PERSISTENT directory out of application-home/Documents into application-home/Library/CdvPersistent? The iOS documentation that you reference explicitly states for Application_Home/Library/, You should not use this directory for user data files. I could see adding a USERDATA setting if you want to make a distinction between user data and app data, although then we are deviating from the W3C spec. I'm also not sure I understand the need for a way to retrieve the application-home directory - why would an app want to write here? I can see why the user might want the APP_ASSETS in order to obtain a full path to the www directory but I think that would be confusing in the File APIs since this is read only. Generally by convention in the core plugins file names with w/o a full path are treated as coming from te www directory. At least this is what media does and we could standardize any other core plugins that do not use this convention. While we are thinking about directory names and locations, I am looking at fixing CB-571 where iOS requires the file to exist before recording. If the user just passes in a file name, I was going to create and store the recording in the application-home/Documents directory since it is user generated and should be backed up. I'm not sure how this flies in the face of your proposed conventions for the File api - I guess the dev could get to these recorded files later using the proposed APP_HOME and appending /Documents to access the directory? Or are you proposing that recorded files would also go in the application-home/Library/CdvPersistent dir??? Add property returning root path of PhoneGap files -- Key: CB-285 URL: https://issues.apache.org/jira/browse/CB-285 Project: Apache Cordova Issue Type: Improvement Components: CordovaJS Affects Versions: 1.4.0 Environment: Both PhoneGap SDK and PhoneGap Build Reporter: Ashley Gullen Assignee: Andrew Grieve Labels: features There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in). For example, if I add 'music.mp3' to my project, in Android it will be located in: /android_asset/www/music.mp3 On iOS after being built with PhoneGap Build it will be located in some path like this: /var/mobile/Applications/app_ID/name.app/www/music.mp3 However, there does not appear to be a programmatic way to determine both app_ID and name.app. This has two side effects: 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient. 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap. Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path. This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator. Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain. This PhoneGap Support thread led to this issue: http://phonegap.tenderapp.com/discussions/questions/208-android_asset-equivalent-for-ios -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CB-285) Add property returning root path of PhoneGap files
[ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13571785#comment-13571785 ] Becky Gibson commented on CB-285: - OK, I can live with not using the Documents directory for PERSISTENT, although I think we should give devs a way to access it if they DO want to put user data in the documents dir - I guess access to application-home would give them that option. I don't know enough about Android to know if this works there or not! For the media object they can pass in documents://filename to store a recording there. I like your idea of requiring a full path name (or documents://) for the file name of the recording. However, one of the biggest complaints in CB-571 is the difference between iOS and Android. Currently iOS requires that the file exist (which is what I am changing) and Android does not. Android accepts just a filename and then stores it in: new File(/data/data/ + handler.cordova.getActivity().getPackageName() + /cache/ + file). Thus, the reason CB-571 has been open so long! I'll put this media specific stuff in that ticket for further conversation. Add property returning root path of PhoneGap files -- Key: CB-285 URL: https://issues.apache.org/jira/browse/CB-285 Project: Apache Cordova Issue Type: Improvement Components: CordovaJS Affects Versions: 1.4.0 Environment: Both PhoneGap SDK and PhoneGap Build Reporter: Ashley Gullen Assignee: Andrew Grieve Labels: features There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in). For example, if I add 'music.mp3' to my project, in Android it will be located in: /android_asset/www/music.mp3 On iOS after being built with PhoneGap Build it will be located in some path like this: /var/mobile/Applications/app_ID/name.app/www/music.mp3 However, there does not appear to be a programmatic way to determine both app_ID and name.app. This has two side effects: 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient. 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap. Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path. This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator. Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain. This PhoneGap Support thread led to this issue: http://phonegap.tenderapp.com/discussions/questions/208-android_asset-equivalent-for-ios -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CB-285) Add property returning root path of PhoneGap files
[ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13572179#comment-13572179 ] Andrew Grieve commented on CB-285: -- Yes. Definitely want to allow users to chose make the decision of where their files go. Android has no iCloud equivalent, but instead has a shared file-system for things like music photos. So, here's another proposal: Instead of adding non-standard constants to requestFileSystem(), we add a new (non-standard) API: LocalFileSystem.getAppDirectory(callback) // gets a (read-only) DirectoryEntry for the www directory. LocalFileSystem.getDirectoryForPurpose({ sandboxed: true || false, persistence: 'temporary' || 'cache' || 'device_persistent' || 'persistent', category: 'data' || 'documents' }, success); sandboxed: will be ignored for iOS. For Android it will toggle between external an internal storage. - Defaults to true. - If non-sandboxed is unavailable (iOS), fall-back to true. persistence: - on Android, 'temporary' == 'cache', but on iOS they are different. - on Android, 'device_persistent' == 'persistent', but on iOS one has iCloud enabled and the other does not. category: - Defaults to 'data' - persistence == 'temporary' or 'cache' == this value is ignored. - Android sandboxed == true == files/ directory - 'data' iOS persistence == 'persistent' == Application_Home/Library - 'data' iOS persistence == 'device_persistent' == Application_Home/Library/NoCloud (and we set the extended attr on this directory to make it unsynced. - 'data' Android == files/ subdirectory of app storage (based on sandboxed value) - 'documents' iOS persistence == 'persistent' == Application_Home/Documents - 'documents' iOS persistence == 'device_persistent' == Application_Home/Documents/NoCloud - 'documents' Android == /sdcard Add property returning root path of PhoneGap files -- Key: CB-285 URL: https://issues.apache.org/jira/browse/CB-285 Project: Apache Cordova Issue Type: Improvement Components: CordovaJS Affects Versions: 1.4.0 Environment: Both PhoneGap SDK and PhoneGap Build Reporter: Ashley Gullen Assignee: Andrew Grieve Labels: features There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in). For example, if I add 'music.mp3' to my project, in Android it will be located in: /android_asset/www/music.mp3 On iOS after being built with PhoneGap Build it will be located in some path like this: /var/mobile/Applications/app_ID/name.app/www/music.mp3 However, there does not appear to be a programmatic way to determine both app_ID and name.app. This has two side effects: 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient. 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap. Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path. This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator. Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain. This PhoneGap Support thread led to this issue: http://phonegap.tenderapp.com/discussions/questions/208-android_asset-equivalent-for-ios -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CB-285) Add property returning root path of PhoneGap files
[ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13559719#comment-13559719 ] Andrew Grieve commented on CB-285: -- I'd like to list out all of the potential storage areas, and then let's talk about whether we should map them to a requestLocalFilesystem constant. Android (http://developer.android.com/guide/topics/data/data-storage.html): - Resources.raw - no URL mapping - read-only - no subdirectories - iteration through reflection only? - Assets directory - file://android_assets (URL mapping works only for initial page load?) - read-only - includes www directory - Internal app storage - file:///data/data/$PACKAGE_NAME/files - read-write - Use Context.openFileOutput / Context.fileList - Internal cache - file:///data/data/$PACKAGE_NAME/cache - Context.getCacheDir() - External app storage: - file:///sdcard/Android/data/$PACKAGE_NAME/files - or this?: content://com.android.htmlfileprovider/ - Context.getExternalFilesDir() - Requires WRITE_EXTERNAL_STORAGE permission - External cache - file:///sdcard/Android/data/$PACKAGE_NAME/cache - Context.getExternalCacheDir() - Requires WRITE_EXTERNAL_STORAGE permission - External root (Root sdcard) - file:///sdcard - Context.getExternalFilesDir(null) or Environment.getExternalStorageDirectory() - Requires WRITE_EXTERNAL_STORAGE permission - External media (shared files) - file:///sdcard/Music / Photos / etc. - Context.getExternalFilesDir(Environment.DIRECTORY_PICTURES) - Requires WRITE_EXTERNAL_STORAGE permission Complicated enough? :P Looking at our current implementation of requestLocalFilesystem(), we use: PERSISTENT == External root if sdcard is mounted, Internal app storage otherwise (minus the /files suffix) TEMPORARY == External cache if sdcard is mounted, Internal cache otherwise. I'll dig into iOS next. Add property returning root path of PhoneGap files -- Key: CB-285 URL: https://issues.apache.org/jira/browse/CB-285 Project: Apache Cordova Issue Type: Improvement Components: CordovaJS Affects Versions: 1.4.0 Environment: Both PhoneGap SDK and PhoneGap Build Reporter: Ashley Gullen Assignee: Andrew Grieve Labels: features There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in). For example, if I add 'music.mp3' to my project, in Android it will be located in: /android_asset/www/music.mp3 On iOS after being built with PhoneGap Build it will be located in some path like this: /var/mobile/Applications/app_ID/name.app/www/music.mp3 However, there does not appear to be a programmatic way to determine both app_ID and name.app. This has two side effects: 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient. 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap. Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path. This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator. Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain. This PhoneGap Support thread led to this issue: http://phonegap.tenderapp.com/discussions/questions/208-android_asset-equivalent-for-ios -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CB-285) Add property returning root path of PhoneGap files
[ https://issues.apache.org/jira/browse/CB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13559932#comment-13559932 ] Andrew Grieve commented on CB-285: -- iOS (http://developer.apple.com/library/ios/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html) *Application Bundle* - [[NSBundle mainBundle] bundlePath] - Read-only *Application_Home/Documents* - For user-data. - Backed up by iCloud, where each file is shown as an entry. *Application_Home/Documents/Inbox* - Can't create or write files, but *can* delete read files. - Used for receiving files from Mail.app *Application_Home/Library* - Backed up by iCloud unless com.apple.MobileBackup attribute is set. - All files shown as a single entry in iCloud *Application_Home/Library/Application Support* - Same as /Library it looks like... *Application_Home/Library/Caches* - Not backed up by iCloud *Application_Home/tmp* - Not backed up by iCloud - Get this via NSTemporaryDirectory() (it's /var/folders/ when on simulator) Application_Home == /var/mobile/Applications/app id/. Retrieve it with NSHomeDirectory() PERSISTENT == Application_Home/Documents TEMPORARY == Application_Home/tmp Add property returning root path of PhoneGap files -- Key: CB-285 URL: https://issues.apache.org/jira/browse/CB-285 Project: Apache Cordova Issue Type: Improvement Components: CordovaJS Affects Versions: 1.4.0 Environment: Both PhoneGap SDK and PhoneGap Build Reporter: Ashley Gullen Assignee: Andrew Grieve Labels: features There needs to be a property in PhoneGap that returns the root path to the general files added to the PhoneGap project (i.e. the directory index.html is in). For example, if I add 'music.mp3' to my project, in Android it will be located in: /android_asset/www/music.mp3 On iOS after being built with PhoneGap Build it will be located in some path like this: /var/mobile/Applications/app_ID/name.app/www/music.mp3 However, there does not appear to be a programmatic way to determine both app_ID and name.app. This has two side effects: 1. Paths to audio for Media must be hard-coded separately depending on the platform, which is inconvenient. 2. Paths to audio for Media cannot be known if developing a framework that uses PhoneGap. Since a framework does not know the App ID or name in advance, it's impossible for the framework to determine the correct path. This is actively blocking audio from working on iOS in PhoneGap projects exported by Construct 2 (www.scirra.com), a HTML5 game creator. Also, it seems like kind of an important function to make available anyway, since hard-coding paths for each platform is a pain. This PhoneGap Support thread led to this issue: http://phonegap.tenderapp.com/discussions/questions/208-android_asset-equivalent-for-ios -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira