Skip to content
Snippets Groups Projects
Commit 3bf29fb6 authored by akwizgran's avatar akwizgran
Browse files

Merge branch '38-touching-startup-failure-notification-should-show-details' into 'master'

Touching startup failure notification now shows details

The text of the startup failure notification is unhelpful due to lack of
space. Touching the notification now launches an activity that gives details
of the problem and what can be done about it.

Closes #38

See merge request !7
parents c57014e9 f4538df6
No related branches found
No related tags found
No related merge requests found
......@@ -219,5 +219,10 @@
android:value=".android.contact.ContactListActivity"
/>
</activity>
<activity
android:name=".android.StartupFailureActivity"
android:logo="@drawable/logo"
android:label="@string/startup_failed_activity_title" >
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="7dp">
<TextView
android:id="@+id/headlineView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/startup_failed_notification_title"
android:layout_gravity="center_horizontal"
android:layout_marginTop="7dp"
android:layout_marginBottom="7dp"/>
<TextView
android:id="@+id/errorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/startup_failed_notification_text"/>
</LinearLayout>
\ No newline at end of file
......@@ -17,6 +17,9 @@
<string name="sign_in_button">Sign In</string>
<string name="startup_failed_notification_title">Briar could not start</string>
<string name="startup_failed_notification_text">You may need to reinstall Briar.</string>
<string name="startup_failed_activity_title">Briar Startup Failure</string>
<string name="startup_failed_db_error">For some reason, your Briar database is corrupted beyond repair. Your account, your data and all your contact connections are lost. Unfortunately, you need to reinstall Briar und set up a new account.</string>
<string name="startup_failed_service_error">Briar was unable to start a required plugin. Reinstalling Briar usually solves this problem. However, please note that you will then lose your account and all data associated with it since Briar is not using central servers to store your data on.</string>
<string name="expiry_warning">This software has expired.\nPlease install a newer version.</string>
<string name="contact_list_button">Contacts</string>
<string name="delete_contact">Delete contact</string>
......
......@@ -102,24 +102,27 @@ public class BriarService extends RoboService implements EventListener {
} else {
if (LOG.isLoggable(WARNING))
LOG.warning("Startup failed: " + result);
showStartupFailureNotification();
showStartupFailureNotification(result);
stopSelf();
}
}
}.start();
}
private void showStartupFailureNotification() {
private void showStartupFailureNotification(StartResult result) {
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
b.setSmallIcon(android.R.drawable.stat_notify_error);
b.setContentTitle(getText(R.string.startup_failed_notification_title));
b.setContentText(getText(R.string.startup_failed_notification_text));
Intent i = new Intent(this, DashboardActivity.class);
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP);
b.setContentIntent(PendingIntent.getActivity(this, 0, i, 0));
Intent i = new Intent(this, StartupFailureActivity.class);
i.setFlags(FLAG_ACTIVITY_NEW_TASK);
i.putExtra("briar.START_RESULT", result);
i.putExtra("briar.FAILURE_NOTIFICATION_ID", FAILURE_NOTIFICATION_ID);
b.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT));
Object o = getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
nm.notify(FAILURE_NOTIFICATION_ID, b.build());
// Bring the dashboard to the front to clear all other activities
i = new Intent(this, DashboardActivity.class);
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP);
......
package org.briarproject.android;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import org.briarproject.R;
import roboguice.activity.RoboActivity;
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult;
public class StartupFailureActivity extends RoboActivity {
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_startup_failure);
handleIntent(getIntent());
}
private void handleIntent(Intent i) {
StartResult result = (StartResult) i.getSerializableExtra("briar.START_RESULT");
int notificationId = i.getIntExtra("briar.FAILURE_NOTIFICATION_ID", -1);
// cancel notification
if (notificationId > -1) {
Object o = getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
nm.cancel(notificationId);
}
// show proper error message
TextView view = (TextView) findViewById(R.id.errorView);
if (result.equals(StartResult.DB_ERROR)) {
view.setText(getText(R.string.startup_failed_db_error));
} else if (result.equals(StartResult.SERVICE_ERROR)) {
view.setText(getText(R.string.startup_failed_service_error));
}
}
}
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