Skip to content

Commit

Permalink
[hapjs-platform#631]【1300联盟版本】无障碍新增组件属性方法
Browse files Browse the repository at this point in the history
Change-Id: Ibbecf575c1387ee592ed328b4883476f59d1d465
  • Loading branch information
gaopeng authored and mingcan-mc committed Dec 13, 2023
1 parent 11901e1 commit fdc1222
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center"
android:src="@drawable/menu_dot" />
android:src="@drawable/menu_dot"
android:contentDescription="@string/talkback_titlebar_left_menu_iv"/>
</LinearLayout>

<LinearLayout
Expand Down Expand Up @@ -100,7 +101,8 @@
android:layout_width="@dimen/menubar_dialog_menu_close_image_width"
android:layout_height="@dimen/menubar_dialog_menu_close_image_height"
android:layout_gravity="center"
android:src="@drawable/menu_close" />
android:src="@drawable/menu_close"
android:contentDescription="@string/talkback_close"/>
</LinearLayout>
</LinearLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,10 @@
<string name="shortcut_add_shortcut_mini">加桌</string>
<string name="shortcut_add_shortcut_desktop">桌面</string>
<string name="shortcut_add_shortcut_long">添加到桌面</string>

<!--menubar 无障碍-->
<string name="talkback_titlebar_left_menu_iv">更多-按钮</string>
<string name="popup_window_default_title">弹出式窗口</string>
<string name="talkback_close">关闭-按钮</string>
<string name="talkback_common_button">按钮</string>
</resources>
8 changes: 7 additions & 1 deletion core/runtime/android/runtime/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,14 @@
<string name="analyzer_network_retry_reopen">, and start debugging again.</string>
<string name="menubar_tips_special">Click to add <xliff:g id="app">%1$s</xliff:g> to the desktop,which is more convenient to use next time.</string>
<string name="menubar_added_shortcut_tips">Added to desktop \"<xliff:g id="app">%1$s</xliff:g>\" </string>
<!-- shortcutbtn-->
<!-- 加桌、桌面-->
<string name="shortcut_add_shortcut_mini">Add to desktop</string>
<string name="shortcut_add_shortcut_desktop">Add to desktop</string>
<string name="shortcut_add_shortcut_long">Add to desktop</string>

<!--menubar 无障碍-->
<string name="talkback_titlebar_left_menu_iv">more-button</string>
<string name="popup_window_default_title">pop-up window</string>
<string name="talkback_close">close-button</string>
<string name="talkback_common_button">button</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.hapjs.component.Component;
import org.hapjs.model.videodata.VideoCacheData;
import org.hapjs.model.videodata.VideoCacheManager;
import org.hapjs.system.utils.TalkBackUtils;
import org.hapjs.widgets.R;
import org.hapjs.widgets.video.ExoPlayer;
import org.hapjs.widgets.video.IMediaPlayer;
Expand Down Expand Up @@ -112,6 +113,7 @@ public void onClick(View v) {
private TextView mTitle;
private int mTitleHeight;
private final String TAG = "MediaController";
private boolean mIsEnableTalkBack;
private FullscreenChangeListener mFullScreenChangeListener;
private OnSeekBarChangeListener mOnSeekBarChangeListener;
// There are two scenarios that can trigger the seekbar listener to trigger:
Expand Down Expand Up @@ -205,6 +207,7 @@ public MediaController(Context context, AttributeSet attrs) {
public MediaController(Context context, boolean useFastForward) {
super(context);
mContext = context;
mIsEnableTalkBack = TalkBackUtils.isEnableTalkBack(mContext, false);
makeControllerView();
}

Expand Down Expand Up @@ -245,6 +248,9 @@ private void initControllerView(View v) {
if (mPauseButton != null) {
mPauseButton.requestFocus();
mPauseButton.setOnClickListener(mPauseListener);
if (mIsEnableTalkBack) {
mPauseButton.setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_play));
}
}
mProgress = (SeekBar) v.findViewById(R.id.mediacontroller_progress);
if (mProgress != null) {
Expand Down Expand Up @@ -279,6 +285,10 @@ public void onClick(View v) {
mTitleBarContainer = v.findViewById(R.id.title_bar_container);
v.findViewById(R.id.back_arrow).setOnClickListener(view -> mVideoView.exitFullscreen());
mTitle = v.findViewById(R.id.title);
if (mIsEnableTalkBack) {
v.findViewById(R.id.back_arrow).setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_exit_full_screen));
mFullButton.setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_full_screen));
}
}

private void applyButtonVisibility() {
Expand Down Expand Up @@ -591,8 +601,14 @@ private void updatePausePlay() {

if (mPlayer.isPlaying()) {
mPauseButton.setImageResource(R.drawable.ic_media_pause);
if (mIsEnableTalkBack) {
mPauseButton.setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_pause));
}
} else {
mPauseButton.setImageResource(R.drawable.ic_media_play);
if (mIsEnableTalkBack) {
mPauseButton.setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_play));
}
}
}

Expand Down Expand Up @@ -642,7 +658,9 @@ public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) {

public void enterFullscreen() {
mFullButton.setImageResource(R.drawable.ic_media_exit_fullscreen);

if (mIsEnableTalkBack) {
mFullButton.setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_exit_full_screen));
}
mTitleBarContainer.setVisibility(VISIBLE);
View statusBarPlaceholder = mTitleBarContainer.findViewById(R.id.status_bar_bg);
LinearLayout.LayoutParams params =
Expand All @@ -658,7 +676,9 @@ public void enterFullscreen() {

public void exitFullscreen() {
mFullButton.setImageResource(R.drawable.ic_media_enter_fullscreen);

if (mIsEnableTalkBack) {
mFullButton.setContentDescription(getContext().getResources().getString(R.string.talkback_video_controller_full_screen));
}
mTitleBarContainer.setVisibility(GONE);
mVideoView.getComponent().getRootComponent().resetStatusBar();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@
<string name="talkback_select">选中</string>
<!--radio-->
<string name="talkback_radio">单选框</string>
<!--video 无障碍-->
<string name="talkback_video_controller_play">播放</string>
<string name="talkback_video_controller_pause">暂停</string>
<string name="talkback_video_controller_full_screen">全屏</string>
<string name="talkback_video_controller_exit_full_screen">退出全屏</string>

</resources>
5 changes: 5 additions & 0 deletions core/runtime/android/widgets/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@
<string name="talkback_select">Check</string>
<!--radio-->
<string name="talkback_radio">Radio</string>
<!--video 无障碍-->
<string name="talkback_video_controller_play">play</string>
<string name="talkback_video_controller_pause">pause</string>
<string name="talkback_video_controller_full_screen">full screen</string>
<string name="talkback_video_controller_exit_full_screen">exit full screen</string>
</resources>

0 comments on commit fdc1222

Please sign in to comment.