AnalyticsUtils.java revision e003b4cc4a23e6d394998bebe26430a361c5ac29
1/*******************************************************************************
2 *      Copyright (C) 2013 Google Inc.
3 *      Licensed to The Android Open Source Project.
4 *
5 *      Licensed under the Apache License, Version 2.0 (the "License");
6 *      you may not use this file except in compliance with the License.
7 *      You may obtain a copy of the License at
8 *
9 *           http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *      Unless required by applicable law or agreed to in writing, software
12 *      distributed under the License is distributed on an "AS IS" BASIS,
13 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *      See the License for the specific language governing permissions and
15 *      limitations under the License.
16 *******************************************************************************/
17
18package com.android.mail.analytics;
19
20import com.android.mail.R;
21
22public class AnalyticsUtils {
23
24    /**
25     * Map of email address suffixes to tags sent to analytics.
26     */
27    private static final String[][] SUFFIX_ACCOUNT_TYPES = {
28        {"@gmail.com", "gmail"},
29        {"@googlemail.com", "gmail"},
30        {"@google.com", "google-corp"},
31        {"@hotmail.com", "hotmail"},
32        {"@outlook.com", "outlook"},
33        {"@yahoo.com", "yahoo"},
34    };
35
36    // individual apps should chain this method call with their own lookup tables if they have
37    // app-specific menu items
38    public static String getMenuItemString(int id) {
39        final String s;
40        if (id == R.id.archive) {
41            s = "archive";
42        } else if (id == R.id.remove_folder) {
43            s = "remove_folder";
44        } else if (id == R.id.delete) {
45            s = "delete";
46        } else if (id == R.id.discard_drafts) {
47            s = "discard_drafts";
48        } else if (id == R.id.mark_important) {
49            s = "mark important";
50        } else if (id == R.id.mark_not_important) {
51            s = "mark not important";
52        } else if (id == R.id.mute) {
53            s = "mute";
54        } else if (id == R.id.report_phishing) {
55            s = "report_phishing";
56        } else if (id == R.id.report_spam) {
57            s = "report_spam";
58        } else if (id == R.id.mark_not_spam) {
59            s = "mark_not_spam";
60        } else if (id == R.id.report_phishing) {
61            s = "report_phishing";
62        } else if (id == R.id.compose) {
63            s = "compose";
64        } else if (id == R.id.refresh) {
65            s = "refresh";
66        } else if (id == R.id.settings) {
67            s = "settings";
68        } else if (id == R.id.folder_options) {
69            s = "folder_options";
70        } else if (id == R.id.help_info_menu_item) {
71            s = "help";
72        } else if (id == R.id.feedback_menu_item) {
73            s = "feedback";
74        } else if (id == R.id.manage_folders_item) {
75            s = "manage_folders";
76        } else if (id == R.id.move_to) {
77            s = "move_to";
78        } else if (id == R.id.change_folders) {
79            s = "change_folders";
80        } else if (id == R.id.move_to_inbox) {
81            s = "move_to_inbox";
82        } else if (id == R.id.empty_trash) {
83            s = "empty_trash";
84        } else if (id == R.id.empty_spam) {
85            s = "empty_spam";
86        } else if (id == android.R.id.home) {
87            s = "home";
88        } else if (id == R.id.inside_conversation_unread) {
89            s = "inside_conversation_unread";
90        } else if (id == R.id.show_original) {
91            s = "show_original";
92        } else if (id == R.id.add_photo_attachment) {
93            s = "add_photo_attachment";
94        } else if (id == R.id.add_video_attachment) {
95            s = "add_video_attachment";
96        } else if (id == R.id.add_cc_bcc) {
97            s = "add_cc_bcc";
98        } else if (id == R.id.save) {
99            s = "save_draft";
100        } else if (id == R.id.send) {
101            s = "send_message";
102        } else if (id == R.id.discard) {
103            s = "compose_discard_draft";
104        } else if (id == R.id.search) {
105            s = "search";
106        } else {
107            s = null;
108        }
109        return s;
110    }
111
112    public static String getAccountTypeForAccount(String name) {
113        if (name == null) {
114            return "unknown";
115        }
116
117        for (int i = 0; i < SUFFIX_ACCOUNT_TYPES.length; i++) {
118            final String[] row = SUFFIX_ACCOUNT_TYPES[i];
119            if (name.endsWith(row[0])) {
120                return row[1];
121            }
122        }
123
124        return "other";
125    }
126
127}
128