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 18 package com.android.mail.analytics; 19 20 import com.android.mail.R; 21 22 public 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.read) { 91 s = "mark_read"; 92 } else if (id == R.id.unread) { 93 s = "mark_unread"; 94 } else if (id == R.id.show_original) { 95 s = "show_original"; 96 } else if (id == R.id.add_photo_attachment) { 97 s = "add_photo_attachment"; 98 } else if (id == R.id.add_video_attachment) { 99 s = "add_video_attachment"; 100 } else if (id == R.id.add_cc_bcc) { 101 s = "add_cc_bcc"; 102 } else if (id == R.id.save) { 103 s = "save_draft"; 104 } else if (id == R.id.send) { 105 s = "send_message"; 106 } else if (id == R.id.discard) { 107 s = "compose_discard_draft"; 108 } else if (id == R.id.search) { 109 s = "search"; 110 } else { 111 s = null; 112 } 113 return s; 114 } 115 116 public static String getAccountTypeForAccount(String name) { 117 if (name == null) { 118 return "unknown"; 119 } 120 121 for (int i = 0; i < SUFFIX_ACCOUNT_TYPES.length; i++) { 122 final String[] row = SUFFIX_ACCOUNT_TYPES[i]; 123 if (name.endsWith(row[0])) { 124 return row[1]; 125 } 126 } 127 128 return "other"; 129 } 130 131 } 132