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
This commit is contained in:
Torsten Grote
2015-12-07 16:31:10 -02:00
parent f0558ceb7a
commit f4538df679
5 changed files with 85 additions and 5 deletions

View File

@@ -0,0 +1,44 @@
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));
}
}
}