Left & Right buttons for Display size & text preview

Test: manually open page and verify buttons work
Bug: 386906497
Flag: EXEMPT small internal change dependant on xml
Change-Id: I49ecf2940be897725a0864cf898655837a3e2399
This commit is contained in:
Riley Jones
2025-02-07 01:01:34 +00:00
parent a7caa23deb
commit 30e63f6178
5 changed files with 102 additions and 14 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="@android:color/white" 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="@android:color/white" android:pathData="M504,480L320,296L376,240L616,480L376,720L320,664L504,480Z" />
</vector>

View File

@@ -38,20 +38,45 @@
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"
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"
style="?android:attr/borderlessButtonStyle" />
</LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View File

@@ -78,6 +78,11 @@
<!-- Content description for preview pager. [CHAR LIMIT=NONE] --> <!-- Content description for preview pager. [CHAR LIMIT=NONE] -->
<string name="preview_pager_content_description">Preview</string> <string name="preview_pager_content_description">Preview</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>
<!-- 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>

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,23 @@ 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);
previousButton.setOnClickListener((view) -> setCurrentItem(getCurrentItem() - 1));
previousButton.setContentDescription(getContext().getString(
R.string.preview_pager_previous_button));
nextButton.setOnClickListener((view) -> setCurrentItem(getCurrentItem() + 1));
previousButton.setContentDescription(getContext().getString(
R.string.preview_pager_next_button));
} }
@Override @Override
@@ -158,7 +176,9 @@ public class TextReadingPreviewPreference extends Preference {
Preconditions.checkNotNull(mPreviewAdapter, Preconditions.checkNotNull(mPreviewAdapter,
"Preview adapter is null, you should init the preview adapter first"); "Preview adapter is null, you should init the preview adapter first");
if (currentItem != mCurrentItem) { if (currentItem < 0 || currentItem >= mPreviewAdapter.getCount()) {
return;
} else if (currentItem != mCurrentItem) {
mCurrentItem = currentItem; mCurrentItem = currentItem;
notifyChanged(); notifyChanged();
} }