OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.annotation.SuppressLint; | |
7 import android.view.Gravity; | 8 import android.view.Gravity; |
8 import android.view.View; | 9 import android.view.View; |
9 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
10 import android.widget.FrameLayout; | 11 import android.widget.FrameLayout; |
11 import android.widget.ZoomButtonsController; | 12 import android.widget.ZoomButtonsController; |
12 | 13 |
13 import org.chromium.content.browser.ContentViewCore.ZoomControlsDelegate; | 14 import org.chromium.content.browser.ContentViewCore.ZoomControlsDelegate; |
14 | 15 |
15 class AwZoomControls implements ZoomControlsDelegate { | 16 class AwZoomControls implements ZoomControlsDelegate { |
16 | 17 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 zoomController.setZoomInEnabled(canZoomIn); | 55 zoomController.setZoomInEnabled(canZoomIn); |
55 zoomController.setZoomOutEnabled(canZoomOut); | 56 zoomController.setZoomOutEnabled(canZoomOut); |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 // This method is used in tests. It doesn't modify the state of zoom control s. | 60 // This method is used in tests. It doesn't modify the state of zoom control s. |
60 View getZoomControlsViewForTest() { | 61 View getZoomControlsViewForTest() { |
61 return mZoomButtonsController != null ? mZoomButtonsController.getZoomCo ntrols() : null; | 62 return mZoomButtonsController != null ? mZoomButtonsController.getZoomCo ntrols() : null; |
62 } | 63 } |
63 | 64 |
65 @SuppressLint("RtlHardcoded") | |
64 private ZoomButtonsController getZoomController() { | 66 private ZoomButtonsController getZoomController() { |
65 if (mZoomButtonsController == null | 67 if (mZoomButtonsController == null |
66 && mAwContents.getSettings().shouldDisplayZoomControls()) { | 68 && mAwContents.getSettings().shouldDisplayZoomControls()) { |
67 mZoomButtonsController = new ZoomButtonsController( | 69 mZoomButtonsController = new ZoomButtonsController( |
68 mAwContents.getContentViewCore().getContainerView()); | 70 mAwContents.getContentViewCore().getContainerView()); |
69 mZoomButtonsController.setOnZoomListener(new ZoomListener()); | 71 mZoomButtonsController.setOnZoomListener(new ZoomListener()); |
70 // ZoomButtonsController positions the buttons at the bottom, but in | 72 // ZoomButtonsController positions the buttons at the bottom, but in |
71 // the middle. Change their layout parameters so they appear on the | 73 // the middle. Change their layout parameters so they appear on the |
72 // right. | 74 // right. |
73 View controls = mZoomButtonsController.getZoomControls(); | 75 View controls = mZoomButtonsController.getZoomControls(); |
74 ViewGroup.LayoutParams params = controls.getLayoutParams(); | 76 ViewGroup.LayoutParams params = controls.getLayoutParams(); |
75 if (params instanceof FrameLayout.LayoutParams) { | 77 if (params instanceof FrameLayout.LayoutParams) { |
76 ((FrameLayout.LayoutParams) params).gravity = Gravity.RIGHT; | 78 ((FrameLayout.LayoutParams) params).gravity = Gravity.RIGHT; |
boliu
2015/03/16 20:40:18
I think this originally came from here:
https://a
| |
77 } | 79 } |
78 } | 80 } |
79 return mZoomButtonsController; | 81 return mZoomButtonsController; |
80 } | 82 } |
81 | 83 |
82 private class ZoomListener implements ZoomButtonsController.OnZoomListener { | 84 private class ZoomListener implements ZoomButtonsController.OnZoomListener { |
83 @Override | 85 @Override |
84 public void onVisibilityChanged(boolean visible) { | 86 public void onVisibilityChanged(boolean visible) { |
85 if (visible) { | 87 if (visible) { |
86 // Bring back the hidden zoom controls. | 88 // Bring back the hidden zoom controls. |
87 mZoomButtonsController.getZoomControls().setVisibility(View.VISI BLE); | 89 mZoomButtonsController.getZoomControls().setVisibility(View.VISI BLE); |
88 updateZoomControls(); | 90 updateZoomControls(); |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 @Override | 94 @Override |
93 public void onZoom(boolean zoomIn) { | 95 public void onZoom(boolean zoomIn) { |
94 if (zoomIn) { | 96 if (zoomIn) { |
95 mAwContents.zoomIn(); | 97 mAwContents.zoomIn(); |
96 } else { | 98 } else { |
97 mAwContents.zoomOut(); | 99 mAwContents.zoomOut(); |
98 } | 100 } |
99 // ContentView will call updateZoomControls after its current page s cale | 101 // ContentView will call updateZoomControls after its current page s cale |
100 // is got updated from the native code. | 102 // is got updated from the native code. |
101 } | 103 } |
102 } | 104 } |
103 } | 105 } |
OLD | NEW |