diff --git a/Command/WebApp.hs b/Command/WebApp.hs index d153190782..0a8c62be84 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -157,10 +157,12 @@ firstRun listenhost = do sendurlback v _origout _origerr url _htmlshim = putMVar v url openBrowser :: Maybe FilePath -> FilePath -> String -> Maybe Handle -> Maybe Handle -> IO () -#ifdef __ANDROID__ -openBrowser mcmd htmlshim realurl outh errh = do -#else +#ifndef __ANDROID__ openBrowser mcmd htmlshim _realurl outh errh = do +#else +openBrowser mcmd htmlshim realurl outh errh = do + {- The Android app has a menu item that opens this file. -} + writeFile "/sdcard/git-annex.home/.git-annex-url" realurl #endif hPutStrLn (fromMaybe stdout outh) $ "Launching web browser on " ++ url hFlush stdout @@ -171,8 +173,11 @@ openBrowser mcmd htmlshim _realurl outh errh = do , std_err = maybe Inherit UseHandle errh } exitcode <- waitForProcess pid - unless (exitcode == ExitSuccess) $ + unless (exitcode == ExitSuccess) $ do hPutStrLn (fromMaybe stderr errh) "failed to start web browser" +#ifdef __ANDROID__ + hPutStrLn (fromMaybe stderr errh) "To open the WebApp, go to the menu and select \"Open WebApp\"" +#endif where p = case mcmd of Just cmd -> proc cmd [htmlshim] diff --git a/debian/changelog b/debian/changelog index 6fa8151ef9..2c40b472d5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,8 @@ git-annex (4.20130522) UNRELEASED; urgency=low preferred content settings. * sync: Fix double merge conflict resolution handling. * XMPP: Fix a file descriptor leak. + * Android: Added an "Open WebApp" item to the terminal's menu. + Should work for Android devices that cannot auto-open the webapp on start. -- Joey Hess Tue, 21 May 2013 18:22:46 -0400 diff --git a/standalone/android/term.patch b/standalone/android/term.patch index e7e2983c8b..da5989328e 100644 --- a/standalone/android/term.patch +++ b/standalone/android/term.patch @@ -23,6 +23,28 @@ index f6952f0..1a8df8f 100644 execBuild.redirectErrorStream(true); Process exec = null; try { +diff --git a/res/menu/main.xml b/res/menu/main.xml +index 064f833..fe5f3a3 100644 +--- a/res/menu/main.xml ++++ b/res/menu/main.xml +@@ -16,6 +16,8 @@ + --> + + ++ + +@@ -34,8 +36,6 @@ + android:icon="@drawable/ic_menu_preferences" /> + +- + + true true true +diff --git a/res/values/strings.xml b/res/values/strings.xml +index f1464e9..b06ec9a 100644 +--- a/res/values/strings.xml ++++ b/res/values/strings.xml +@@ -23,7 +23,7 @@ + Prev window + Next window + Reset term +- Email to ++ Open WebApp + Special keys + Toggle soft keyboard + +diff --git a/src/jackpal/androidterm/Term.java b/src/jackpal/androidterm/Term.java +index 8a3a4ac..af8d1ad 100644 +--- a/src/jackpal/androidterm/Term.java ++++ b/src/jackpal/androidterm/Term.java +@@ -21,6 +21,9 @@ import java.text.Collator; + import java.util.Arrays; + import java.util.Locale; + ++import java.io.FileReader; ++import java.io.BufferedReader; ++ + import android.app.Activity; + import android.app.AlertDialog; + import android.content.ActivityNotFoundException; +@@ -59,6 +62,11 @@ import android.view.inputmethod.InputMethodManager; + import android.widget.TextView; + import android.widget.Toast; + ++import android.content.Intent; ++import android.net.Uri; ++import android.app.Activity; ++import android.content.Context; ++ + import jackpal.androidterm.emulatorview.ColorScheme; + import jackpal.androidterm.emulatorview.EmulatorView; + import jackpal.androidterm.emulatorview.TermSession; +@@ -911,31 +919,15 @@ public class Term extends Activity implements UpdateCallback { + } + + private void doEmailTranscript() { ++ // Hack: repurposed to open the git-annex webapp + TermSession session = getCurrentTermSession(); + if (session != null) { +- // Don't really want to supply an address, but +- // currently it's required, otherwise nobody +- // wants to handle the intent. +- String addr = "user@example.com"; +- Intent intent = +- new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" +- + addr)); +- +- String subject = getString(R.string.email_transcript_subject); +- String title = session.getTitle(); +- if (title != null) { +- subject = subject + " - " + title; +- } +- intent.putExtra(Intent.EXTRA_SUBJECT, subject); +- intent.putExtra(Intent.EXTRA_TEXT, +- session.getTranscriptText().trim()); + try { +- startActivity(Intent.createChooser(intent, +- getString(R.string.email_transcript_chooser_title))); +- } catch (ActivityNotFoundException e) { +- Toast.makeText(this, +- R.string.email_transcript_no_email_activity_found, +- Toast.LENGTH_LONG).show(); ++ BufferedReader buf = new BufferedReader(new FileReader("/sdcard/git-annex.home/.git-annex-url")); ++ String s = buf.readLine(); ++ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s)); ++ startActivity(intent); ++ } catch (Exception e) { + } + } + } diff --git a/tools/build-debug b/tools/build-debug index 1f15cd2..e611956 100755 --- a/tools/build-debug