-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from Microsoft/develop
Version 0.3.3 changes
- Loading branch information
Showing
44 changed files
with
1,345 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
172 changes: 172 additions & 0 deletions
172
...asquatch/src/main/java/com/microsoft/azure/mobile/sasquatch/activities/CrashActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...uatch/src/main/java/com/microsoft/azure/mobile/sasquatch/activities/CrashSubActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.