package com.plugin.openbrowser;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

public class OpenBrowser {

    public String echo(String value) {
        Log.i("Echo", value);
        return value;
    }

    /**
     * 브라우저 실행
     *
     * @param activity
     * @param url
     * @param isExternal
     */
    public void open(Activity activity, String url, boolean isExternal) {
        if(activity != null && url != null && !url.isEmpty()) {
            Intent intent;
            if(isExternal) {
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            } else {
                intent = new Intent(activity, WebViewActivity.class);
                intent.putExtra("url", url);
            }
            activity.startActivity(intent);
        }
    }
}
