<commit_before>package edu.cscie71.imm.slacker.plugin;

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import edu.cscie71.imm.app.slacker.client.ISlackerClient;
import edu.cscie71.imm.app.slacker.client.SlackerClient;

public class Slacker extends CordovaPlugin {

    private ISlackerClient slackerClient = new SlackerClient();
    private String token = "<KEY>";
    private String immTestChannel = "C0F6U0R5E";

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("postMessage")) {
            String message = args.getString(0);
            this.postMessage(message, callbackContext);
        }
        return false;
    }

    private void postMessage(String message, CallbackContext callbackContext) {
        String response = slackerClient.postMessage(token, immTestChannel, message);
        if (response.contains("\"ok\":true"))
            callbackContext.success(message);
        else
            callbackContext.error("Error posting to the Slack channel.");
    }
}<commit_msg>[SKCP-86] Store OAuth token on Android<commit_after>package edu.cscie71.imm.slacker.plugin;

import android.content.Context;
import android.content.SharedPreferences;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;
import edu.cscie71.imm.app.slacker.client.ISlackerClient;
import edu.cscie71.imm.app.slacker.client.SlackerClient;

public class Slacker extends CordovaPlugin {

    private ISlackerClient slackerClient = new SlackerClient();
    private String token = "xoxp-10020492535-10036686290-14227963249-1cb545e1ae";
    private String immTestChannel = "C0F6U0R5E";
    private static final String PREFS = "Slacker";

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if (action.equals("postMessage")) {
            String message = args.getString(0);
            this.postMessage(message, callbackContext);
        }
        return false;
    }

    private void postMessage(String message, CallbackContext callbackContext) {
        String response = slackerClient.postMessage(token, immTestChannel, message);
        if (response.contains("\"ok\":true"))
            callbackContext.success(message);
        else
            callbackContext.error("Error posting to the Slack channel.");
    }

    private void storeOAuthToken(String token) {
        Context context = cordova.getActivity();
    	SharedPreferences.Editor editor = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit();
 		editor.putString("token", token);
 		editor.apply();
    }

    private String getOAuthToken() {
        Context context = cordova.getActivity();
    	SharedPreferences prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
        // Return null as default value
    	return prefs.getString("token", null);
    }
}
{'fraction_non_alphanumeric': 0.0962962962962963, 'fraction_numerical': 0.01996779388083736, 'mean_word_length': 3.7419847328244273, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3709932', 'n_tokens_mistral': 901, 'n_tokens_neox': 859, 'n_words': 193}