Git Product home page Git Product logo

nativefileso's People

Contributors

keiwando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nativefileso's Issues

Excellent work, can we avoid app restart on file open?

Hi, first of all thanks for sharing your project. Excellent work done by you. I can open custom files with my app now.
The only downside I feel is the app restart when opening a file from outside. I know it's the intended behaviour as per the limitations written by you. Can this be avoided anyhow?

java.lang.NullPointerException com.keiwando.lib_nativefileso.NativeFileOpenURLBuffer.getFilenameFromUri

I'm trying to find out why some of my customers on Android getting these errors, perhaps you can help?

In the Google Play Console it says:
Type
java.lang.RuntimeException

java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3634)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3879)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2203)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:268)
at android.app.ActivityThread.main (ActivityThread.java:8017)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:627)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:997)
Caused by: java.lang.NullPointerException:
at java.util.Objects.requireNonNull (Objects.java:245)
at android.content.ContentResolver.query (ContentResolver.java:1172)
at android.content.ContentResolver.query (ContentResolver.java:1130)
at com.keiwando.lib_nativefileso.NativeFileOpenURLBuffer.getFilenameFromUri (NativeFileOpenURLBuffer.java:119)
at com.keiwando.lib_nativefileso.NativeFileOpenURLBuffer.saveFilesInCacheDir (NativeFileOpenURLBuffer.java:171)
at com.keiwando.lib_nativefileso.NativeFileOpenActivity.onCreate (NativeFileOpenActivity.java:73)
at android.app.Activity.performCreate (Activity.java:8077)
at android.app.Activity.performCreate (Activity.java:8061)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1315)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3607)

My code is:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_ANDROID

using Keiwando.NFSO;
#endif

public class PresetHandler : MonoBehaviour
{
/*#if UNITY_ANDROID
void Start() {
    DontDestroyOnLoad(this.gameObject);
        NativeFileSOMobile.shared.FilesWereOpened += delegate (OpenedFile[] files) {
            
            // Process the opened files
            Debug.Log(files[0].Name);
        GameObject.Find("Canvas").GetComponent<UIStateMachineFluid>().loadPresetString(files[0].ToUTF8String()); 
        };		
    }
#else*/
void Start()
    {
        ImaginationOverflow.UniversalFileAssociation.FileAssociationManager.Instance.FileActivated += FileActivatedHandler;
    }
    private void
    FileActivatedHandler(ImaginationOverflow.UniversalFileAssociation.Data.FileInformation s)
    {
        GameObject.Find("Canvas").GetComponent<UIStateMachineFluid>().loadPresetStream(s.Stream); 
    }

    void OnDestroy()
    {
        ImaginationOverflow.UniversalFileAssociation.FileAssociationManager.Instance.FileActivated -= FileActivatedHandler;
    }
//#endif

}

And for import / export files I use:

if (path == null)
            {

                
SupportedFileType[] supportedFileTypes = {
    SupportedFileType.Any
};

NativeFileSO.shared.OpenFile(supportedFileTypes,
  delegate (bool fileWasOpened, OpenedFile file) {
    if (fileWasOpened) {
        // Process the loaded contents of "file"
        success = loadPresetString(file.ToUTF8String());
    } else {
         GameObject.Find("Notification").GetComponent<UINotificationManager>().Notify("", "Preset importing failed", "Failed to import Preset.");
    }
});
            }
            else
            {
                success = loadPresetPath(path); 
            }

   

And:

string filePath = Path.Combine(Application.temporaryCachePath, name + ".fluids");
            StreamWriter writer = new StreamWriter(filePath, false);
            writer.Write(encrypted);
            writer.Close();
FileToSave file = new FileToSave(filePath,  name + ".fluids", SupportedFileType.Any);

// Allows the user to choose a save location and saves the 
// file to that location
NativeFileSO.shared.SaveFile(file);

ArgumentException: Value must be a Com object

The following statements generate an error:

 NativeFileSO.shared.OpenFile(SupportedFilePreferences.supportedFileTypes,
    delegate (bool fileWasOpened, OpenedFile file)
          { /* do something */ });

Getting this error:

ArgumentException: Value must be a Com object.
Parameter name: o
System.Runtime.InteropServices.Marshal.ReleaseComObject (System.Object o) (at <231f6c5a042647adb84a9cc42c982c35>:0)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject (System.Object o) (at <231f6c5a042647adb84a9cc42c982c35>:0)
Ookii.Dialogs.VistaFileDialog.RunFileDialog (System.IntPtr hwndOwner) (at <31af777adad04cb788cee0ae18e55ae1>:0)
Ookii.Dialogs.VistaFileDialog.RunDialog (System.IntPtr hwndOwner) (at <31af777adad04cb788cee0ae18e55ae1>:0)
System.Windows.Forms.CommonDialog.ShowDialog (System.Windows.Forms.IWin32Window owner) (at <ee7d35d55c334b8f8f4a9c7bf3b9f8a7>:0)
(wrapper remoting-invoke-with-check) System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)
Keiwando.NFSO.NativeFileSOWindows.SelectOpenPathsSync (Keiwando.NFSO.SupportedFileType[] fileTypes, System.Boolean canSelectMultiple, System.String title, System.String directory) (at Assets/NativeFileSO/Scripts/NativeFileSOWindows.cs:126)
Keiwando.NFSO.NativeFileSOWindows.OpenFilesSync (Keiwando.NFSO.SupportedFileType[] fileTypes, System.Boolean canSelectMultiple, System.String title, System.String directory) (at Assets/NativeFileSO/Scripts/NativeFileSOWindows.cs:79)
Keiwando.NFSO.NativeFileSOWindows.OpenFile (Keiwando.NFSO.SupportedFileType[] fileTypes, System.Action`2[T1,T2] onCompletion) (at Assets/NativeFileSO/Scripts/NativeFileSOWindows.cs:42)
Keiwando.NFSO.NativeFileSOMacWin.OpenFile (Keiwando.NFSO.SupportedFileType[] supportedTypes, System.Action`2[T1,T2] onCompletion) (at Assets/NativeFileSO/Scripts/NativeFileSOMacWin.cs:123)
Keiwando.NFSO.NativeFileSO.OpenFile (Keiwando.NFSO.SupportedFileType[] supportedTypes, System.Action`2[T1,T2] onCompletion) (at Assets/NativeFileSO/Scripts/NativeFileSO.cs:146)

No matter what I do, I cannot resolve this. Please help.

Windows Edition: Windows 10 Pro
Version: 21H1
OS Build: 19043.1237

M1 Mac support

hi,

I've just started trying out your package on an M1 Mac with native unity editor.
when running in the editor im getting DllNotFoundException exception

DllNotFoundException: NativeFileSOMac assembly:<unknown assembly> type:<unknown type> member:(null)

im fairly sure this is because the .bundle file was built for x86_64 only (seen the same issue with a different plugin)

macOS % lipo -archs NativeFileSOMac.bundle/Contents/MacOS/NativeFileSOMac
x86_64

whereas for a multi arch .bundle it should read:

macOS % lipo -archs AnotherPlugin.bundle/Contents/MacOS/AnotherPlugin 
x86_64 arm64

any chance you could rebuild the bundle as an universal binary for the next release?

here's some info:
https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary

best,
wiktor

Feature Request: Open File as a Stream, but Not Byte Array.

Great job of making this plugin!
But I think there's a problem: opening a very big file may cause app to crash, because it loads the entire file into memory.
Opening a very big file as a stream will solve this problem but don't know if it's practical or not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.