Bug 895000 - Set content descriptions on page action buttons. r=wesj

This commit is contained in:
Max Li 2013-07-18 14:50:42 -04:00
Родитель 76ce8020e7
Коммит 99f0b34bc0
3 изменённых файлов: 38 добавлений и 16 удалений

Просмотреть файл

@ -166,33 +166,50 @@ public class PageActionLayout extends LinearLayout implements GeckoEventListener
}
}
private void setActionForView(final ImageButton view, final PageAction pageAction) {
if (pageAction == null) {
view.setTag(null);
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run () {
view.setImageDrawable(null);
view.setVisibility(View.GONE);
view.setContentDescription(null);
}
});
return;
}
view.setTag(pageAction.getID());
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run () {
view.setImageDrawable(pageAction.getDrawable());
view.setVisibility(View.VISIBLE);
view.setContentDescription(pageAction.getTitle());
}
});
}
private void refreshPageActionIcons() {
final Resources resources = mContext.getResources();
for(int index = 0; index < this.getChildCount(); index++) {
final ImageButton v = (ImageButton)this.getChildAt(index);
final PageAction pageAction = getPageActionForViewAt(index);
if (index == (this.getChildCount() - 1)) {
String id = (pageAction != null) ? pageAction.getID() : null;
v.setTag((mPageActionList.size() > mMaxVisiblePageActions) ? MENU_BUTTON_KEY : id);
// If there are more pageactions then buttons, set the menu icon. Otherwise set the page action's icon if there is a page action.
if (index == (this.getChildCount() - 1) && mPageActionList.size() > mMaxVisiblePageActions) {
v.setTag(MENU_BUTTON_KEY);
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run () {
// If there are more pageactions then buttons, set the menu icon. Otherwise set the page action's icon if there is a page action.
Drawable d = (pageAction != null) ? pageAction.getDrawable() : null;
v.setImageDrawable((mPageActionList.size() > mMaxVisiblePageActions) ? resources.getDrawable(R.drawable.icon_pageaction) : d);
v.setImageDrawable(resources.getDrawable(R.drawable.icon_pageaction));
v.setVisibility((pageAction != null) ? View.VISIBLE : View.GONE);
v.setContentDescription(resources.getString(R.string.page_action_dropmarker_description));
}
});
} else {
v.setTag((pageAction != null) ? pageAction.getID() : null);
ThreadUtils.postToUiThread(new Runnable() {
@Override
public void run () {
v.setImageDrawable((pageAction != null) ? pageAction.getDrawable() : null);
v.setVisibility((pageAction != null) ? View.VISIBLE : View.GONE);
}
});
setActionForView(v, pageAction);
}
}
}
@ -313,4 +330,4 @@ public class PageActionLayout extends LinearLayout implements GeckoEventListener
return false;
}
}
}
}

Просмотреть файл

@ -252,7 +252,10 @@ size. -->
<!ENTITY reading_list_removed "Page removed from your Reading List">
<!ENTITY reading_list_failed "Failed to add page to your Reading List">
<!ENTITY reading_list_duplicate "Page already in your Reading List">
<!ENTITY reader "Reader">
<!-- Localization note : These strings are used as alternate text for accessibility.
They are not visible in the UI. -->
<!ENTITY page_action_dropmarker_description "Additional Actions">
<!ENTITY masterpassword_create_title "Create Master Password">
<!ENTITY masterpassword_remove_title "Remove Master Password">

Просмотреть файл

@ -196,6 +196,8 @@
<string name="reading_list_failed">&reading_list_failed;</string>
<string name="reading_list_duplicate">&reading_list_duplicate;</string>
<string name="page_action_dropmarker_description">&page_action_dropmarker_description;</string>
<string name="contextmenu_open_new_tab">&contextmenu_open_new_tab;</string>
<string name="contextmenu_open_private_tab">&contextmenu_open_private_tab;</string>
<string name="contextmenu_open_in_reader">&contextmenu_open_in_reader;</string>