зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 88bc05432845 (bug 1027135) for talos remote-trobopan test failure
This commit is contained in:
Родитель
c697516add
Коммит
81ccbff0be
|
@ -18,7 +18,6 @@ import org.mozilla.gecko.widget.GeckoPopupMenu;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -59,8 +58,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNumberShown(int count) {
|
private void setNumberShown(int count) {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
mMaxVisiblePageActions = count;
|
mMaxVisiblePageActions = count;
|
||||||
|
|
||||||
for(int index = 0; index < count; index++) {
|
for(int index = 0; index < count; index++) {
|
||||||
|
@ -77,26 +74,12 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(final String event, final NativeJSObject message, final EventCallback callback) {
|
public void handleMessage(String event, NativeJSObject message, EventCallback callback) {
|
||||||
// NativeJSObject cannot be used off of the Gecko thread, so convert it to a Bundle.
|
|
||||||
final Bundle bundle = message.toBundle();
|
|
||||||
|
|
||||||
ThreadUtils.postToUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
handleUiMessage(event, bundle);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleUiMessage(final String event, final Bundle message) {
|
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
if (event.equals("PageActions:Add")) {
|
if (event.equals("PageActions:Add")) {
|
||||||
final String id = message.getString("id");
|
final String id = message.getString("id");
|
||||||
final String title = message.getString("title");
|
final String title = message.getString("title");
|
||||||
final String imageURL = message.getString("icon", null);
|
final String imageURL = message.optString("icon", null);
|
||||||
final boolean important = message.getBoolean("important");
|
final boolean mImportant = message.getBoolean("important");
|
||||||
|
|
||||||
addPageAction(id, title, imageURL, new OnPageActionClickListeners() {
|
addPageAction(id, title, imageURL, new OnPageActionClickListeners() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -109,7 +92,7 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("PageActions:LongClicked", id));
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("PageActions:LongClicked", id));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}, important);
|
}, mImportant);
|
||||||
} else if (event.equals("PageActions:Remove")) {
|
} else if (event.equals("PageActions:Remove")) {
|
||||||
final String id = message.getString("id");
|
final String id = message.getString("id");
|
||||||
|
|
||||||
|
@ -118,8 +101,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPageAction(final String id, final String title, final String imageData, final OnPageActionClickListeners mOnPageActionClickListeners, boolean mImportant) {
|
private void addPageAction(final String id, final String title, final String imageData, final OnPageActionClickListeners mOnPageActionClickListeners, boolean mImportant) {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
final PageAction pageAction = new PageAction(id, title, null, mOnPageActionClickListeners, mImportant);
|
final PageAction pageAction = new PageAction(id, title, null, mOnPageActionClickListeners, mImportant);
|
||||||
|
|
||||||
int insertAt = mPageActionList.size();
|
int insertAt = mPageActionList.size();
|
||||||
|
@ -140,8 +121,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePageAction(String id) {
|
private void removePageAction(String id) {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
for(int i = 0; i < mPageActionList.size(); i++) {
|
for(int i = 0; i < mPageActionList.size(); i++) {
|
||||||
if (mPageActionList.get(i).getID().equals(id)) {
|
if (mPageActionList.get(i).getID().equals(id)) {
|
||||||
mPageActionList.remove(i);
|
mPageActionList.remove(i);
|
||||||
|
@ -152,8 +131,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageButton createImageButton() {
|
private ImageButton createImageButton() {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
ImageButton imageButton = new ImageButton(mContext, null, R.style.UrlBar_ImageButton_Icon);
|
ImageButton imageButton = new ImageButton(mContext, null, R.style.UrlBar_ImageButton_Icon);
|
||||||
imageButton.setLayoutParams(new LayoutParams(mContext.getResources().getDimensionPixelSize(R.dimen.page_action_button_width), LayoutParams.MATCH_PARENT));
|
imageButton.setLayoutParams(new LayoutParams(mContext.getResources().getDimensionPixelSize(R.dimen.page_action_button_width), LayoutParams.MATCH_PARENT));
|
||||||
imageButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
imageButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||||
|
@ -188,21 +165,29 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
private void setActionForView(final ImageButton view, final PageAction pageAction) {
|
private void setActionForView(final ImageButton view, final PageAction pageAction) {
|
||||||
if (pageAction == null) {
|
if (pageAction == null) {
|
||||||
view.setTag(null);
|
view.setTag(null);
|
||||||
view.setImageDrawable(null);
|
ThreadUtils.postToUiThread(new Runnable() {
|
||||||
view.setVisibility(View.GONE);
|
@Override
|
||||||
view.setContentDescription(null);
|
public void run () {
|
||||||
|
view.setImageDrawable(null);
|
||||||
|
view.setVisibility(View.GONE);
|
||||||
|
view.setContentDescription(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setTag(pageAction.getID());
|
view.setTag(pageAction.getID());
|
||||||
view.setImageDrawable(pageAction.getDrawable());
|
ThreadUtils.postToUiThread(new Runnable() {
|
||||||
view.setVisibility(View.VISIBLE);
|
@Override
|
||||||
view.setContentDescription(pageAction.getTitle());
|
public void run () {
|
||||||
|
view.setImageDrawable(pageAction.getDrawable());
|
||||||
|
view.setVisibility(View.VISIBLE);
|
||||||
|
view.setContentDescription(pageAction.getTitle());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshPageActionIcons() {
|
private void refreshPageActionIcons() {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
final Resources resources = mContext.getResources();
|
final Resources resources = mContext.getResources();
|
||||||
for(int index = 0; index < this.getChildCount(); index++) {
|
for(int index = 0; index < this.getChildCount(); index++) {
|
||||||
final ImageButton v = (ImageButton)this.getChildAt(index);
|
final ImageButton v = (ImageButton)this.getChildAt(index);
|
||||||
|
@ -211,9 +196,14 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
// 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 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) {
|
if (index == (this.getChildCount() - 1) && mPageActionList.size() > mMaxVisiblePageActions) {
|
||||||
v.setTag(MENU_BUTTON_KEY);
|
v.setTag(MENU_BUTTON_KEY);
|
||||||
v.setImageDrawable(resources.getDrawable(R.drawable.icon_pageaction));
|
ThreadUtils.postToUiThread(new Runnable() {
|
||||||
v.setVisibility((pageAction != null) ? View.VISIBLE : View.GONE);
|
@Override
|
||||||
v.setContentDescription(resources.getString(R.string.page_action_dropmarker_description));
|
public void run () {
|
||||||
|
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 {
|
} else {
|
||||||
setActionForView(v, pageAction);
|
setActionForView(v, pageAction);
|
||||||
}
|
}
|
||||||
|
@ -221,8 +211,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageAction getPageActionForViewAt(int index) {
|
private PageAction getPageActionForViewAt(int index) {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We show the user the most recent pageaction added since this keeps the user aware of any new page actions being added
|
* We show the user the most recent pageaction added since this keeps the user aware of any new page actions being added
|
||||||
* Also, the order of the pageAction is important i.e. if a page action is added, instead of shifting the pagactions to the
|
* Also, the order of the pageAction is important i.e. if a page action is added, instead of shifting the pagactions to the
|
||||||
|
@ -244,8 +232,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageAction getPageActionWithId(String id) {
|
private PageAction getPageActionWithId(String id) {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
for(int i = 0; i < mPageActionList.size(); i++) {
|
for(int i = 0; i < mPageActionList.size(); i++) {
|
||||||
PageAction pageAction = mPageActionList.get(i);
|
PageAction pageAction = mPageActionList.get(i);
|
||||||
if (pageAction.getID().equals(id)) {
|
if (pageAction.getID().equals(id)) {
|
||||||
|
@ -256,8 +242,6 @@ public class PageActionLayout extends LinearLayout implements NativeEventListene
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMenu(View mPageActionButton, int toShow) {
|
private void showMenu(View mPageActionButton, int toShow) {
|
||||||
ThreadUtils.assertOnUiThread();
|
|
||||||
|
|
||||||
if (mPageActionsMenu == null) {
|
if (mPageActionsMenu == null) {
|
||||||
mPageActionsMenu = new GeckoPopupMenu(mPageActionButton.getContext(), mPageActionButton);
|
mPageActionsMenu = new GeckoPopupMenu(mPageActionButton.getContext(), mPageActionButton);
|
||||||
mPageActionsMenu.inflate(0);
|
mPageActionsMenu.inflate(0);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче