This source file includes following definitions.
- invokeZoomPicker
- dismissZoomPicker
- updateZoomControls
- getZoomControlsViewForTest
- getZoomController
- onVisibilityChanged
- onZoom
package org.chromium.android_webview;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ZoomButtonsController;
import org.chromium.content.browser.ContentViewCore.ZoomControlsDelegate;
class AwZoomControls implements ZoomControlsDelegate {
private AwContents mAwContents;
private ZoomButtonsController mZoomButtonsController;
AwZoomControls(AwContents awContents) {
mAwContents = awContents;
}
@Override
public void invokeZoomPicker() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController != null) {
zoomController.setVisible(true);
}
}
@Override
public void dismissZoomPicker() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController != null) {
zoomController.setVisible(false);
}
}
@Override
public void updateZoomControls() {
ZoomButtonsController zoomController = getZoomController();
if (zoomController == null) {
return;
}
boolean canZoomIn = mAwContents.canZoomIn();
boolean canZoomOut = mAwContents.canZoomOut();
if (!canZoomIn && !canZoomOut) {
zoomController.getZoomControls().setVisibility(View.GONE);
} else {
zoomController.setZoomInEnabled(canZoomIn);
zoomController.setZoomOutEnabled(canZoomOut);
}
}
View getZoomControlsViewForTest() {
return mZoomButtonsController != null ? mZoomButtonsController.getZoomControls() : null;
}
private ZoomButtonsController getZoomController() {
if (mZoomButtonsController == null &&
mAwContents.getSettings().shouldDisplayZoomControls()) {
mZoomButtonsController = new ZoomButtonsController(
mAwContents.getContentViewCore().getContainerView());
mZoomButtonsController.setOnZoomListener(new ZoomListener());
View controls = mZoomButtonsController.getZoomControls();
ViewGroup.LayoutParams params = controls.getLayoutParams();
if (params instanceof FrameLayout.LayoutParams) {
((FrameLayout.LayoutParams) params).gravity = Gravity.RIGHT;
}
}
return mZoomButtonsController;
}
private class ZoomListener implements ZoomButtonsController.OnZoomListener {
@Override
public void onVisibilityChanged(boolean visible) {
if (visible) {
mZoomButtonsController.getZoomControls().setVisibility(View.VISIBLE);
updateZoomControls();
}
}
@Override
public void onZoom(boolean zoomIn) {
if (zoomIn) {
mAwContents.zoomIn();
} else {
mAwContents.zoomOut();
}
}
}
}