@Override
  public Contacts create() {
    Contacts contacts = new Contacts(identityTestFactory.create());

    contacts.put(a);
    contacts.put(b);

    return contacts;
  }
 /** 同步通讯录 */
 public void cuContacts() {
   Contacts cts = new Contacts(mContext);
   ArrayList<Contact> cc = cts.getPhoneContacts();
   for (int i = 0; i < cc.size(); i++) {
     if (contactdao.search(cc.get(i).get_cid()) == 0) {
       contactdao.add(cc.get(i).get_cid(), cc.get(i).get_name());
     }
   }
 }
Beispiel #3
0
    // criar função para retornar o emelento do array
    @Override
    public View getView(int position, View view, ViewGroup parent) {
      if (view == null) view = getLayoutInflater().inflate(R.layout.listview_item, parent, false);

      Contact currentContact = Contacts.get(position);

      TextView name = (TextView) view.findViewById(R.id.contactName);
      name.setText(currentContact.get_name());

      // The below 3 statements are used to update the text to hyperlink
      // or normal next depending on the state of their checkbox.
      TextView phone = (TextView) view.findViewById(R.id.phoneNumber);
      phone.setText(makeLinkOrText(R.id.checkBox, currentContact.get_phone()));

      TextView email = (TextView) view.findViewById(R.id.emailAddress);
      email.setText(makeLinkOrText(R.id.checkBox2, currentContact.get_email()));

      TextView address = (TextView) view.findViewById(R.id.cAddress);
      address.setText(makeLinkOrText(R.id.checkBox3, currentContact.get_address()));

      ImageView ivContactImage = (ImageView) view.findViewById(R.id.ivContactImage);
      ivContactImage.setImageURI(currentContact.get_imageURI());

      return view;
    }
  private static void queryContact() {
    System.out.println("Enter existing contact name: ");
    String name = scanner.nextLine();
    Contacts existingContactRecord = mobilePhone.queryContact(name);

    if (existingContactRecord == null) {
      System.out.println("Contact not found");
      return;
    }

    System.out.println(
        "Name: "
            + existingContactRecord.getContactName()
            + ", phone number is "
            + existingContactRecord.getPhoneNumber());
  }
Beispiel #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            // test notification
            Notifications not = new Notifications();
            synchronized (not) {
              not.notification(getBaseContext());
            }
          }
        });
    Config.context = this;

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    phone();

    Contacts c = new Contacts();
    c.contacts();

    SocketConnection sc = new SocketConnection();
    sc.setAction("get_messages");
    sc.execute();
    SocketConnection sc2 = new SocketConnection();
    sc2.setAction("get_new_messages");
    sc2.execute();
  }
  public void populate(
      final MessageInfoHolder target,
      final Message m,
      final FolderInfoHolder folder,
      final Account account) {
    final Contacts contactHelper =
        RakuPhotoMail.showContactName() ? Contacts.getInstance(mContext) : null;
    try {
      LocalMessage message = (LocalMessage) m;
      target.message = message;
      target.compareDate = message.getSentDate();
      if (target.compareDate == null) {
        target.compareDate = message.getInternalDate();
      }

      target.folder = folder;

      target.read = message.isSet(Flag.SEEN);
      target.answered = message.isSet(Flag.ANSWERED);
      target.flagged = message.isSet(Flag.FLAGGED);
      target.downloaded = message.isSet(Flag.X_DOWNLOADED_FULL);
      target.partially_downloaded = message.isSet(Flag.X_DOWNLOADED_PARTIAL);

      Address[] addrs = message.getFrom();

      if (addrs.length > 0 && account.isAnIdentity(addrs[0])) {
        CharSequence to =
            Address.toFriendly(message.getRecipients(RecipientType.TO), contactHelper);
        target.compareCounterparty = to.toString();
        target.sender =
            new SpannableStringBuilder(mContext.getString(R.string.message_to_label)).append(to);
      } else {
        target.sender = Address.toFriendly(addrs, contactHelper);
        target.compareCounterparty = target.sender.toString();
      }

      if (addrs.length > 0) {
        target.senderAddress = addrs[0].getAddress();
      } else {
        // a reasonable fallback "whomever we were corresponding with
        target.senderAddress = target.compareCounterparty;
      }

      target.uid = message.getUid();

      target.account = account.getDescription();
      target.uri =
          "email://messages/"
              + account.getAccountNumber()
              + "/"
              + m.getFolder().getName()
              + "/"
              + m.getUid();

    } catch (MessagingException me) {
      Log.w(RakuPhotoMail.LOG_TAG, "Unable to load message info", me);
    }
  }
  private static void addNewContact() {
    System.out.println("Enter new contact name:");
    String name = scanner.nextLine();
    System.out.println("Enter phone number:");
    String phone = scanner.nextLine();
    Contacts newContact = Contacts.createContact(name, phone);

    if (mobilePhone.addNewContact(newContact)) {
      System.out.println("New contact added: " + name + ", phone " + phone);
    } else {
      System.out.println("Cannot add, " + name + " name is already on file");
    }
  }
Beispiel #8
0
  /**
   * Erstellt einen Eintrag aus dem jcbSelName ("Vorname Name" oder "Standort Name") und jcbSelAdd
   * ("AdressText")
   */
  public Entry createEntry(String jcbSelName, String jcbSelAdd) {
    c = serializer.getContactsFromXML();
    String name = jcbSelName.split("\\s+")[1];
    String prename = jcbSelName.split("\\s+")[0];
    Entry e = c.getEntries().get(c.search(jcbSelName));
    Entry res;

    if (e.isPerson()) {
      Person p = new Person(name, prename);
      Address a = new Address();
      a.setAddressText(jcbSelAdd);
      p.add(a);
      res = p;
    } else {
      Component p = new Component(name, prename);
      Address a = new Address();
      a.setAddressText(jcbSelAdd);
      p.add(a);
      res = p;
    }
    return res;
  }
Beispiel #9
0
  @Test
  public void validatePhone() {
    assertNull(contacts.validatePhone("Aa333"));
    assertNull(contacts.validatePhone("4444"));
    assertNull(contacts.validatePhone("999-999-999"));
    assertNull(contacts.validatePhone("88 888 888"));
    assertNull(contacts.validatePhone("+372 56 888 888"));

    assertNotNull(contacts.validatePhone("55555"));
    assertNotNull(contacts.validatePhone("+37256888888"));
  }
Beispiel #10
0
  // Get the contact they picked to notify
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CONTACT_PICKER_RESULT) {
      Uri uri = data.getData();
      Cursor cur = getContentResolver().query(uri, null, null, null, null);
      try {
        cur.moveToFirst();
        int col = cur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
        String num = cur.getString(col);
        Contacts.add(num);
      } catch (NullPointerException n) {

      }
    }
  }
Beispiel #11
0
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
    Uri contactUri =
        Contacts.getLookupUri(
            cursor.getLong(ContactsQuery.ID), cursor.getString(ContactsQuery.LOOKUP_KEY));

    ViewHolder holder = (ViewHolder) view.getTag();
    holder.text1.setText(cursor.getString(ContactsQuery.DISPLAY_NAME));
    holder.icon.assignContactUri(contactUri);

    Picasso.with(context)
        .load(contactUri)
        .placeholder(R.drawable.contact_picture_placeholder)
        .tag(context)
        .into(holder.icon);
  }
  private static void updateContact() {
    System.out.println("Enter existing contact name: ");
    String name = scanner.nextLine();
    Contacts existingContactRecord = mobilePhone.queryContact(name);

    if (existingContactRecord == null) {
      System.out.println("Contact not found");
      return;
    }

    System.out.println("Enter new contact name: ");
    String newName = scanner.nextLine();
    System.out.println("Enter new contact phone number: ");
    String newNumber = scanner.nextLine();

    Contacts newContact = Contacts.createContact(newName, newNumber);

    if (mobilePhone.updateContact(existingContactRecord, newContact)) {
      System.out.println("Successfully updated record");
    } else {
      System.out.println("Error updating record");
    }
  }
Beispiel #13
0
 /** Findet raus ob der aktuelle Eintrag vom Typ Person oder Komponente ist */
 public boolean isPerson() {
   c = serializer.getContactsFromXML();
   Entry e = c.getEntries().get(c.search(this.name));
   return e.getClass().isInstance(new Person());
 }
Beispiel #14
0
  @Test
  public void validateEmail() {
    assertNull(contacts.validateEmail("vadim"));
    assertNull(contacts.validateEmail("*****@*****.**"));
    assertNull(contacts.validateEmail("[email protected]"));
    assertNull(contacts.validateEmail("[email protected]"));
    assertNull(contacts.validateEmail("*****@*****.**"));
    assertNull(contacts.validateEmail("*****@*****.**"));
    assertNull(contacts.validateEmail("vadim()*@gmail.com"));
    assertNull(contacts.validateEmail("vadim@%*.com"));
    assertNull(contacts.validateEmail("*****@*****.**"));
    assertNull(contacts.validateEmail("*****@*****.**"));
    assertNull(contacts.validateEmail("vadim@[email protected]"));
    assertNull(contacts.validateEmail("[email protected]"));

    assertNotNull(contacts.validateEmail("*****@*****.**"));
    assertNotNull(contacts.validateEmail("*****@*****.**"));
    assertNotNull(contacts.validateEmail("*****@*****.**"));
    assertNotNull(contacts.validateEmail("*****@*****.**"));
    assertNotNull(contacts.validateEmail("*****@*****.**"));
    assertNotNull(contacts.validateEmail("*****@*****.**"));
    assertNotNull(contacts.validateEmail("*****@*****.**"));
  }
Beispiel #15
0
  @Test
  public void validateName() {
    assertNull(contacts.validateName("vadim"));
    assertNull(contacts.validateName("Vadim"));
    assertNull(contacts.validateName("Vadim V"));
    assertNull(contacts.validateName("Vadim Vadim Vadim"));
    assertNull(contacts.validateName("Vadim v Vadim"));
    assertNull(contacts.validateName("Vadim V Vadim"));
    assertNull(contacts.validateName("Vadim V V Vadim"));
    assertNull(contacts.validateName("Vadim v. Vadim"));
    assertNull(contacts.validateName("888 Vadim"));
    assertNull(contacts.validateName("Vadim.Vadim"));
    assertNull(contacts.validateName("Vadim-Vadim"));
    assertNull(contacts.validateName("Vadim_Vadim"));

    assertNotNull(contacts.validateName("Vadim Vadim"));
    assertNotNull(contacts.validateName("Vadim V. Vadim"));
    assertNotNull(contacts.validateName("Vadim V. V. Vadim"));
  }