-
Notifications
You must be signed in to change notification settings - Fork 11
Better Android custom data location support. #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* Move critical System.IO call to UniversalIO. * Add custom Android storage access plugin. * Support content:// uri
Add support for track editor saving. Hide track create when enabling custom location, since it won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like TECHMANIA/Assets/Plugins/AndroidNativeIO/lib-release.aar
is a compiled Android library.
- Is this the library that
cn.samnya.nativeandroid.io
refers to? - Is the source code of this library available?
Yes, and the source code was released here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This project is getting very complex in terms of I/O and this worries me. I hope you don't mind some high-level questions, so I can understand your code better.
- Where do
content://
paths come from? - What exactly does
UniversalIO.GetRealPathFromUri
do? What does the output look like? - Could the method names in
UniversalIO
be improved? For example, instead ofUniversalIO.DirectoryCreateDirectory
, justUniversalIO.CreateDirectory
. Or create subclasses insideUniversalIO
so we can sayUniversalIO.Directory.CreateDirectory
. - Some methods in
UniversalIO
handlecontent://
but some don't. Are those checks added on a case-by-case basis? Is this an easy way to tell which methods handlecontent://
at a glance? - Do you plan to handle streaming assets on Android with
AndroidNativeIO
?BetterStreamingAssets
? Or something else entirely?
At the same time, could you attach a license to your UnityNativeAndroidIO
repo? So we can properly depend on it.
Content URI
For example, the Google Drive app can provide a URI like By using the file picker provided by Android when setting the custom data location, it returns a URI looks like This means the file access is provided by UniversalIO.GetRealPathFromUriThe URI provided by
So the resulting output will look like The old Fantom plugin will return this real path as the file picker result. This is why most of the file access will be handled by the plugins. About the UniversalIOI will create a subclass inside For the streaming assets, I don't think it will handle by this native io. I'm still working on that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate the reply, I learned a lot! While you update UniversalIO
method names I gave your PR an initial round of review. Some are just comments that I ask you to add to the code.
{ | ||
public class Constants | ||
{ | ||
public const string ANDROID_PACKAGE = "cn.samnya.nativeandroid.io"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This points to a compiled library at Assets/Plugins/AndroidNativeIO/lib-release.aar
// Source code: https://github.com/samnyan/UnityNativeAndroidIO
TECHMANIA/Assets/Scripts/Paths.cs
Outdated
kTrackFolderName); | ||
Directory.CreateDirectory(trackRootFolder); | ||
streamingTrackRootFolder = Path.Combine( | ||
UniversalIO.DirectoryCreateDirectoryCSharp(trackRootFolder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does DirectoryCreateDirectoryCSharp
work on Android?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a folder with full path doesn't support on content uri. I will replace it with the parentPath and childName one.
TECHMANIA/Assets/Scripts/Paths.cs
Outdated
if (fullPath.StartsWith(UniversalIO.ANDROID_CONTENT_URI)) | ||
{ | ||
return UniversalIO.GetRealPathFromUri(fullPath) | ||
.Replace(UniversalIO.GetRealPathFromUri(Paths.GetTrackRootFolder()), "Tracks"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please handle "Skins"
as well. IIRC some error dialogs will show skin folders.
|
||
#region Path | ||
|
||
public static string PathGetDirectoryName(string path, bool returnToTreeUri = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it was my oversight that there are 2 ways to get the directory name (DirectoryInfo.Name
and Path.GetDirectoryName
). Could you test if it's okay to replace the former with latter?
Remove UniversalIO.DirectoryCreateDirectoryCSharp. Cleanup Debug message.
PR for #22
Allow targeting SDK to Android 12
A preview build can download here.
https://github.com/samnyan/techmania/releases/tag/1.0.2-android