예제 #1
0
 private static void a(Account paramAccount, String paramString1, String paramString2)
 {
   g5.b(z[3] + paramString1 + z[9] + paramString2);
   ArrayList localArrayList = new ArrayList();
   ContentProviderOperation.Builder localBuilder1 = ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI);
   localBuilder1.withValue(z[4], paramAccount.name);
   localBuilder1.withValue(z[10], paramAccount.type);
   localBuilder1.withValue(z[13], paramString2);
   localArrayList.add(localBuilder1.build());
   ContentProviderOperation.Builder localBuilder2 = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
   localBuilder2.withValueBackReference(z[6], 0);
   localBuilder2.withValue(z[11], z[8]);
   localBuilder2.withValue(z[0], paramString1);
   localArrayList.add(localBuilder2.build());
   ContentProviderOperation.Builder localBuilder3 = ContentProviderOperation.newInsert(a(ContactsContract.Data.CONTENT_URI));
   localBuilder3.withValueBackReference(z[6], 0);
   localBuilder3.withValue(z[11], z[2]);
   localBuilder3.withValue(z[0], paramString2);
   localBuilder3.withValue(z[12], App.Mb.getString(2131296836));
   localBuilder3.withValue(z[1], "+" + paramString2.substring(0, paramString2.indexOf("@")));
   localArrayList.add(localBuilder3.build());
   try
   {
     App.ib.applyBatch(z[5], localArrayList);
     return;
   }
   catch (Exception localException)
   {
     while (true)
       g5.d(z[7] + paramString1 + z[9] + paramString2 + localException.toString());
   }
 }
예제 #2
0
  /**
   * Inserts postal data into the builder object. Note that the data structure of ContactsContract
   * is different from that defined in vCard. So some conversion may be performed in this method.
   * See also { {@link #getVCardPostalElements(ContentValues)}
   */
  public static void insertStructuredPostalDataUsingContactsStruct(
      int vcardType,
      final ContentProviderOperation.Builder builder,
      final ContactStruct.PostalData postalData) {
    builder.withValueBackReference(StructuredPostal.RAW_CONTACT_ID, 0);
    builder.withValue(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);

    builder.withValue(StructuredPostal.TYPE, postalData.type);
    if (postalData.type == StructuredPostal.TYPE_CUSTOM) {
      builder.withValue(StructuredPostal.LABEL, postalData.label);
    }

    builder.withValue(StructuredPostal.POBOX, postalData.pobox);
    // Extended address is dropped since there's no relevant entry in
    // ContactsContract.
    builder.withValue(StructuredPostal.STREET, postalData.street);
    builder.withValue(StructuredPostal.CITY, postalData.localty);
    builder.withValue(StructuredPostal.REGION, postalData.region);
    builder.withValue(StructuredPostal.POSTCODE, postalData.postalCode);
    builder.withValue(StructuredPostal.COUNTRY, postalData.country);

    builder.withValue(
        StructuredPostal.FORMATTED_ADDRESS, postalData.getFormattedAddress(vcardType));
    if (postalData.isPrimary) {
      builder.withValue(Data.IS_PRIMARY, 1);
    }
  }
예제 #3
0
  private void insertSingleContact(String name, String phone, String email, boolean starred) {
    final ArrayList<ContentProviderOperation> operationList =
        new ArrayList<ContentProviderOperation>();
    ContentProviderOperation.Builder builder =
        ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI);
    builder.withValue(ContactsContract.RawContacts.STARRED, starred ? 1 : 0);
    operationList.add(builder.build());

    builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
    builder.withValueBackReference(StructuredName.RAW_CONTACT_ID, 0);
    builder.withValue(ContactsContract.Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
    builder.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name);
    operationList.add(builder.build());

    if (phone != null) {
      builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
      builder.withValueBackReference(Phone.RAW_CONTACT_ID, 0);
      builder.withValue(ContactsContract.Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
      builder.withValue(Phone.TYPE, Phone.TYPE_MOBILE);
      builder.withValue(Phone.NUMBER, phone);
      builder.withValue(ContactsContract.Data.IS_PRIMARY, 1);
      operationList.add(builder.build());
    }
    if (email != null) {
      builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
      builder.withValueBackReference(Email.RAW_CONTACT_ID, 0);
      builder.withValue(ContactsContract.Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
      builder.withValue(Email.TYPE, Email.TYPE_HOME);
      builder.withValue(Email.DATA, email);
      operationList.add(builder.build());
    }

    try {
      mContext.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operationList);
    } catch (RemoteException e) {
      Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
    } catch (OperationApplicationException e) {
      Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
    }
  }
 public void buildOwnershipInsert(
     CapsuleOwnership ownership,
     boolean withYield,
     int capsuleIdBackRefIndex,
     CapsuleContract.SyncStateAction syncAction) {
   // Build the URI
   Uri uri =
       CapsuleOperations.appendDirtyQueryParam(syncAction, CapsuleContract.Ownerships.CONTENT_URI);
   // Build the INSERT operation
   ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
   builder.withValues(Ownerships.buildContentValues(ownership));
   builder.withYieldAllowed(withYield);
   // Add the back value reference index for the Capsule ID
   if (capsuleIdBackRefIndex >= 0) {
     builder.withValueBackReference(CapsuleContract.Ownerships.CAPSULE_ID, capsuleIdBackRefIndex);
   }
   // Add it to the collection
   this.mOperations.add(builder.build());
 }
 public void buildDiscoveryUpdate(
     CapsuleDiscovery discovery,
     boolean withYield,
     int capsuleIdBackRefIndex,
     CapsuleContract.SyncStateAction syncAction) {
   // Build the URI
   Uri uri =
       CapsuleOperations.appendDirtyQueryParam(
           syncAction,
           ContentUris.withAppendedId(
               CapsuleContract.Discoveries.CONTENT_URI, discovery.getDiscoveryId()));
   // Build the UPDATE operation
   ContentProviderOperation.Builder builder = ContentProviderOperation.newUpdate(uri);
   builder.withValues(Discoveries.buildContentValues(discovery));
   builder.withYieldAllowed(withYield);
   // Add the back value reference for the Capsule ID
   if (capsuleIdBackRefIndex >= 0) {
     builder.withValueBackReference(CapsuleContract.Discoveries.CAPSULE_ID, capsuleIdBackRefIndex);
   }
   // Add it to the collection
   this.mOperations.add(builder.build());
 }
 public final String toString() {
   StringBuilder localStringBuilder = new StringBuilder("Op: ");
   if (a != null) {}
   for (Object localObject = a;
       ;
       localObject = ((ContentProviderOperation.Builder) localObject).build()) {
     localStringBuilder.append(f[0]);
     localObject = ((ContentProviderOperation) localObject).getUri();
     localStringBuilder.append(' ');
     localStringBuilder.append(((Uri) localObject).getPath());
     if (c != null) {
       localStringBuilder.append("Back value of ").append(c).append(": ").append(d);
     }
     return localStringBuilder.toString();
     if (b == null) {
       throw new IllegalArgumentException("Operation must have CPO.Builder");
     }
     localObject = b;
     if (c != null) {
       ((ContentProviderOperation.Builder) localObject).withValueBackReference(c, d + 0);
     }
   }
 }
예제 #7
0
  private static void addContact(Context context, Account account, JuickUser user) {
    //     Log.i(TAG, "Adding contact: " + name);
    ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();

    // Create our RawContact
    ContentProviderOperation.Builder builder =
        ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
    builder.withValue(RawContacts.ACCOUNT_NAME, account.name);
    builder.withValue(RawContacts.ACCOUNT_TYPE, account.type);
    builder.withValue(RawContacts.SYNC1, user.UName);
    operationList.add(builder.build());

    // Nickname
    builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
    builder.withValueBackReference(ContactsContract.CommonDataKinds.Nickname.RAW_CONTACT_ID, 0);
    builder.withValue(
        ContactsContract.Data.MIMETYPE,
        ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE);
    builder.withValue(ContactsContract.CommonDataKinds.Nickname.NAME, user.UName);
    operationList.add(builder.build());

    // StructuredName
    if (user.FullName != null) {
      builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
      builder.withValueBackReference(
          ContactsContract.CommonDataKinds.StructuredName.RAW_CONTACT_ID, 0);
      builder.withValue(
          ContactsContract.Data.MIMETYPE,
          ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
      builder.withValue(
          ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, user.FullName);
      operationList.add(builder.build());
    }

    // Photo
    Bitmap photo = Utils.downloadImage("http://i.juick.com/a/" + user.UID + ".png");
    if (photo != null) {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      photo.compress(Bitmap.CompressFormat.PNG, 100, baos);
      builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
      builder.withValueBackReference(ContactsContract.CommonDataKinds.Photo.RAW_CONTACT_ID, 0);
      builder.withValue(
          ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE);
      builder.withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, baos.toByteArray());
      operationList.add(builder.build());
    }

    // link to profile
    builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
    builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0);
    builder.withValue(
        ContactsContract.Data.MIMETYPE, "vnd.android.cursor.item/vnd.com.juick.profile");
    builder.withValue(ContactsContract.Data.DATA1, user.UID);
    builder.withValue(ContactsContract.Data.DATA2, user.UName);
    builder.withValue(ContactsContract.Data.DATA3, context.getString(R.string.Juick_profile));
    builder.withValue(ContactsContract.Data.DATA4, user.UName);
    operationList.add(builder.build());

    try {
      mContentResolver.applyBatch(ContactsContract.AUTHORITY, operationList);
    } catch (Exception e) {
      //      Log.e(TAG, "Something went wrong during creation! " + e);
      e.printStackTrace();
    }
  }
예제 #8
0
 private static ContentProviderOperation.Builder referenceRawContact(
     ContentProviderOperation.Builder builder, long rawContactId) {
   return rawContactId == -1
       ? builder.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
       : builder.withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId);
 }
예제 #9
0
 private static void a(Account paramAccount, ArrayList<zq> paramArrayList)
 {
   boolean bool = b;
   ArrayList localArrayList1 = new ArrayList();
   StringBuilder localStringBuilder = new StringBuilder();
   ArrayList localArrayList2 = new ArrayList();
   Iterator localIterator = paramArrayList.iterator();
   int k;
   for (int i = 0; ; i = k)
     while (true)
     {
       zq localzq;
       if (localIterator.hasNext())
       {
         localzq = (zq)localIterator.next();
         if (4 + localArrayList1.size() < a);
       }
       try
       {
         App.ib.applyBatch(z[5], localArrayList1);
         localArrayList1.clear();
         if (i > 0);
         localStringBuilder.delete(0, localStringBuilder.length());
         if (localzq.b.indexOf("@") <= 0)
         {
           localArrayList2.add(localzq);
           if (!bool);
         }
         else
         {
           int j = localArrayList1.size();
           localStringBuilder.append(localzq).append(z[9]);
           ContentProviderOperation.Builder localBuilder1 = ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI);
           localBuilder1.withValue(z[4], paramAccount.name);
           localBuilder1.withValue(z[10], paramAccount.type);
           localBuilder1.withValue(z[13], localzq.b);
           localArrayList1.add(localBuilder1.build());
           ContentProviderOperation.Builder localBuilder2 = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI);
           localBuilder2.withValueBackReference(z[6], j);
           localBuilder2.withValue(z[11], z[8]);
           localBuilder2.withValue(z[0], localzq.h);
           localArrayList1.add(localBuilder2.build());
           ContentProviderOperation.Builder localBuilder3 = ContentProviderOperation.newInsert(a(ContactsContract.Data.CONTENT_URI));
           localBuilder3.withValueBackReference(z[6], j);
           localBuilder3.withValue(z[11], z[2]);
           localBuilder3.withValue(z[0], localzq.b);
           localBuilder3.withValue(z[12], App.Mb.getString(2131296836));
           localBuilder3.withValue(z[1], "+" + localzq.b.substring(0, localzq.b.indexOf("@")));
           localArrayList1.add(localBuilder3.build());
           if (Build.VERSION.SDK_INT >= 14)
           {
             ContentProviderOperation.Builder localBuilder4 = ContentProviderOperation.newUpdate(ContactsContract.AggregationExceptions.CONTENT_URI);
             localBuilder4.withValue(z[26], Long.valueOf(localzq.a()));
             localBuilder4.withValueBackReference(z[28], j);
             localBuilder4.withValue(z[24], Integer.valueOf(1));
             localArrayList1.add(localBuilder4.build());
           }
           k = i + 1;
           if (!bool)
             break;
         }
       }
       catch (Exception localException2)
       {
         try
         {
           while (true)
           {
             if (!localArrayList1.isEmpty())
             {
               App.ib.applyBatch(z[5], localArrayList1);
               localArrayList1.clear();
             }
             localStringBuilder.delete(0, localStringBuilder.length());
             return;
             localException2 = localException2;
             g5.d(z[25] + i + "/" + localException2.toString());
           }
         }
         catch (Exception localException1)
         {
           while (true)
           {
             g5.d(z[27] + localException1.toString());
             App.w.a(localArrayList2);
           }
         }
         finally
         {
           App.w.a(localArrayList2);
         }
       }
     }
 }
예제 #10
0
  private static void importOneSimContact(
      final Cursor cursor, final ContentResolver resolver, Account account) {
    final NamePhoneTypePair namePhoneTypePair =
        new NamePhoneTypePair(
            cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
    final String name = namePhoneTypePair.name;
    final int phoneType = namePhoneTypePair.phoneType;
    final String phoneNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA1));
    final String emailAddresses = null;
    final String[] emailAddressArray;

    if (!TextUtils.isEmpty(emailAddresses)) {
      emailAddressArray = emailAddresses.split(",");
    } else {
      emailAddressArray = null;
    }

    final ArrayList<ContentProviderOperation> operationList =
        new ArrayList<ContentProviderOperation>();
    ContentProviderOperation.Builder builder =
        ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
    if (account != null) {
      builder.withValue(RawContacts.ACCOUNT_NAME, account.name);
      builder.withValue(RawContacts.ACCOUNT_TYPE, account.type);
    } else {
      builder.withValues(sEmptyContentValues);
    }
    operationList.add(builder.build());

    builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
    builder.withValueBackReference(StructuredName.RAW_CONTACT_ID, 0);
    builder.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
    builder.withValue(StructuredName.DISPLAY_NAME, name);
    operationList.add(builder.build());

    builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
    builder.withValueBackReference(Phone.RAW_CONTACT_ID, 0);
    builder.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
    builder.withValue(Phone.TYPE, phoneType);
    builder.withValue(Phone.NUMBER, phoneNumber);
    builder.withValue(Data.IS_PRIMARY, 1);
    operationList.add(builder.build());

    if (emailAddresses != null) {
      for (String emailAddress : emailAddressArray) {
        builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
        builder.withValueBackReference(Email.RAW_CONTACT_ID, 0);
        builder.withValue(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
        builder.withValue(Email.TYPE, Email.TYPE_MOBILE);
        builder.withValue(Email.DATA, emailAddress);
        operationList.add(builder.build());
      }
    }

    try {
      resolver.applyBatch(ContactsContract.AUTHORITY, operationList);
    } catch (RemoteException e) {
      Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
    } catch (OperationApplicationException e) {
      Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
    }
  }