konklone / congress-android

Congress for Android, an app for tracking Congress.
https://play.google.com/store/apps/details?id=com.sunlightlabs.android.congress
Other
157 stars 42 forks source link

Added support for adding legislators as phone contacts. #531

Closed smoak closed 12 years ago

smoak commented 12 years ago

This is for issue #514

It adds a menu item on the legislators pager fragment allowing the user to add the legislator to their phone contacts. It does this in a background thread (AsyncTask) so the app stays responsive. It should be noted that this will not work on Android versions < 2.0 as it makes use of the new Contacts API that was added in 2.0

konklone commented 12 years ago

This looks great. I've left a few comments inline.

One thing I did not consider: this is going to add a permission to the app, which is a big deal. It means users will have to manually update instead of letting it happen automatically, and that users will have to look at the permissions before updating and possibly get paranoid about all the permissions - both of which I expect to cause a dropoff in updates.

However, I'm still inclined to do this, partly because I have another permissions change I've been wanting to make that I've been dragging my heels on (making it so that the Call button starts a call immediately, rather than pre-loading the dialer), and partly because we're going to be embarking on some promotion and marketing for the app in February which should help make up for this.

konklone commented 12 years ago

Actually, two more questions -

Are either the permissions or the code seriously different if we don't insert the contacts silently, but instead bring the user to the Add Contacts screen, with data pre-populated for them to verify before hitting Save?

We have many legislators' Twitter and Facebook accounts. The Twitter and Facebook apps both integrate this into Android's contacts system. What's involved in adding in legislators' Twitter and Facebook accounts to their contact details? I assume the Facebook or Twitter apps would need to be installed on the phone for Android to understand what they are. I also assume that you would not need to be following that legislator on Facebook or Twitter to integrate their social media accounts into the contacts system. (Just to be clear: I'm not requesting that you add this support as a condition of merging this code or anything.)

smoak commented 12 years ago

Are either the permissions or the code seriously different if we don't insert the contacts silently, but instead bring the user to the Add Contacts screen, with data pre-populated for them to verify before hitting Save?

Both would be completely different. It does not require the WRITE_CONTACT permission if you're just displaying the Edit screen with prepopulated data. The code would just be an ACTION_INSERT intent for the Contacts CONTENT_URI with some extras for the data. Getting the avatar data might be a bit tricky though, since it requires a download of the picture which could potentially take awhile.

What's involved in adding in legislators' Twitter and Facebook accounts to their contact details?

Not a whole lot. That's what's neat about the new Contacts API; it makes it really easy to add this stuff to a Contact. It's just a matter of figuring out the Facebook/Twitter data mimetype and inserting a row into the Contacts Data table with that mimetype.

I also assume that you would not need to be following that legislator on Facebook or Twitter to integrate their social media accounts into the contacts system.

You are correct. We can add that info even when the user is not following the legislator on Facebook or Twitter.

konklone commented 12 years ago

Both would be completely different. It does not require the WRITE_CONTACT permission if you're just displaying the Edit screen with prepopulated data. The code would just be an ACTION_INSERT intent for the Contacts CONTENT_URI with some extras for the data. Getting the avatar data might be a bit tricky though, since it requires a download of the picture which could potentially take awhile.

Yeah, that avatar trickiness is why I removed the ability to create home screen shortcuts to legislators.

I think I'm inclined to add legislators directly, instead of using the ACTION_INSERT approach - and further, I think it makes sense that if you "favorite" a legislator, it adds them to your contact list, with a toast message the first time to let you know that this happened, and a setting to disable this behavior. That also makes me think that I could change the "star" to a "plus" icon.

I go back and forth on this - would be interested in your opinion.

Not a whole lot. That's what's neat about the new Contacts API; it makes it really easy to add this stuff to a Contact. It's just a matter of figuring out the Facebook/Twitter data mimetype and inserting a row into the Contacts Data table with that mimetype.

Would the Twitter or Facebook apps need to be installed on the user's phone for this to work?

smoak commented 12 years ago

Would the Twitter or Facebook apps need to be installed on the user's phone for this to work?

I believe so. I don't think the built in Contacts app would be able to display any of that info without the Twitter or Facebook apps installed. I don't use the Twitter or Facebook apps myself so I'm not sure how it would all tie in with the Contacts app, but I know the Contacts detail view can show custom fields. At the very least the data can be stored in on the Contact but retrieving/displaying it may be the more tricky part.

smoak commented 12 years ago

Just curious what the status was on this. Was there something I need to add/fix?

konklone commented 12 years ago

Nope, this is waiting on me. The last couple weeks were packed, including a week of vacation. I'll get this added, and resolve as many issues as I can in the current milestone that are marked "Bug", this week and try to get a release out soon.

konklone commented 12 years ago

Just to be clear, I think I'm going to add this without much UI effort for now, to the action bar overflow menu on a legislator page, and have it add silently. Do you know offhand how the WRITE_CONTACT permission appears in the Android Market? Does it say "read and write contacts", or just "write"? People get pretty touchy about apps that ask to read their contacts.

smoak commented 12 years ago

Do you know offhand how the WRITE_CONTACT permission appears in the Android Market?

It will show up as:

WRITE CONTACT DATA Allows an application to modify the contact (address) data stored on your device. Malicious applications can use this to erase or modify your contact data.

The READ_CONTACT permission appears separate and looks like:

READ CONTACT DATA Allows an application to read all of the contact (address) data stored on your device. Malicious applications can use this to send your data to other people.

smoak commented 12 years ago

I got rid of the WRITE_CONTACTS permission. So now it will open up a prefilled contact screen for the user when they click add

konklone commented 12 years ago

Merged and done. Thank you for the revisions! This will definitely be in the next March release.

smoak commented 12 years ago

Awesome :)