blob: e41ca5645acf9781daa591a84e571cfe13531201 [file] [log] [blame]
Ben Murdochaf554522010-09-10 22:09:30 +01001/*
2 * Copyright (C) 2010 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
17package com.android.browser;
18
19import android.app.Fragment;
Ben Murdochaf554522010-09-10 22:09:30 +010020import android.os.Bundle;
21import android.util.Log;
22import android.view.View;
23import android.view.ViewGroup;
24import android.view.View.OnClickListener;
25import android.view.LayoutInflater;
Ben Murdoch0cb81892010-10-08 12:41:33 +010026import android.webkit.WebSettings.AutoFillProfile;
Ben Murdochaf554522010-09-10 22:09:30 +010027import android.widget.Button;
28import android.widget.EditText;
Ben Murdochaf554522010-09-10 22:09:30 +010029
30public class AutoFillSettingsFragment extends Fragment {
31
32 private static final String LOGTAG = "AutoFillSettingsFragment";
33
Ben Murdochaf554522010-09-10 22:09:30 +010034 public AutoFillSettingsFragment() {
35
36 }
37
38 @Override
39 public void onCreate(Bundle savedState) {
40 super.onCreate(savedState);
41 }
42
43 @Override
44 public View onCreateView(LayoutInflater inflater, ViewGroup container,
45 Bundle savedInstanceState) {
46 View v = inflater.inflate(R.layout.autofill_settings_fragment, container, false);
47
48 Button saveButton = (Button)v.findViewById(R.id.autofill_profile_editor_save_button);
49 saveButton.setOnClickListener(new OnClickListener() {
50 public void onClick(View button) {
51 View v = getView();
52 EditText fullName = (EditText)v.findViewById(
53 R.id.autofill_profile_editor_name_edit);
54 EditText email = (EditText)v.findViewById(
55 R.id.autofill_profile_editor_email_address_edit);
Ben Murdoch0cb81892010-10-08 12:41:33 +010056 BrowserSettings.getInstance().setAutoFillProfile(getActivity(),
57 new AutoFillProfile(
58 fullName.getText().toString(),
59 email.getText().toString()));
Ben Murdochaf554522010-09-10 22:09:30 +010060 }
61 });
62
Ben Murdoch0cb81892010-10-08 12:41:33 +010063 // Populate the text boxes with any pre existing AutoFill data.
64 EditText fullName = (EditText)v.findViewById(
65 R.id.autofill_profile_editor_name_edit);
66 EditText email = (EditText)v.findViewById(
67 R.id.autofill_profile_editor_email_address_edit);
68 AutoFillProfile activeProfile = BrowserSettings.getInstance().getAutoFillProfile();
69 fullName.setText(activeProfile.getFullName());
70 email.setText(activeProfile.getEmailAddress());
Ben Murdochaf554522010-09-10 22:09:30 +010071
72 return v;
73 }
74
75 @Override
76 public void onPause() {
77 AutoFillProfileDatabase db =
78 AutoFillProfileDatabase.getInstance(getActivity());
79 db.close();
80 super.onPause();
81 }
Ben Murdochaf554522010-09-10 22:09:30 +010082}