1 /*
2  * Copyright (C) 2017 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 foo.bar.filled;
18 
19 import android.annotation.NonNull;
20 import android.app.Activity;
21 import android.os.Bundle;
22 import android.view.View;
23 import android.view.autofill.AutofillManager;
24 import android.widget.Button;
25 
26 import foo.bar.filled.R;
27 
28 public class MainActivity extends Activity {
29     public static final String LOG_TAG = "PrintActivity";
30 
31     @Override
onCreate(Bundle savedInstanceState)32     protected void onCreate(Bundle savedInstanceState) {
33         super.onCreate(savedInstanceState);
34         setContentView(R.layout.activity_main);
35 
36         if (!CustomLinearLayout.VIRTUAL) {
37             findViewById(R.id.username).setImportantForAutofill(
38                     View.IMPORTANT_FOR_AUTOFILL_AUTO);
39             findViewById(R.id.password).setImportantForAutofill(
40                     View.IMPORTANT_FOR_AUTOFILL_AUTO);
41         }
42 
43         Button finishButton = findViewById(R.id.finish);
44         finishButton.setOnClickListener((view) -> finish());
45 
46         AutofillManager autofillManager = getSystemService(AutofillManager.class);
47         autofillManager.registerCallback(new AutofillManager.AutofillCallback() {
48             @Override
49             public void onAutofillEvent(@NonNull View view, int event) {
50                 super.onAutofillEvent(view, event);
51             }
52         });
53     }
54 }
55