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

Remove extra state and use Android APIs in activities with checkable lists #303 #480

Merged
merged 29 commits into from
Mar 2, 2017
Merged

Remove extra state and use Android APIs in activities with checkable lists #303 #480

merged 29 commits into from
Mar 2, 2017

Conversation

dcbriccetti
Copy link
Contributor

This is branched off another pending branch, but the new commits start Mar 1.

I managed to remove the state and use the ListView methods, as requested, so far for one class: InstanceUploaderList. The rest will follow.

…eferencesActivity, and removes dependencies on it from those classes which only need the key strings.
…eferencesActivity, and removes dependencies on it from those classes which only need the key strings. Inline a variable.
# Conflicts:
#	collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesActivity.java
# Conflicts:
#	collect_app/src/main/java/org/odk/collect/android/preferences/PreferencesActivity.java
…lity.

AdminPreferencesActivity: Move keys to new AdminKeys class.
… the values of the admin preferences. Clean up more code.
@dcbriccetti dcbriccetti changed the title 303 activities checkable lists Remove extra state and use Android APIs in activities with checkable lists #303 Mar 1, 2017
…eckable-lists

# Conflicts:
#	collect_app/src/main/java/org/odk/collect/android/activities/InstanceUploaderList.java
…eckable-lists

# Conflicts:
#	collect_app/src/main/java/org/odk/collect/android/activities/InstanceUploaderList.java
…lists #303.

Create a common superclass for these list classes. This could join with or replace ListViewUtils later.
…lists #303.

This completes most of the work. More testing is needed.
…at for buttons’ enabled state, which is not saved automatically by Android.
@grzesiek2010
Copy link
Member

I think we should follow field naming conventions from https://source.android.com/source/code-style.html insetad of using "this.something".

@dcbriccetti
Copy link
Contributor Author

Hi @grzesiek2010. Thanks for looking at the change. I can’t see what you’re referring to. (Did you attach your comment to a specific line of code?) Is it CheckedItemInfo? Are you talking about the “m” prefix? If so, did you consider that the fields are public, and that rule doesn’t apply?

@grzesiek2010
Copy link
Member

grzesiek2010 commented Mar 2, 2017

@lognaturel
Copy link
Member

@grzesiek2010 @dcbriccetti I guess the question is whether the m convention should apply to "plain old Java objects." I think the current code base isn't very consistent so I'm ok accepting both and making that decision as part of an eventual concretizing of the style guidelines.

@dcbriccetti
Copy link
Contributor Author

“Non-public, non-static field names start with m.”
These fields are public. Of course, a JavaBean purist would say that they should be private and I should have made getter methods.

This is not very relevant, but I really dislike the “m” convention. Modern IDEs make it very clear what’s what. “this” is usually needed only in the constructor, for copying an argument’s value to a field with the same name. To me, the “m” is noise. It slows me down. Examining an object in the debugger, nearly everything starts with an m.

@lognaturel
Copy link
Member

lognaturel commented Mar 2, 2017

Ah, yes, I was assuming they were private. 😊 But the convention also is very much an Android thing.

Like I said, I'm not terribly worried about that kind of stylistic thing for now. We need to get a checkstyle file we can all agree in and just make formatting and checking automatic. In fact, I have one to propose and I will create an issue for that shortly.

@nribeka
Copy link
Contributor

nribeka commented Mar 2, 2017

I'm with Jake Wharton on this "m" issue 👎

https://twitter.com/jakewharton/status/497243553311907840

int[] checkedPositions = new int[checkedItemCount];
long[] checkedIds = new long[checkedItemCount];
int resultIndex = 0;
for (int posIdx = 0; posIdx < itemCount; ++posIdx) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe using a prefix increment here is any different than using a postfix one. I think postfix is more familiar and that this could be surprising.

}

/** Returns the IDs of the checked items, as an array of Long */
@NonNull
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that @NonNull was the default. Is there a reason to make it explicit here?


private static final String BUNDLE_SELECTED_ITEMS_KEY = "selected_items";
public class InstanceUploaderList extends AppListActivity implements OnLongClickListener {
private static final String t = "InstanceUploaderList";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TAG

@lognaturel lognaturel merged commit 2d14564 into getodk:master Mar 2, 2017
@dcbriccetti dcbriccetti deleted the 303-activities-checkable-lists branch March 4, 2017 20:32
// keys for each preference

// main menu
public static String KEY_EDIT_SAVED = "edit_saved";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcbriccetti I noticed during your pairing session that the keys aren't final here. I think they probably should be, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation. I missed that myself. They were that way when I moved them to the new file, but I missed an opportunity to improve them. Want to take any action now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll file it as a quick win for one of our new contributors! 😊 Just wanted to make sure I wasn't missing something.

snavarreteimmap pushed a commit to snavarreteimmap/collect that referenced this pull request Oct 2, 2020
…le-lists

getodk#303, Remove extra state and use Android APIs in activities with checkable lists
getodk#441, Refactor preference classes
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.

4 participants