rschilling / websmsdroid

Automatically exported from code.google.com/p/websmsdroid
0 stars 0 forks source link

Support Custom SMS-length Calculation #574

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In both the fishtext connector as well as another I am working on the standard 
calculation of characters remaining / number of SMSs used does not match the 
provider's own calculations.

For example, fishtext allows 160 characters to count as one text, but only 146 
characters in addition to count as two, and then 153 in the third and final.

Not having the provider's calculation match the shown length/remaining is 
especially bad when we reach the (newly enabled) maximum length for a message. 
Currently you can reach the maximum length with fishtext and therefore not be 
able to add any characters, but the display says "4/152"!

I propose the following:
- Add an interface SMSLengthCalculator that has just one method - 
calculateLength, with same signature as the method with the same name from 
TelephonyWrapper.
- Either make TelephonyWrapper implement this interface, or create a simple 
implementation (DefaultSMSLengthCalculator) of SMSLengthCalculator that wraps 
up a call to TelephonyWrapper.getInstance().calculateLength
- Add two methods to the ConnectorSpec: get/setSMSLengthCalculator. As a result 
SMSLengthCalculator interface must be serializable (not hard as there will be 
little or no state in any implementations).
- Add a basic implementation (BasicSMSLengthCalculator) that allows connector 
developers to easily specify the calculation formula in most cases - say with 
an int array (which would be [160, 146, 153] for fishtext, as above).
- Modify the WebSMS class to get the connector's SMSLengthCalculator 
implementation from the connector spec, using DefaultSMSLengthCalculator as the 
default when it is not set.

I am happy to make all these additions, but I wanted to ask where the interface 
and basic implementations (as above) should go. There is currently no 
dependency on ub0rlib from websms-api, so I propose putting the files:

- SMSLengthCalculator interface in websms-api
- DefaultSMSLengthCalculator class in websms
- BasicSMSLengthCalculator in websms-api

Felix, would you be happy with the above changes? It shouldn't take too long to 
do, I'll create the pull request(s) soon if you approve.

Original issue reported on code.google.com by fint...@gmail.com on 2 Sep 2011 at 4:14

GoogleCodeExporter commented 9 years ago
i'm totally happy with the changes :)

Original comment by f...@ub0r.de on 2 Sep 2011 at 4:26

GoogleCodeExporter commented 9 years ago
btw: if you are using eclipse as ide, you would do me a great favor with 
respecting the .settings regarding code style and stuff ;)

it will just mess up the git history when both of us are using auto code 
formatting but with different style

Original comment by f...@ub0r.de on 2 Sep 2011 at 5:00

GoogleCodeExporter commented 9 years ago
Yea, I'm sorry about the superfluous changes last time.

I had tried to get my formatter to match though. You don't seem to have 
project-specific formatting set on the projects, which means it's using the 
workspace settings. I set it to use the standard eclipse formatting settings 
and it came close to your formatting, but it was slightly out. I think it is 
possibly a difference with eclipse formatter defaults between eclipse versions. 
I was using the new Indigo version of Eclipse.

Can you add project-specific formatting settings to each project and commit to 
github? Hopefully with your settings my formatter will do the same thing.

Original comment by fint...@gmail.com on 2 Sep 2011 at 6:02

GoogleCodeExporter commented 9 years ago
actually the .settings directory is checked into git.
but i can provide global settings tomorrow.

Original comment by f...@ub0r.de on 2 Sep 2011 at 7:55

GoogleCodeExporter commented 9 years ago
Yep, the .settings dir is there, but there is only org.eclipse.jdt.ui.prefs 
inside and it doesn't contain any formatting settings. I suspect you are just 
using your workspace settings, which unfortunately I don't have and can't seem 
to replicate precisely.

Original comment by fint...@gmail.com on 2 Sep 2011 at 7:59

GoogleCodeExporter commented 9 years ago
Two pull requests for this:
https://github.com/felixb/websms-api/pull/2
https://github.com/felixb/websms/pull/2

I made sure the formatter didn't mangle any of the existing code. My own code 
format might be slightly off, but should be relatively close.

Works well with fishtext. I haven't tested with any other connectors, but if I 
do not set the option in the connector spec it seems to function as before.

Original comment by fint...@gmail.com on 2 Sep 2011 at 9:32

GoogleCodeExporter commented 9 years ago
just merged your changes. thx a lot!

Original comment by f...@ub0r.de on 4 Sep 2011 at 3:04

GoogleCodeExporter commented 9 years ago

Original comment by f...@ub0r.de on 14 Sep 2011 at 6:37