// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
// public class CustomTabsHelper {
// 
//     public static void openUrl(Context context, String url) {
//         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
// 
//         if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
//             CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
//             builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
//             builder.build().launchUrl(context, Uri.parse(url));
//         } else {
//             try {
//                 context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
//             } catch (ActivityNotFoundException e) {
//                 Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show();
//             }
//         }
//     }
// 
// }


import io.github.marktony.espresso.customtabs.CustomTabsHelper;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.widget.Toast;
import io.github.marktony.espresso.BuildConfig;
import io.github.marktony.espresso.R;
            @Override
            public boolean onPreferenceClick(Preference preference) {
                try {
                    Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
                    Intent intent = new Intent(Intent.ACTION_VIEW,uri);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                } catch (android.content.ActivityNotFoundException ex){
                    showError();
                }
                return true;
            }
        });

        // Licenses
        prefLicenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                Intent intent = new Intent(getContext(), PrefsActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_LICENSES);
                startActivity(intent);
                return true;
            }
        });

        // Thanks 1
        prefThx1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
// Path: app/src/main/java/io/github/marktony/espresso/customtabs/CustomTabsHelper.java
// public class CustomTabsHelper {
// 
//     public static void openUrl(Context context, String url) {
//         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
// 
//         if (sharedPreferences.getBoolean(SettingsUtil.KEY_CUSTOM_TABS, true)) {
//             CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
//             builder.setToolbarColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
//             builder.build().launchUrl(context, Uri.parse(url));
//         } else {
//             try {
//                 context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
//             } catch (ActivityNotFoundException e) {
//                 Toast.makeText(context, R.string.error_no_browser, Toast.LENGTH_SHORT).show();
//             }
//         }
//     }
// 
// }


// Path: app/src/main/java/io/github/marktony/espresso/ui/AboutFragment.java
import io.github.marktony.espresso.customtabs.CustomTabsHelper;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.widget.Toast;
import io.github.marktony.espresso.BuildConfig;
import io.github.marktony.espresso.R;

            @Override
            public boolean onPreferenceClick(Preference preference) {
                try {
                    Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
                    Intent intent = new Intent(Intent.ACTION_VIEW,uri);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                } catch (android.content.ActivityNotFoundException ex){
                    showError();
                }
                return true;
            }
        });

        // Licenses
        prefLicenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                Intent intent = new Intent(getContext(), PrefsActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.putExtra(PrefsActivity.EXTRA_FLAG, PrefsActivity.FLAG_LICENSES);
                startActivity(intent);
                return true;
            }
        });

        // Thanks 1
        prefThx1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                CustomTabsHelper.openUrl(getContext(), getString(R.string.thanks_1_url));