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

View File

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

View File

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