You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual Behaviour
In the PowerSourceActivity, whenever an invalid (non-float parsable) value is entered as an input, the app crashes.
Expected Behaviour
The app should identify whenever the user has input an invalid value, and reset the value to default.
Steps to reproduce it
Open the PowerSourceActivity.
Enter a non-float parsable value (such as "-.", "-V", etc.) as an input in any one of the EditTexts.
One would observe that the app crashes.
LogCat for the issue
FATAL EXCEPTION: main (Ask Gemini)
Process: io.pslab, PID: 19872
java.lang.NumberFormatException: For input string: "-"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at io.pslab.activity.PowerSourceActivity$5.onEditorAction(PowerSourceActivity.java:193)
at android.widget.TextView.onEditorAction(TextView.java:7042)
at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138)
at android.view.inputmethod.InputConnectionWrapper.performEditorAction(InputConnectionWrapper.java:205)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:357)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:89)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7617)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Screenshots of the issue
Here is a recording demonstrating the issue -
Screen_recording_20240615_122759.mp4
Would you like to work on the issue?
Yes
The text was updated successfully, but these errors were encountered:
Just some information which may be helpful or maybe not (feel free to ignore 😉):
I started working on a horizontal layout for the Power Source a few days ago (see https://github.com/marcnause/pslab-android/tree/powersrc_horizontal). The layout is still unfinished, because I am not good at creating layouts, but I stumbled over exceptions since I use a different locale (German) where decimal points are written as commas ("2.5" is "2,5" for the German locale).
I tried to solve the issue by removing some characters ("+" and the unit) and by using Java's NumberFormat to parse the number (see: 74d58f6).
Since locales don't seem to be handled uniformly in the app (see #2481), I thought that it may be useful to subclass TextViews and EditTexts and use it everywhere in the app.
@marcnause Thank you so much for that information and updating on your progress on the PowerSource screen. Certainly, a horizontal layout for the screen would be amazing. My main point in this issue is that there are no checks written in the code, which check whether the input is float-parsable or not (like I have done for the Position Controls feature). Even if we subclass the TextViews and EditTexts, we would anyways be needing those checks as the user could still enter non-float parsable values (like '-.' for instance). That's what I wish to work on in the scope of this issue. Does this sound right to you ?
Actual Behaviour
In the PowerSourceActivity, whenever an invalid (non-float parsable) value is entered as an input, the app crashes.
Expected Behaviour
The app should identify whenever the user has input an invalid value, and reset the value to default.
Steps to reproduce it
LogCat for the issue
FATAL EXCEPTION: main (Ask Gemini)
Process: io.pslab, PID: 19872
java.lang.NumberFormatException: For input string: "-"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at io.pslab.activity.PowerSourceActivity$5.onEditorAction(PowerSourceActivity.java:193)
at android.widget.TextView.onEditorAction(TextView.java:7042)
at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:138)
at android.view.inputmethod.InputConnectionWrapper.performEditorAction(InputConnectionWrapper.java:205)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:357)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:89)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:7617)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)
Screenshots of the issue
Here is a recording demonstrating the issue -
Screen_recording_20240615_122759.mp4
Would you like to work on the issue?
Yes
The text was updated successfully, but these errors were encountered: