Multi-Contact Selection

Put your problem here if it does not fit any of the other categories.

Re: Multi-Contact Selection

Postby Phyll » Sun Jan 08, 2012 1:56 am

Hi Skullmonkey,

That just has an xml layout and the checkbox is in it with a textview.

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="8.0">


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="8.0">

    <TextView android:id="@+id/txtExample"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="18sp"
        android:textColor="#FFFFFF"
        android:background="@drawable/custom_selector"
        android:layout_weight="2.0"
        />
    <CheckBox
        android:id="@+id/checkbox"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""
        android:layout_weight="6.0"
        />   

</LinearLayout>       
        <ImageView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:scaleType="fitXY"
          android:gravity="center"
          android:src="@drawable/sep"/>   

</LinearLayout>


This has two linearlayouts. The first brackets the second one and the separator image. That could be better but I was just trying it out. The second linearlayout packages the textview and the checkbox. I took all the text out of the checkbox because I wanted it on that side. Maybe it can be put over there and do away with a separate textview. That xml is passed to the listview adapter to use when it lays out the rows.

I had a heck of a time getting the sizes right for some reason. Those weights didn't behave the way I thought they should. I'll look at your message.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Re: Multi-Contact Selection

Postby Skullmonkey » Wed Jan 11, 2012 4:10 pm

Sorry I have been MIA the past few days. Been working on getting school up and running plus we had a pretty good structure fire that took an entire day.

In response to your PM:
Phyll wrote:Hi Skullmonkey,

Wow, that's a lot of stuff. I take it you're not starting over. I also see you would probably like the same list tied to several (or more) different messages. Pretty much with a button for each message so that's all you have to push.

Getting the contacts:
I think this might be a little simpler than what I saw in your code. Might not be so confusing. Although in this editor it looks all messed up right now. It just logs the list to logcat so you have to put it into an array for a list view. I see you are using the simple adapter to show this. It may not be real obvious how to get to the data or how it uses it in the list.

Code: Select all
       public void getContacts() {
           ContentResolver cr = getContentResolver();
           Cursor qc = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
           if (qc.moveToFirst()) {
               do {
                   Log.d("TEST",
                       qc.getString(qc.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)) + ": " +
                       qc.getString(qc.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
                  }//do
                  while (qc.moveToNext());
               }//if
           }//getcontacts


Hope this helps.

Phyll

You are correct that I am not planning to start over. If I get around to making a customizable one to market, then I will basically be starting over.

Ultimately, I think the part that is confusing me is that I don't see how everything works. I usually do tutorials that explains what each line of code does by putting a comment after it.
The example above I get fully but in the program, I'm not really seeing where or how everything works.
Skullmonkey
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Jan 05, 2012 4:48 am

Re: Multi-Contact Selection

Postby Phyll » Wed Jan 11, 2012 4:51 pm

Hi Skullmonkey,

Here's a better example of using that function. If you looked closely at my texting example, the names are kept in an array with a flag, name, number. This routine goes through the contacts list and picks out everyone with a mobile number, assembles them into one gigantic comma delimited string, and returns it to the caller. It initially sets all the flags to zero, anticipating that only a few would be turned on for a list of recipients. In this case, I take the string and parse it into the array I need for making the calls.

Code: Select all
       public String getContacts() {
           ContentResolver cr = getContentResolver();
           Cursor qc = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
           String sr = "";
           String s ="";
           String s1 = "";
           if (qc.moveToFirst()) {
               do {
                   s = qc.getString(qc.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                   s = clean(s);
                   int type = qc.getInt(qc.getColumnIndex(Phone.TYPE));
                   if (type == Phone.TYPE_MOBILE) {
                       s1 = qc.getString(qc.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                       s1 = clean(s1);
                       if (sr.length()!=0) sr = sr+"\n";
                       sr = sr+"0,"+s+","+s1;
                       }//got a mobile
                  }//do
                  while (qc.moveToNext());
              
               Log.e("CONTACT","File "+sr);
              
               }//if
           return sr;
           }//getcontacts

     public String clean(String in) {
        String s = in.replaceAll(",", "_");
        return s.replaceAll("\n", " ");
         }//clean



If I remember correctly, your code for getting numbers from the contact list is all entangled with a simple list adapter and not easily intercepted for editing or inspecting, things like that. You could make an array for a spinner from a string like this and understand it better I think. But for a full fledged listview with its own adapter and xml and stuff this kind of string and eventual array works pretty good. The other reason I keep it in a string like this is so it can be stored and reloaded to fill a list of recipients that is different from other lists of recipients and the contact list.

I tend to work on everything at once and immediately have a plan how the whole thing fits together.
In this case for instance:

The main screen is a grid of buttons (no real limit) that allows you to send to a group when each button is pressed. You can also change the mode of that screen to allow you to edit the recipient list, the messages that you can send to that particular list and the name of the button itself.

I did establish early on that when a group was selected, you would also have to select a message if there was a choice of messages to send which this system would allow.

There would be two additional list activities where you can edit the items in them.

And finally when it sends, it passes that to a service that runs a thread to send so that you can call it and forget it, maybe even have more than one list being called at a time. Although you might have to check for duplicates but maybe not.

I didn't send these examples as tutorials. You are right about that. These are just code out of projects for the most part. I use T2J to store all these things and then kind of forget about them. When I need one, I create a project in T2J and copy/paste the code out of there. Parts of this will undoubtedly end up there. As for the market, there's already oodles of these kind of apps around so you'll probably have to promote your niche. Just naming it might be somewhat of a challenge.

Glad to see you're still working at it. Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Multi-Contact Selection

Postby Skullmonkey » Fri Jan 13, 2012 3:50 pm

Now, could I take this and make a SQLite table out of it and store it that way? I just think that would be the way to go to be able to call it from the contact selector and when I need to send the page out.
Skullmonkey
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Jan 05, 2012 4:48 am

Re: Multi-Contact Selection

Postby Adamrock » Fri Jan 13, 2012 7:01 pm

Hello friends,

Tidewater portable self-storage units from SMARTBOX are the perfect solution if you are looking for local moving pods, portable stroage, mobile storage, seasonal storage facilities, or to store stuff.

Thanks,
Adam

moving storage containers
Adamrock
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jan 13, 2012 7:01 pm

Re: Multi-Contact Selection

Postby Skullmonkey » Mon Jan 23, 2012 1:48 am

Bringing this back to life. Still need help with this.
Skullmonkey
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Jan 05, 2012 4:48 am

Top

Re: Multi-Contact Selection

Postby Phyll » Mon Jan 23, 2012 2:24 am

Hey Skullmonkey,

Where are you at with this now? Wanting to get a list from the contacts, use that with a listview which has checkboxes and store it with sqlite?

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Multi-Contact Selection

Postby Skullmonkey » Thu Jan 26, 2012 6:21 pm

Right now, I am still trying to get a list with a check box and populate it. After that, I would like to store all of the selected contacts numbers in SQLite. From there, work on getting the contacts to be checked accordingly if they are on the list to send to or not when you bring the contact list up again (say after a reboot).
Skullmonkey
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Jan 05, 2012 4:48 am

Re: Multi-Contact Selection

Postby Adolf_tom » Thu Mar 01, 2012 6:48 pm

Hello friends,

Tidewater portable self-storage units from SMARTBOX are the perfect solution if you are looking for local moving pods, portable storage, mobile storage, seasonal storage facilities, or to store stuff.

Thanks,
Adam

moving companies california
Adolf_tom
Freshman
Freshman
 
Posts: 2
Joined: Thu Mar 01, 2012 6:48 pm

Top
Previous

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests