package com.eggheadgames.aboutbox.share;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;

import com.eggheadgames.aboutbox.AboutConfig;

public final class EmailUtil {

    private EmailUtil() {
        // Utility class
    }

    public static void contactUs(Activity activity) {
        AboutConfig config = AboutConfig.getInstance();

        final Uri mailto = Uri.fromParts("mailto", config.emailAddress, null);

        final String emailSubject;

        switch (config.buildType) {
            case GOOGLE:
                emailSubject = config.emailSubject + "G";
                break;
            case AMAZON:
                emailSubject = config.emailSubject + "K";
                break;
            default:
                emailSubject = config.emailSubject;
                break;
        }
        String emailBody = config.emailBody;
        if (TextUtils.isEmpty(emailBody)) {
            String deviceInfo = "";
            deviceInfo += "\n App version: " + config.version;
            deviceInfo += "\n Android version: " + Build.VERSION.RELEASE + " (" + android.os.Build.VERSION.SDK_INT + ")";
            deviceInfo += "\n OS version: " + System.getProperty("os.version") + " (" + android.os.Build.VERSION.INCREMENTAL + ")";
            deviceInfo += "\n Device: " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";

            emailBody = "Please type your question here: \n\n\n\n\n"
                    + "---------------------------" + deviceInfo;
        }

        try {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO, mailto);
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
            emailIntent.putExtra(Intent.EXTRA_TEXT, emailBody);
            activity.startActivity(Intent.createChooser(emailIntent, "Send email..."));
        } catch (Exception e) {
            if (config.analytics != null) {
                config.analytics.logException(e, false);
            }
        }
    }
}

@@ -508,398 +508,8 @@
 );%0A%0A
-        final String emailSubject;%0A%0A        switch (config.buildType) %7B%0A            case GOOGLE:%0A                emailSubject = config.emailSubject + %22G%22;%0A                break;%0A            case AMAZON:%0A                emailSubject = config.emailSubject + %22K%22;%0A                break;%0A            default:%0A                emailSubject = config.emailSubject;%0A                break;%0A        %7D%0A
     
@@ -549,16 +549,16 @@
 ilBody;%0A
+
         
@@ -1051,16 +1051,92 @@
 T + %22)%22;
+%0A            deviceInfo += %22%5Cn Platform: %22 + platformName(config.buildType);
 %0A%0A      
@@ -1419,16 +1419,23 @@
 UBJECT, 
+config.
 emailSub
@@ -1726,16 +1726,16 @@
 false);%0A
-
         
@@ -1755,11 +1755,279 @@
  %7D%0A    %7D
+%0A%0A    private static String platformName(AboutConfig.BuildType buildType) %7B%0A        switch (buildType) %7B%0A            case GOOGLE:    return %22Google Play%22;%0A            case AMAZON:    return %22Amazon Kindle%22;%0A            default:        return %22Unknown%22;%0A        %7D%0A    %7D
 %0A%7D%0A

Add platform to footer instead of header