<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/color_background_secondary">

        <include android:id="@+id/toolbar"
            layout="@layout/toolbar" />

        <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/button_bar"
            android:layout_below="@id/toolbar">

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


                <android.support.v7.widget.CardView
                    android:id="@+id/editor"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginLeft="@dimen/activity_horizontal_margin"
                    android:layout_marginRight="@dimen/activity_horizontal_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="@dimen/card_padding_regular">

                        <com.makeramen.roundedimageview.RoundedImageView
                            android:id="@+id/avater"
                            android:layout_width="@dimen/avatar_on_details_screen_size"
                            android:layout_height="@dimen/avatar_on_details_screen_size"
                            android:layout_alignParentTop="true"
                            android:layout_marginRight="@dimen/avatar_item_distance"
                            android:contentDescription="@string/account_image_description"
                            app:riv_corner_radius="2dp"/>

                        <LinearLayout
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_toRightOf="@+id/avater"
                            android:orientation="vertical">

                            <android.support.design.widget.TextInputLayout
                                android:id="@+id/account_jid_layout"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="@string/account_settings_jabber_id"
                                app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
                                app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">

                                <AutoCompleteTextView
                                    android:id="@+id/account_jid"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:imeOptions="actionNext"
                                    android:inputType="textEmailAddress"
                                    style="@style/Widget.Conversations.EditText"/>
                            </android.support.design.widget.TextInputLayout>


                            <android.support.design.widget.TextInputLayout
                                android:id="@+id/account_password_layout"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
                                app:passwordToggleEnabled="true"
                                app:passwordToggleTint="?android:textColorSecondary"
                                app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
                                app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">

                                <android.support.design.widget.TextInputEditText
                                    android:id="@+id/account_password"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:layout_alignParentTop="true"
                                    android:hint="@string/password"
                                    android:inputType="textPassword"
                                    style="@style/Widget.Conversations.EditText"/>
                            </android.support.design.widget.TextInputLayout>

                            <LinearLayout
                                android:id="@+id/name_port"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="8dp"
                                android:orientation="horizontal"
                                android:weightSum="1">

                                <LinearLayout
                                    android:layout_width="0dp"
                                    android:layout_height="match_parent"
                                    android:layout_weight="0.8"
                                    android:orientation="vertical">

                                    <android.support.design.widget.TextInputLayout
                                        android:id="@+id/hostname_layout"
                                        android:layout_width="match_parent"
                                        android:layout_height="wrap_content"
                                        android:hint="@string/account_settings_hostname"
                                        app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
                                        app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">

                                        <EditText
                                            android:id="@+id/hostname"
                                            android:layout_width="fill_parent"
                                            android:layout_height="wrap_content"
                                            android:inputType="textNoSuggestions"
                                            style="@style/Widget.Conversations.EditText"/>
                                    </android.support.design.widget.TextInputLayout>
                                </LinearLayout>

                                <LinearLayout
                                    android:layout_width="0dp"
                                    android:layout_height="match_parent"
                                    android:layout_weight="0.2"
                                    android:orientation="vertical">

                                    <android.support.design.widget.TextInputLayout
                                        android:id="@+id/port_layout"
                                        android:layout_width="match_parent"
                                        android:layout_height="wrap_content"
                                        android:hint="@string/account_settings_port"
                                        app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
                                        app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">

                                        <EditText
                                            android:id="@+id/port"
                                            android:layout_width="match_parent"
                                            android:layout_height="match_parent"
                                            android:inputType="number"
                                            android:maxLength="5"
                                            style="@style/Widget.Conversations.EditText"/>
                                    </android.support.design.widget.TextInputLayout>
                                </LinearLayout>
                            </LinearLayout>

                            <CheckBox
                                android:id="@+id/account_register_new"
                                style="@style/Widget.Conversations.CheckBox"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="8dp"
                                android:text="@string/register_account"/>
                        </LinearLayout>
                    </RelativeLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/os_optimization"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginLeft="@dimen/activity_horizontal_margin"
                    android:layout_marginRight="@dimen/activity_horizontal_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:visibility="gone">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            android:padding="@dimen/card_padding_regular">

                            <TextView
                                android:id="@+id/os_optimization_headline"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="@string/battery_optimizations_enabled"
                                android:textAppearance="@style/TextAppearance.Conversations.Title"/>

                            <TextView
                                android:id="@+id/os_optimization_body"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="8dp"
                                android:text="@string/battery_optimizations_enabled_explained"
                                android:textAppearance="@style/TextAppearance.Conversations.Body1"/>
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="right"
                            android:gravity="right">

                            <Button
                                android:id="@+id/os_optimization_disable"
                                style="@style/Widget.Conversations.Button.Borderless"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:minWidth="0dp"
                                android:paddingLeft="16dp"
                                android:paddingRight="16dp"
                                android:text="@string/disable"
                                android:textColor="?colorAccent"/>
                        </LinearLayout>
                    </LinearLayout>
                </android.support.v7.widget.CardView>


                <android.support.v7.widget.CardView
                    android:id="@+id/stats"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginLeft="@dimen/activity_horizontal_margin"
                    android:layout_marginRight="@dimen/activity_horizontal_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:visibility="gone">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:padding="@dimen/card_padding_regular">

                        <TableLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:shrinkColumns="0"
                            android:stretchColumns="1">

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content"
                                tools:ignore="UselessParent">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_session_established"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/session_est"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>
                            </TableRow>

                        </TableLayout>

                        <TableLayout
                            android:id="@+id/server_info_more"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:shrinkColumns="0"
                            android:stretchColumns="1"
                            android:visibility="gone">

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_pep"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_pep"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_blocking"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_blocking"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_stream_management"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_sm"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_roster_version"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_roster_version"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_carbon_messages"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_carbons"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_mam"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_mam"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_csi"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_csi"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"
                                    tools:ignore="RtlHardcoded"/>
                            </TableRow>

                            <TableRow
                                android:id="@+id/push_row"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_push"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_push"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>
                            </TableRow>

                            <TableRow
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content">

                                <TextView
                                    android:id="@+id/server_info_http_upload_description"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:ellipsize="end"
                                    android:singleLine="true"
                                    android:text="@string/server_info_http_upload"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>

                                <TextView
                                    android:id="@+id/server_info_http_upload"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="right"
                                    android:paddingLeft="4dp"
                                    android:textAppearance="@style/TextAppearance.Conversations.Body1"/>
                            </TableRow>
                        </TableLayout>

                        <RelativeLayout
                            android:id="@+id/pgp_fingerprint_box"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginTop="32dp">

                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentLeft="true"
                                android:layout_centerVertical="true"
                                android:layout_toLeftOf="@+id/action_delete_pgp"
                                android:orientation="vertical">

                                <TextView
                                    android:id="@+id/pgp_fingerprint"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:textAppearance="@style/TextAppearance.Conversations.Fingerprint"/>

                                <TextView
                                    android:id="@+id/pgp_fingerprint_desc"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="@string/openpgp_key_id"
                                    android:textAppearance="@style/TextAppearance.Conversations.Caption"/>
                            </LinearLayout>

                            <ImageButton
                                android:id="@+id/action_delete_pgp"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentRight="true"
                                android:layout_centerVertical="true"
                                android:alpha="?attr/icon_alpha"
                                android:background="?attr/selectableItemBackgroundBorderless"
                                android:padding="@dimen/image_button_padding"
                                android:src="?attr/icon_remove"
                                android:visibility="visible"/>
                        </RelativeLayout>

                        <RelativeLayout
                            android:id="@+id/axolotl_fingerprint_box"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginTop="24dp">

                            <LinearLayout
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentLeft="true"
                                android:layout_centerVertical="true"
                                android:layout_toLeftOf="@+id/axolotl_actions"
                                android:orientation="vertical">

                                <TextView
                                    android:id="@+id/axolotl_fingerprint"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:textAppearance="@style/TextAppearance.Conversations.Fingerprint"/>

                                <TextView
                                    android:id="@+id/own_fingerprint_desc"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:textAppearance="@style/TextAppearance.Conversations.Caption"/>
                            </LinearLayout>

                            <LinearLayout
                                android:id="@+id/axolotl_actions"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentRight="true"
                                android:layout_centerVertical="true"
                                android:orientation="vertical">

                                <ImageButton
                                    android:id="@+id/action_copy_axolotl_to_clipboard"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:alpha="?attr/icon_alpha"
                                    android:background="?attr/selectableItemBackgroundBorderless"
                                    android:contentDescription="@string/copy_omemo_clipboard_description"
                                    android:padding="@dimen/image_button_padding"
                                    android:src="?attr/icon_copy"
                                    android:visibility="visible"/>

                                <ImageButton
                                    android:id="@+id/action_regenerate_axolotl_key"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:alpha="?attr/icon_alpha"
                                    android:background="?attr/selectableItemBackgroundBorderless"
                                    android:contentDescription="@string/regenerate_omemo_key"
                                    android:padding="@dimen/image_button_padding"
                                    android:src="?attr/icon_refresh"
                                    android:visibility="gone"/>

                            </LinearLayout>
                        </RelativeLayout>
                    </LinearLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/other_device_keys_card"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/activity_vertical_margin"
                    android:layout_marginLeft="@dimen/activity_horizontal_margin"
                    android:layout_marginRight="@dimen/activity_horizontal_margin"
                    android:layout_marginTop="@dimen/activity_vertical_margin"
                    android:visibility="gone">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        android:padding="@dimen/card_padding_list">

                        <TextView
                            android:id="@+id/other_device_keys_title"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_margin="@dimen/list_padding"
                            android:text="@string/other_devices"
                            android:textAppearance="@style/TextAppearance.Conversations.Title"/>

                        <LinearLayout
                            android:id="@+id/other_device_keys"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"/>

                        <Button
                            android:id="@+id/clear_devices"
                            style="@style/Widget.Conversations.Button.Borderless"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center_horizontal"
                            android:text="@string/clear_other_devices"
                            android:textColor="?colorAccent"/>
                    </LinearLayout>
                </android.support.v7.widget.CardView>
            </LinearLayout>
        </ScrollView>

        <LinearLayout
            android:id="@+id/button_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentStart="true">

            <Button
                android:id="@+id/cancel_button"
                style="@style/Widget.Conversations.Button.Borderless"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/cancel"/>

            <View
                android:layout_width="1dp"
                android:layout_height="fill_parent"
                android:layout_marginBottom="7dp"
                android:layout_marginTop="7dp"
                android:background="?attr/divider"/>

            <Button
                android:id="@+id/save_button"
                style="@style/Widget.Conversations.Button.Borderless"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:enabled="false"
                android:text="@string/save"/>
        </LinearLayout>

    </RelativeLayout>
</layout>
