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.example.android.autofill.service.model;
18 
19 import java.util.List;
20 
21 /**
22  * JSON model class, representing an autofillable field type. It is called "Default" because only
23  * default field types will be included in the packaged JSON. After the JSON is initially read and
24  * written to the DB, the field types can be dynamically added, modified, and removed.
25  *<p>
26  * It contains all of the metadata about the field type. For example, if the field type is
27  * "country", this is the JSON object associated with it:
28  <pre class="prettyprint">
29  {
30      "autofillHints": [
31          "country"
32      ],
33      "fieldType": {
34          "autofillTypes": [
35              1,
36              3
37          ],
38          "fakeData": {
39              "strictExampleSet": [],
40              "textTemplate": "countryseed"
41          },
42          "partition": 1,
43          "saveInfo": 2,
44          "typeName": "country"
45      }
46  }
47  </pre>
48  */
49 public class DefaultFieldTypeWithHints {
50     public DefaultFieldType fieldType;
51     public List<String> autofillHints;
52 
53     public static class DefaultFieldType {
54         public String typeName;
55         public List<Integer> autofillTypes;
56         public int saveInfo;
57         public int partition;
58         public DefaultFakeData fakeData;
59     }
60 
61     public static class DefaultFakeData {
62         public List<String> strictExampleSet;
63         public String textTemplate;
64         public String dateTemplate;
65 
DefaultFakeData(List<String> strictExampleSet, String textTemplate, String dateTemplate)66         public DefaultFakeData(List<String> strictExampleSet, String textTemplate,
67                 String dateTemplate) {
68             this.strictExampleSet = strictExampleSet;
69             this.textTemplate = textTemplate;
70             this.dateTemplate = dateTemplate;
71         }
72     }
73 }
74