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

A large number of small changes to improve readability and maintainability #28

Open
wants to merge 104 commits into
base: master
Choose a base branch
from

Conversation

kwhitefoot
Copy link

I'm using this project as a way of becoming more familiar with both Android and Java.

My personal way of doing this is to do a code review exercise.

I have made a lot of small changes all aimed at making the code easier to read and safer to maintain. The largest change is the introduction of an enum called Security that allows the switch statements that define proto and acceptcrt to be eliminated along with several other if statements. I have tried to use strong typed fields and methods instead of using strings.

It seems to work but I can't claim to have tested it extensively.

Anyway, if you think it is useful here it is.

The process of adding comments to code that I read helps me make sense of it even if I never read them again.  Comments that are just a question mark are place holders to return to when I have a better idea of what that piece of code is for.
Added Security Enum, WIP to get rid of literal code numbers in configuration and replace with enum names.
…s no longer a need for a switch statement to find them.
@N0ury
Copy link
Owner

N0ury commented Nov 6, 2016

Thanks, very good idea.
I’m a little bit busy, and I’ll be on leave this week.
I’ll try to have a look at your changes next week

Noury

Le 5 nov. 2016 à 01:40, kwhitefoot [email protected] a écrit :

I'm using this project as a way of becoming more familiar with both Android and Java.

My personal way of doing this is to do a code review exercise.

I have made a lot of small changes all aimed at making the code easier to read and safer to maintain. The largest change is the introduction of an enum called Security that allows the switch statements that define proto and acceptcrt to be eliminated along with several other if statements. I have tried to use strong typed fields and methods instead of using strings.

It seems to work but I can't claim to have tested it extensively.

Anyway, if you think it is useful here it is.

You can view, comment on, or merge this pull request online at:

#28

Commit Summary

• Added comments to make it easier to understand
• Added comments.
• Reformatted all files to get consistent indentation, etc.
• Corrected Accont -> Account.
• Added proto and acceptcrt properties to Security enum so that there is no longer a need for a switch statement to find them.
• Folder override can never be null so do not check for it.
File Changes

• M ImapNote2/build.gradle (4)
• M ImapNote2/src/main/AndroidManifest.xml (152)
• D ImapNote2/src/main/java/com/Pau/ImapNotes2/AccontConfigurationActivity.java (349)
• A ImapNote2/src/main/java/com/Pau/ImapNotes2/AccountConfigurationActivity.java (356)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Data/ConfigurationFile.java (255)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Data/ImapNotes2Account.java (88)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Data/NotesDb.java (157)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/ImapNotes2.java (102)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Listactivity.java (458)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/ImapNotes2Result.java (26)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/ImapNotesAuthenticatorService.java (159)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/Imaper.java (286)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/OneNote.java (106)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/Sticky.java (78)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/SyncThread.java (34)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Miscs/UpdateThread.java (137)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/NewNoteActivity.java (72)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/NoteDetailActivity.java (266)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/NotesListAdapter.java (84)
• A ImapNote2/src/main/java/com/Pau/ImapNotes2/Sync/Security.java (75)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Sync/SyncAdapter.java (120)
• M ImapNote2/src/main/java/com/Pau/ImapNotes2/Sync/SyncUtils.java (857)
• M ImapNote2/src/main/res/layout/account_selection.xml (354)
• M ImapNote2/src/main/res/layout/main.xml (12)
• M ImapNote2/src/main/res/layout/new_note.xml (12)
• M ImapNote2/src/main/res/layout/note_detail.xml (41)
• M ImapNote2/src/main/res/layout/note_element.xml (45)
• M ImapNote2/src/main/res/menu/detail.xml (54)
• M ImapNote2/src/main/res/menu/list.xml (37)
• M ImapNote2/src/main/res/menu/newnote.xml (8)
• M ImapNote2/src/main/res/values-v14/styles.xml (29)
• M ImapNote2/src/main/res/values/strings.xml (5)
• M ImapNote2/src/main/res/values/styles.xml (25)
• M ImapNote2/src/main/res/xml/authenticator.xml (9)
• M ImapNote2/src/main/res/xml/searchable.xml (4)
• M ImapNote2/src/main/res/xml/syncadapter.xml (7)
• M build.gradle (2)
• M gradle/wrapper/gradle-wrapper.properties (4)
Patch Links:

https://github.com/nbenm/ImapNote2/pull/28.patch
https://github.com/nbenm/ImapNote2/pull/28.diff

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

…ot reuse variables and so that we do not compile them every time.
…ved code inside try in some cases, use Log.d instead of exception.printStackTrace. Suppress MessagingException when closing connection because the connection is always closed after the call even if the execption is thrown.
…dded CreateLocalDirectories and ClearHomeDir to Account class to reduce repetition and put them closer to the data that is used by them. Moved various declarations nearer to first use. Upgraded buildtoos to 23.0.3.
…have the vector clocks and history we can remove this an allow the user to retrieve old versions instead.
…to get rid of the Sticky note stuff as it no longer makes sense.
…to get rid of the Sticky note stuff as it no longer makes sense.

Added flag for AutomaticMerge.  This should probably be an enum together with the stickynotes because they are mutually exclusive.

Added Db and associated classes as a container for the various classes representing tables because we now have two more tables to deal with to support the vector clocks.  Moved NotesDbHelper to the new Db class.

Added MakeMessageWithAttachment function to begin storing messages in attachments instead of inline this should simplify the business of handling composite documents.

Added @nonnull to some argument lists.
… of an error message. Added the Result type to return both the message and the success flag instead of modifying the statusMessage field which allows the message to be final.
…moved imapnotes2Account field from ImapNotes2 class because it was only used in one call so it can be local to the caller.
…elsewhere. Added function to validate synchronization interval. Moved creation of progress dialog to LogIn thread as it is the only user.
…on that mutates the state of the object, use constructors instead. Get some data from ImapNotes2Account instance instead of using AccountManager because ImapNotes2Account instance should already have them. Use int instead of long for sync interval. Added ShowToast function that shows a toast for a caller defined number of seconds.
…tion because it is now not possible for it to be invalid.
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.

3 participants