1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16package com.android.contacts;
17
18import android.content.Context;
19import android.content.CursorLoader;
20import android.net.Uri;
21import android.provider.ContactsContract.Groups;
22
23/**
24 * Group loader for the group list that includes details such as the number of contacts per group
25 * and number of groups per account. This list is sorted by account type, account name, where the
26 * group names are in alphabetical order. Note that the list excludes default, favorite, and deleted
27 * groups.
28 */
29public final class GroupListLoader extends CursorLoader {
30
31    private final static String[] COLUMNS = new String[] {
32        Groups.ACCOUNT_NAME,
33        Groups.ACCOUNT_TYPE,
34        Groups.DATA_SET,
35        Groups._ID,
36        Groups.TITLE,
37        Groups.SUMMARY_COUNT,
38    };
39
40    public final static int ACCOUNT_NAME = 0;
41    public final static int ACCOUNT_TYPE = 1;
42    public final static int DATA_SET = 2;
43    public final static int GROUP_ID = 3;
44    public final static int TITLE = 4;
45    public final static int MEMBER_COUNT = 5;
46
47    private static final Uri GROUP_LIST_URI = Groups.CONTENT_SUMMARY_URI;
48
49    public GroupListLoader(Context context) {
50        super(context, GROUP_LIST_URI, COLUMNS, Groups.ACCOUNT_TYPE + " NOT NULL AND "
51                + Groups.ACCOUNT_NAME + " NOT NULL AND " + Groups.AUTO_ADD + "=0 AND " +
52                Groups.FAVORITES + "=0 AND " + Groups.DELETED + "=0", null,
53                Groups.ACCOUNT_TYPE + ", " + Groups.ACCOUNT_NAME + ", " + Groups.DATA_SET + ", " +
54                Groups.TITLE + " COLLATE LOCALIZED ASC");
55    }
56}
57