Skip to content

Commit

Permalink
Experiments with writing files from android
Browse files Browse the repository at this point in the history
more progress needs some way to request for permissions at runtime
see reflex-frp/reflex-platform#524
  • Loading branch information
nomeata committed Sep 7, 2019
1 parent e82bb6f commit a343236
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ let
executableName = "kaleidogen-android-clib";
applicationId = "de.nomeata.kaleidogen";
displayName = "Kaleidogen";
permissions = ''
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
'';
};


Expand Down
2 changes: 2 additions & 0 deletions kaleidogen.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ executable kaleidogen-android-clib
build-depends: jsaddle
build-depends: reflex-dom

build-depends: directory

if flag(android)
build-depends: jsaddle-clib

Expand Down
8 changes: 8 additions & 0 deletions src/CanvasSave.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import Language.Javascript.JSaddle (toJSVal)
import Language.Javascript.JSaddle.Object
import Control.Lens ((^.))

import System.Directory
import System.IO
import System.IO.Error
import Control.Monad.Trans

src :: BS.ByteString
src = $(embedFile "vendor/FileSaver.1.3.8.min.js")

Expand All @@ -30,6 +35,9 @@ save :: MonadJSM m => T.Text -> HTMLCanvasElement -> m ()
save name e = liftJSM $ do
domEl <- toJSVal e
_ <- domEl ^. js1 "toBlob" (fun $ \_ _ [blob] -> () <$ jsg2 "saveAs" blob name )
liftIO $ (`catchIOError` print) $
createDirectory "/sdcard/Kaleidogen"
writeFile "/sdcard/Kaleidogen/test.txt" "hi"
return ()

{-
Expand Down

0 comments on commit a343236

Please sign in to comment.