// Path: src/com/suchagit/android2cloud/util/ErrorMethods.java
// public class ErrorMethods {
// 	public static Intent getEmailIntent(Fragment context, String type, String message) {
// 		Intent i = new Intent(Intent.ACTION_SEND);
// 		i.setType("message/rfc822");
// 		i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"android@2cloudproject.com"});
// 		i.putExtra(Intent.EXTRA_SUBJECT, "In-App Error Report");
// 		String message_prefix = "Error:\n";
// 		message_prefix += "Type: "+type+"\n";
// 		try {
// 			message_prefix += "Version: " + context.getActivity().getPackageManager().getPackageInfo(context.getActivity().getPackageName(), 0 ).versionCode + "\n";
// 		} catch (NameNotFoundException e) {
// 			message_prefix += "\n";
// 		}
// 		message_prefix += "Android Version: " + android.os.Build.VERSION.SDK + "\n";
// 		message_prefix += "Phone: " + android.os.Build.MODEL + "\n";
// 		message = message_prefix + message;
// 		i.putExtra(Intent.EXTRA_TEXT   , message);
// 		return i;
// 	}
// }


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import com.suchagit.android2cloud.R;
import com.suchagit.android2cloud.util.ErrorMethods;
        
        final String stacktrace = getArguments().getString("stacktrace");
        final String host = getArguments().getString("host");
        final String account = getArguments().getString("account");
        final String verifier = getArguments().getString("verifier");
        final String requestUrl = getArguments().getString("request_url");

        return new AlertDialog.Builder(getActivity())
    		.setCancelable(false)
            .setTitle(title)
            .setMessage(body)
            .setPositiveButton(yesButton,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                        	dialog.cancel();
                        	getActivity().finish();
                        }
                    }
                )
            .setNegativeButton(noButton,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                		String message = "Account: " + account +"\n";
                		message += "Host: " + host + "\n";
                		if(requestUrl != null)
                			message += "Request URL: " + requestUrl + "\n";
                		else if(verifier != null)
                			message += "Verifier: " + verifier + "\n";
                		message += "Stacktrace: \n";
                		message += stacktrace + "\n";
// Path: src/com/suchagit/android2cloud/util/ErrorMethods.java
// public class ErrorMethods {
// 	public static Intent getEmailIntent(Fragment context, String type, String message) {
// 		Intent i = new Intent(Intent.ACTION_SEND);
// 		i.setType("message/rfc822");
// 		i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"android@2cloudproject.com"});
// 		i.putExtra(Intent.EXTRA_SUBJECT, "In-App Error Report");
// 		String message_prefix = "Error:\n";
// 		message_prefix += "Type: "+type+"\n";
// 		try {
// 			message_prefix += "Version: " + context.getActivity().getPackageManager().getPackageInfo(context.getActivity().getPackageName(), 0 ).versionCode + "\n";
// 		} catch (NameNotFoundException e) {
// 			message_prefix += "\n";
// 		}
// 		message_prefix += "Android Version: " + android.os.Build.VERSION.SDK + "\n";
// 		message_prefix += "Phone: " + android.os.Build.MODEL + "\n";
// 		message = message_prefix + message;
// 		i.putExtra(Intent.EXTRA_TEXT   , message);
// 		return i;
// 	}
// }


// Path: src/com/suchagit/android2cloud/errors/OAuthMessageSignerExceptionDialogFragment.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import com.suchagit.android2cloud.R;
import com.suchagit.android2cloud.util.ErrorMethods;

        
        final String stacktrace = getArguments().getString("stacktrace");
        final String host = getArguments().getString("host");
        final String account = getArguments().getString("account");
        final String verifier = getArguments().getString("verifier");
        final String requestUrl = getArguments().getString("request_url");

        return new AlertDialog.Builder(getActivity())
    		.setCancelable(false)
            .setTitle(title)
            .setMessage(body)
            .setPositiveButton(yesButton,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                        	dialog.cancel();
                        	getActivity().finish();
                        }
                    }
                )
            .setNegativeButton(noButton,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                		String message = "Account: " + account +"\n";
                		message += "Host: " + host + "\n";
                		if(requestUrl != null)
                			message += "Request URL: " + requestUrl + "\n";
                		else if(verifier != null)
                			message += "Verifier: " + verifier + "\n";
                		message += "Stacktrace: \n";
                		message += stacktrace + "\n";
                		Intent report = ErrorMethods.getEmailIntent(OAuthMessageSignerExceptionDialogFragment.this, "oauth_message_signer_exception_error", message);