package org.fathens.cordova.acra;

import org.acra.ACRA;
import org.acra.ACRAConfiguration;
import org.acra.ACRAConfigurationException;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import org.acra.sender.EmailIntentSender;

import android.app.Application;
import android.util.Log;

@ReportsCrashes(formKey = "")
public class AcraApplication extends Application {
    static final String TAG = "ACRA_Application";

    @Override
    public void onCreate() {
	super.onCreate();

	// Initialization of ACRA
	final ReportingInteractionMode mode = ReportingInteractionMode.TOAST;
	final int toastText = getResources().getIdentifier("acra_toast_text", "string", getPackageName());
	final String url = getResources().getString(getResources().getIdentifier("acra_url", "string", getPackageName()));
	final String username = getResources().getString(getResources().getIdentifier("acra_username", "string", getPackageName()));
	final String password = getResources().getString(getResources().getIdentifier("acra_password", "string", getPackageName()));
	Log.d(TAG, String.format("Configuration Setup: MODE=%s, TOAST_TEXT=%x, PUT_URI='%s'", mode, toastText, url));
	try {
	    final ACRAConfiguration config = ACRA.getNewDefaultConfig(this);
	    config.setMode(mode);
	    config.setResToastText(toastText);
	    config.setHttpMethod(org.acra.sender.HttpSender.Method.PUT);
	    config.setFormUri(url);
	    config.setFormUriBasicAuthLogin(username);
	    config.setFormUriBasicAuthPassword(password);
	    ACRA.setConfig(config);
	    ACRA.init(this);
	    ACRA.getErrorReporter().setReportSender(new EmailIntentSender(getApplicationContext()));
	} catch (ACRAConfigurationException ex) {
	    throw new RuntimeException(ex);
	}
    }
}

@@ -447,16 +447,252 @@
 tion%22;%0A%0A
+    private int getId(String name) %7B%0A        return getResources().getIdentifier(%22acra_%22 + name, %22string%22, getPackageName());%0A    %7D%0A%0A    private String getText(String name) %7B%0A        return getResources().getString(getId(name));%0A    %7D%0A%0A
     @Ove
@@ -726,17 +726,24 @@
 ate() %7B%0A
-%09
+        
 super.on
@@ -753,17 +753,24 @@
 ate();%0A%0A
-%09
+        
 // Initi
@@ -787,17 +787,24 @@
 of ACRA%0A
-%09
+        
 final Re
@@ -865,17 +865,24 @@
 .TOAST;%0A
-%09
+        
 final in
@@ -902,451 +902,183 @@
  get
-Resources().getIdentifier(%22acra_toast_text%22, %22string%22, getPackageName());%0A%09final String url = getResources().getString(getResources().getIdentifier(%22acra_url%22, %22string%22, getPackageName()));%0A%09final String username = getResources().getString(getResources().getIdentifier(%22acra_username%22, %22string%22, getPackageName()));%0A%09final String password = getResources().getString(getResources().getIdentifier(%22acra_password%22, %22string%22, getPackageName()));%0A%09
+Id(%22toast_text%22);%0A        final String url = getText(%22url%22);%0A        final String username = getText(%22username%22);%0A        final String password = getText(%22password%22);%0A        
 Log.
@@ -1187,16 +1187,30 @@
 ));%0A
-%09try %7B%0A%09
+        try %7B%0A        
     
@@ -1270,25 +1270,32 @@
 nfig(this);%0A
-%09
+        
     config.s
@@ -1304,25 +1304,32 @@
 Mode(mode);%0A
-%09
+        
     config.s
@@ -1355,17 +1355,24 @@
 tText);%0A
-%09
+        
     conf
@@ -1428,17 +1428,96 @@
 d.PUT);%0A
-%09
+            config.setReportType(org.acra.sender.HttpSender.Type.JSON);%0A        
     conf
@@ -1536,17 +1536,24 @@
 i(url);%0A
-%09
+        
     conf
@@ -1591,17 +1591,24 @@
 rname);%0A
-%09
+        
     conf
@@ -1649,17 +1649,24 @@
 sword);%0A
-%09
+        
     ACRA
@@ -1685,17 +1685,24 @@
 onfig);%0A
-%09
+        
     ACRA
@@ -1718,103 +1718,16 @@
 s);%0A
-%09
     
-ACRA.getErrorReporter().setReportSender(new EmailIntentSender(getApplicationContext()));%0A%09
+    
 %7D ca
@@ -1764,17 +1764,24 @@
 n ex) %7B%0A
-%09
+        
     thro
@@ -1812,9 +1812,16 @@
 x);%0A
-%09
+        
 %7D%0A  

Remove setReportSender