acra wtih intented crash on manual loc select

This commit is contained in:
Adam Domagalski 2018-12-02 21:29:47 +01:00
parent 7c1b9e4494
commit f3f2f3b90a
8 changed files with 97 additions and 3 deletions

View File

@ -28,8 +28,14 @@ repositories {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
def acraVersion = '5.2.1'
dependencies {
implementation "ch.acra:acra-http:$acraVersion"
implementation "ch.acra:acra-toast:$acraVersion"
implementation "ch.acra:acra-notification:$acraVersion"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'

View File

@ -17,11 +17,13 @@
<uses-feature android:name="android.hardware.location.gps" />
<application
android:name=".FindMyTutor"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning"
android:theme="@style/AppTheme">
<activity
android:name=".activity.StartupActivity"
@ -52,7 +54,7 @@
<activity
android:name=".activity.TutorTab"
android:theme="@style/AppTheme"></activity>
android:theme="@style/AppTheme"/>
</application>
</manifest>

View File

@ -0,0 +1,75 @@
package com.uam.wmi.findmytutor;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import static org.acra.ReportField.*;
import org.acra.ACRA;
import org.acra.annotation.AcraNotification;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.HttpSenderConfigurationBuilder;
import org.acra.config.ToastConfigurationBuilder;
import org.acra.data.StringFormat;
import org.acra.sender.HttpSender;
import java.util.HashMap;
import java.util.Map;
@AcraNotification(resText = R.string.notification_text,
resTitle = R.string.notification_title,
resChannelName = R.string.notification_channel)
public class FindMyTutor extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// ACRA core
CoreConfigurationBuilder builder = new CoreConfigurationBuilder(this)
.setBuildConfigClass(BuildConfig.class)
.setReportContent(REPORT_ID, PHONE_MODEL, LOGCAT, USER_APP_START_DATE, USER_CRASH_DATE, SHARED_PREFERENCES,
ANDROID_VERSION, STACK_TRACE, CUSTOM_DATA, BUILD_CONFIG)
.setReportFormat(StringFormat.JSON);
// Toast for user
builder.setBuildConfigClass(BuildConfig.class)
.setReportFormat(StringFormat.JSON);
builder.getPluginConfigurationBuilder(
ToastConfigurationBuilder.class
).setResText(R.string.acra_toast_text);
SharedPreferences sharedPreferences = base.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
Map header = new HashMap();
String token = sharedPreferences.getString("API_KEY", "KEY_EMPTY");
header.put("Authorization","Bearer " + token);
// Api POST
builder.getPluginConfigurationBuilder(
HttpSenderConfigurationBuilder.class
// ).setUri("http://192.168.0.15:3000/api/acra")
).setUri("https://s416084.projektstudencki.pl/develop/api/Feedback/autoFeedback")
.setHttpMethod(HttpSender.Method.POST)
.setHttpHeaders(header)
.setEnabled(true);
ACRA.init(this, builder);
//Shared preferences
ACRA.getErrorReporter().putCustomData("USER_ID", sharedPreferences.getString("USER_ID", "no user id"));
}
// Called by the system when the device configuration changes while your component is running.
// Overriding this method is totally optional!
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
// This is called when the overall system is running low on memory,
// and would like actively running processes to tighten their belts.
// Overriding this method is totally optional!
@Override
public void onLowMemory() {
super.onLowMemory();
}
}

View File

@ -149,8 +149,11 @@ public class LoginActivity extends AppCompatActivity {
private void loginProcess(String email, String password) {
ValidateUser user = new ValidateUser(email, password);
LdapUser fuser = new LdapUser(email, password, "wmi", "tutor", "henryk", "zdzblo", email);
// disposable.add(ldapService.validate(user)
disposable.add(ldapService.fakeValidate(fuser)
disposable.add(ldapService.validate(user)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleResponse, this::handleError));

View File

@ -301,6 +301,8 @@ public class MapActivity extends BaseActivity
tmpLocalMarker = null;
showLocationDialog(latLng);
// TODO remove after acra tests
throw new RuntimeException("This is a crash");
}
});
});

View File

@ -22,7 +22,7 @@ public class ApiClient {
private static Retrofit retrofit = null;
private static int REQUEST_TIMEOUT = 60;
private static OkHttpClient okHttpClient;
private static final String BASE_URL = "https://s416084.projektstudencki.pl/master/";
private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
public static Retrofit getClient(Context context) {

View File

@ -159,6 +159,7 @@
<string name="network_error">Błąd sieci!</string>
<string name="manual_status_error">Błąd podczas pobierania danych.</string>
<string name="error_status_fetch">Błąd podczas pobierania statusów.</string>
<string name="notification_text">Upss. Coś poszło nie tak. Pracujemy nad tym!</string>
</resources>

View File

@ -228,4 +228,9 @@
<string name="network_error">Network Error!</string>
<string name="manual_status_error">Error handling status fetch</string>
<string name="error_status_fetch">Error handling status fetch</string>
<string name="acra_toast_text" translatable="false">Sorry, the application crashed. A report will be sent to the developers</string>
<string name="notification_text">Sorry, the application crashed. A report will be sent to the developers</string>
<string name="notification_title" translatable="false">FMT Crash</string>
<string name="notification_channel" translatable="false">FMT</string>
</resources>