<commit_before>// fork from https://github.com/markeeftb/FileOpener
package org.apache.cordova.openfilenative;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.webkit.URLUtil;
import android.widget.Toast;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;

public class OpenFileNative extends CordovaPlugin {

    private Context context;

    @Override
    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        super.initialize(cordova, webView);
        context  = cordova.getActivity();
    }

    @Override
    public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
        if (action.equals("openFileNative")) {
            final String fileToOpen = args.getString(0);
            cordova.getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    try {
                        URI uri = new URI(fileToOpen);
                        new DownloadAndOpenTask().execute(uri);
                        callbackContext.success();
                    } catch (URISyntaxException e) {
                        callbackContext.error("Error while opening file \"" + fileToOpen + "\".");
                    }
                }
            });
            return true;
        } else {
            return false;
        }
    }

    private class DownloadAndOpenTask extends AsyncTask<URI, Integer, String> {

        // declare the dialog as a member field of your activity
        private ProgressDialog mProgressDialog;
        private File targetFile;

        @Override<commit_msg>add the abillity to open marketlinks<commit_after>// fork from https://github.com/markeeftb/FileOpener
package org.apache.cordova.openfilenative;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.webkit.URLUtil;
import android.widget.Toast;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;

public class OpenFileNative extends CordovaPlugin {

    private Context context;

    @Override
    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        super.initialize(cordova, webView);
        context  = cordova.getActivity();
    }

    @Override
    public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
        if (action.equals("openFileNative")) {
            final String fileToOpen = args.getString(0);
            cordova.getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    try {
                        URI uri = new URI(fileToOpen);
                        if (uri.getScheme().equalsIgnoreCase("market")) {
                            openMarketLink(fileToOpen);
                        } else {
                            new DownloadAndOpenTask().execute(uri);
                        }
                        callbackContext.success();
                    } catch (URISyntaxException e) {
                        callbackContext.error("Error while opening file \"" + fileToOpen + "\".");
                    }
                }
            });
            return true;
        } else {
            return false;
        }
    }

    private void openMarketLink(String uriString){
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uriString)));
    }

    private class DownloadAndOpenTask extends AsyncTask<URI, Integer, String> {

        // declare the dialog as a member field of your activity
        private ProgressDialog mProgressDialog;
        private File targetFile;

        @Override
{'fraction_non_alphanumeric': 0.08736476832006532, 'fraction_numerical': 0.0004082465809348847, 'mean_word_length': 2.58187134502924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '904577', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1250, 'n_words': 301}