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 package com.example.android.autofill.app.antipatterns;
17 
18 import android.app.Activity;
19 import android.content.Intent;
20 import android.os.Bundle;
21 
22 import com.example.android.autofill.app.R;
23 import com.example.android.autofill.app.WelcomeActivity;
24 
25 /**
26  * This activity is the second step in a multi-screen login workflow that uses 2 distinct activities
27  * for username and password, which causes 2 Autofill Save UI to be shown.
28  *
29  * <p>This is a bad pattern anyways&mdash;apps should use Fragments in such scenarios.
30  */
31 /*
32  * TODO list
33  * - use ConstraintLayout
34  * - use strings.xml insteaf of hardcoded strings
35  * - add icon with information
36  * - extend AppCompatActivity
37  */
38 public final class PasswordOnlyActivity extends Activity {
39 
40     @Override
onCreate(Bundle savedInstanceState)41     protected void onCreate(Bundle savedInstanceState) {
42         super.onCreate(savedInstanceState);
43         setContentView(R.layout.password_only_activity);
44 
45         findViewById(R.id.login).setOnClickListener((v) -> login());
46     }
47 
getContentView()48     protected int getContentView() {
49         return R.layout.password_only_activity;
50     }
51 
login()52     void login() {
53         startActivity(new Intent(this, WelcomeActivity.class));
54         finish();
55     }
56 }
57