Touching the notification shows the home screen instead of quitting.

This allows quick access to any part of the app, including quitting (two
touches).
This commit is contained in:
akwizgran
2013-12-05 13:28:15 +00:00
parent b7dbacb000
commit 80970d3daa
3 changed files with 10 additions and 12 deletions

View File

@@ -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>

View File

@@ -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());

View File

@@ -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()));