The design is not ready yet, so at this point I just wanted to create the ViewModel logic.
We want to enable or disable the proxy according to the user's interaction.
We want some kind of validation when the user inputs the proxy data (valid IP + port numeric & in range).
What?
Created a ProxyValidator class that uses the AndroidX pattern validation for checking if the IP and port are valid.
Added a ViewModel that exposes validation events (for now, at least) and the proxy state, mapping the liveData from the DeviceSettingsManager.
Bonus
Refactored the Proxy class to use two Strings: it makes everything more readable, and now that we have validation makes more sense.
Added SingleLiveEvent for one-time only events.
Why?
The design is not ready yet, so at this point I just wanted to create the ViewModel logic. We want to enable or disable the proxy according to the user's interaction. We want some kind of validation when the user inputs the proxy data (valid IP + port numeric & in range).
What?
Created a ProxyValidator class that uses the AndroidX pattern validation for checking if the IP and port are valid. Added a ViewModel that exposes validation events (for now, at least) and the proxy state, mapping the liveData from the DeviceSettingsManager.
Bonus
Refactored the Proxy class to use two Strings: it makes everything more readable, and now that we have validation makes more sense. Added SingleLiveEvent for one-time only events.