From 80970d3daa0f2a97a810a6534a7fd2d9595b3598 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Thu, 5 Dec 2013 13:28:15 +0000
Subject: [PATCH] Touching the notification shows the home screen instead of
 quitting.

This allows quick access to any part of the app, including quitting (two
touches).
---
 briar-android/res/values/strings.xml                 |  2 +-
 .../src/net/sf/briar/android/BriarService.java       | 12 ++++++++----
 .../src/net/sf/briar/android/HomeScreenActivity.java |  8 +-------
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/briar-android/res/values/strings.xml b/briar-android/res/values/strings.xml
index 0042630921..8406c17870 100644
--- a/briar-android/res/values/strings.xml
+++ b/briar-android/res/values/strings.xml
@@ -2,7 +2,7 @@
 <resources>
 	<string name="app_name">Briar</string>
 	<string name="notification_title">Briar is running</string>
-	<string name="notification_text">Touch to quit.</string>
+	<string name="notification_text">Touch to show the home screen.</string>
 	<string name="setup_title">Briar Setup</string>
 	<string name="choose_nickname">Choose your nickname:</string>
 	<string name="choose_password">Choose your password:</string>
diff --git a/briar-android/src/net/sf/briar/android/BriarService.java b/briar-android/src/net/sf/briar/android/BriarService.java
index 569c6e9101..23f0576c8b 100644
--- a/briar-android/src/net/sf/briar/android/BriarService.java
+++ b/briar-android/src/net/sf/briar/android/BriarService.java
@@ -1,7 +1,9 @@
 package net.sf.briar.android;
 
-import static android.app.PendingIntent.FLAG_ONE_SHOT;
+import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
 import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
 import static java.util.logging.Level.INFO;
 
 import java.util.concurrent.CountDownLatch;
@@ -42,11 +44,13 @@ public class BriarService extends RoboService {
 		b.setContentTitle(getText(R.string.notification_title));
 		b.setContentText(getText(R.string.notification_text));
 		b.setWhen(0); // Don't show the time
-		// Touch the notification to quit
+		// Touch the notification to show the home screen
 		Intent i = new Intent(this, HomeScreenActivity.class);
+		i.addFlags(FLAG_ACTIVITY_CLEAR_TASK);
+		i.addFlags(FLAG_ACTIVITY_NEW_TASK);
 		i.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
-		i.putExtra("net.sf.briar.QUIT", true);
-		PendingIntent pi = PendingIntent.getActivity(this, 0, i, FLAG_ONE_SHOT);
+		i.addFlags(FLAG_ACTIVITY_SINGLE_TOP);
+		PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
 		b.setContentIntent(pi);
 		b.setOngoing(true);
 		startForeground(1, b.build());
diff --git a/briar-android/src/net/sf/briar/android/HomeScreenActivity.java b/briar-android/src/net/sf/briar/android/HomeScreenActivity.java
index 6495889b6a..f826570802 100644
--- a/briar-android/src/net/sf/briar/android/HomeScreenActivity.java
+++ b/briar-android/src/net/sf/briar/android/HomeScreenActivity.java
@@ -86,14 +86,8 @@ public class HomeScreenActivity extends RoboActivity {
 	public void onCreate(Bundle state) {
 		super.onCreate(state);
 		Intent i = getIntent();
-		boolean quit = i.getBooleanExtra("net.sf.briar.QUIT", false);
 		long handle = i.getLongExtra("net.sf.briar.LOCAL_AUTHOR_HANDLE", -1);
-		if(quit) {
-			// The activity was launched from the notification bar
-			showSpinner();
-			bindService();
-			quit();
-		} else if(handle != -1) {
+		if(handle != -1) {
 			// The activity was launched from the setup wizard
 			showSpinner();
 			startService(new Intent(BriarService.class.getName()));
-- 
GitLab