summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-28 18:25:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-28 18:25:27 -0400
commitf9aef09f97a864a9bc2663af80736df1a3f0a816 (patch)
treeeb946f52a22763feb0caf4705ac623fefd8b5d5b
parentb6eb8760322b3615a05ebc440598379c137c397d (diff)
Android: Added an "Open WebApp" item to the terminal's menu. Should work for Android devices that cannot auto-open the webapp on start.
-rw-r--r--Command/WebApp.hs13
-rw-r--r--debian/changelog2
-rw-r--r--standalone/android/term.patch99
3 files changed, 110 insertions, 4 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs
index d15319078..0a8c62be8 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 6fa8151ef..2c40b472d 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 <joeyh@debian.org> Tue, 21 May 2013 18:22:46 -0400
diff --git a/standalone/android/term.patch b/standalone/android/term.patch
index e7e2983c8..da5989328 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 @@
+ -->
+
+ <menu xmlns:android="http://schemas.android.com/apk/res/android">
++ <item android:id="@+id/menu_send_email"
++ android:title="@string/send_email" />
+ <item android:id="@+id/menu_new_window"
+ android:title="@string/new_window"
+ android:icon="@drawable/ic_menu_add" />
+@@ -34,8 +36,6 @@
+ android:icon="@drawable/ic_menu_preferences" />
+ <item android:id="@+id/menu_reset"
+ android:title="@string/reset" />
+- <item android:id="@+id/menu_send_email"
+- android:title="@string/send_email" />
+ <item android:id="@+id/menu_toggle_wakelock"
+ android:title="@string/enable_wakelock" />
+ <item android:id="@+id/menu_toggle_wifilock"
diff --git a/res/values/defaults.xml b/res/values/defaults.xml
index 67287b2..9b7cfcd 100644
--- a/res/values/defaults.xml
@@ -41,6 +63,83 @@ index 67287b2..9b7cfcd 100644
<bool name="pref_verify_path_default">true</bool>
<bool name="pref_do_path_extensions_default">true</bool>
<bool name="pref_allow_prepend_path_default">true</bool>
+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 @@
+ <string name="prev_window">Prev window</string>
+ <string name="next_window">Next window</string>
+ <string name="reset">Reset term</string>
+- <string name="send_email">Email to</string>
++ <string name="send_email">Open WebApp</string>
+ <string name="special_keys">Special keys</string>
+ <string name="toggle_soft_keyboard">Toggle soft keyboard</string>
+
+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