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:
19
res/drawable/keyboard_arrow_left.xml
Normal file
19
res/drawable/keyboard_arrow_left.xml
Normal 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>
|
19
res/drawable/keyboard_arrow_right.xml
Normal file
19
res/drawable/keyboard_arrow_right.xml
Normal 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>
|
@@ -38,20 +38,45 @@
|
|||||||
android:text="@string/screen_zoom_preview_title"
|
android:text="@string/screen_zoom_preview_title"
|
||||||
style="@style/AccessibilityTextReadingPreviewTitle" />
|
style="@style/AccessibilityTextReadingPreviewTitle" />
|
||||||
|
|
||||||
<com.android.settings.accessibility.TextReadingPreviewPager
|
<LinearLayout
|
||||||
android:id="@+id/preview_pager"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="217dp"
|
|
||||||
android:contentDescription="@string/preview_pager_content_description"
|
|
||||||
android:nestedScrollingEnabled="true" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.DotsPageIndicator
|
|
||||||
android:id="@+id/page_indicator"
|
|
||||||
style="@style/PreviewPagerPageIndicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:orientation="vertical">
|
||||||
android:padding="6dp"
|
<com.android.settings.accessibility.TextReadingPreviewPager
|
||||||
android:visibility="gone" />
|
android:id="@+id/preview_pager"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="217dp"
|
||||||
|
android:contentDescription="@string/preview_pager_content_description"
|
||||||
|
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
|
||||||
|
android:id="@+id/page_indicator"
|
||||||
|
style="@style/PreviewPagerPageIndicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:padding="6dp"
|
||||||
|
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>
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
@@ -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();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user