• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 
17 package com.android.textclassifier.common.statsd;
18 
19 import android.view.textclassifier.TextClassifier;
20 
21 /** Converts TextClassifier's WidgetTypes to enum values that are logged to server. */
22 final class WidgetTypeConverter {
toLoggingValue(String widgetType)23   public static int toLoggingValue(String widgetType) {
24     switch (widgetType) {
25       case TextClassifier.WIDGET_TYPE_UNKNOWN:
26         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_UNKNOWN;
27       case TextClassifier.WIDGET_TYPE_TEXTVIEW:
28         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_TEXTVIEW;
29       case TextClassifier.WIDGET_TYPE_EDITTEXT:
30         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_EDITTEXT;
31       case TextClassifier.WIDGET_TYPE_UNSELECTABLE_TEXTVIEW:
32         return TextClassifierStatsLog
33             .TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_UNSELECTABLE_TEXTVIEW;
34       case TextClassifier.WIDGET_TYPE_WEBVIEW:
35         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_WEBVIEW;
36       case TextClassifier.WIDGET_TYPE_EDIT_WEBVIEW:
37         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_EDIT_WEBVIEW;
38       case TextClassifier.WIDGET_TYPE_CUSTOM_TEXTVIEW:
39         return TextClassifierStatsLog
40             .TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_CUSTOM_TEXTVIEW;
41       case TextClassifier.WIDGET_TYPE_CUSTOM_EDITTEXT:
42         return TextClassifierStatsLog
43             .TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_CUSTOM_EDITTEXT;
44       case TextClassifier.WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW:
45         return TextClassifierStatsLog
46             .TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_CUSTOM_UNSELECTABLE_TEXTVIEW;
47       case TextClassifier.WIDGET_TYPE_NOTIFICATION:
48         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_NOTIFICATION;
49       case "clipboard": // TODO(tonymak) Replace it with WIDGET_TYPE_CLIPBOARD once S SDK is dropped
50         return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_CLIPBOARD;
51       default: // fall out
52     }
53     return TextClassifierStatsLog.TEXT_SELECTION_EVENT__WIDGET_TYPE__WIDGET_TYPE_UNKNOWN;
54   }
55 
WidgetTypeConverter()56   private WidgetTypeConverter() {}
57 }
58