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.discard_outbox) { 49 s = "discard_outbox"; 50 } else if (id == R.id.mark_important) { 51 s = "mark important"; 52 } else if (id == R.id.mark_not_important) { 53 s = "mark not important"; 54 } else if (id == R.id.mute) { 55 s = "mute"; 56 } else if (id == R.id.report_phishing) { 57 s = "report_phishing"; 58 } else if (id == R.id.report_spam) { 59 s = "report_spam"; 60 } else if (id == R.id.mark_not_spam) { 61 s = "mark_not_spam"; 62 } else if (id == R.id.report_phishing) { 63 s = "report_phishing"; 64 } else if (id == R.id.compose) { 65 s = "compose"; 66 } else if (id == R.id.refresh) { 67 s = "refresh"; 68 } else if (id == R.id.settings) { 69 s = "settings"; 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.move_to) { 75 s = "move_to"; 76 } else if (id == R.id.change_folders) { 77 s = "change_folders"; 78 } else if (id == R.id.move_to_inbox) { 79 s = "move_to_inbox"; 80 } else if (id == R.id.empty_trash) { 81 s = "empty_trash"; 82 } else if (id == R.id.empty_spam) { 83 s = "empty_spam"; 84 } else if (id == android.R.id.home) { 85 s = "home"; 86 } else if (id == R.id.inside_conversation_unread) { 87 s = "inside_conversation_unread"; 88 } else if (id == R.id.read) { 89 s = "mark_read"; 90 } else if (id == R.id.unread) { 91 s = "mark_unread"; 92 } else if (id == R.id.show_original) { 93 s = "show_original"; 94 } else if (id == R.id.add_file_attachment) { 95 s = "add_file_attachment"; 96 } else if (id == R.id.add_photo_attachment) { 97 s = "add_photo_attachment"; 98 } else if (id == R.id.add_cc_bcc) { 99 s = "add_cc_bcc"; 100 } else if (id == R.id.save) { 101 s = "save_draft"; 102 } else if (id == R.id.send) { 103 s = "send_message"; 104 } else if (id == R.id.discard) { 105 s = "compose_discard_draft"; 106 } else if (id == R.id.search) { 107 s = "search"; 108 } else if (id == R.id.print_all) { 109 s = "print_all"; 110 } else if (id == R.id.print_message) { 111 s = "print_message"; 112 } else if (id == R.id.star) { 113 s = "star"; 114 } else if (id == R.id.remove_star) { 115 s = "unstar"; 116 } else if (id == R.id.reply) { 117 s = "reply"; 118 } else if (id == R.id.reply_all) { 119 s = "reply_all"; 120 } else if (id == R.id.forward) { 121 s = "forward"; 122 } else if (id == R.id.edit_draft) { 123 s = "edit_draft"; 124 } else if (id == R.id.send_date) { 125 s = "expand_message_details"; 126 } else if (id == R.id.details_expanded_content || id == R.id.hide_details) { 127 s = "collapse_message_details"; 128 } else if (id == R.id.upper_header) { 129 s = "message_upper_header"; 130 } else if (id == R.id.download_again || id == R.id.menu_download_again) { 131 s = "download_again"; 132 } else if (id == R.id.menu_save) { 133 s = "photo_save"; 134 } else if (id == R.id.menu_save_all) { 135 s = "photo_save_all"; 136 } else if (id == R.id.menu_share) { 137 s = "photo_share"; 138 } else if (id == R.id.menu_share_all) { 139 s = "photo_share_all"; 140 } else if (id == R.id.show_pictures_text) { 141 s = "show_pictures"; 142 } else { 143 s = null; 144 } 145 return s; 146 } 147 148 public static String getAccountTypeForAccount(String name) { 149 if (name == null) { 150 return "unknown"; 151 } 152 153 for (int i = 0; i < SUFFIX_ACCOUNT_TYPES.length; i++) { 154 final String[] row = SUFFIX_ACCOUNT_TYPES[i]; 155 if (name.endsWith(row[0])) { 156 return row[1]; 157 } 158 } 159 160 return "other"; 161 } 162 163} 164