зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1379066
- 6. PageAction supports Private Mode r=jwu
PageAction are views which be added to awesomebar dynamically, for example "Reader mode icon". Now let it becomes ThemedImageButton to support Private mode. MozReview-Commit-ID: HQXgJWL19Oz --HG-- extra : rebase_source : 7cfde97d4f1eba02497d0219e5b3b61273489625
This commit is contained in:
Родитель
f468181c80
Коммит
de3e7cc58e
|
@ -11,6 +11,7 @@
|
||||||
<dimen name="autocomplete_row_height">32dp</dimen>
|
<dimen name="autocomplete_row_height">32dp</dimen>
|
||||||
|
|
||||||
<dimen name="browser_toolbar_height">48dp</dimen>
|
<dimen name="browser_toolbar_height">48dp</dimen>
|
||||||
|
<dimen name="browser_toolbar_image_button_width">@dimen/page_action_button_width</dimen>
|
||||||
<!-- This value is the height of the Tabs Panel header view
|
<!-- This value is the height of the Tabs Panel header view
|
||||||
(browser_toolbar_height) minus the height of the indicator
|
(browser_toolbar_height) minus the height of the indicator
|
||||||
(6dp). This value should change when the height of the view changes. -->
|
(6dp). This value should change when the height of the view changes. -->
|
||||||
|
|
|
@ -8,12 +8,15 @@ package org.mozilla.gecko.toolbar;
|
||||||
import org.mozilla.gecko.EventDispatcher;
|
import org.mozilla.gecko.EventDispatcher;
|
||||||
import org.mozilla.gecko.GeckoAppShell;
|
import org.mozilla.gecko.GeckoAppShell;
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
|
import org.mozilla.gecko.skin.SkinConfig;
|
||||||
import org.mozilla.gecko.util.ResourceDrawableUtils;
|
import org.mozilla.gecko.util.ResourceDrawableUtils;
|
||||||
import org.mozilla.gecko.util.BundleEventListener;
|
import org.mozilla.gecko.util.BundleEventListener;
|
||||||
import org.mozilla.gecko.util.EventCallback;
|
import org.mozilla.gecko.util.EventCallback;
|
||||||
import org.mozilla.gecko.util.GeckoBundle;
|
import org.mozilla.gecko.util.GeckoBundle;
|
||||||
import org.mozilla.gecko.util.ThreadUtils;
|
import org.mozilla.gecko.util.ThreadUtils;
|
||||||
import org.mozilla.gecko.widget.GeckoPopupMenu;
|
import org.mozilla.gecko.widget.GeckoPopupMenu;
|
||||||
|
import org.mozilla.gecko.widget.themed.ThemedImageButton;
|
||||||
|
import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -32,7 +35,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class PageActionLayout extends LinearLayout implements BundleEventListener,
|
public class PageActionLayout extends ThemedLinearLayout implements BundleEventListener,
|
||||||
View.OnClickListener,
|
View.OnClickListener,
|
||||||
View.OnLongClickListener {
|
View.OnLongClickListener {
|
||||||
private static final String MENU_BUTTON_KEY = "MENU_BUTTON_KEY";
|
private static final String MENU_BUTTON_KEY = "MENU_BUTTON_KEY";
|
||||||
|
@ -57,8 +60,9 @@ public class PageActionLayout extends LinearLayout implements BundleEventListene
|
||||||
refreshPageActionIcons();
|
refreshPageActionIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bug 1375351 - should change to protected after bug 1366704 land
|
||||||
@Override
|
@Override
|
||||||
protected void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
|
|
||||||
EventDispatcher.getInstance().registerUiThreadListener(this,
|
EventDispatcher.getInstance().registerUiThreadListener(this,
|
||||||
|
@ -66,8 +70,9 @@ public class PageActionLayout extends LinearLayout implements BundleEventListene
|
||||||
"PageActions:Remove");
|
"PageActions:Remove");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bug 1375351 - should change to protected after bug 1366704 land
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
EventDispatcher.getInstance().unregisterUiThreadListener(this,
|
EventDispatcher.getInstance().unregisterUiThreadListener(this,
|
||||||
"PageActions:Add",
|
"PageActions:Add",
|
||||||
"PageActions:Remove");
|
"PageActions:Remove");
|
||||||
|
@ -75,6 +80,17 @@ public class PageActionLayout extends LinearLayout implements BundleEventListene
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPrivateMode(boolean isPrivate) {
|
||||||
|
super.setPrivateMode(isPrivate);
|
||||||
|
for (int i = 0; i < getChildCount(); i++) {
|
||||||
|
View child = getChildAt(i);
|
||||||
|
if (child instanceof ThemedImageButton) {
|
||||||
|
((ThemedImageButton) child).setPrivateMode(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setNumberShown(int count) {
|
private void setNumberShown(int count) {
|
||||||
ThreadUtils.assertOnUiThread();
|
ThreadUtils.assertOnUiThread();
|
||||||
|
|
||||||
|
@ -157,13 +173,21 @@ public class PageActionLayout extends LinearLayout implements BundleEventListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageButton createImageButton() {
|
private ThemedImageButton createImageButton() {
|
||||||
ThreadUtils.assertOnUiThread();
|
ThreadUtils.assertOnUiThread();
|
||||||
|
|
||||||
|
ThemedImageButton imageButton = new ThemedImageButton(mContext, null, R.style.UrlBar_ImageButton);
|
||||||
|
// bug 1375351: different appearance in two skin
|
||||||
|
if (SkinConfig.isAustralis()) {
|
||||||
final int width = mContext.getResources().getDimensionPixelSize(R.dimen.page_action_button_width);
|
final int width = mContext.getResources().getDimensionPixelSize(R.dimen.page_action_button_width);
|
||||||
ImageButton imageButton = new ImageButton(mContext, null, R.style.UrlBar_ImageButton);
|
|
||||||
imageButton.setLayoutParams(new LayoutParams(width, LayoutParams.MATCH_PARENT));
|
imageButton.setLayoutParams(new LayoutParams(width, LayoutParams.MATCH_PARENT));
|
||||||
imageButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
imageButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||||
|
} else {
|
||||||
|
final int width = mContext.getResources().getDimensionPixelSize(R.dimen.browser_toolbar_image_button_width);
|
||||||
|
imageButton.setLayoutParams(new LayoutParams(width, LayoutParams.MATCH_PARENT));
|
||||||
|
imageButton.setBackgroundResource(R.drawable.action_bar_button);
|
||||||
|
imageButton.setScaleType(ImageView.ScaleType.CENTER);
|
||||||
|
}
|
||||||
imageButton.setOnClickListener(this);
|
imageButton.setOnClickListener(this);
|
||||||
imageButton.setOnLongClickListener(this);
|
imageButton.setOnLongClickListener(this);
|
||||||
return imageButton;
|
return imageButton;
|
||||||
|
@ -227,6 +251,10 @@ public class PageActionLayout extends LinearLayout implements BundleEventListene
|
||||||
} else {
|
} else {
|
||||||
setActionForView(v, pageAction);
|
setActionForView(v, pageAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v instanceof ThemedImageButton) {
|
||||||
|
((ThemedImageButton) v).setPrivateMode(isPrivateMode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,7 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
|
||||||
public void setPrivateMode(boolean isPrivate) {
|
public void setPrivateMode(boolean isPrivate) {
|
||||||
super.setPrivateMode(isPrivate);
|
super.setPrivateMode(isPrivate);
|
||||||
mSiteSecurity.setPrivateMode(isPrivate);
|
mSiteSecurity.setPrivateMode(isPrivate);
|
||||||
|
mPageActionLayout.setPrivateMode(isPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче