Skip to content

Commit

Permalink
Merge 62909c5 into d068292
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Feb 7, 2018
2 parents d068292 + 62909c5 commit 24700aa
Show file tree
Hide file tree
Showing 33 changed files with 202 additions and 103 deletions.
2 changes: 2 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
<property name="eachLine" value="true"/>
</module>

<module name="SuppressWarningsFilter" />
<module name="TreeWalker">
<module name="SuppressWarningsHolder" />
<module name="OuterTypeFilename"/>
<module name="IllegalTokenText">
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
Expand Down
13 changes: 12 additions & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,15 @@ dependencies {
}

apply plugin: 'com.bugsnag.android.gradle'
apply from: "../checkstyle.gradle"

apply plugin: 'checkstyle'

checkstyle {
toolVersion = "6.16"
}
task("checkstyle", type: Checkstyle) {
configFile rootProject.file("config/checkstyle/checkstyle.xml")
source "src/javaExample/java"
include "**/*.java"
classpath = files()
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package com.bugsnag.android.example;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;
import static android.widget.Toast.LENGTH_SHORT;

import com.bugsnag.android.BeforeNotify;
import com.bugsnag.android.BreadcrumbType;
Expand All @@ -18,13 +12,19 @@
import com.bugsnag.android.Severity;
import com.bugsnag.android.other.CrashyClass;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static android.widget.Toast.LENGTH_SHORT;

public class ExampleActivity extends AppCompatActivity {

@Override
Expand Down Expand Up @@ -78,8 +78,8 @@ public void crashUnhandled(View view) {
public void crashHandled(View view) {
try {
throw new RuntimeException("Non-Fatal Crash");
} catch (RuntimeException e) {
Bugsnag.notify(e);
} catch (RuntimeException exception) {
Bugsnag.notify(exception);
}
displayToastNotification();
}
Expand All @@ -89,8 +89,8 @@ public void crashHandled(View view) {
* exceptions which occur often but are not visible to the user.
*/
public void crashWithCustomSeverity(View view) {
RuntimeException e = new RuntimeException("Error Report with altered Severity");
Bugsnag.notify(e, Severity.INFO);
RuntimeException exception = new RuntimeException("Error Report with altered Severity");
Bugsnag.notify(exception, Severity.INFO);
displayToastNotification();
}

Expand All @@ -100,8 +100,8 @@ public void crashWithCustomSeverity(View view) {
*/
public void crashWithUserDetails(View view) {
Bugsnag.setUser("123456", "joebloggs@example.com", "Joe Bloggs");
RuntimeException e = new RuntimeException("Error Report with User Info");
Bugsnag.notify(e);
RuntimeException exception = new RuntimeException("Error Report with User Info");
Bugsnag.notify(exception);
displayToastNotification();
}

Expand All @@ -111,10 +111,10 @@ public void crashWithUserDetails(View view) {
* with {@link Bugsnag#beforeNotify(BeforeNotify)} that adds metadata to the report.
*/
public void crashWithMetadata(View view) {
RuntimeException e = new RuntimeException("Error report with Additional Metadata");
RuntimeException exception = new RuntimeException("Error report with Additional Metadata");
MetaData metaData = generateUserMetaData();

Bugsnag.notify(e, Severity.ERROR, metaData);
Bugsnag.notify(exception, Severity.ERROR, metaData);
displayToastNotification();
}

Expand All @@ -130,8 +130,8 @@ public void crashWithBreadcrumbs(View view) {
metadata.put("reason", "Incorrect password");
Bugsnag.leaveBreadcrumb("WebAuthFailure", BreadcrumbType.ERROR, metadata);

RuntimeException e = new RuntimeException("Error Report with Breadcrumbs");
Bugsnag.notify(e);
RuntimeException exception = new RuntimeException("Error Report with Breadcrumbs");
Bugsnag.notify(exception);
displayToastNotification();
}

Expand All @@ -140,9 +140,9 @@ public void crashWithBreadcrumbs(View view) {
* to be modified before it is sent.
*/
public void crashWithCallback(View view) {
RuntimeException e = new RuntimeException("Customized Error Report");
RuntimeException exception = new RuntimeException("Customized Error Report");

Bugsnag.notify(e, new Callback() {
Bugsnag.notify(exception, new Callback() {
@Override
public void beforeNotify(Report report) { // modify the report
report.getError().setMetaData(generateUserMetaData());
Expand All @@ -165,20 +165,27 @@ private void setupToolbarLogo() {
}
}

/**
* Reads the android bugsnag docs
*
* @param view the XML layout view
*/
public void readDocs(View view) {
Uri uri = Uri.parse("https://docs.bugsnag.com/platforms/android/sdk/");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

private MetaData generateUserMetaData() {
List<String> completedLevels = Arrays.asList("Level 1 - The Beginning", "Level 2 - Tower Defence");
Map<String, String> userDetails = new HashMap<>();
userDetails.put("playerName", "Joe Bloggs the Invincible");

MetaData metaData = new MetaData();
metaData.addToTab("CustomMetaData", "HasLaunchedGameTutorial", true);
metaData.addToTab("CustomMetaData", "UserDetails", userDetails);

List<String> completedLevels =
Arrays.asList("Level 1 - The Beginning", "Level 2 - Tower Defence");
metaData.addToTab("CustomMetaData", "CompletedLevels", completedLevels);
return metaData;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.bugsnag.android.example;

import android.app.Application;

import com.bugsnag.android.Bugsnag;

import android.app.Application;

public class ExampleApplication extends Application {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void testSessionIncluded() throws Exception {
assertNotNull(sessionNode);
assertEquals(3, sessionNode.length());
assertEquals(session.getId(), sessionNode.getString("id"));
assertEquals(DateUtils.toISO8601(session.getStartedAt()), sessionNode.getString("startedAt"));
assertEquals(DateUtils.toIso8601(session.getStartedAt()), sessionNode.getString("startedAt"));

JSONObject eventsNode = sessionNode.getJSONObject("events");
assertNotNull(eventsNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import org.junit.Test;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import static com.bugsnag.android.BugsnagTestUtils.generateSession;
Expand Down Expand Up @@ -56,7 +54,7 @@ public void testPayloadSerialisation() throws Exception {
JSONObject sessionNode = sessions.getJSONObject(0);
assertNotNull(sessionNode);
assertEquals("test", sessionNode.getString("id"));
assertEquals(DateUtils.toISO8601(session.getStartedAt()), sessionNode.getString("startedAt"));
assertEquals(DateUtils.toIso8601(session.getStartedAt()), sessionNode.getString("startedAt"));
assertNotNull(sessionNode.getJSONObject("user"));

assertNotNull(rootNode.getJSONObject("notifier"));
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/main/java/com/bugsnag/android/AppData.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ String getActiveScreenClass() {
ActivityManager.RunningTaskInfo runningTask = tasks.get(0);
return runningTask.topActivity.getClassName();
} catch (Exception exception) {
Logger.warn("Could not get active screen information," +
" we recommend granting the 'android.permission.GET_TASKS' permission");
Logger.warn("Could not get active screen information,"
+ " we recommend granting the 'android.permission.GET_TASKS' permission");
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/main/java/com/bugsnag/android/Breadcrumbs.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static class Breadcrumb implements JsonStream.Streamable {
final Map<String, String> metadata;

Breadcrumb(@NonNull String message) {
this.timestamp = DateUtils.toISO8601(new Date());
this.timestamp = DateUtils.toIso8601(new Date());
this.type = BreadcrumbType.MANUAL;
String msg = message.substring(0, Math.min(message.length(), MAX_MESSAGE_LENGTH));
this.metadata = Collections.singletonMap(MESSAGE_METAKEY, msg);
Expand All @@ -41,7 +41,7 @@ private static class Breadcrumb implements JsonStream.Streamable {
Breadcrumb(@NonNull String name,
@NonNull BreadcrumbType type,
@NonNull Map<String, String> metadata) {
this.timestamp = DateUtils.toISO8601(new Date());
this.timestamp = DateUtils.toIso8601(new Date());
this.type = type;
this.metadata = metadata;
this.name = name;
Expand Down
8 changes: 6 additions & 2 deletions sdk/src/main/java/com/bugsnag/android/Bugsnag.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* @see Client
*/
@SuppressWarnings("checkstyle:JavadocTagContinuationIndentation")
public final class Bugsnag {

@Nullable
Expand Down Expand Up @@ -131,6 +132,7 @@ public static void setEndpoint(final String endpoint) {
*
* @param buildUUID the buildUUID.
*/
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public static void setBuildUUID(final String buildUUID) {
getClient().setBuildUUID(buildUUID);
}
Expand Down Expand Up @@ -465,6 +467,8 @@ public void beforeNotify(@NonNull Report report) {
* to send and modify error reports
*/
@Deprecated
@SuppressWarnings("checkstyle:JavadocTagContinuationIndentation")

public static void notify(@NonNull String name, @NonNull String message, String context,
@NonNull StackTraceElement[] stacktrace, Severity severity,
@NonNull MetaData metaData) {
Expand Down Expand Up @@ -623,8 +627,8 @@ public static void startSession() {
@NonNull
public static Client getClient() {
if (client == null) {
throw new IllegalStateException("You must call Bugsnag.init before any" +
" other Bugsnag methods");
throw new IllegalStateException("You must call Bugsnag.init before any"
+ " other Bugsnag methods");
}

return client;
Expand Down

0 comments on commit 24700aa

Please sign in to comment.