<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <!-- This outer linear layout protects the fixed dimensions of the dialog.
         The dimensions are not respected if this outer layout is not present. -->
    <LinearLayout
        android:layout_width="@dimen/recurrence_picker_width"
        android:layout_height="@dimen/recurrence_picker_height"
        android:background="@color/recurrence_picker_background"
        android:orientation="vertical"
        android:padding="0dp" >

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="1" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:descendantFocusability="beforeDescendants"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/white"
                    android:paddingLeft="12dip"
                    android:paddingTop="12dip"
                    android:paddingRight="12dip"
                    android:paddingBottom="4dip">

                    <Spinner
                        android:id="@+id/freqSpinner"
                        style="@style/TextAppearance.RecurrencePickerStyle"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_horizontal"
                        android:entries="@array/recurrence_freq"
                        android:gravity="left"
                        android:padding="0dp" />

                    <Switch
                        android:id="@+id/repeat_switch"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:thumb="@drawable/switch_thumb"
                        android:layout_marginLeft="4dp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/options"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:measureAllChildren="true"
                    android:orientation="vertical"
                    android:paddingBottom="4dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="12dp"
                    android:paddingTop="4dp" >

                    <LinearLayout
                        android:id="@+id/intervalGroup"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="start"
                        android:paddingLeft="4dp" >

                        <TextView
                            android:id="@+id/intervalPreText"
                            style="@style/TextAppearance.RecurrencePickerStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" />

                        <EditText
                            android:id="@+id/interval"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:ems="2"
                            android:gravity="center_horizontal"
                            android:inputType="number"
                            android:maxLength="2"
                            android:paddingLeft="4dp"
                            android:paddingRight="4dp"
                            android:selectAllOnFocus="true"
                            android:textSize="15sp"
                            android:singleLine="true" >
                        </EditText>

                        <TextView
                            android:id="@+id/intervalPostText"
                            style="@style/TextAppearance.RecurrencePickerStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" />
                    </LinearLayout>

                    <com.android.calendar.recurrencepicker.LinearLayoutWithMaxWidth
                        android:id="@+id/weekGroup"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:layout_marginRight="4dp"
                        android:layout_marginTop="8dp"
                        android:gravity="center_horizontal"
                        android:orientation="horizontal" >

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />
                    </com.android.calendar.recurrencepicker.LinearLayoutWithMaxWidth>

                    <com.android.calendar.recurrencepicker.LinearLayoutWithMaxWidth
                        android:id="@+id/weekGroup2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="4dp"
                        android:layout_marginRight="4dp"
                        android:gravity="center_horizontal"
                        android:orientation="horizontal"
                        android:visibility="gone" >

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton style="@style/RecurrenceDayOfWeekStyle" />

                        <com.android.calendar.recurrencepicker.WeekButton
                            style="@style/RecurrenceDayOfWeekStyle"
                            android:visibility="invisible" />
                    </com.android.calendar.recurrencepicker.LinearLayoutWithMaxWidth>

                    <RadioGroup
                        android:id="@+id/monthGroup"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical" >

                        <RadioButton
                            android:id="@+id/repeatMonthlyByNthDayOfMonth"
                            style="@style/TextAppearance.RecurrencePickerStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/recurrence_month_pattern_by_day" />

                        <RadioButton
                            android:id="@+id/repeatMonthlyByNthDayOfTheWeek"
                            style="@style/TextAppearance.RecurrencePickerStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" />
                    </RadioGroup>

                    <LinearLayout
                        android:id="@+id/endGroup"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="start"
                        android:orientation="horizontal"
                        android:paddingLeft="0dp" >

                        <Spinner
                            android:id="@+id/endSpinner"
                            style="@style/TextAppearance.RecurrencePickerStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginLeft="-4dp"
                            android:layout_marginRight="8dp"
                            android:entries="@array/recurrence_freq"
                            android:gravity="left|center_vertical"
                            android:padding="0dp" />

                        <EditText
                            android:id="@+id/endCount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_marginBottom="-3dp"
                            android:ems="3"
                            android:gravity="center_horizontal"
                            android:inputType="number"
                            android:maxLength="3"
                            android:selectAllOnFocus="true"
                            android:textSize="15sp"
                            android:singleLine="true" />

                        <TextView
                            android:id="@+id/postEndCount"
                            style="@style/TextAppearance.RecurrencePickerStyle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:gravity="bottom"
                            android:singleLine="true"
                            android:layout_marginBottom="-3dp"
                            android:visibility="gone" />

                        <TextView
                            android:id="@+id/endDate"
                            style="@style/TextAppearance.EditEvent_SpinnerButton"
                            android:textSize="15sp"
                            android:textColor="@color/recurrence_spinner_text_color"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:singleLine="true"
                            android:minWidth="80dp"
                            android:contentDescription="@string/acessibility_recurrence_choose_end_date_description"
                            android:gravity="center_horizontal|bottom"
                            android:layout_marginTop="3dp"
                            android:layout_marginLeft="0dp"
                            android:layout_marginRight="0dp"
                            android:paddingLeft="12dp"
                            android:paddingRight="16dp"
                            android:paddingBottom="8dp"
                            android:visibility="gone" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

        <View
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:layout_marginTop="8dp"
            android:background="?android:attr/listDivider"
            tools:ignore="PxUsage" />

        <LinearLayout
            style="?android:attr/buttonBarStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/done"
                style="?android:attr/buttonBarButtonStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/save_label"
                android:textColor="@color/done_text_color" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>