From 815752af4a61faac210150db4084944fa0f4af33 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Thu, 16 Jun 2011 19:47:08 +0100 Subject: Fix up AutoFill profile editor UI in portrait mode Create layout-port version of the autofill profile editor that extends vertically rather than horizontally. In both portrait and landscape, make the "Save profile" button always visible, remove the "cancel" button as there are already several ways to leave the activity without saving changes and move the "Delete profile" button to the options menu. Change-Id: I3b03c998bc8cb005f066733a3b6979a03396f31f --- .../android/browser/AutoFillSettingsFragment.java | 65 +++++++++++----------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'src/com/android/browser') diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java index e87645e..b282789 100644 --- a/src/com/android/browser/AutoFillSettingsFragment.java +++ b/src/com/android/browser/AutoFillSettingsFragment.java @@ -28,6 +28,9 @@ import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.inputmethod.InputMethodManager; import android.webkit.WebSettings.AutoFillProfile; import android.widget.Button; @@ -131,10 +134,41 @@ public class AutoFillSettingsFragment extends Fragment { @Override public void onCreate(Bundle savedState) { super.onCreate(savedState); + setHasOptionsMenu(true); mSettings = BrowserSettings.getInstance(); } @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.autofill_profile_editor, menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.autofill_profile_editor_delete_profile_menu_id) { + // Clear the UI. + mFullNameEdit.setText(""); + mEmailEdit.setText(""); + mCompanyEdit.setText(""); + mAddressLine1Edit.setText(""); + mAddressLine2Edit.setText(""); + mCityEdit.setText(""); + mStateEdit.setText(""); + mZipEdit.setText(""); + mCountryEdit.setText(""); + mPhoneEdit.setText(""); + + // Update browser settings and native with a null profile. This will + // trigger the current profile to get deleted from the DB. + mSettings.setAutoFillProfile(null, + mHandler.obtainMessage(PROFILE_DELETED_MSG)); + updateButtonState(); + return true; + } + return false; + } + + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.autofill_settings_fragment, container, false); @@ -185,37 +219,6 @@ public class AutoFillSettingsFragment extends Fragment { } }); - Button deleteButton = (Button)v.findViewById(R.id.autofill_profile_editor_delete_button); - deleteButton.setOnClickListener(new OnClickListener() { - public void onClick(View button) { - // Clear the UI. - mFullNameEdit.setText(""); - mEmailEdit.setText(""); - mCompanyEdit.setText(""); - mAddressLine1Edit.setText(""); - mAddressLine2Edit.setText(""); - mCityEdit.setText(""); - mStateEdit.setText(""); - mZipEdit.setText(""); - mCountryEdit.setText(""); - mPhoneEdit.setText(""); - - // Update browser settings and native with a null profile. This will - // trigger the current profile to get deleted from the DB. - mSettings.setAutoFillProfile(null, - mHandler.obtainMessage(PROFILE_DELETED_MSG)); - - updateButtonState(); - } - }); - - Button cancelButton = (Button)v.findViewById(R.id.autofill_profile_editor_cancel_button); - cancelButton.setOnClickListener(new OnClickListener() { - public void onClick(View button) { - closeEditor(); - } - }); - // Populate the text boxes with any pre existing AutoFill data. AutoFillProfile activeProfile = mSettings.getAutoFillProfile(); if (activeProfile != null) { -- cgit v1.1