<commit_before>/**
 *
 */
package org.javarosa.user.activity;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;

import org.javarosa.core.Context;
import org.javarosa.core.JavaRosaServiceProvider;
import org.javarosa.core.api.Constants;
import org.javarosa.core.api.IActivity;
import org.javarosa.core.api.IShell;
import org.javarosa.user.view.LoginForm;

/**
 * @author <NAME> - Schafer
 *
 */
public class LoginActivity implements IActivity, CommandListener, ItemCommandListener {

	private LoginForm loginScreen = null;
	private IShell parent = null;
	public static final String COMMAND_KEY = "command";
	public static final String USER = "user";

	Context context;

	public LoginActivity(IShell p, String title) {
		this.parent = p;
		this.loginScreen = new LoginForm(this, title);
		this.loginScreen.setCommandListener(this);
		this.loginScreen.loginButton.setItemCommandListener(this);       // set item command listener
	}

	public void start(Context context) {
		parent.setDisplay(this, this.loginScreen);
		this.context = context;
	}

	public void commandAction(Command c, Item item) {
		if (c == this.loginScreen.loginButtonCommand) {
			System.out.println("login pressed");
			if (loginScreen.validateUser()) {
				javax.microedition.lcdui.Alert success = loginScreen
						.successfulLogin();
				parent.setDisplay(this, success);
				Hashtable returnArgs = new Hashtable();
				returnArgs.put(COMMAND_KEY, "USER_VALIDATED");
				returnArgs.put(USER, loginScreen.getLoggedInUser());
				parent.returnFromActivity(this, Constants.ACTIVITY_COMPLETE,
						returnArgs);
			} else {
				// /display an error that login failed and return to login
				// screen
				javax.microedition.lcdui.Alert error = loginScreen.tryAgain();
				parent.setDisplay(this, error);
				parent.setDisplay(this, this.loginScreen);

			}
		}
	}

	public void viewCompleted(Hashtable returnvals, int view_ID) {<commit_msg>[r1073] [branches/dev] Made the "secret" login username and password customizable in the JAD manifest file.<commit_after>/**
 *
 */
package org.javarosa.user.activity;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;

import org.javarosa.core.Context;
import org.javarosa.core.JavaRosaServiceProvider;
import org.javarosa.core.api.Constants;
import org.javarosa.core.api.IActivity;
import org.javarosa.core.api.IShell;
import org.javarosa.user.view.LoginForm;

/**
 * @author <NAME> - Schafer
 *
 */
public class LoginActivity implements IActivity, CommandListener, ItemCommandListener {

	private LoginForm loginScreen = null;
	private IShell parent = null;
	public static final String COMMAND_KEY = "command";
	public static final String USER = "user";

	Context context;

	public LoginActivity(IShell p, String title) {
		this.parent = p;
		
	}

	public void start(Context context) {
		
		this.context = context;
		this.loginScreen = new LoginForm(this, "formTitle");
		this.loginScreen.setCommandListener(this);
		this.loginScreen.loginButton.setItemCommandListener(this);       // set item command listener
		parent.setDisplay(this, this.loginScreen);
	}

	public void commandAction(Command c, Item item) {
		if (c == this.loginScreen.loginButtonCommand) {
			System.out.println("login pressed");
			if (loginScreen.validateUser()) {
				javax.microedition.lcdui.Alert success = loginScreen
						.successfulLogin();
				parent.setDisplay(this, success);
				Hashtable returnArgs = new Hashtable();
				returnArgs.put(COMMAND_KEY, "USER_VALIDATED");
				returnArgs.put(USER, loginScreen.getLoggedInUser());
				parent.returnFromActivity(this, Constants.ACTIVITY_COMPLETE,
						returnArgs);
			} else {
				// /display an error that login failed and return to login
				// screen
				javax.microedition.lcdui.Alert error = loginScreen.tryAgain();
				parent.setDisplay(this, error);
				parent.setDisplay(this, this.loginScreen);

			}
		}
	}

	public void viewCompleted(Hashtable returnvals, int view_ID) {
{'fraction_non_alphanumeric': 0.10715893741557857, 'fraction_numerical': 0.0009004952723998199, 'mean_word_length': 4.602774274905422, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5563862', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1371, 'n_words': 300}