Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/InsetConsumerView.java

Issue 1386403003: Resize only the virtual viewport when the OSK triggers a resize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase master Inset handling logic Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser;
6
7 import android.annotation.SuppressLint;
8 import android.content.Context;
9 import android.graphics.Rect;
10 import android.os.Build;
11 import android.util.AttributeSet;
12 import android.view.WindowInsets;
13 import android.widget.FrameLayout;
14
15 import org.chromium.chrome.browser.tabmodel.TabModelSelector;
16 import org.chromium.content.browser.ContentViewCore;
17
18 /**
19 * The purpose of this view is to consume the insets (OSK resizes, status bar).
20 * It stores the value of the insets in ContentViewCore so that size of things
21 * like the OSK can be known.
22 */
23 public class InsetConsumerView extends FrameLayout {
24
25 private TabModelSelector mTabModelSelector;
26
27 /**
28 * Creates an {@link InsetConsumerView}.
29 *
30 * @param context The Context to create this {@link InsetConsumerView} in.
31 */
32 public InsetConsumerView(Context context) {
33 super(context);
34 }
35
36 /**
37 * Creates an {@link InsetConsumerView}.
38 *
39 * @param context The Context to create this {@link InsetConsumerView} in.
40 * @param attrs The AttributeSet used to create this
41 * {@link InsetConsumerView}.
42 */
43 public InsetConsumerView(Context context, AttributeSet attrs) {
44 super(context, attrs);
45 }
46
47 /**
48 * Sets the {@link TabModelSelector} that will be queried for information
49 * about the state of the system.
50 *
51 * @param tabModelSelector A {@link TabModelSelector} that represents the
52 * state of the system.
53 */
54 public void setTabModelSelector(TabModelSelector tabModelSelector) {
55 mTabModelSelector = tabModelSelector;
56 }
57
58 @Deprecated
aelias_OOO_until_Jul13 2016/01/28 05:04:55 It's not conventional to mark something like this
ymalik 2016/02/11 01:06:22 Makes sense. Thanks!
59 @Override
60 protected boolean fitSystemWindows(Rect insets) {
61 // For Lollipop and above, onApplyWindowInsets will set the insets on
62 // ContentViewCore.
63 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
64 && mTabModelSelector != null && mTabModelSelector.getCurrentTab( ) != null) {
65 ContentViewCore cvc = mTabModelSelector.getCurrentTab().getContentVi ewCore();
66 if (cvc != null) {
67 cvc.setWindowInsets(new Rect(insets));
aelias_OOO_until_Jul13 2016/01/28 05:04:55 I don't see any reason to use 'new' here instead o
ymalik 2016/02/11 01:06:22 See comment below.
68 }
69 }
70 return super.fitSystemWindows(insets);
71 }
72
73 @SuppressLint("NewApi")
aelias_OOO_until_Jul13 2016/01/28 05:04:55 I think the correct annotation is @TargetApi(Build
ymalik 2016/02/11 01:06:22 Done. Thanks!
74 @Override
75 public WindowInsets onApplyWindowInsets(WindowInsets insets) {
76 if (mTabModelSelector != null && mTabModelSelector.getCurrentTab() != nu ll) {
77 ContentViewCore cvc = mTabModelSelector.getCurrentTab().getContentVi ewCore();
78 if (cvc != null) {
79 cvc.setWindowInsets(new WindowInsets(insets));
aelias_OOO_until_Jul13 2016/01/28 05:04:55 Likewise, I don't see any reason to use 'new' here
ymalik 2016/02/11 01:06:22 You're right, there is no need for new in this cas
80 }
81 }
82 return super.onApplyWindowInsets(insets);
83 }
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698