diff options
author | Damian Minkov <damencho@jitsi.org> | 2014-04-15 09:30:03 +0300 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2014-04-15 14:12:35 +0300 |
commit | 95619dc872f144d68f3c185eed2db96afc5ac56b (patch) | |
tree | d42934f59b3f292a91b70b3b4952ae934e062f1c /src/net/java/sip/communicator/impl/gui/main/chat | |
parent | c22a8f367f49ca1febdf82720ed91ce6f6c3abff (diff) | |
download | jitsi-95619dc872f144d68f3c185eed2db96afc5ac56b.zip jitsi-95619dc872f144d68f3c185eed2db96afc5ac56b.tar.gz jitsi-95619dc872f144d68f3c185eed2db96afc5ac56b.tar.bz2 |
Fixes char counters in chat write panel.
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/main/chat')
-rwxr-xr-x | src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 5308450..80bc6e2 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -1497,16 +1497,7 @@ public class ChatWritePanel // If we're in sms mode count the chars typed. if (smsButton.isVisible()) { - if (smsCharCount == 0) - { - smsCharCount = 159; - smsNumberCount ++; - } - else - smsCharCount--; - - smsCharCountLabel.setText(String.valueOf(smsCharCount)); - smsNumberLabel.setText(String.valueOf(smsNumberCount)); + updateSmsCounters(event.getDocument().getLength()); } } @@ -1521,20 +1512,24 @@ public class ChatWritePanel // If we're in sms mode count the chars typed. if (smsButton.isVisible()) { - if (smsCharCount == 160 && smsNumberCount > 1) - { - smsCharCount = 0; - smsNumberCount --; - } - else - smsCharCount++; - - smsCharCountLabel.setText(String.valueOf(smsCharCount)); - smsNumberLabel.setText(String.valueOf(smsNumberCount)); + updateSmsCounters(event.getDocument().getLength()); } } /** + * Updates sms counters, 160 chars in one sms. + * @param documentLength the current document length + */ + private void updateSmsCounters(int documentLength) + { + smsCharCount = 160 - documentLength % 160; + smsNumberCount = 1 + documentLength/160; + + smsCharCountLabel.setText(String.valueOf(smsCharCount)); + smsNumberLabel.setText(String.valueOf(smsNumberCount)); + } + + /** * Sets the background of the write area to the specified color. * * @param color The color to set the background to. |