<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 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.
  -->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <View
        android:id="@+id/magnification_inner_border"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/magnification_outer_border_margin"
        android:background="@drawable/accessibility_window_magnification_background"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <View
            android:id="@+id/left_handle"
            android:layout_width="@dimen/magnification_border_drag_size"
            android:layout_height="match_parent"
            android:layout_alignParentStart="true"/>

        <View
            android:id="@+id/top_handle"
            android:layout_width="match_parent"
            android:layout_height="@dimen/magnification_border_drag_size"
            android:layout_alignParentTop="true"
            android:accessibilityTraversalAfter="@id/left_handle"/>

        <View
            android:id="@+id/right_handle"
            android:layout_width="@dimen/magnification_border_drag_size"
            android:layout_height="match_parent"
            android:layout_alignParentEnd="true"
            android:accessibilityTraversalAfter="@id/top_handle"/>

        <View
            android:id="@+id/bottom_handle"
            android:layout_width="match_parent"
            android:layout_height="@dimen/magnification_border_drag_size"
            android:layout_alignParentBottom="true"
            android:accessibilityTraversalAfter="@id/right_handle"/>

        <SurfaceView
            android:id="@+id/surface_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/magnification_mirror_surface_margin"/>
    </RelativeLayout>

    <ImageView
        android:id="@+id/top_right_corner"
        android:background="@drawable/accessibility_window_magnification_drag_corner_background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/magnification_drag_corner_margin"
        android:layout_gravity="right|top"
        android:scaleType="center"
        android:contentDescription="@string/magnification_drag_corner_to_resize"
        android:src="@drawable/ic_arrow_top_right_and_bottom_left"
        android:accessibilityTraversalAfter="@id/top_left_corner"/>

    <ImageView
        android:id="@+id/top_left_corner"
        android:background="@drawable/accessibility_window_magnification_drag_corner_background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/magnification_drag_corner_margin"
        android:layout_gravity="left|top"
        android:scaleType="center"
        android:contentDescription="@string/magnification_drag_corner_to_resize"
        android:src="@drawable/ic_arrow_top_left_and_bottom_right"
        android:accessibilityTraversalAfter="@id/bottom_handle"/>

    <ImageView
        android:id="@+id/bottom_right_corner"
        android:background="@drawable/accessibility_window_magnification_drag_corner_background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/magnification_drag_corner_margin"
        android:layout_gravity="right|bottom"
        android:scaleType="center"
        android:contentDescription="@string/magnification_drag_corner_to_resize"
        android:src="@drawable/ic_arrow_top_left_and_bottom_right"
        android:accessibilityTraversalAfter="@id/top_right_corner"/>

    <ImageView
        android:id="@+id/bottom_left_corner"
        android:background="@drawable/accessibility_window_magnification_drag_corner_background"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/magnification_drag_corner_margin"
        android:layout_gravity="left|bottom"
        android:scaleType="center"
        android:contentDescription="@string/magnification_drag_corner_to_resize"
        android:src="@drawable/ic_arrow_top_right_and_bottom_left"
        android:accessibilityTraversalAfter="@id/bottom_right_corner"/>

    <ImageView
        android:id="@+id/drag_handle"
        android:layout_width="@dimen/magnification_drag_view_size"
        android:layout_height="@dimen/magnification_drag_view_size"
        android:layout_gravity="right|bottom"
        android:padding="@dimen/magnifier_drag_handle_padding"
        android:scaleType="center"
        android:src="@drawable/ic_move_magnification"
        android:background="@drawable/accessibility_window_magnification_drag_handle_background_inset"/>

    <ImageView
        android:id="@+id/close_button"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_margin="30dp"
        android:padding="@dimen/magnification_switch_button_padding"
        android:layout_gravity="right|bottom"
        android:scaleType="center"
        android:visibility="gone"
        android:background="@drawable/accessibility_magnifier_btn_bg"
        android:src="@drawable/ic_magnification_menu_close" />
</FrameLayout>
