1/*
2 * Copyright (C) 2017 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 */
16
17package com.android.settings.applications;
18
19import android.content.Intent;
20import android.net.Uri;
21import android.provider.ContactsContract;
22import android.provider.MediaStore;
23
24/**
25 * UI grouping of important intents that can be configured by device and profile owners.
26 */
27public enum EnterpriseDefaultApps {
28    BROWSER(new Intent[] {
29            buildIntent(Intent.ACTION_VIEW, Intent.CATEGORY_BROWSABLE, "http:", null)}),
30    CALENDAR(new Intent[] {
31            buildIntent(Intent.ACTION_INSERT, null, null, "vnd.android.cursor.dir/event")}),
32    CAMERA(new Intent[] {
33            new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
34            new Intent(MediaStore.ACTION_VIDEO_CAPTURE)}),
35    CONTACTS(new Intent[] {
36            buildIntent(Intent.ACTION_PICK, null, null, ContactsContract.Contacts.CONTENT_TYPE)}),
37    EMAIL(new Intent[] {
38            new Intent(Intent.ACTION_SENDTO), new Intent(Intent.ACTION_SEND),
39            new Intent(Intent.ACTION_SEND_MULTIPLE)}),
40    MAP(new Intent[] {buildIntent(Intent.ACTION_VIEW, null, "geo:", null)}),
41    PHONE(new Intent[] {new Intent(Intent.ACTION_DIAL), new Intent(Intent.ACTION_CALL)});
42    private final Intent[] mIntents;
43
44    EnterpriseDefaultApps(Intent[] intents) {
45        mIntents = intents;
46    }
47
48    public Intent[] getIntents() {
49        return mIntents;
50    }
51
52    private static Intent buildIntent(String action, String category, String protocol,
53            String type) {
54        final Intent intent = new Intent(action);
55        if (category != null) {
56            intent.addCategory(category);
57        }
58        if (protocol != null) {
59            intent.setData(Uri.parse(protocol));
60        }
61        if (type != null) {
62            intent.setType(type);
63        }
64        return intent;
65    }
66
67}
68