Closed
Bug 583242
Opened 14 years ago
Closed 4 years ago
Add contact support to form autocomplete (Android)
Categories
(Firefox for Android Graveyard :: General, defect, P5)
Tracking
(fennec+)
RESOLVED
INCOMPLETE
Tracking | Status | |
---|---|---|
fennec | + | --- |
People
(Reporter: mfinkle, Unassigned, Mentored)
References
Details
(Whiteboard: [lang=java])
Attachments
(1 file, 4 obsolete files)
(deleted),
patch
|
Details | Diff | Splinter Review |
Bug 578691 adds most of the infrastructure to support showing contact information in form autocomplete. We need to add a data provider for Android.
Updated•14 years ago
|
OS: Linux → Android
Hardware: x86 → All
Comment 1•14 years ago
|
||
flagging for fennec 2.0 to get on triage plate
blocking2.0: --- → ?
tracking-fennec: --- → ?
Updated•14 years ago
|
blocking2.0: ? → ---
Updated•14 years ago
|
tracking-fennec: ? → 2.0+
Comment 2•14 years ago
|
||
Assignee: nobody → blassey.bugs
Attachment #495185 -
Flags: review?(mwu)
Comment 3•14 years ago
|
||
forgot to add the new files
Attachment #495185 -
Attachment is obsolete: true
Attachment #495541 -
Flags: review?(mwu)
Attachment #495185 -
Flags: review?(mwu)
Comment 4•14 years ago
|
||
Attachment #495542 -
Flags: review?(mark.finkle)
Reporter | ||
Comment 5•14 years ago
|
||
Comment on attachment 495542 [details] [diff] [review]
m-b patch
>-#ifndef ANDROID
>+#ifdef ANDROID
>+function AndroidContactsProvider() {
>+}
>+AndroidContactsProvider.prototype = {
nit: Add a blank line
>+ getContacts: function() {
>+ return JSON.parse(Cc["@mozilla.org/dom/contacts;1"].getService(Ci.nsIContacts).contacts);
As I mentioned on IRC, since this is going in platform, I think .getContactsAsJSON() might be better. Then, in the future, we could add other means of retrieving contacts, which would be wrapped nicely in a JSM.
but that is for the platform review. This looks good to me.
Attachment #495542 -
Flags: review?(mark.finkle) → review+
Comment 6•14 years ago
|
||
This seems like something that needs superreview. It looks mostly ok to me otherwise - I'll do a more thorough review with superreview.
Updated•14 years ago
|
Attachment #495541 -
Flags: superreview?(pavlov)
Updated•14 years ago
|
Attachment #495541 -
Flags: superreview?(pavlov) → superreview?(jst)
Comment 7•14 years ago
|
||
Might take if reviewed, but not blocking at this point
tracking-fennec: 2.0+ → 2.0-
Comment 8•14 years ago
|
||
Comment on attachment 495541 [details] [diff] [review]
patch
sr=jst (verbally)
Attachment #495541 -
Flags: superreview?(jst) → superreview+
Updated•14 years ago
|
Attachment #495541 -
Flags: review?(mwu) → review?(mbrubeck)
Comment 9•14 years ago
|
||
Comment on attachment 495541 [details] [diff] [review]
patch
>+++ b/embedding/android/AndroidManifest.xml.in
>+ <uses-permission android:name="android.permission.READ_CONTACTS" />
Outside the scope of this bug, but we need to think about how to tell users why Firefox requests these permissions. (I've already seen some comment threads speculating about why we request location permissions, and this one probably looks even weirder/more dangerous.)
>+++ b/embedding/android/GeckoAppShell.java
>+import android.provider.Contacts.*;
Do you actually use anything from this deprecated class?
>+ Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
>+ null, null, null, null);
We should pass a projection argument to avoid retrieving all columns, which the docs say is "inefficient."
>+ if (cur.getCount() > 0) {
>+ while (cur.moveToNext()) {
You can remove the "if" statement.
>+ JSONObject obj = new JSONObject();
>+ String id = cur.getString(
>+ cur.getColumnIndex(ContactsContract.Contacts._ID));
>+ String name = cur.getString(
>+ cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Move the getColumnIndex calls out of the while loops and save the results in local variables.
>+ if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
Can't you use cur.getInt instead?
>+ Cursor pCur = cr.query(
>+ ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
>+ null,
>+ ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
>+ new String[]{id}, null);
It would probably be much faster if we could query all the tables at once with a join, or query each table once and join the results. But the only way I can see to do this is CursorJoiner, which looks kind of annoying. Since we're only using this data for form suggestions, could we change the format to include separate arrays of names, emails, and phone numbers, without joining them at all? This would probably be most efficient.
I'd like to see some timing of this function with a large (say 500+) number of contacts. If there's a chance it will block for a significant amount of time on a very large (say 5000+) contact database, then we should either limit the number of rows we read, or make this API async.
Attachment #495541 -
Flags: review?(mbrubeck) → review-
Reporter | ||
Updated•14 years ago
|
Whiteboard: [fennec-4.1?]
Reporter | ||
Comment 10•14 years ago
|
||
Matt - Want to take a shot at refactoring? Possible things to tweak besides the cleanup:
* Projection
* Timing
* Async
Reporter | ||
Comment 11•14 years ago
|
||
This feature has implications to the form autocomplete system, but also for add-ons and a future built-in sharing system.
Reporter | ||
Comment 12•14 years ago
|
||
... and possibly any future web content contact APIs
Updated•13 years ago
|
tracking-fennec: - → 7+
Whiteboard: [fennec-4.1?]
Reporter | ||
Comment 13•13 years ago
|
||
This patch replaces the two separate previous patches. This patch also addresses some of Matt's review comments. The Android code uses projects to limit the queries and removes the need for the column index calls.
The form autocomplete code now reuses the previous list of contacts, filtering _that_ list instead of filtering the entire list of contacts. We also limit the number of suggestions shown in the popup bubble - to speed up the display of the UI.
Assignee: blassey.bugs → mark.finkle
Attachment #495541 -
Attachment is obsolete: true
Attachment #495542 -
Attachment is obsolete: true
Reporter | ||
Comment 14•13 years ago
|
||
The last patch had speed issues. On my Nexus One, with 391 contacts, it was taking >4400ms to load the contacts from Android. Brad has many more contacts and it was taking over 40secs.
I tried to turn the query into an async query, but I ran into trouble with using Looper. I converted the XPCOM part of the patch to work async, but I left the Java part sync for now.
I did change the Java query part into two separate queries: 1 to fetch the emails, and 1 to fetch the phone numbers. Each query also returns the contact's display name. I use a HashMap to create a master list of contacts with emails and phoneNumbers properties, just like before. However, this approach is 40x faster.
Queries on my Nexus One now take 108ms. Posting the patch for feedback and to let people stress test the performance.
Attachment #546000 -
Attachment is obsolete: true
Updated•13 years ago
|
tracking-fennec: 7+ → +
Updated•13 years ago
|
Updated•12 years ago
|
Assignee: mark.finkle → nobody
Flags: superreview+
Product: Fennec → Fennec Native
Updated•11 years ago
|
Assignee: nobody → esawin
Updated•11 years ago
|
Assignee: esawin → nobody
Updated•11 years ago
|
Whiteboard: [lang=java][mentor=blassey]
Assignee | ||
Updated•10 years ago
|
Mentor: blassey.bugs
Whiteboard: [lang=java][mentor=blassey] → [lang=java]
Comment 16•4 years ago
|
||
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
Assignee | ||
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•