Position trigger

This commit is contained in:
jens 2021-11-28 20:01:58 +01:00
parent 81d6ab7b5f
commit a9bd7b9561
6 changed files with 285 additions and 119 deletions

View File

@ -263,6 +263,11 @@ public class ActivityManageRule extends Activity
wifiEditor.putExtra("wifiName", selectedTrigger.getTriggerParameter2()); wifiEditor.putExtra("wifiName", selectedTrigger.getTriggerParameter2());
startActivityForResult(wifiEditor, requestCodeTriggerWifiEdit); startActivityForResult(wifiEditor, requestCodeTriggerWifiEdit);
break; break;
case devicePosition:
Intent devicePositionEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerDevicePosition.class);
devicePositionEditor.putExtra(ActivityManageTriggerDevicePosition.vectorFieldName, selectedTrigger.getTriggerParameter2());
startActivityForResult(devicePositionEditor, requestCodeTriggerDevicePositionEdit);
break;
default: default:
break; break;
} }
@ -1354,6 +1359,28 @@ public class ActivityManageRule extends Activity
this.refreshActionList(); this.refreshActionList();
} }
} }
else if(requestCode == requestCodeTriggerDevicePositionAdd)
{
if(resultCode == RESULT_OK)
{
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
ruleToEdit.getTriggerSet().add(newTrigger);
this.refreshTriggerList();
}
}
else if(requestCode == requestCodeTriggerDevicePositionEdit)
{
if(resultCode == RESULT_OK)
{
Trigger editedTrigger = new Trigger();
editedTrigger.setTriggerType(Trigger_Enum.devicePosition);
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
this.refreshTriggerList();
}
}
} }
protected Dialog getActionTypeDialog() protected Dialog getActionTypeDialog()

View File

@ -1,8 +1,11 @@
package com.jens.automation2; package com.jens.automation2;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
@ -17,57 +20,61 @@ import org.apache.commons.lang3.StringUtils;
public class ActivityManageTriggerDevicePosition extends Activity public class ActivityManageTriggerDevicePosition extends Activity
{ {
TextView currentOrientationX, currentOrientationY, currentOrientationZ, tvAppliesX, tvAppliesY, tvAppliesZ; TextView currentAzimuth, currentPitch, currentRoll, tvAppliesAzimuth, tvAppliesPitch, tvAppliesRoll;
Button bApplyPositionValues, bSavePositionValues; Button bApplyPositionValues, bSavePositionValues;
EditText etDesiredPositionX, etDesiredPositionXTolerance, etDesiredPositionY, etDesiredPositionYTolerance, etDesiredPositionZ, etDesiredPositionZTolerance; EditText etDesiredAzimuth, etDesiredAzimuthTolerance, etDesiredPitch, etDesiredPitchTolerance, etDesiredRoll, etDesiredRollTolerance;
float desiredX, desiredY, desiredZ, desiredXTolerance, desiredYTolerance, desiredZTolerance; public static String vectorFieldName = "deviceVector";
public void updateFields(float x, float y, float z) boolean editMode = false;
float desiredAzimuth, desiredPitch, desiredRoll, desiredAzimuthTolerance, desiredPitchTolerance, desiredRollTolerance;
public void updateFields(float azimuth, float pitch, float roll)
{ {
currentOrientationX.setText(Float.toString(x)); currentAzimuth.setText(Float.toString(azimuth));
currentOrientationY.setText(Float.toString(y)); currentPitch.setText(Float.toString(pitch));
currentOrientationZ.setText(Float.toString(z)); currentRoll.setText(Float.toString(roll));
if(checkInputs()) if(checkInputs())
{ {
desiredX = Float.parseFloat(etDesiredPositionX.getText().toString()); desiredAzimuth = Float.parseFloat(etDesiredAzimuth.getText().toString());
desiredXTolerance = Float.parseFloat(etDesiredPositionXTolerance.getText().toString()); desiredAzimuthTolerance = Float.parseFloat(etDesiredAzimuthTolerance.getText().toString());
if(x >= desiredX - desiredXTolerance || x <= desiredX + desiredXTolerance) if(Math.abs(azimuth) <= Math.abs(desiredAzimuth - desiredAzimuthTolerance) || Math.abs(azimuth) <= desiredAzimuth + desiredAzimuthTolerance)
{ {
tvAppliesX.setText(getResources().getString(R.string.yes)); tvAppliesAzimuth.setText(getResources().getString(R.string.yes));
tvAppliesX.setTextColor(Color.GREEN); tvAppliesAzimuth.setTextColor(Color.GREEN);
} }
else else
{ {
tvAppliesX.setText(getResources().getString(R.string.no)); tvAppliesAzimuth.setText(getResources().getString(R.string.no));
tvAppliesX.setTextColor(Color.RED); tvAppliesAzimuth.setTextColor(Color.RED);
} }
desiredY = Float.parseFloat(etDesiredPositionY.getText().toString()); desiredPitch = Float.parseFloat(etDesiredPitch.getText().toString());
desiredYTolerance = Float.parseFloat(etDesiredPositionYTolerance.getText().toString()); desiredPitchTolerance = Float.parseFloat(etDesiredPitchTolerance.getText().toString());
if(y >= desiredY - desiredYTolerance || y <= desiredY + desiredYTolerance) if(Math.abs(pitch) <= Math.abs(desiredPitch - desiredPitchTolerance) || Math.abs(pitch) <= desiredPitch + desiredPitchTolerance)
{ {
tvAppliesY.setText(getResources().getString(R.string.yes)); tvAppliesPitch.setText(getResources().getString(R.string.yes));
tvAppliesY.setTextColor(Color.GREEN); tvAppliesPitch.setTextColor(Color.GREEN);
} }
else else
{ {
tvAppliesY.setText(getResources().getString(R.string.no)); tvAppliesPitch.setText(getResources().getString(R.string.no));
tvAppliesY.setTextColor(Color.RED); tvAppliesPitch.setTextColor(Color.RED);
} }
desiredZ = Float.parseFloat(etDesiredPositionZ.getText().toString()); desiredRoll = Float.parseFloat(etDesiredRoll.getText().toString());
desiredZTolerance = Float.parseFloat(etDesiredPositionZTolerance.getText().toString()); desiredRollTolerance = Float.parseFloat(etDesiredRollTolerance.getText().toString());
if(z >= desiredZ - desiredZTolerance || z <= desiredZ + desiredZTolerance) if(Math.abs(roll) <= Math.abs(desiredRoll - desiredRollTolerance) || Math.abs(roll) <= desiredRoll + desiredRollTolerance)
{ {
tvAppliesZ.setText(getResources().getString(R.string.yes)); tvAppliesRoll.setText(getResources().getString(R.string.yes));
tvAppliesZ.setTextColor(Color.GREEN); tvAppliesRoll.setTextColor(Color.GREEN);
} }
else else
{ {
tvAppliesZ.setText(getResources().getString(R.string.no)); tvAppliesRoll.setText(getResources().getString(R.string.no));
tvAppliesZ.setTextColor(Color.RED); tvAppliesRoll.setTextColor(Color.RED);
} }
} }
} }
@ -78,36 +85,55 @@ public class ActivityManageTriggerDevicePosition extends Activity
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_trigger_device_position); setContentView(R.layout.activity_manage_trigger_device_position);
currentOrientationX = (TextView) findViewById(R.id.currentOrientationX); currentAzimuth = (TextView) findViewById(R.id.tvCurrentAzimuth);
currentOrientationY = (TextView) findViewById(R.id.currentOrientationY); currentPitch = (TextView) findViewById(R.id.tvCurrentOrientationPitch);
currentOrientationZ = (TextView) findViewById(R.id.currentOrientationZ); currentRoll = (TextView) findViewById(R.id.tvCurrentRoll);
tvAppliesX = (TextView) findViewById(R.id.tvAppliesX); tvAppliesAzimuth = (TextView) findViewById(R.id.tvAppliesAzimuth);
tvAppliesY = (TextView) findViewById(R.id.tvAppliesY); tvAppliesPitch = (TextView) findViewById(R.id.tvAppliesPitch);
tvAppliesZ = (TextView) findViewById(R.id.tvAppliesZ); tvAppliesRoll = (TextView) findViewById(R.id.tvAppliesRoll);
bApplyPositionValues = (Button) findViewById(R.id.bApplyPositionValues); bApplyPositionValues = (Button) findViewById(R.id.bApplyPositionValues);
bSavePositionValues = (Button) findViewById(R.id.bSavePositionValues); bSavePositionValues = (Button) findViewById(R.id.bSavePositionValues);
etDesiredPositionX = (EditText) findViewById(R.id.etDesiredPositionX); etDesiredAzimuth = (EditText) findViewById(R.id.etDesiredAzimuth);
etDesiredPositionXTolerance = (EditText) findViewById(R.id.etDesiredPositionXTolerance); etDesiredAzimuthTolerance = (EditText) findViewById(R.id.etDesiredAzimuthTolerance);
etDesiredPositionY = (EditText) findViewById(R.id.etDesiredPositionY); etDesiredPitch = (EditText) findViewById(R.id.etDesiredPitch);
etDesiredPositionYTolerance = (EditText) findViewById(R.id.etDesiredPositionYTolerance); etDesiredPitchTolerance = (EditText) findViewById(R.id.etDesiredPitchTolerance);
etDesiredPositionZ = (EditText) findViewById(R.id.etDesiredPositionZ); etDesiredRoll = (EditText) findViewById(R.id.etDesiredRoll);
etDesiredPositionZTolerance = (EditText) findViewById(R.id.etDesiredPositionZTolerance); etDesiredRollTolerance = (EditText) findViewById(R.id.etDesiredRollTolerance);
// etDesiredAzimuth.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
// etDesiredPitch.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
// etDesiredRoll.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
etDesiredAzimuthTolerance.setFilters(new InputFilter[]{new InputFilterMinMax(0, 359)});
etDesiredPitchTolerance.setFilters(new InputFilter[]{new InputFilterMinMax(0, 359)});
etDesiredRollTolerance.setFilters(new InputFilter[]{new InputFilterMinMax(0, 359)});
if(getIntent().hasExtra(vectorFieldName))
{
editMode = true;
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
etDesiredAzimuth.setText(values[0]);
etDesiredAzimuthTolerance.setText(values[1]);
etDesiredPitch.setText(values[2]);
etDesiredPitchTolerance.setText(values[3]);
etDesiredRoll.setText(values[4]);
etDesiredRollTolerance.setText(values[5]);
}
bApplyPositionValues.setOnClickListener(new View.OnClickListener() bApplyPositionValues.setOnClickListener(new View.OnClickListener()
{ {
@Override @Override
public void onClick(View v) public void onClick(View v)
{ {
if(!StringUtils.isEmpty(currentOrientationX.getText())) if(!StringUtils.isEmpty(currentAzimuth.getText()))
etDesiredPositionX.setText(currentOrientationX.getText()); etDesiredAzimuth.setText(currentAzimuth.getText());
if(!StringUtils.isEmpty(currentOrientationY.getText())) if(!StringUtils.isEmpty(currentPitch.getText()))
etDesiredPositionY.setText(currentOrientationY.getText()); etDesiredPitch.setText(currentPitch.getText());
if(!StringUtils.isEmpty(currentOrientationZ.getText())) if(!StringUtils.isEmpty(currentRoll.getText()))
etDesiredPositionZ.setText(currentOrientationZ.getText()); etDesiredRoll.setText(currentRoll.getText());
} }
}); });
@ -116,13 +142,24 @@ public class ActivityManageTriggerDevicePosition extends Activity
@Override @Override
public void onClick(View v) public void onClick(View v)
{ {
if(checkInputs()) if(!checkInputs())
{ {
Toast.makeText(ActivityManageTriggerDevicePosition.this, getResources().getString(R.string.enterValidNumbersIntoAllFields), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityManageTriggerDevicePosition.this, getResources().getString(R.string.enterValidNumbersIntoAllFields), Toast.LENGTH_LONG).show();
} }
else else
{ {
// Save // Save
Intent returnData = new Intent();
returnData.putExtra(vectorFieldName,
etDesiredAzimuth.getText().toString() + Trigger.triggerParameter2Split +
etDesiredAzimuthTolerance.getText().toString() + Trigger.triggerParameter2Split +
etDesiredPitch.getText().toString() + Trigger.triggerParameter2Split +
etDesiredPitchTolerance.getText().toString() + Trigger.triggerParameter2Split +
etDesiredRoll.getText().toString() + Trigger.triggerParameter2Split +
etDesiredRollTolerance.getText().toString());
setResult(RESULT_OK, returnData);
finish();
} }
} }
}); });
@ -130,19 +167,29 @@ public class ActivityManageTriggerDevicePosition extends Activity
boolean checkInputs() boolean checkInputs()
{ {
return( if(
!StringUtils.isEmpty(etDesiredPositionX.getText().toString()) && Miscellaneous.isNumeric(etDesiredPositionX.getText().toString()) !StringUtils.isEmpty(etDesiredAzimuth.getText().toString()) && Miscellaneous.isNumeric(etDesiredAzimuth.getText().toString())
&& &&
!StringUtils.isEmpty(etDesiredPositionXTolerance.getText().toString()) && Miscellaneous.isNumeric(etDesiredPositionXTolerance.getText().toString()) !StringUtils.isEmpty(etDesiredAzimuthTolerance.getText().toString()) && Miscellaneous.isNumeric(etDesiredAzimuthTolerance.getText().toString())
&& &&
!StringUtils.isEmpty(etDesiredPositionY.getText().toString()) && Miscellaneous.isNumeric(etDesiredPositionY.getText().toString()) !StringUtils.isEmpty(etDesiredPitch.getText().toString()) && Miscellaneous.isNumeric(etDesiredPitch.getText().toString())
&& &&
!StringUtils.isEmpty(etDesiredPositionYTolerance.getText().toString()) && Miscellaneous.isNumeric(etDesiredPositionYTolerance.getText().toString()) !StringUtils.isEmpty(etDesiredPitchTolerance.getText().toString()) && Miscellaneous.isNumeric(etDesiredPitchTolerance.getText().toString())
&& &&
!StringUtils.isEmpty(etDesiredPositionZ.getText().toString()) && Miscellaneous.isNumeric(etDesiredPositionZ.getText().toString()) !StringUtils.isEmpty(etDesiredRoll.getText().toString()) && Miscellaneous.isNumeric(etDesiredRoll.getText().toString())
&& &&
!StringUtils.isEmpty(etDesiredPositionZTolerance.getText().toString()) && Miscellaneous.isNumeric(etDesiredPositionZTolerance.getText().toString()) !StringUtils.isEmpty(etDesiredRollTolerance.getText().toString()) && Miscellaneous.isNumeric(etDesiredRollTolerance.getText().toString())
); )
{
float da = Float.parseFloat(etDesiredAzimuth.getText().toString());
float dp = Float.parseFloat(etDesiredPitch.getText().toString());
float dr = Float.parseFloat(etDesiredRoll.getText().toString());
if(Math.abs(da) <= 180 || Math.abs(dp) <= 180 || Math.abs(dr) <= 180)
return true;
}
return false;
} }
@Override @Override
@ -158,4 +205,36 @@ public class ActivityManageTriggerDevicePosition extends Activity
super.onPause(); super.onPause();
DevicePositionListener.getInstance().stopSensor(); DevicePositionListener.getInstance().stopSensor();
} }
public class InputFilterMinMax implements InputFilter
{
private float minimumValue;
private float maximumValue;
public InputFilterMinMax(float minimumValue, float maximumValue)
{
this.minimumValue = minimumValue;
this.maximumValue = maximumValue;
}
private boolean isInRange(float a, float b, float c)
{
return b > a ? c >= a && c <= b : c >= b && c <= a;
}
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
{
try
{
int input = Integer.parseInt(dest.subSequence(0, dstart).toString() + source + dest.subSequence(dend, dest.length()));
if (isInRange(minimumValue, maximumValue, input))
return null;
}
catch (NumberFormatException nfe)
{
}
return "";
}
}
} }

View File

@ -833,6 +833,9 @@ public class Trigger
setTriggerParameter2("-1" + triggerParameter2Split + directionEquals + triggerParameter2Split + triggerParameter2Split + directionEquals + triggerParameter2Split + triggerParameter2Split); setTriggerParameter2("-1" + triggerParameter2Split + directionEquals + triggerParameter2Split + triggerParameter2Split + directionEquals + triggerParameter2Split + triggerParameter2Split);
} }
break; break;
case devicePosition:
returnString.append(Miscellaneous.getAnyContext().getString(R.string.deviceIsInCertainPosition));
break;
default: default:
returnString.append("error"); returnString.append("error");
break; break;

View File

@ -22,22 +22,49 @@ public class DevicePositionListener implements SensorEventListener
private SensorManager sManager; private SensorManager sManager;
static DevicePositionListener instance = null; static DevicePositionListener instance = null;
// Gravity rotational data
private float gravity[];
// Magnetic rotational data
private float magnetic[]; //for magnetic rotational data
private float accels[] = new float[3];
private float mags[] = new float[3];
private float[] values = new float[3];
// azimuth, pitch and roll
private float azimuth;
private float pitch;
private float roll;
public static DevicePositionListener getInstance() public static DevicePositionListener getInstance()
{ {
if(instance == null) if (instance == null)
instance = new DevicePositionListener(); instance = new DevicePositionListener();
return instance; return instance;
} }
/*
Computes the device's orientation based on the rotation matrix.
When it returns, the array values are as follows:
values[0]: Azimuth, angle of rotation about the -z axis. This value represents the angle between the device's y axis and the magnetic north pole. When facing north, this angle is 0, when facing south, this angle is π. Likewise, when facing east, this angle is π/2, and when facing west, this angle is -π/2. The range of values is -π to π.
values[1]: Pitch, angle of rotation about the x axis. This value represents the angle between a plane parallel to the device's screen and a plane parallel to the ground. Assuming that the bottom edge of the device faces the user and that the screen is face-up, tilting the top edge of the device toward the ground creates a positive pitch angle. The range of values is -π to π.
values[2]: Roll, angle of rotation about the y axis. This value represents the angle between a plane perpendicular to the device's screen and a plane perpendicular to the ground. Assuming that the bottom edge of the device faces the user and that the screen is face-up, tilting the left edge of the device toward the ground creates a positive roll angle. The range of values is -π/2 to π/2.
Applying these three rotations in the azimuth, pitch, roll order transforms an identity matrix to the rotation matrix passed into this method. Also, note that all three orientation angles are expressed in radians.
*/
public void startSensor(Context context, ActivityManageTriggerDevicePosition activityManageTriggerDevicePositionInstance) public void startSensor(Context context, ActivityManageTriggerDevicePosition activityManageTriggerDevicePositionInstance)
{ {
this.activityManageTriggerDevicePositionInstance = activityManageTriggerDevicePositionInstance; this.activityManageTriggerDevicePositionInstance = activityManageTriggerDevicePositionInstance;
sManager = (SensorManager) context.getSystemService(SENSOR_SERVICE); sManager = (SensorManager) context.getSystemService(SENSOR_SERVICE);
/*register the sensor listener to listen to the gyroscope sensor, use the /*register the sensor listener to listen to the gyroscope sensor, use the
callbacks defined in this class, and gather the sensor information as quick callbacks defined in this class, and gather the sensor information as quick
as possible*/ as possible*/
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),SensorManager.SENSOR_DELAY_FASTEST);
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL);
// SensorManager.getOrientation()
} }
public void stopSensor() public void stopSensor()
@ -55,19 +82,39 @@ public class DevicePositionListener implements SensorEventListener
@Override @Override
public void onSensorChanged(SensorEvent event) public void onSensorChanged(SensorEvent event)
{ {
//if sensor is unreliable, return void switch (event.sensor.getType())
if (event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE)
{ {
return; case Sensor.TYPE_MAGNETIC_FIELD:
mags = event.values.clone();
break;
case Sensor.TYPE_ACCELEROMETER:
accels = event.values.clone();
break;
}
if (mags != null && accels != null)
{
gravity = new float[9];
magnetic = new float[9];
SensorManager.getRotationMatrix(gravity, magnetic, accels, mags);
float[] outGravity = new float[9];
SensorManager.remapCoordinateSystem(gravity, SensorManager.AXIS_X, SensorManager.AXIS_Z, outGravity);
SensorManager.getOrientation(outGravity, values);
azimuth = values[0] * 57.2957795f;
pitch = values[1] * 57.2957795f;
roll = values[2] * 57.2957795f;
mags = null;
accels = null;
} }
//else it will output the Roll, Pitch and Yawn values //else it will output the Roll, Pitch and Yawn values
activityManageTriggerDevicePositionInstance.updateFields(event.values[2], event.values[1], event.values[0]); activityManageTriggerDevicePositionInstance.updateFields(azimuth, pitch, roll);
// tvToUpdate.setText("Orientation X (Roll) :"+ Float.toString(event.values[2]) +"\n"+ // tvToUpdate.setText("Orientation X (Roll) :"+ Float.toString(event.values[2]) +"\n"+
// "Orientation Y (Pitch) :"+ Float.toString(event.values[1]) +"\n"+ // "Orientation Y (Pitch) :"+ Float.toString(event.values[1]) +"\n"+
// "Orientation Z (Yaw) :"+ Float.toString(event.values[0])); // "Orientation Z (Yaw) :"+ Float.toString(event.values[0]));
}
/* /*
Azimuth (degrees of rotation about the -z axis). Azimuth (degrees of rotation about the -z axis).
@ -88,4 +135,5 @@ public class DevicePositionListener implements SensorEventListener
edge of the device toward the ground causes the roll angle to become negative. The range of values is -90 degrees edge of the device toward the ground causes the roll angle to become negative. The range of values is -90 degrees
to 90 degrees. to 90 degrees.
*/ */
}
} }

View File

@ -25,12 +25,12 @@
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
android:text="@string/orientationX" android:text="@string/orientationAzimuth"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/currentOrientationX" android:id="@+id/tvCurrentAzimuth"
android:layout_marginLeft="@dimen/default_margin" android:layout_marginLeft="@dimen/default_margin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -42,12 +42,12 @@
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
android:text="@string/orientationY" android:text="@string/orientationPitch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/currentOrientationY" android:id="@+id/tvCurrentOrientationPitch"
android:layout_marginLeft="@dimen/default_margin" android:layout_marginLeft="@dimen/default_margin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -59,12 +59,12 @@
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
android:text="@string/orientationZ" android:text="@string/orientationRoll"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/currentOrientationZ" android:id="@+id/tvCurrentRoll"
android:layout_marginLeft="@dimen/default_margin" android:layout_marginLeft="@dimen/default_margin"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -82,10 +82,12 @@
<TableLayout <TableLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" > android:layout_height="wrap_content"
android:shrinkColumns="0"
android:stretchColumns="1">
<TableRow <TableRow
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
@ -108,6 +110,9 @@
<TextView <TextView
android:text="@string/wouldCurrentlyApply" android:text="@string/wouldCurrentlyApply"
android:singleLine="false"
android:maxLines="2"
android:lines="2"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -115,31 +120,32 @@
</TableRow> </TableRow>
<TableRow <TableRow
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
android:text="x" android:text="@string/orientationAzimuth"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/default_margin" /> android:layout_marginRight="@dimen/default_margin" />
<EditText <EditText
android:id="@+id/etDesiredPositionX" android:id="@+id/etDesiredAzimuth"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:minWidth="50dp"
android:minWidth="100dp"/> android:enabled="false"
android:inputType="number" />
<EditText <EditText
android:id="@+id/etDesiredPositionXTolerance" android:id="@+id/etDesiredAzimuthTolerance"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="numberDecimal" android:minWidth="50dp"
android:minWidth="100dp"/> android:inputType="number" />
<TextView <TextView
android:id="@+id/tvAppliesX" android:id="@+id/tvAppliesAzimuth"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -150,27 +156,28 @@
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
android:text="y" android:text="@string/orientationPitch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/default_margin" /> android:layout_marginRight="@dimen/default_margin" />
<EditText <EditText
android:id="@+id/etDesiredPositionY" android:id="@+id/etDesiredPitch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:minWidth="50dp"
android:minWidth="100dp"/> android:enabled="false"
android:inputType="number" />
<EditText <EditText
android:id="@+id/etDesiredPositionYTolerance" android:id="@+id/etDesiredPitchTolerance"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="numberDecimal" android:minWidth="50dp"
android:minWidth="100dp"/> android:inputType="number" />
<TextView <TextView
android:id="@+id/tvAppliesY" android:id="@+id/tvAppliesPitch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -181,27 +188,28 @@
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<TextView <TextView
android:text="z" android:text="@string/orientationRoll"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/default_margin" /> android:layout_marginRight="@dimen/default_margin" />
<EditText <EditText
android:id="@+id/etDesiredPositionZ" android:id="@+id/etDesiredRoll"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="number" android:minWidth="50dp"
android:minWidth="100dp"/> android:enabled="false"
android:inputType="number" />
<EditText <EditText
android:id="@+id/etDesiredPositionZTolerance" android:id="@+id/etDesiredRollTolerance"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="numberDecimal" android:minWidth="50dp"
android:minWidth="100dp"/> android:inputType="number" />
<TextView <TextView
android:id="@+id/tvAppliesZ" android:id="@+id/tvAppliesRoll"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />

View File

@ -715,10 +715,11 @@
<string name="notice">Notice</string> <string name="notice">Notice</string>
<string name="devicePosition">Device position (Gyroscope)</string> <string name="devicePosition">Device position (Gyroscope)</string>
<string name="tolerance">Tolerance</string> <string name="tolerance">Tolerance</string>
<string name="orientationX">Orientation X (Roll):</string> <string name="orientationAzimuth">Azimuth:</string>
<string name="orientationY">Orientation Y (Pitch):</string> <string name="orientationPitch">Pitch:</string>
<string name="orientationZ">Orientation Z (Yaw):</string> <string name="orientationRoll">Roll:</string>
<string name="enterValidNumbersIntoAllFields">Enter valid numbers in all fields.</string> <string name="enterValidNumbersIntoAllFields">Enter valid numbers in all fields.</string>
<string name="devicePositionExplanation">When you move your device the below numbers should update. What you can see there, is the current \"position\" of your device. If it is in the desired position, click the apply button to copy the current values to the desired fields.\nBecause you will probably not be able to reach this exact position ever again, enter a tolerance. The is amount to which the position can deviate in one direction or the other.</string> <string name="devicePositionExplanation">When you move your device the below numbers should update. What you can see there, is the current \"position\" of your device. If it is in the desired position, click the apply button to copy the current values to the desired fields.\nBecause you will probably not be able to reach this exact position ever again, enter a tolerance. The is amount to which the position can deviate in one direction or the other.</string>
<string name="wouldCurrentlyApply">Would currently apply?</string> <string name="wouldCurrentlyApply">Would currently apply?</string>
<string name="deviceIsInCertainPosition">the device is in a certain position</string>
</resources> </resources>