Skip to content

Commit

Permalink
Merge pull request #287 from Microsoft/develop
Browse files Browse the repository at this point in the history
Version 0.3.3 changes
  • Loading branch information
guperrot authored Dec 14, 2016
2 parents 9cfdffd + 8b2e6aa commit e661dd6
Show file tree
Hide file tree
Showing 44 changed files with 1,345 additions and 297 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ You create your own Crashes listener and assign it like this:
}
```
* **User Confirmation:** If user privacy is important to you as a developer, you might want to get user confirmation before sending a crash report to Mobile Center. The SDK exposes a callback where you can tell it to await user confirmation before sending any crash reports.
* **User Confirmation:** By default the SDK automatically sends crash reports to Mobile Center. However, the SDK exposes a callback where you can tell it to await user confirmation before sending any crash reports.
Your app is then responsible for obtaining confirmation, e.g. through a dialog prompt with one of these options - "Always Send", "Send", and "Don't Send". Based on the user input, you will tell the SDK and the crash will then respectively be forwarded to Mobile Center or not.
```Java
Expand Down
10 changes: 9 additions & 1 deletion apps/sasquatch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ android {
productFlavors {
projectDependency {
applicationIdSuffix ".project"
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher",
appName: "@string/app_name"
]
}
jcenterDependency {
applicationIdSuffix ".jcenter"
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher_jcenter",
appName: "@string/app_name_jcenter"
]
}
}
}

dependencies {
def version = "0.3.1"
def version = "0.3.2"
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
projectDependencyCompile project(':sdk:mobile-center-analytics')
projectDependencyCompile project(':sdk:mobile-center-crashes')
Expand Down
28 changes: 16 additions & 12 deletions apps/sasquatch/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.microsoft.azure.mobile.sasquatch">
xmlns:tools="http://schemas.android.com/tools"
package="com.microsoft.azure.mobile.sasquatch">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:icon="${appIcon}"
android:label="${appName}"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".activities.CrashActivity"
android:label="@string/title_crashes"/>
<activity android:name=".activities.CrashSubActivity"/>
<activity
android:name=".activities.DeviceInfoActivity"
android:label="@string/title_device_info" />
android:label="@string/title_device_info"/>
<activity
android:name=".activities.EventActivity"
android:label="@string/title_event" />
android:label="@string/title_event"/>
<activity
android:name=".activities.PageActivity"
android:label="@string/title_page" />
android:label="@string/title_page"/>
<activity
android:name=".activities.DummyActivity"
android:label="@string/title_generate_page_log" />
android:label="@string/title_generate_page_log"/>
<activity
android:name=".activities.SettingsActivity"
android:label="@string/settings" />
android:label="@string/settings"/>
<activity
android:name=".activities.ManagedErrorActivity"
android:label="@string/title_error" />
android:label="@string/title_error"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
package com.microsoft.azure.mobile.sasquatch.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.microsoft.azure.mobile.crashes.Crashes;
import com.microsoft.azure.mobile.crashes.model.TestCrashException;
import com.microsoft.azure.mobile.sasquatch.R;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

import static com.microsoft.azure.mobile.sasquatch.activities.CrashSubActivity.INTENT_EXTRA_CRASH_TYPE;

public class CrashActivity extends AppCompatActivity {

private boolean mCrashSuperPauseNotCalled;

private boolean mCrashSuperDestroyNotCalled;

private final List<Crash> sCrashes = Arrays.asList(
new Crash(R.string.title_test_crash, R.string.description_test_crash, new Runnable() {

@Override
public void run() {
Crashes.generateTestCrash();
throw new TestCrashException();
}
}),
new Crash(R.string.title_crash_divide_by_0, R.string.title_crash_divide_by_0, new Runnable() {

@Override
@SuppressWarnings("ResultOfMethodCallIgnored")
public void run() {
("" + (42 / Integer.valueOf("0"))).toCharArray();
}
}),
new Crash(R.string.title_test_ui_crash, R.string.description_test_ui_crash, new Runnable() {

@Override
@SuppressWarnings("ResultOfMethodCallIgnored")
public void run() {
ListView view = (ListView) findViewById(R.id.list);
view.setAdapter(new ArrayAdapter<>(CrashActivity.this, android.R.layout.simple_list_item_2, sCrashes));
}
}),
new Crash(R.string.title_stack_overflow_crash, R.string.description_stack_overflow_crash, new Runnable() {

@Override
@SuppressWarnings("InfiniteRecursion")
public void run() {
run();
}
}),
new Crash(R.string.title_memory_crash, R.string.description_memory_crash, new Runnable() {

@Override
public void run() {
new int[Integer.MAX_VALUE].clone();
}
}),
new Crash(R.string.title_memory_crash2, R.string.description_memory_crash2, new Runnable() {

@Override
public void run() {
startActivity(new Intent(CrashActivity.this, CrashSubActivity.class).putExtra(INTENT_EXTRA_CRASH_TYPE, 1));
}
}),
new Crash(R.string.title_variable_message, R.string.description_variable_message, new Runnable() {

@Override
public void run() {
getResources().openRawResource(~new Random().nextInt(10));
}
}),
new Crash(R.string.title_variable_message2, R.string.description_variable_message2, new Runnable() {

@Override
public void run() {
startActivity(new Intent(CrashActivity.this, CrashSubActivity.class).putExtra(INTENT_EXTRA_CRASH_TYPE, 2));
}
}),
new Crash(R.string.title_super_not_called_exception, R.string.description_super_not_called_exception, new Runnable() {

@Override
public void run() {
mCrashSuperPauseNotCalled = true;
finish();
}
}),
new Crash(R.string.title_super_not_called_exception2, R.string.description_super_not_called_exception2, new Runnable() {

@Override
public void run() {
mCrashSuperDestroyNotCalled = true;
finish();
}
}),
new Crash(R.string.title_super_not_called_exception3, R.string.description_super_not_called_exception3, new Runnable() {

@Override
public void run() {
startActivity(new Intent(CrashActivity.this, CrashSubActivity.class).putExtra(INTENT_EXTRA_CRASH_TYPE, 0));
}
})
);

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);

ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(new ArrayAdapter<Crash>(this, android.R.layout.simple_list_item_2, android.R.id.text1, sCrashes) {

@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View view = super.getView(position, convertView, parent);
((TextView) view.findViewById(android.R.id.text1)).setText(getItem(position).title);
((TextView) view.findViewById(android.R.id.text2)).setText(getItem(position).description);
return view;
}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
((Crash) parent.getItemAtPosition(position)).crashTask.run();
}
});
}

@Override
protected void onPause() {
if (!mCrashSuperPauseNotCalled) {
super.onPause();
}
}

@Override
protected void onDestroy() {
if (!mCrashSuperDestroyNotCalled) {
super.onDestroy();
}
}

private static class Crash {
final int title;

final int description;

final Runnable crashTask;

Crash(int title, int description, Runnable crashTask) {
this.title = title;
this.description = description;
this.crashTask = crashTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.microsoft.azure.mobile.sasquatch.activities;

import android.support.v7.app.AppCompatActivity;

import java.util.Random;

public class CrashSubActivity extends AppCompatActivity {

static final String INTENT_EXTRA_CRASH_TYPE = "INTENT_EXTRA_CRASH_TYPE";

@Override
public void onResume() {
switch (getIntent().getIntExtra(INTENT_EXTRA_CRASH_TYPE, 0)) {

case 1:
new StringBuilder(Integer.MAX_VALUE);
break;

case 2:
getResources().openRawResource(~new Random().nextInt(10));
break;

case 0:
default:
/* super not called crash */
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public ErrorAttachment getErrorAttachment(ErrorReport report) {
return ErrorAttachments.attachment("This is a text attachment.", "This is a binary attachment.".getBytes(), "binary.txt", "text/plain");
}

@Override
public void onBeforeSending(ErrorReport report) {
Toast.makeText(MainActivity.this, R.string.crash_before_sending, Toast.LENGTH_SHORT).show();
}

@Override
public void onSendingFailed(ErrorReport report, Exception e) {
Toast.makeText(MainActivity.this, R.string.crash_sent_failed, Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class ManagedErrorActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_managed_error);
setContentView(R.layout.activity_list);

ListView listView = (ListView) findViewById(R.id.throwables_list_view);
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(new ArrayAdapter<Class<? extends Throwable>>(this, android.R.layout.simple_list_item_1, sSupportedThrowables) {
@SuppressWarnings("ConstantConditions")
@NonNull
Expand Down
Loading

0 comments on commit e661dd6

Please sign in to comment.