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

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

Issue 1840513002: Redesign sign in and sign in confirmation screens for Narnia 2.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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.signin;
6
7 import android.content.Context;
8 import android.util.AttributeSet;
9 import android.widget.LinearLayout;
10 import android.widget.RelativeLayout;
11 import android.widget.ScrollView;
12
13 import org.chromium.chrome.R;
14
15 /**
16 * This view allows the user to confirm signed in account, sync, and service pers onalization.
17 */
18 public class AccountSigninConfirmationView extends ScrollView {
19 private Observer mObserver;
20 private boolean mScrolledToBottom = false;
21
22 /**
23 * Scrolled to bottom observer.
24 */
25 public interface Observer {
26 /**
27 * On scrolled to bottom. This is called only once when showing the view.
28 */
29 void onScrolledToBottom();
30 }
31
32 public AccountSigninConfirmationView(Context context, AttributeSet attrs) {
33 super(context, attrs);
34 }
35
36 @Override
37 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
38 // This assumes that view's layout_width and layout_height are set to ma tch_parent.
39 assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
40 assert MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY;
41
42 int width = MeasureSpec.getSize(widthMeasureSpec);
43 int height = MeasureSpec.getSize(heightMeasureSpec);
44
45 // Sets aspect ratio of the head to 16:9.
46 if (height > width) {
47 LinearLayout layout = (LinearLayout) findViewById(R.id.signin_confir mation_head);
48 RelativeLayout.LayoutParams params =
49 (RelativeLayout.LayoutParams) layout.getLayoutParams();
50 params.height = width * 9 / 16;
51 params.width = LayoutParams.MATCH_PARENT;
52 layout.setLayoutParams(params);
53 }
54
55 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
56 }
57
58 @Override
59 protected float getTopFadingEdgeStrength() {
60 // Disable fading out effect at the top of this ScrollView.
61 return 0;
62 }
63
64 @Override
65 protected void onLayout(boolean changed, int left, int top, int right, int b ottom) {
66 super.onLayout(changed, left, top, right, bottom);
67
68 notifyIfScrolledToBottom(true);
69 }
70
71 @Override
72 protected void onScrollChanged(int l, int t, int oldl, int oldt) {
73 super.onScrollChanged(l, t, oldl, oldt);
74
75 notifyIfScrolledToBottom(false);
76 }
77
78 /**
79 * Sets scrolled to bottom observer. See {@link Observer}
80 *
81 * @param observer The observer.
82 */
83 public void setScrolledToBottomObserver(Observer observer) {
84 mObserver = observer;
85 }
86
87 private void notifyIfScrolledToBottom(boolean forceNotify) {
88 if (mObserver == null) return;
89
90 if (!forceNotify && mScrolledToBottom) return;
91
92 int distance = (getChildAt(getChildCount() - 1).getBottom() - (getHeight () + getScrollY()));
93 if (distance <= findViewById(R.id.signin_settings_control).getPaddingBot tom()) {
94 mObserver.onScrolledToBottom();
95 mScrolledToBottom = true;
96 } else {
97 mScrolledToBottom = false;
98 }
99 }
100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698