Code Style

0 views
Skip to first unread message

Matthias Jordan

unread,
Mar 15, 2010, 4:36:44 PM3/15/10
to AndTweet
Hi, folks.

Is there any convention on the Code Style to use? I mean, which tab
width to use, tabs or spaces, indentation style, line width, etc.? Is
there any Eclipse configuration that the code complies to? This would
make it much easier to merge code changed by different developers
because trivial changes would not grow diffs more than needed. Plus, I
can hit Ctrl-Shift-F whenever I feel the code needs a bit more
style ;-)


Matthias

yvolk

unread,
Mar 18, 2010, 11:34:44 AM3/18/10
to AndTweet
Thank you, Matthias, for the reminder!
I don't think we should reinvent a wheel for AndTweet, there is
Android-wide "Code Style Guide" already:
http://source.android.com/submit-patches/code-style-guide

As that article says "The rules below are not guidelines or
recommendations, but strict rules. You may not disregard the rules we
list below except as approved on a need-to-use basis.
Not all existing code follows these rules, but all new code is
expected to."

...I'll try to follow it.
--
Yuri

Matthias Jordan

unread,
Mar 19, 2010, 2:23:08 PM3/19/10
to andt...@googlegroups.com
Hi, Yuri.

> I don't think we should reinvent a wheel for AndTweet, there is
> Android-wide "Code Style Guide" already:
> http://source.android.com/submit-patches/code-style-guide

Looks terrific. What is your take on creating an Eclipse formatting
XML file and checking it in so everybody can use the same file to
automatically format the code?

The only problem will be that after deciding on a global coding
style, all code will have to be formatted and committed otherwise we
might run into severe problems with merging.


> As that article says "The rules below are not guidelines or
> recommendations, but strict rules. You may not disregard the rules we
> list below except as approved on a need-to-use basis.
> Not all existing code follows these rules, but all new code is
> expected to."

I think that refers to the Android OS source code, since that is the
code base they have control over. They can hardly dictate the coding
style of anybody developing their own apps for Android, can they?

Anyway, attached you will find my current patch. I've tried it for
some time now (a few hours) with many interactions with AndTweet and
other apps and haven't seen a crash or even an NPE on the LogCat.
Plus, the time on Partial Wake Lock as displayed in the Spare Parts
app is 0 (or close to) for AndTweet, even though updates are pulled
from Twitter if the device is in sleep/stand-by.

Please tell me what you think about it.


Sincerely

Matthias

AndTweet.patch.zip

yvolk

unread,
Mar 19, 2010, 5:18:01 PM3/19/10
to AndTweet
Hi Matthias,

I was lazy to create formatting profile for Android myself, so I've
asked the question at stackoverflow.com:
http://tinyurl.com/yhm8avz
...Let's wait for a while :-)

Matthias Jordan

unread,
Mar 20, 2010, 1:34:11 PM3/20/10
to AndTweet
Hey, Yuri.

Just modded the question up ;-) I'm really curious if anybody has an
XML file ready.


Greetings

Matthias

yvolk

unread,
Mar 20, 2010, 2:30:22 PM3/20/10
to AndTweet
Hi Matthias,
I've merged your patch with my recent changes on localization into
Russian language
and found out, that in this new version:
1. There is no crash of AndTweetService
2. After app update automatic updates don't occure. So to see new
tweets one have to explicitly select "Reload" in the menu.
But, after I go to the AndTweet settings and turn "Automatic updates"
off and then "on" again, periodic automatic updated do occure!
3 After reboot device 'forgets' about periodic updates (though I see
in the log; "D/AndTweetServiceManager(11948): Alarm started. Automatic
updates turned on. ")
- I have go to settings again and turn off|on "Automatic updates"

Update on Your today's new version of AndTweetService (see r137 in
SVN):
- I think that we should try to move Alarm initialization code from
TimelineActivity.onCreate to AndTweetService.startAutomaticUpdates ...

On Mar 19, 9:23 pm, Matthias Jordan <matthias.jor...@googlemail.com>
wrote:


>
> Anyway, attached you will find my current patch. I've tried it for
> some time now (a few hours) with many interactions with AndTweet and
> other apps and haven't seen a crash or even an NPE on the LogCat.
> Plus, the time on Partial Wake Lock as displayed in the Spare Parts
> app is 0 (or close to) for AndTweet, even though updates are pulled
> from Twitter if the device is in sleep/stand-by.
>
> Please tell me what you think about it.
>
> Sincerely
>
> Matthias
>

>  AndTweet.patch.zip
> 7KViewDownload

Matthias Jordan

unread,
Mar 21, 2010, 9:10:33 AM3/21/10
to andt...@googlegroups.com
Hey, folks.

I guess I found and fixed the reboot issue.

It was a timing thing - the service that was started in the manager wasn't awake in most cases when the intent was sent to start the alarm. I tested this by inserting a Thread.sleep() which "solved" the problem. Thread.sleep() not being my favourite fix for timing related things, I changed the code to now start the service by sending the intent as before but now the start intent also includes the information on whether to start the alarm or not.

I'll commit the changes after a bit of more testing.


Greetings

Matthias

yvolk

unread,
Mar 29, 2010, 10:34:44 AM3/29/10
to AndTweet
Returning to the subject of this topic :-)
We do have formatting profile for Android,
please see the answer at:
http://tinyurl.com/yhm8avz
Reply all
Reply to author
Forward
0 new messages