Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore saved TCP port setting #193

Closed

Conversation

zjw
Copy link
Contributor

@zjw zjw commented Oct 12, 2012

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:

  1. Create mSecurityTypeView, a spinner widget for selecting the server security protocol.

  2. 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).

  3. Initialize the mSecurityTypeView spinner with the saved security protocol option value for the account.

  4. 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.

Beginning with Android 4.1 (Jelly Bean), The saved custom server port was not
being restored upon entry into the (incoming/outgoing) account server
setup screen. Instead, the saved value was replaced with the default
port applicable for the saved server security protocol.
@cketti
Copy link
Member

cketti commented Oct 21, 2012

Thanks for the detailed analysis. However, I used a slightly different approach to fix this problem: 6af48bd

@cketti cketti closed this Oct 21, 2012
@Truddel
Copy link

Truddel commented Dec 15, 2012

Sorry for my nooby question but i have this problem and dont know how to get it on my K9 App so that it will work? How i will get this on my phone?

@zjw zjw deleted the restore_custom_server_port_setting branch January 12, 2013 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants