diff options
author | Ben Murdoch <benm@google.com> | 2010-10-14 07:48:43 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-10-14 07:48:43 -0700 |
commit | daece2e96475d269ea54cd92a290a787071e7298 (patch) | |
tree | 076100cbe30aa8575bcabf830f120765daae6153 | |
parent | 5a49c5977c23f720aa70266e99b93f931869d16c (diff) | |
parent | 36a23dd3e46167507070bd9f0e6237570d721b2f (diff) | |
download | packages_apps_Browser-daece2e96475d269ea54cd92a290a787071e7298.zip packages_apps_Browser-daece2e96475d269ea54cd92a290a787071e7298.tar.gz packages_apps_Browser-daece2e96475d269ea54cd92a290a787071e7298.tar.bz2 |
Merge "Full profile editor and syncing with WebSettings."
-rw-r--r-- | res/layout/autofill_settings_fragment.xml | 299 | ||||
-rw-r--r-- | res/values/strings.xml | 28 | ||||
-rw-r--r-- | src/com/android/browser/AutoFillProfileDatabase.java | 66 | ||||
-rw-r--r-- | src/com/android/browser/AutoFillSettingsFragment.java | 84 | ||||
-rw-r--r-- | src/com/android/browser/BrowserSettings.java | 40 |
5 files changed, 424 insertions, 93 deletions
diff --git a/res/layout/autofill_settings_fragment.xml b/res/layout/autofill_settings_fragment.xml index 35dfbe6..327cbd1 100644 --- a/res/layout/autofill_settings_fragment.xml +++ b/res/layout/autofill_settings_fragment.xml @@ -13,59 +13,260 @@ See the License for the specific language governing permissions and limitations under the License. --> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical"> + android:fillViewport="true"> -<TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceLarge" - android:text="@string/pref_autofill_profile_editor" /> + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="20dip"> -<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:stretchColumns="1" - android:paddingLeft="100dip" - android:paddingRight="100dip" > + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textAppearance="?android:attr/textAppearanceLarge" + android:text="@string/pref_autofill_profile_editor" /> + + <View + android:layout_height="20dip" + android:layout_width="match_parent" /> + + <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:stretchColumns="1"> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_name" /> + <EditText android:id="@+id/autofill_profile_editor_name_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:inputType="textPersonName|textCapWords" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_company_name" /> + <EditText android:id="@+id/autofill_profile_editor_company_name_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="10dip" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_address_line_1" /> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:textAppearance="?android:attr/textAppearanceSmall" + android:text="@string/autofill_profile_editor_address_line_1_hint" /> + </LinearLayout> + <EditText android:id="@+id/autofill_profile_editor_address_line_1_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="10dip" + android:orientation="vertical"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_address_line_2" /> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:textAppearance="?android:attr/textAppearanceSmall" + android:text="@string/autofill_profile_editor_address_line_2_hint" /> + </LinearLayout> + <EditText android:id="@+id/autofill_profile_editor_address_line_2_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_city" /> + <EditText android:id="@+id/autofill_profile_editor_city_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_state" /> + <EditText android:id="@+id/autofill_profile_editor_state_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_zip_code" /> + <EditText android:id="@+id/autofill_profile_editor_zip_code_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_country" /> + <EditText android:id="@+id/autofill_profile_editor_country_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_phone_number" /> + <EditText android:id="@+id/autofill_profile_editor_phone_number_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:singleLine="true" + android:phoneNumber="true" /> + </TableRow> + <TableRow + android:layout_height="match_parent" + android:layout_weight="1"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/autofill_profile_editor_email_address" /> + <EditText android:id="@+id/autofill_profile_editor_email_address_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="10dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:inputType="textEmailAddress" + android:singleLine="true" /> + </TableRow> + </TableLayout> + + <View + android:layout_height="20dip" + android:layout_width="match_parent" /> + + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:gravity="center"> + <Button + android:id="@+id/autofill_profile_editor_save_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/autofill_profile_editor_save_profile" + android:textAppearance="?android:attr/textAppearanceMedium" /> - <TableRow> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="center_vertical" - android:padding="10dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/autofill_profile_editor_name" /> - <EditText android:id="@+id/autofill_profile_editor_name_edit" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:singleLine="true" /> - </TableRow> - <TableRow> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="center_vertical" - android:padding="10dip" - android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/autofill_profile_editor_email_address" /> - <EditText android:id="@+id/autofill_profile_editor_email_address_edit" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:singleLine="true" /> - </TableRow> -</TableLayout> + <Button + android:id="@+id/autofill_profile_editor_cancel_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/cancel" + android:textAppearance="?android:attr/textAppearanceMedium" /> -<Button - android:id="@+id/autofill_profile_editor_save_button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/autofill_profile_editor_save_profile" - android:textAppearance="?android:attr/textAppearanceMedium" /> + <Button + android:id="@+id/autofill_profile_editor_delete_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/autofill_profile_editor_delete_profile" + android:textAppearance="?android:attr/textAppearanceMedium" /> + </LinearLayout> -</LinearLayout> + </LinearLayout> +</ScrollView> diff --git a/res/values/strings.xml b/res/values/strings.xml index 0b2d53a..3e7c644 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -349,14 +349,38 @@ <string name="pref_autofill_profile_editor">AutoFill Settings</string> <!-- Summary for the AutoFill Settings preference [CHAR-LIMIT=none] --> <string name="pref_autofill_profile_editor_summary">Set up & manage data for AutoFilled forms</string> + <!-- String for the user's full name in the AutoFill profile editor. [CHAR-LIMIT=32] --> - <string name="autofill_profile_editor_name">Full Name:</string> + <string name="autofill_profile_editor_name">Full name:</string> <!-- String for the user's e-mail address in the AutoFill profile editor. [CHAR-LIMIT=32] --> - <string name="autofill_profile_editor_email_address">e-mail Address:</string> + <string name="autofill_profile_editor_email_address">Email:</string> + <!-- String for the user's company name in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_company_name">Company name:</string> + <!-- String for the first line of the user's address in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_address_line_1">Address line 1:</string> + <!-- String to suggest to the user the kind of data to be used for the first line of the address. CHAR-LIMIT=64] --> + <string name="autofill_profile_editor_address_line_1_hint">Street address, P.O. box, c/o</string> + <!-- String for the second line of the user's address in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_address_line_2">Address line 2:</string> + <!-- String to suggest to the user the kind of data to be used for the second line of the address. CHAR-LIMIT=64] --> + <string name="autofill_profile_editor_address_line_2_hint">Apartment, suite, unit, building, floor etc.</string> + <!-- String for the user's city or town in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_city">City / Town:</string> + <!-- String for the user's state or province or region in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_state">State / Province / Region:</string> + <!-- String for the user's zip code in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_zip_code">Zip code:</string> + <!-- String for the user's country in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_country">Country:</string> + <!-- String for the user's phone number in the AutoFill profile editor. [CHAR-LIMIT=32] --> + <string name="autofill_profile_editor_phone_number">Phone:</string> + <!-- Button text to save the AutoFill profile [CHAR-LIMIT=20] --> <string name="autofill_profile_editor_save_profile">Save profile</string> <!-- Toast message displayed when the profile has been successfully saved [CHAR-LIMIT=none] --> <string name="autofill_profile_successful_save">Profile saved</string> + <!-- Button text to delete all the AutoFill profile data [CHAR-LIMIT=20] --> + <string name="autofill_profile_editor_delete_profile">Delete profile data</string> <!-- Settings screen, section title --> <string name="pref_privacy_title">Privacy settings</string> diff --git a/src/com/android/browser/AutoFillProfileDatabase.java b/src/com/android/browser/AutoFillProfileDatabase.java index 5557aaf..0204d7e 100644 --- a/src/com/android/browser/AutoFillProfileDatabase.java +++ b/src/com/android/browser/AutoFillProfileDatabase.java @@ -29,7 +29,7 @@ public class AutoFillProfileDatabase { static final String LOGTAG = "AutoFillProfileDatabase"; static final String DATABASE_NAME = "autofill.db"; - static final int DATABASE_VERSION = 1; + static final int DATABASE_VERSION = 2; static final String PROFILES_TABLE_NAME = "profiles"; private AutoFillProfileDatabaseHelper mOpenHelper; private static AutoFillProfileDatabase sInstance; @@ -39,6 +39,14 @@ public class AutoFillProfileDatabase { static final String FULL_NAME = "fullname"; static final String EMAIL_ADDRESS = "email"; + static final String COMPANY_NAME = "companyname"; + static final String ADDRESS_LINE_1 = "addressline1"; + static final String ADDRESS_LINE_2 = "addressline2"; + static final String CITY = "city"; + static final String STATE = "state"; + static final String ZIP_CODE = "zipcode"; + static final String COUNTRY = "country"; + static final String PHONE_NUMBER = "phone"; } private static class AutoFillProfileDatabaseHelper extends SQLiteOpenHelper { @@ -51,7 +59,15 @@ public class AutoFillProfileDatabase { db.execSQL("CREATE TABLE " + PROFILES_TABLE_NAME + " (" + Profiles._ID + " INTEGER PRIMARY KEY," + Profiles.FULL_NAME + " TEXT," - + Profiles.EMAIL_ADDRESS + " TEXT" + + Profiles.EMAIL_ADDRESS + " TEXT," + + Profiles.COMPANY_NAME + " TEXT," + + Profiles.ADDRESS_LINE_1 + " TEXT," + + Profiles.ADDRESS_LINE_2 + " TEXT," + + Profiles.CITY + " TEXT," + + Profiles.STATE + " TEXT," + + Profiles.ZIP_CODE + " TEXT," + + Profiles.COUNTRY + " TEXT," + + Profiles.PHONE_NUMBER + " TEXT" + " );"); } @@ -80,19 +96,49 @@ public class AutoFillProfileDatabase { } public void addOrUpdateProfile(final int id, AutoFillProfile profile) { - final String SQL = "INSERT OR REPLACE INTO " + PROFILES_TABLE_NAME + " (" + final String sql = "INSERT OR REPLACE INTO " + PROFILES_TABLE_NAME + " (" + Profiles._ID + "," + Profiles.FULL_NAME + "," - + Profiles.EMAIL_ADDRESS - + ") VALUES (?,?,?);"; - final Object[] PARAMS = { id, profile.getFullName(), profile.getEmailAddress() }; - getDatabase(true).execSQL(SQL, PARAMS); + + Profiles.EMAIL_ADDRESS + "," + + Profiles.COMPANY_NAME + "," + + Profiles.ADDRESS_LINE_1 + "," + + Profiles.ADDRESS_LINE_2 + "," + + Profiles.CITY + "," + + Profiles.STATE + "," + + Profiles.ZIP_CODE + "," + + Profiles.COUNTRY + "," + + Profiles.PHONE_NUMBER + + ") VALUES (?,?,?,?,?,?,?,?,?,?,?);"; + final Object[] params = { id, + profile.getFullName(), + profile.getEmailAddress(), + profile.getCompanyName(), + profile.getAddressLine1(), + profile.getAddressLine2(), + profile.getCity(), + profile.getState(), + profile.getZipCode(), + profile.getCountry(), + profile.getPhoneNumber() }; + getDatabase(true).execSQL(sql, params); } public Cursor getProfile(int id) { - final String[] COLS = {Profiles.FULL_NAME, Profiles.EMAIL_ADDRESS }; - final String[] SEL_ARGS = { Integer.toString(id) }; - return getDatabase(false).query(PROFILES_TABLE_NAME, COLS, Profiles._ID + "=?", SEL_ARGS, + final String[] cols = { + Profiles.FULL_NAME, + Profiles.EMAIL_ADDRESS, + Profiles.COMPANY_NAME, + Profiles.ADDRESS_LINE_1, + Profiles.ADDRESS_LINE_2, + Profiles.CITY, + Profiles.STATE, + Profiles.ZIP_CODE, + Profiles.COUNTRY, + Profiles.PHONE_NUMBER + }; + + final String[] selectArgs = { Integer.toString(id) }; + return getDatabase(false).query(PROFILES_TABLE_NAME, cols, Profiles._ID + "=?", selectArgs, null, null, null, "1"); } diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java index e41ca56..608c3de 100644 --- a/src/com/android/browser/AutoFillSettingsFragment.java +++ b/src/com/android/browser/AutoFillSettingsFragment.java @@ -26,11 +26,23 @@ import android.view.LayoutInflater; import android.webkit.WebSettings.AutoFillProfile; import android.widget.Button; import android.widget.EditText; +import android.widget.Toast; public class AutoFillSettingsFragment extends Fragment { private static final String LOGTAG = "AutoFillSettingsFragment"; + private EditText mFullNameEdit; + private EditText mEmailEdit; + private EditText mCompanyEdit; + private EditText mAddressLine1Edit; + private EditText mAddressLine2Edit; + private EditText mCityEdit; + private EditText mStateEdit; + private EditText mZipEdit; + private EditText mCountryEdit; + private EditText mPhoneEdit; + public AutoFillSettingsFragment() { } @@ -42,41 +54,69 @@ public class AutoFillSettingsFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { View v = inflater.inflate(R.layout.autofill_settings_fragment, container, false); + mFullNameEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_name_edit); + mEmailEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_email_address_edit); + mCompanyEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_company_name_edit); + mAddressLine1Edit = (EditText)v.findViewById( + R.id.autofill_profile_editor_address_line_1_edit); + mAddressLine2Edit = (EditText)v.findViewById( + R.id.autofill_profile_editor_address_line_2_edit); + mCityEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_city_edit); + mStateEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_state_edit); + mZipEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_zip_code_edit); + mCountryEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_country_edit); + mPhoneEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_phone_number_edit); + Button saveButton = (Button)v.findViewById(R.id.autofill_profile_editor_save_button); saveButton.setOnClickListener(new OnClickListener() { public void onClick(View button) { - View v = getView(); - EditText fullName = (EditText)v.findViewById( - R.id.autofill_profile_editor_name_edit); - EditText email = (EditText)v.findViewById( - R.id.autofill_profile_editor_email_address_edit); BrowserSettings.getInstance().setAutoFillProfile(getActivity(), new AutoFillProfile( - fullName.getText().toString(), - email.getText().toString())); + mFullNameEdit.getText().toString(), + mEmailEdit.getText().toString(), + mCompanyEdit.getText().toString(), + mAddressLine1Edit.getText().toString(), + mAddressLine2Edit.getText().toString(), + mCityEdit.getText().toString(), + mStateEdit.getText().toString(), + mZipEdit.getText().toString(), + mCountryEdit.getText().toString(), + mPhoneEdit.getText().toString())); + } + }); + + Button deleteButton = (Button)v.findViewById(R.id.autofill_profile_editor_delete_button); + deleteButton.setOnClickListener(new OnClickListener() { + public void onClick(View button) { + Toast.makeText(getActivity(), "TODO: Implement me", Toast.LENGTH_SHORT).show(); } }); + Button cancelButton = (Button)v.findViewById(R.id.autofill_profile_editor_cancel_button); + cancelButton.setOnClickListener(new OnClickListener() { + public void onClick(View button) { + getFragmentManager().popBackStack(); + } + }); + // Populate the text boxes with any pre existing AutoFill data. - EditText fullName = (EditText)v.findViewById( - R.id.autofill_profile_editor_name_edit); - EditText email = (EditText)v.findViewById( - R.id.autofill_profile_editor_email_address_edit); AutoFillProfile activeProfile = BrowserSettings.getInstance().getAutoFillProfile(); - fullName.setText(activeProfile.getFullName()); - email.setText(activeProfile.getEmailAddress()); + if (activeProfile != null) { + mFullNameEdit.setText(activeProfile.getFullName()); + mEmailEdit.setText(activeProfile.getEmailAddress()); + mCompanyEdit.setText(activeProfile.getCompanyName()); + mAddressLine1Edit.setText(activeProfile.getAddressLine1()); + mAddressLine2Edit.setText(activeProfile.getAddressLine2()); + mCityEdit.setText(activeProfile.getCity()); + mStateEdit.setText(activeProfile.getState()); + mZipEdit.setText(activeProfile.getZipCode()); + mCountryEdit.setText(activeProfile.getCountry()); + mPhoneEdit.setText(activeProfile.getPhoneNumber()); + } return v; } - - @Override - public void onPause() { - AutoFillProfileDatabase db = - AutoFillProfileDatabase.getInstance(getActivity()); - db.close(); - super.onPause(); - } } diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index d3c1c00..96b6fd2 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -316,16 +316,35 @@ public class BrowserSettings extends Observable { // Load the autofill profile data from the database. We use a database separate // to the browser preference DB to make it easier to support multiple profiles // and switching between them. - mAutoFillProfile = new AutoFillProfile(); AutoFillProfileDatabase autoFillDb = AutoFillProfileDatabase.getInstance(ctx); Cursor c = autoFillDb.getProfile(mActiveAutoFillProfileId); if (c.getCount() > 0) { c.moveToFirst(); - mAutoFillProfile.setFullName(c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.FULL_NAME))); - mAutoFillProfile.setEmailAddress(c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.EMAIL_ADDRESS))); + + String fullName = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.FULL_NAME)); + String email = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.EMAIL_ADDRESS)); + String company = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.COMPANY_NAME)); + String addressLine1 = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.ADDRESS_LINE_1)); + String addressLine2 = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.ADDRESS_LINE_2)); + String city = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.CITY)); + String state = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.STATE)); + String zip = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.ZIP_CODE)); + String country = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.COUNTRY)); + String phone = c.getString(c.getColumnIndex( + AutoFillProfileDatabase.Profiles.PHONE_NUMBER)); + mAutoFillProfile = new AutoFillProfile(fullName, email, company, + addressLine1, addressLine2, city, state, zip, country, + phone); } c.close(); autoFillDb.close(); @@ -686,21 +705,22 @@ public class BrowserSettings extends Observable { private class SaveProfileToDbTask extends AsyncTask<AutoFillProfile, Void, Void> { Context mContext; + AutoFillProfileDatabase mAutoFillProfileDb; public SaveProfileToDbTask(Context ctx) { mContext = ctx; } protected Void doInBackground(AutoFillProfile... values) { - AutoFillProfileDatabase db = - AutoFillProfileDatabase.getInstance(mContext); - db.addOrUpdateProfile(mActiveAutoFillProfileId, values[0]); + mAutoFillProfileDb = AutoFillProfileDatabase.getInstance(mContext); + mAutoFillProfileDb.addOrUpdateProfile(mActiveAutoFillProfileId, values[0]); return null; } protected void onPostExecute(Void result) { - String message = mContext.getString(R.string.autofill_profile_successful_save); - Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); + Toast.makeText(mContext, R.string.autofill_profile_successful_save, + Toast.LENGTH_SHORT).show(); + mAutoFillProfileDb.close(); } } |