The current auto-reconnection implementation will only try reconnecting
once, immediately after the server is disconnected. This will of course
almost always fail if the network is down or otherwise unavailable, so
as it stands, enabling auto-reconnect isn't particularly useful.
This patch implements multiple retries for auto-reconnect, with the
frequency of retries controlled by a preference. The Android alarm
infrastructure is used to schedule reconnection attempts; if the phone
misses a scheduled attempt while it's asleep, the reconnection will be
attempted the next time the phone wakes up.
At the moment, the reconnect feature is somewhat glitchy, popping up
multiple reconnect prompts even if a reconnection succeeds, and
occasionally causing crashes. A successful reconnection results in the
conversation history being cleared, which is an annoying outcome when
connected over an unreliable network.
This patch does the following:
* Keep track of whether a reconnect dialog is active, to prevent
multiple dialogs from opening.
* Introduce a new field to the Server object, mayReconnect, which is
used to keep track of whether a reconnection should be attempted in
the event of a disconnection. It's set to "true" when we connect to a
server, and "false" if the user asks for a disconnection.
* Prevent the clearing of active conversations and conversation history
on disconnect, unless the user specifically asked for the disconnect.
* Keep the IRCService running even when no servers are connected, unless
the user has disconnected from all servers herself. This is needed
for reliable auto-reconnects (see next patch), but has the side effect
of keeping conversation history around even if the activity isn't open
when a disconnect happens.
(1) Let full-screen IMEs wrap the text into multiple lines instead of
making the text scroll off the screen.
(2) Provide a preference to let the user choose whether or not to enable
autocorrection of typed text.
(3) Provide a preference to let the user choose whether or not to enable
autocapitalization of sentences. Note that even when this is enabled,
autocapitalization will only happen if the option is also enabled in the
IME.
(4) In landscape mode only, don't replace the Enter key with a Send
button, to make it harder to accidentally send a message. (We can't do
this in portrait, because we would be left without any send button at
all -- perhaps the input line should be changed to be similar to the
text message application, which has a send button next to the input
line?)
Features:
* Now displays the number of mentions that the user has not seen in the
notification.
* When no mentions are outstanding, display which servers the user is
connected to, not the last message.
* When more than one mention is outstanding, display the names of the
conversations with new mentions, not just the last message received.
* Notifications of mentions are suppressed if you're in the conversation
at the time of the mention.
* Notifications of mentions automatically clear when you bring up the
conversation.
* Vibrate notifications now generate the user's chosen default vibrate
pattern, not a hard-coded one.
* Add ticker text to the notification that's displayed when the IRCService
goes into the foreground, instead of displaying a blank ticker.
To allow for all of this, the implementation moves most of the details
of generating the notification text into the IRCService, which now
exposes addNewMention() and notifyConnected()/notifyDisconnected()
methods instead of the lower-level updateNotification().
There are at least two significant memory leaks in Yaaic, which cause
the client to force close after a few hours with an
OutOfMemoryException:
(1) The IRCService holds Conversation objects, which contain a
MessageListAdapter, which have references to the ConversationActivity
context. This causes Activity contexts to outlast the Activity, causing
a significant memory leak over time.
Fix this by holding the MessageListAdapter in the ConversationActivity's
DeckAdapter instead of in the Conversation objects. The DeckAdapter's
lifecycle matches that of the Activity, so this prevents the leak.
(2) Every call to DeckAdapter.getView()/renderConversation() creates a
new MessageListView and adds it to the deck. But adding the view to
the deck causes the deck to take a reference to the view, leaking the
MessageListView until the Activity is finished. (This has the effect of
exacerbating the first leak, since the Activity context holds a
reference to the deck.)
Fix this leak by caching MessageListViews in the DeckAdapter, and
returning an existing MessageListView for a Conversation in getView() if
one already exists.
This makes it easier to ignore unintersting messages wihout turning off the setting to show joins/parts/quits.
Once circle is colored for a new message, the join/part/quit cannot override it anymore.