Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b88a494 authored by Santiago Etchebehere's avatar Santiago Etchebehere
Browse files

[ThemePicker 4/N] Add a PreviewPager widget

Simply a ViewPager linked to a PageIndicator widget and
arrows that can be used to page over that ViewPager.

Bug: 120559294
Change-Id: Ic90b8df9b746deef8b9ef0af851db236a6cf9121
parent 6d6e84d8
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
<!--
     Copyright (C) 2018 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="?android:attr/colorForeground"
        android:pathData="M16.41,5.41l-1.41,-1.41l-8,8l8,8l1.41,-1.41l-6.58,-6.59"/>
</vector>
+24 −0
Original line number Diff line number Diff line
<!--
     Copyright (C) 2018 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="?android:attr/colorForeground"
        android:pathData="M7.59,18.59l1.41,1.41l8,-8l-8,-8l-1.41,1.41l6.58,6.59"/>
</vector>
+78 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--

     Copyright (C) 2018 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/preview_viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <FrameLayout
        android:id="@+id/indicator_container"
        android:layout_width="match_parent"
        android:layout_height="@dimen/indicator_container_height"
        android:layout_gravity="bottom">

        <com.android.customization.widget.PageIndicator
            android:id="@+id/page_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <FrameLayout
            android:id="@+id/arrow_previous"
            android:layout_width="@dimen/indicator_arrow_touch_area_size"
            android:layout_height="@dimen/indicator_arrow_touch_area_size"
            android:layout_gravity="center_vertical|start"
            android:layout_marginStart="@dimen/indicator_arrow_container_margin_horizontal"
            android:background="?android:attr/selectableItemBackgroundBorderless"
            android:contentDescription="@string/previous_page_content_description"
            android:visibility="gone">

            <ImageView
                android:layout_width="@dimen/indicator_arrow_size"
                android:layout_height="@dimen/indicator_arrow_size"
                android:layout_gravity="center"
                android:contentDescription="@null"
                android:src="@drawable/ic_arrow_back_24px" />
        </FrameLayout>

        <FrameLayout
            android:id="@+id/arrow_next"
            android:layout_width="@dimen/indicator_arrow_touch_area_size"
            android:layout_height="@dimen/indicator_arrow_touch_area_size"
            android:layout_gravity="center_vertical|end"
            android:layout_marginEnd="@dimen/indicator_arrow_container_margin_horizontal"
            android:background="?android:attr/selectableItemBackgroundBorderless"
            android:contentDescription="@string/next_page_content_description"
            android:visibility="gone">

            <ImageView
                android:layout_width="@dimen/indicator_arrow_size"
                android:layout_height="@dimen/indicator_arrow_size"
                android:layout_gravity="center"
                android:contentDescription="@null"
                android:src="@drawable/ic_arrow_forward_24px" />
        </FrameLayout>
    </FrameLayout>
</LinearLayout>
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
@@ -20,5 +20,15 @@

    <dimen name="preview_indicator_width">16dp</dimen>
    <dimen name="preview_indicator_height">8dp</dimen>
    <dimen name="indicator_container_height">48dp</dimen>
    <dimen name="indicator_container_divider_height">1dp</dimen>
    <dimen name="indicator_arrow_size">24dp</dimen>
    <dimen name="indicator_arrow_touch_area_size">48dp</dimen>

    <dimen name="indicator_arrow_container_margin_horizontal">4dp</dimen>
    <dimen name="preview_page_gap">16dp</dimen>
    <dimen name="preview_page_horizontal_margin">56dp</dimen>
    <dimen name="preview_page_top_margin">16dp</dimen>
    <dimen name="preview_page_bottom_margin">2dp</dimen>

</resources>
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -40,4 +40,9 @@

    <!-- Accessibility label for paging indicator in theme picker preview [CHAR LIMIT=NONE] -->
    <string name="accessibility_preview_pager">Page <xliff:g name="current_page" example="1">%1$d</xliff:g> of <xliff:g name="num_pages" example="2">%2$d</xliff:g></string>
    <!-- Content description of the next button to bring user to the next preview page.[CHAR LIMIT=NONE] -->
    <string name="next_page_content_description">Next</string>
    <!-- Content description of the previous button to bring user to the previous preview page. [CHAR LIMIT=NONE] -->
    <string name="previous_page_content_description">Previous</string>

</resources>
Loading