<commit_before>package org.javarosa.formmanager.view.singlequestionscreen.screen;

import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

import org.javarosa.core.model.data.GeoPointData;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.form.api.FormEntryPrompt;

import de.enough.polish.ui.Command;
import de.enough.polish.ui.Style;
import de.enough.polish.util.MathUtil;

public class LocationQuestionScreen extends SingleQuestionScreen {

	protected StringItem label;
	protected TextField tfLat;
	protected TextField tfLon;
	protected TextField tfAlt;
	protected TextField tfAcc;
	
	public static Command captureCommand = new Command("Capture", Command.SCREEN, 2);

	public LocationQuestionScreen(FormEntryPrompt prompt, String groupName, Style style) {
		super(prompt,groupName,style);
	}

	public void createView() {
		setHint("Capture a GPS location");
		
		label = new StringItem("", "");
		if (prompt.isRequired())
			label.setLabel("*" + prompt.getLongText());
		else
			label.setLabel(prompt.getLongText());
		this.append(label);
		
		//#style leftlabeledTextField
		tfLat = new TextField("Latitude:", "", 20, TextField.DECIMAL);
		//#style leftlabeledTextField
		tfLon = new TextField("Longitude:", "", 20, TextField.DECIMAL);
		//#style leftlabeledTextField
		tfAlt = new TextField("Altitude (m):", "", 20, TextField.DECIMAL);
		//#style leftlabeledTextField
		tfAcc = new TextField("Accuracy (m):", "", 20, TextField.DECIMAL);
		

		IAnswerData answerData = prompt.getAnswerValue();
		if ((answerData != null) && (answerData instanceof GeoPointData))
		{
			double[] gp = (double[])((GeoPointData)answerData).getValue();
			tfLat.setString(""+MathUtil.round(gp[0]*10000)/10000.00);
			tfLon.setString(""+MathUtil.round(gp[1]*10000)/10000.00);
			tfAlt.setString(""+MathUtil.round(gp[2]));
			tfAcc.setString(""+MathUtil.round(gp[3]));
		}

		this.append(tfLat);
		this.append(tfLon);
		this.append(tfAlt);
		this.append(tfAcc);
		
		this.addNavigationWidgets();
		if (prompt.getHelpText() != null) {
			setHint(prompt.getHelpText());
		}
		
		this.addCommand(captureCommand);
	}

	public IAnswerData getWidgetValue() {
		double[] gp = new double[4];
<commit_msg>uneditable location question text fields<commit_after>package org.javarosa.formmanager.view.singlequestionscreen.screen;

import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;

import org.javarosa.core.model.data.GeoPointData;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.core.services.locale.Localization;
import org.javarosa.form.api.FormEntryPrompt;
import org.javarosa.j2me.view.J2MEDisplay;

import de.enough.polish.ui.Command;
import de.enough.polish.ui.Style;
import de.enough.polish.util.MathUtil;

public class LocationQuestionScreen extends SingleQuestionScreen {

	protected StringItem label;
	protected TextField tfLat;
	protected TextField tfLon;
	protected TextField tfAlt;
	protected TextField tfAcc;
	
	public static Command captureCommand = new Command(Localization.get("menu.Capture"), Command.SCREEN, 2);

	public LocationQuestionScreen(FormEntryPrompt prompt, String groupName, Style style) {
		super(prompt,groupName,style);
	}

	public void createView() {
		setHint(Localization.get("activity.locationcapture.capturelocationhint"));
		
		label = new StringItem("", "");
		if (prompt.isRequired())
			label.setLabel("*" + prompt.getLongText());
		else
			label.setLabel(prompt.getLongText());
		this.append(label);
		
		//#style leftlabeledTextField
		tfLat = new TextField(Localization.get("activity.locationcapture.Latitude")+":", "", 20, TextField.DECIMAL | TextField.UNEDITABLE);
		//#style leftlabeledTextField
		tfLon = new TextField(Localization.get("activity.locationcapture.Longitude")+":", "", 20, TextField.DECIMAL| TextField.UNEDITABLE);
		//#style leftlabeledTextField
		tfAlt = new TextField(Localization.get("activity.locationcapture.Altitude")+"(m):", "", 20, TextField.DECIMAL| TextField.UNEDITABLE);
		//#style leftlabeledTextField
		tfAcc = new TextField(Localization.get("activity.locationcapture.Accuracy")+"(m):", "", 20, TextField.DECIMAL| TextField.UNEDITABLE);
		

		IAnswerData answerData = prompt.getAnswerValue();
		if ((answerData != null) && (answerData instanceof GeoPointData))
		{
			double[] gp = (double[])((GeoPointData)answerData).getValue();
			tfLat.setString(""+MathUtil.round(gp[0]*10000)/10000.00);
			tfLon.setString(""+MathUtil.round(gp[1]*10000)/10000.00);
			tfAlt.setString(""+MathUtil.round(gp[2]));
			tfAcc.setString(""+MathUtil.round(gp[3]));
		}

		this.append(tfLat);
		this.append(tfLon);
		this.append(tfAlt);
		this.append(tfAcc);
		
		this.addNavigationWidgets();
		if (prompt.getHelpText() != null) {
			setHint(prompt.getHelpText());
		}
		
		this.addCommand(captureCommand);
	}

	public IAnswerData getWidgetValue() {
		double[] gp = new double[4];

{'fraction_non_alphanumeric': 0.14323499491353, 'fraction_numerical': 0.015869786368260426, 'mean_word_length': 5.545938748335552, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '2775864', 'n_tokens_mistral': 1799, 'n_tokens_neox': 1574, 'n_words': 275}