Left & right buttons for display size & text preview

Test: manually open page and verify buttons work. Make sure to check the buttons during setup wizard.
Bug: 386906497
Flag: EXEMPT xml-dependent change
Change-Id: I488d74591d698ad918fd864cf39b2f3133abd463
This commit is contained in:
Riley Jones
2025-02-24 20:01:56 +00:00
parent 29b9665128
commit 998929d688
5 changed files with 105 additions and 13 deletions

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 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="960" android:viewportHeight="960" android:tint="?attr/colorControlNormal" android:autoMirrored="true">
<path android:fillColor="@color/settingslib_materialColorPrimary" android:pathData="M560,720L320,480L560,240L616,296L432,480L616,664L560,720Z"/>
</vector>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 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="960" android:viewportHeight="960" android:tint="?attr/colorControlNormal" android:autoMirrored="true">
<path android:fillColor="@color/settingslib_materialColorPrimary" android:pathData="M504,480L320,296L376,240L616,480L376,720L320,664L504,480Z" />
</vector>

View File

@@ -38,20 +38,47 @@
android:text="@string/screen_zoom_preview_title" android:text="@string/screen_zoom_preview_title"
style="@style/AccessibilityTextReadingPreviewTitle" /> style="@style/AccessibilityTextReadingPreviewTitle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.android.settings.accessibility.TextReadingPreviewPager <com.android.settings.accessibility.TextReadingPreviewPager
android:id="@+id/preview_pager" android:id="@+id/preview_pager"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="217dp" android:layout_height="217dp"
android:contentDescription="@string/preview_pager_content_description" android:contentDescription="@string/preview_pager_content_description"
android:nestedScrollingEnabled="true" /> android:nestedScrollingEnabled="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal">
<ImageButton
android:id="@+id/preview_left_button"
android:src="@drawable/keyboard_arrow_left"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/preview_pager_previous_button"
style="?android:attr/borderlessButtonStyle" />
<com.android.settings.widget.DotsPageIndicator <com.android.settings.widget.DotsPageIndicator
android:id="@+id/page_indicator" android:id="@+id/page_indicator"
style="@style/PreviewPagerPageIndicator" style="@style/PreviewPagerPageIndicator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_vertical"
android:padding="6dp" android:padding="6dp"
android:visibility="gone" /> android:visibility="gone" />
<ImageButton
android:id="@+id/preview_right_button"
android:src="@drawable/keyboard_arrow_right"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:contentDescription="@string/preview_pager_next_button"
style="?android:attr/borderlessButtonStyle" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View File

@@ -80,6 +80,10 @@
<string name="preview_pager_content_description">Preview</string> <string name="preview_pager_content_description">Preview</string>
<!-- Content description for qrcode image. [CHAR LIMIT=none]--> <!-- Content description for qrcode image. [CHAR LIMIT=none]-->
<string name="qr_code_content_description">QR code</string> <string name="qr_code_content_description">QR code</string>
<!-- Previous button for preview pager. [CHAR LIMIT=NONE] -->
<string name="preview_pager_previous_button">Previous preview</string>
<!-- Next button for preview pager. [CHAR LIMIT=NONE] -->
<string name="preview_pager_next_button">Next preview</string>
<!-- Description for the button that makes interface elements smaller. [CHAR_LIMIT=NONE] --> <!-- Description for the button that makes interface elements smaller. [CHAR_LIMIT=NONE] -->
<string name="font_size_make_smaller_desc">Make smaller</string> <string name="font_size_make_smaller_desc">Make smaller</string>

View File

@@ -22,6 +22,7 @@ import android.os.Parcelable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import androidx.preference.Preference; import androidx.preference.Preference;
@@ -99,6 +100,28 @@ public class TextReadingPreviewPreference extends Preference {
(DotsPageIndicator) holder.findViewById(R.id.page_indicator); (DotsPageIndicator) holder.findViewById(R.id.page_indicator);
updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter); updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter);
updatePagerAndIndicator(viewPager, pageIndicator); updatePagerAndIndicator(viewPager, pageIndicator);
viewPager.setClipToOutline(true);
int layoutDirection =
getContext().getResources().getConfiguration().getLayoutDirection();
int previousId = (layoutDirection == View.LAYOUT_DIRECTION_RTL)
? R.id.preview_right_button : R.id.preview_left_button;
int nextId = (layoutDirection == View.LAYOUT_DIRECTION_RTL)
? R.id.preview_left_button : R.id.preview_right_button;
final ImageButton previousButton = previewLayout.findViewById(previousId);
final ImageButton nextButton = previewLayout.findViewById(nextId);
// These call ViewPager#setCurrentItem directly
// because that doesn't force a refresh through notifyChanged().
// We found this avoids a crash in SUW (See b/386906497).
previousButton.setOnClickListener((view) ->
viewPager.setCurrentItem(getCurrentItem() - 1));
previousButton.setContentDescription(getContext().getString(
R.string.preview_pager_previous_button));
nextButton.setOnClickListener((view) ->
viewPager.setCurrentItem(getCurrentItem() + 1));
previousButton.setContentDescription(getContext().getString(
R.string.preview_pager_next_button));
} }
@Override @Override