Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This bug occurs with Android 4.1 (Jelly Bean). Saved TCP port values are no longer being restored when entering the server setup screens. To reproduce:
Go into Settings -> Account Settings -> Fetching mail -> Incoming server. Change the port to a non-standard number (e.g., 1234). Click Next. You will likely get a 'cannot connect' error -- ignore it. Click 'continue'. The port number has now been saved. Go back into 'Incoming server' again. Prior to Jelly Bean, you would see the saved port number (1234). With Jelly Bean, the port number has been reset to a default value.
The cause:
Before this patch, the code in AccountSetupIncoming.onCreate() did the following:
Create mSecurityTypeView, a spinner widget for selecting the server security protocol.
Set an onItemSelected() listener for mSecurityTypeView so that whenever a spinner option value is selected, a call is made to updatePortFromSecurityType() (which sets a default port value based on the selected security protocol).
Initialize the mSecurityTypeView spinner with the saved security protocol option value for the account.
Initialize mPortView (a text widget) with the saved TCP port setting for the account.
On Android versions prior to Jelly Bean, the execution of step (3) immediately resulted in triggering the onItemSelected() listener, resulting in an immediate call to updatePortFromSecurityType() which initialized mPortView with a default value. However, this default initialization was irrelevant, because mPortView was subsequently reinitialized in step (4).
With Jelly Bean, step (3) still results in triggering the onItemSelected() listener. However, the subsequent call to updatePortFromSecurityType() is no longer immediate; instead, the call is posted to the UI message queue to be invoked later -- i.e., the call to updatePortFromSecurityType() is delayed until after step (4), so the saved port value ends up being wiped out and replaced with a default value in the UI.
The problem occurs for both the incoming and outgoing server settings.
This patch moves step (4) from inside of onCreate() to inside of updatePortFromSecurityType().
Tested on Gingerbread, ICS, and Jelly Bean.