Skip to content
Snippets Groups Projects
Commit 80970d3d authored by akwizgran's avatar akwizgran
Browse files

Touching the notification shows the home screen instead of quitting.

This allows quick access to any part of the app, including quitting (two
touches).
parent b7dbacb0
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
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());
......
......@@ -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()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment