adjust webapp paths when run in termux on Android
And display the special case Android UI
This commit is contained in:
parent
aa652a4933
commit
b0df331b4a
3 changed files with 49 additions and 9 deletions
|
@ -98,6 +98,9 @@ checkRepositoryPath p = do
|
|||
{- On first run, if run in the home directory, default to putting it in
|
||||
- ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.
|
||||
-
|
||||
- When on Android, default to ~/storage/shared/annex, which termux sets up
|
||||
- as a link to the sdcard.
|
||||
-
|
||||
- If run in another directory, that the user can write to,
|
||||
- the user probably wants to put it there. Unless that directory
|
||||
- contains a git-annex file, in which case the user has probably
|
||||
|
@ -120,18 +123,31 @@ defaultRepositoryPath firstrun = do
|
|||
if firstrun then inhome else inhome
|
||||
#endif
|
||||
where
|
||||
inhome = do
|
||||
desktop <- userDesktopDir
|
||||
ifM (doesDirectoryExist desktop <&&> canWrite desktop)
|
||||
( relHome $ desktop </> gitAnnexAssistantDefaultDir
|
||||
, return $ "~" </> gitAnnexAssistantDefaultDir
|
||||
)
|
||||
inhome = ifM osAndroid
|
||||
( do
|
||||
home <- myHomeDir
|
||||
let storageshared = home </> "storage" </> "shared"
|
||||
ifM (doesDirectoryExist storageshared)
|
||||
( relHome $ storageshared </> gitAnnexAssistantDefaultDir
|
||||
, return $ "~" </> gitAnnexAssistantDefaultDir
|
||||
)
|
||||
, do
|
||||
desktop <- userDesktopDir
|
||||
ifM (doesDirectoryExist desktop <&&> canWrite desktop)
|
||||
( relHome $ desktop </> gitAnnexAssistantDefaultDir
|
||||
, return $ "~" </> gitAnnexAssistantDefaultDir
|
||||
)
|
||||
)
|
||||
#ifndef mingw32_HOST_OS
|
||||
-- Avoid using eg, standalone build's git-annex.linux/ directory
|
||||
-- when run from there.
|
||||
legit d = not <$> doesFileExist (d </> "git-annex")
|
||||
#endif
|
||||
|
||||
-- Detect when the Linux build is running on Android, eg in termux.
|
||||
osAndroid :: IO Bool
|
||||
osAndroid = ("Android" == ) <$> readProcess "uname" ["-o"]
|
||||
|
||||
newRepositoryForm :: FilePath -> Hamlet.Html -> MkMForm RepositoryPath
|
||||
newRepositoryForm defpath msg = do
|
||||
(pathRes, pathView) <- mreq (repositoryPathField True) (bfs "")
|
||||
|
@ -156,7 +172,7 @@ postFirstRepositoryR = page "Getting started" (Just Configuration) $ do
|
|||
androidspecial <- liftIO $ doesDirectoryExist "/sdcard/DCIM"
|
||||
let path = "/sdcard/annex"
|
||||
#else
|
||||
let androidspecial = False
|
||||
androidspecial <- liftIO osAndroid
|
||||
path <- liftIO . defaultRepositoryPath =<< liftH inFirstRun
|
||||
#endif
|
||||
((res, form), enctype) <- liftH $ runFormPostNoToken $ newRepositoryForm path
|
||||
|
@ -166,8 +182,14 @@ postFirstRepositoryR = page "Getting started" (Just Configuration) $ do
|
|||
_ -> $(widgetFile "configurators/newrepository/first")
|
||||
|
||||
getAndroidCameraRepositoryR :: Handler ()
|
||||
getAndroidCameraRepositoryR =
|
||||
startFullAssistant "/sdcard/DCIM" SourceGroup $ Just addignore
|
||||
getAndroidCameraRepositoryR = do
|
||||
#ifdef __ANDROID__
|
||||
let dcim = "/sdcard/DCIM"
|
||||
#else
|
||||
home <- liftIO myHomeDir
|
||||
let dcim = home </> "storage" </> "dcim"
|
||||
#endif
|
||||
startFullAssistant dcim SourceGroup $ Just addignore
|
||||
where
|
||||
addignore = do
|
||||
liftIO $ unlessM (doesFileExist ".gitignore") $
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 8"""
|
||||
date="2018-04-25T17:49:30Z"
|
||||
content="""
|
||||
We may be moving away from the git-annex Android app, and to running
|
||||
git-annex in Termux on Android.
|
||||
|
||||
I think that will avoid this particular problem, since it uses the linux
|
||||
build of git-annex which bundles the linux linker, so the behavior of the
|
||||
android linker is no longer an issue.
|
||||
|
||||
If the people who have been bitten by this bug want to give it a try,
|
||||
see <http://git-annex.branchable.com/tips/install_on_Android_in_Termux/>
|
||||
"""]]
|
|
@ -20,3 +20,6 @@ tor package. And would avoid needing to bundle other
|
|||
often out of date stuff with git-annex.apk.
|
||||
|
||||
--[[Joey]]
|
||||
|
||||
> Retargeting this todo to be about making the git-annex linux standalone
|
||||
> build work well when unpacked in termux. --[[Joey]]
|
||||
|
|
Loading…
Reference in a new issue