// 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 android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.customtabs.CustomTabsHelper;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_company_details, container, false);

        initViews(view);

        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                share();
            }
        });

        textViewTel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tel != null && !tel.isEmpty()) {
                    Intent intent = new Intent(Intent.ACTION_DIAL);
                    intent.setData(Uri.parse("tel:" + tel));
                    getActivity().startActivity(intent);
                }
            }
        });

        textViewWebsite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (website != null) {
// 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/mvp/companydetails/CompanyDetailFragment.java
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import io.github.marktony.espresso.R;
import io.github.marktony.espresso.customtabs.CustomTabsHelper;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_company_details, container, false);

        initViews(view);

        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                share();
            }
        });

        textViewTel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tel != null && !tel.isEmpty()) {
                    Intent intent = new Intent(Intent.ACTION_DIAL);
                    intent.setData(Uri.parse("tel:" + tel));
                    getActivity().startActivity(intent);
                }
            }
        });

        textViewWebsite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (website != null) {
                    CustomTabsHelper.openUrl(getContext(), website);