// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/ActivityUtils.java
// public class ActivityUtils {
//     private ActivityUtils() {}
// 
//     public static void startActivitySafe(Context context, Intent intent) {
//         try {
//             context.startActivity(intent);
//         } catch (Exception e) {
//             // ignore
//             e.printStackTrace();
//         }
//     }
// }


import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.preference.DialogPreference;
import android.text.Html;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.ActivityUtils;
        super(context, attrs);
        init();
    }

    private void init() {
        final Context context = getContext();
        PackageManager packageManager = context.getPackageManager();
        String versionName;
        try {
            PackageInfo info = packageManager.getPackageInfo(context.getPackageName(), 0);
            versionName = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            versionName = "1.0";
        }

        setTitle(R.string.dlg_feedback_title);
        setSummary(new StringBuilder(getContext().getString(R.string.app_name)).append(" v").append(versionName));
        setDialogTitle(R.string.dlg_feedback_title);
        setDialogMessage(Html.fromHtml(getContext().getString(R.string.dlg_feedback_content)));
        setPositiveButtonText(R.string.dlg_feedback_positive_text);
        setNegativeButtonText(R.string.dlg_feedback_negative_text);
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        super.onClick(dialog, which);
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE: {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + getContext().getPackageName()));
// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/utils/ActivityUtils.java
// public class ActivityUtils {
//     private ActivityUtils() {}
// 
//     public static void startActivitySafe(Context context, Intent intent) {
//         try {
//             context.startActivity(intent);
//         } catch (Exception e) {
//             // ignore
//             e.printStackTrace();
//         }
//     }
// }


// Path: app/src/main/java/io/github/mobodev/heartbeatfixerforgcm/preference/FeedbackPreference.java
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.preference.DialogPreference;
import android.text.Html;
import android.util.AttributeSet;
import io.github.mobodev.heartbeatfixerforgcm.R;
import io.github.mobodev.heartbeatfixerforgcm.utils.ActivityUtils;

        super(context, attrs);
        init();
    }

    private void init() {
        final Context context = getContext();
        PackageManager packageManager = context.getPackageManager();
        String versionName;
        try {
            PackageInfo info = packageManager.getPackageInfo(context.getPackageName(), 0);
            versionName = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            versionName = "1.0";
        }

        setTitle(R.string.dlg_feedback_title);
        setSummary(new StringBuilder(getContext().getString(R.string.app_name)).append(" v").append(versionName));
        setDialogTitle(R.string.dlg_feedback_title);
        setDialogMessage(Html.fromHtml(getContext().getString(R.string.dlg_feedback_content)));
        setPositiveButtonText(R.string.dlg_feedback_positive_text);
        setNegativeButtonText(R.string.dlg_feedback_negative_text);
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        super.onClick(dialog, which);
        switch (which) {
            case DialogInterface.BUTTON_POSITIVE: {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + getContext().getPackageName()));
                ActivityUtils.startActivitySafe(getContext(), intent);