Skip to content

Commit

Permalink
Merge branch 'development' into fix/issue2188
Browse files Browse the repository at this point in the history
  • Loading branch information
marcnause authored Sep 20, 2024
2 parents 8a1720b + 41561f0 commit ee977bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions app/src/main/java/io/pslab/activity/PowerSourceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import butterknife.ButterKnife;
import io.pslab.R;
import io.pslab.activity.guide.GuideActivity;
import io.pslab.communication.CommunicationHandler;
import io.pslab.communication.ScienceLab;
import io.pslab.items.SquareImageButton;
import io.pslab.models.PowerSourceData;
Expand Down Expand Up @@ -88,7 +87,7 @@ public class PowerSourceActivity extends GuideActivity {
private static final Range<Float> PV3_VOLTAGE_RANGE = Range.create(0.0f, 3.30f);
private static final Range<Float> PCS_CURRENT_RANGE = Range.create(0.0f, 3.30f);

private final NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.getDefault());
private final NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.ROOT);

/**
* Step of one tap on an up or down button.
Expand Down Expand Up @@ -214,7 +213,8 @@ public void onClick(View v) {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
final String voltageValue = remove(displayPV1.getText(), "V", "\\+").trim();
final float voltage = PV1_VOLTAGE_RANGE.clamp(parseFloat(voltageValue, PV1_VOLTAGE_RANGE.getLower()));
final String decimalVoltageValue = voltageValue.replace(",", ".");
final float voltage = PV1_VOLTAGE_RANGE.clamp(parseFloat(decimalVoltageValue, PV1_VOLTAGE_RANGE.getLower()));
setText(displayPV1, VOLTAGE_FORMAT, voltage);
controllerPV1.setProgress(mapPowerToProgress(voltage, PV1_CONTROLLER_MAX,
PV1_VOLTAGE_RANGE.getUpper(), PV1_VOLTAGE_RANGE.getLower()));
Expand All @@ -228,7 +228,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
final String voltageValue = remove(displayPV2.getText(), "V", "\\+").trim();
final float voltage = PV2_VOLTAGE_RANGE.clamp(parseFloat(voltageValue, PV2_VOLTAGE_RANGE.getLower()));
final String decimalVoltageValue = voltageValue.replace(",", ".");
final float voltage = PV2_VOLTAGE_RANGE.clamp(parseFloat(decimalVoltageValue, PV2_VOLTAGE_RANGE.getLower()));
setText(displayPV2, VOLTAGE_FORMAT, voltage);
controllerPV2.setProgress(mapPowerToProgress(voltage, PV2_CONTROLLER_MAX,
PV2_VOLTAGE_RANGE.getUpper(), PV2_VOLTAGE_RANGE.getLower()));
Expand All @@ -242,7 +243,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
final String voltageValue = remove(displayPV3.getText(), "V", "\\+").trim();
final float voltage = PV3_VOLTAGE_RANGE.clamp(parseFloat(voltageValue, PV3_VOLTAGE_RANGE.getLower()));
final String decimalVoltageValue = voltageValue.replace(",", ".");
final float voltage = PV3_VOLTAGE_RANGE.clamp(parseFloat(decimalVoltageValue, PV3_VOLTAGE_RANGE.getLower()));
setText(displayPV3, VOLTAGE_FORMAT, voltage);
controllerPV3.setProgress(mapPowerToProgress(voltage, PV3_CONTROLLER_MAX,
PV3_VOLTAGE_RANGE.getUpper(), PV3_VOLTAGE_RANGE.getLower()));
Expand All @@ -256,7 +258,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
final String currentValue = remove(displayPCS.getText(), "mA", "\\+").trim();
final float current = PCS_CURRENT_RANGE.clamp(parseFloat(currentValue, PCS_CURRENT_RANGE.getLower()));
final String decimalCurrentValue = currentValue.replace(",", ".");
final float current = PCS_CURRENT_RANGE.clamp(parseFloat(decimalCurrentValue, PCS_CURRENT_RANGE.getLower()));
setText(displayPV3, CURRENT_FORMAT, current);
controllerPCS.setProgress(mapPowerToProgress(current, PCS_CONTROLLER_MAX,
PCS_CURRENT_RANGE.getUpper(), PCS_CURRENT_RANGE.getLower()));
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/activity_powersource_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
android:cursorVisible="false"
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789-.,"
android:padding="@dimen/power_card_medium_margin"
android:singleLine="true"
android:textSize="@dimen/power_card_display_text"
Expand Down Expand Up @@ -192,7 +193,8 @@
android:cursorVisible="false"
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:inputType="numberDecimal|numberSigned"
android:digits="0123456789-.,"
android:padding="@dimen/power_card_medium_margin"
android:singleLine="true"
android:textSize="@dimen/power_card_display_text"
Expand Down Expand Up @@ -317,8 +319,8 @@
android:background="@drawable/control_edittext"
android:cursorVisible="false"
android:gravity="center"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:imeOptions="actionDone"
android:padding="@dimen/power_card_medium_margin"
android:singleLine="true"
android:textSize="@dimen/power_card_display_text"
Expand Down

0 comments on commit ee977bb

Please sign in to comment.