Fix spinners layout mangling

Setting the gravity to center_vertical seems to make them behave. Not asking.

Also clean up the layout file in general.

b/17380851

Change-Id: I45ac202825295c577dd1a13a3176ac685bd9b9d8
This commit is contained in:
Tony Mantler 2014-09-08 15:51:05 -07:00
parent c845295ffb
commit e5ac64a103
3 changed files with 62 additions and 83 deletions

View File

@ -16,119 +16,102 @@
<!-- Common data-entry area of account options setup screen - check freq, options, etc. --> <!-- Common data-entry area of account options setup screen - check freq, options, etc. -->
<!-- tablet version --> <!-- tablet version -->
<RelativeLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"
> >
<!-- Spinners in a table to line everything up nicely --> <!-- Spinners in a table to line everything up nicely -->
<TableLayout <android.support.v7.widget.GridLayout
android:id="@+id/spinners_table"
android:layout_alignParentTop="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:stretchColumns="1" > app:columnCount="2" >
<TableRow
android:paddingTop="16dip" > <TextView
<TextView android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_width="wrap_content" app:layout_gravity="center_vertical"
android:layout_marginRight="16dip" android:layout_margin="8dp"
android:text="@string/account_setup_options_mail_check_frequency_label" android:text="@string/account_setup_options_mail_check_frequency_label"
style="@style/account_setup_label_text" /> style="@style/account_setup_label_text" />
<Spinner <Spinner
android:id="@+id/account_check_frequency" android:id="@+id/account_check_frequency"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" /> app:layout_gravity="center_vertical|fill_horizontal"/>
</TableRow>
<!-- 2nd row is shown only for EAS accounts --> <!-- 2nd row is shown only for EAS accounts -->
<TableRow <TextView
android:id="@+id/account_sync_window_row" android:id="@+id/account_sync_window_label"
android:paddingTop="16dip" android:layout_height="wrap_content"
android:visibility="gone" > android:layout_width="wrap_content"
<TextView app:layout_gravity="center_vertical"
android:layout_height="wrap_content" android:layout_margin="8dp"
android:layout_width="wrap_content" android:text="@string/account_setup_options_mail_window_label"
android:layout_marginRight="16dip" android:visibility="gone"
android:text="@string/account_setup_options_mail_window_label" style="@style/account_setup_label_text" />
style="@style/account_setup_label_text" /> <Spinner
<Spinner android:id="@+id/account_sync_window"
android:id="@+id/account_sync_window" android:layout_height="wrap_content"
android:layout_height="wrap_content" app:layout_gravity="center_vertical|fill_horizontal"
android:layout_width="match_parent" /> android:visibility="gone" />
</TableRow>
</TableLayout> </android.support.v7.widget.GridLayout>
<CheckBox <CheckBox
android:id="@+id/account_notify" android:id="@+id/account_notify"
android:layout_below="@+id/spinners_table"
style="@style/account_setup_checkbox" style="@style/account_setup_checkbox"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="@string/account_setup_options_notify_label" /> android:text="@string/account_setup_options_notify_label" />
<!-- Contacts sync - hide unless EAS -->
<View <View
android:id="@+id/account_notify_divider" android:id="@+id/account_sync_contacts_divider"
android:layout_below="@+id/account_notify"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1px" android:layout_height="1px"
android:background="@color/account_setup_divider_color" /> android:background="@color/account_setup_divider_color"
<!-- Contacts sync - hide unless EAS --> android:visibility="gone" />
<CheckBox <CheckBox
android:id="@+id/account_sync_contacts" android:id="@+id/account_sync_contacts"
android:layout_below="@+id/account_notify_divider"
style="@style/account_setup_checkbox" style="@style/account_setup_checkbox"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="@string/account_setup_options_sync_contacts_label" android:text="@string/account_setup_options_sync_contacts_label"
android:visibility="gone" /> android:visibility="gone" />
<!-- Calendar sync - hide unless EAS -->
<View <View
android:id="@+id/account_sync_contacts_divider" android:id="@+id/account_sync_calendar_divider"
android:layout_below="@+id/account_sync_contacts"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1px" android:layout_height="1px"
android:background="@color/account_setup_divider_color" android:background="@color/account_setup_divider_color"
android:visibility="gone" /> android:visibility="gone" />
<!-- Calendar sync - hide unless EAS -->
<CheckBox <CheckBox
android:id="@+id/account_sync_calendar" android:id="@+id/account_sync_calendar"
android:layout_below="@+id/account_sync_contacts_divider"
style="@style/account_setup_checkbox" style="@style/account_setup_checkbox"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="@string/account_setup_options_sync_calendar_label" android:text="@string/account_setup_options_sync_calendar_label"
android:visibility="gone" /> android:visibility="gone" />
<!-- Email sync - always show -->
<View <View
android:id="@+id/account_sync_calendar_divider"
android:layout_below="@+id/account_sync_calendar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1px" android:layout_height="1px"
android:background="@color/account_setup_divider_color" android:background="@color/account_setup_divider_color" />
android:visibility="gone" />
<!-- Email sync - always show -->
<CheckBox <CheckBox
android:id="@+id/account_sync_email" android:id="@+id/account_sync_email"
android:layout_below="@+id/account_sync_calendar_divider"
style="@style/account_setup_checkbox" style="@style/account_setup_checkbox"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="@string/account_setup_options_sync_email_label" /> android:text="@string/account_setup_options_sync_email_label" />
<!-- Auto-download attachments - always show, unless POP3 -->
<View <View
android:id="@+id/account_sync_email_divider" android:id="@+id/account_background_attachments_divider"
android:layout_below="@+id/account_sync_email"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1px" android:layout_height="1px"
android:background="@color/account_setup_divider_color" /> android:background="@color/account_setup_divider_color" />
<!-- Auto-download attachments - always show, unless POP3 -->
<CheckBox <CheckBox
android:id="@+id/account_background_attachments" android:id="@+id/account_background_attachments"
android:layout_below="@+id/account_sync_email_divider"
style="@style/account_setup_checkbox" style="@style/account_setup_checkbox"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="@string/account_setup_options_background_attachments_label" /> android:text="@string/account_setup_options_background_attachments_label" />
<View </LinearLayout>
android:id="@+id/account_background_attachments_divider"
android:layout_below="@+id/account_sync_email"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/account_setup_divider_color" />
</RelativeLayout>

View File

@ -28,23 +28,18 @@
android:id="@+id/account_check_frequency" android:id="@+id/account_check_frequency"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" /> android:layout_width="match_parent" />
<LinearLayout <TextView
android:id="@+id/account_sync_window_row" android:id="@+id/account_sync_window_label"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_width="match_parent"
android:visibility="gone" > android:text="@string/account_setup_options_mail_window_label"
<TextView android:visibility="gone"
android:id="@+id/account_sync_window_label" style="@style/account_setup_label_text" />
android:text="@string/account_setup_options_mail_window_label" <Spinner
android:layout_height="wrap_content" android:id="@+id/account_sync_window"
android:layout_width="match_parent" android:layout_height="wrap_content"
style="@style/account_setup_label_text" /> android:layout_width="match_parent"
<Spinner android:visibility="gone" />
android:id="@+id/account_sync_window"
android:layout_height="wrap_content"
android:layout_width="match_parent" />
</LinearLayout>
<CheckBox <CheckBox
android:id="@+id/account_notify" android:id="@+id/account_notify"
style="@style/account_setup_checkbox" style="@style/account_setup_checkbox"

View File

@ -34,12 +34,12 @@ import com.android.emailcommon.service.SyncWindow;
public class AccountSetupOptionsFragment extends AccountSetupFragment { public class AccountSetupOptionsFragment extends AccountSetupFragment {
private Spinner mCheckFrequencyView; private Spinner mCheckFrequencyView;
private Spinner mSyncWindowView; private Spinner mSyncWindowView;
private View mSyncwindowLabel;
private CheckBox mNotifyView; private CheckBox mNotifyView;
private CheckBox mSyncContactsView; private CheckBox mSyncContactsView;
private CheckBox mSyncCalendarView; private CheckBox mSyncCalendarView;
private CheckBox mSyncEmailView; private CheckBox mSyncEmailView;
private CheckBox mBackgroundAttachmentsView; private CheckBox mBackgroundAttachmentsView;
private View mAccountSyncWindowRow;
/** Default sync window for new EAS accounts */ /** Default sync window for new EAS accounts */
private static final int SYNC_WINDOW_EAS_DEFAULT = SyncWindow.SYNC_WINDOW_1_WEEK; private static final int SYNC_WINDOW_EAS_DEFAULT = SyncWindow.SYNC_WINDOW_1_WEEK;
@ -68,7 +68,7 @@ public class AccountSetupOptionsFragment extends AccountSetupFragment {
mSyncEmailView.setChecked(true); mSyncEmailView.setChecked(true);
mBackgroundAttachmentsView = UiUtilities.getView(view, R.id.account_background_attachments); mBackgroundAttachmentsView = UiUtilities.getView(view, R.id.account_background_attachments);
mBackgroundAttachmentsView.setChecked(true); mBackgroundAttachmentsView.setChecked(true);
mAccountSyncWindowRow = UiUtilities.getView(view, R.id.account_sync_window_row); mSyncwindowLabel = UiUtilities.getView(view, R.id.account_sync_window_label);
return view; return view;
} }
@ -96,7 +96,7 @@ public class AccountSetupOptionsFragment extends AccountSetupFragment {
Integer.valueOf(frequencyValues[i].toString()), frequencyEntries[i].toString()); Integer.valueOf(frequencyValues[i].toString()), frequencyEntries[i].toString());
} }
final ArrayAdapter<SpinnerOption> checkFrequenciesAdapter = final ArrayAdapter<SpinnerOption> checkFrequenciesAdapter =
new ArrayAdapter<SpinnerOption>(getActivity(), android.R.layout.simple_spinner_item, new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item,
checkFrequencies); checkFrequencies);
checkFrequenciesAdapter checkFrequenciesAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -130,7 +130,8 @@ public class AccountSetupOptionsFragment extends AccountSetupFragment {
*/ */
private void enableLookbackSpinner(Account account) { private void enableLookbackSpinner(Account account) {
// Show everything // Show everything
mAccountSyncWindowRow.setVisibility(View.VISIBLE); mSyncWindowView.setVisibility(View.VISIBLE);
mSyncwindowLabel.setVisibility(View.VISIBLE);
// Generate spinner entries using XML arrays used by the preferences // Generate spinner entries using XML arrays used by the preferences
final CharSequence[] windowValues = getResources().getTextArray( final CharSequence[] windowValues = getResources().getTextArray(
@ -164,7 +165,7 @@ public class AccountSetupOptionsFragment extends AccountSetupFragment {
} }
final ArrayAdapter<SpinnerOption> windowOptionsAdapter = final ArrayAdapter<SpinnerOption> windowOptionsAdapter =
new ArrayAdapter<SpinnerOption>(getActivity(), android.R.layout.simple_spinner_item, new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item,
windowOptions); windowOptions);
windowOptionsAdapter windowOptionsAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -188,7 +189,7 @@ public class AccountSetupOptionsFragment extends AccountSetupFragment {
* @return Sync window value or null if view is hidden * @return Sync window value or null if view is hidden
*/ */
public Integer getAccountSyncWindowValue() { public Integer getAccountSyncWindowValue() {
if (mAccountSyncWindowRow.getVisibility() != View.VISIBLE) { if (mSyncWindowView.getVisibility() != View.VISIBLE) {
return null; return null;
} }
return (Integer)((SpinnerOption)mSyncWindowView.getSelectedItem()).value; return (Integer)((SpinnerOption)mSyncWindowView.getSelectedItem()).value;