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

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

Issue 2848173002: 🔍 Yank out measurement logic for FirstRun pages (Closed)
Patch Set: Rebased Created 3 years, 7 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 2017 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.firstrun;
6
7 import android.content.Context;
8 import android.util.AttributeSet;
9 import android.view.View;
10 import android.view.ViewGroup;
11 import android.widget.ScrollView;
12
13 import org.chromium.chrome.R;
14
15 /**
16 * View that is used when asking the user to choose between options during First Run.
17 *
18 * Manages the appearance of a large header at the top of the dialog.
19 */
20 public class FirstRunChooserView extends ScrollView {
21 private View mChooserTitleView;
22
23 public FirstRunChooserView(Context context, AttributeSet attrs) {
24 super(context, attrs);
25 }
26
27 @Override
28 protected void onFinishInflate() {
29 super.onFinishInflate();
30 mChooserTitleView = findViewById(R.id.chooser_title);
31 }
32
33 @Override
34 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
35 // This assumes that view's layout_width and layout_height are set to ma tch_parent.
36 assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
37 assert MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY;
38
39 int width = MeasureSpec.getSize(widthMeasureSpec);
40 int height = MeasureSpec.getSize(heightMeasureSpec);
41
42 ViewGroup.LayoutParams params = mChooserTitleView.getLayoutParams();
43 if (height > width) {
44 // Sets the title aspect ratio to be 16:9.
45 params.height = width * 9 / 16;
46 mChooserTitleView.setPadding(mChooserTitleView.getPaddingLeft(), 0,
47 mChooserTitleView.getPaddingRight(), mChooserTitleView.getPa ddingBottom());
48 } else {
49 params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
50
51 // Adds top padding.
52 mChooserTitleView.setPadding(mChooserTitleView.getPaddingLeft(),
53 getResources().getDimensionPixelOffset(R.dimen.signin_screen _top_padding),
54 mChooserTitleView.getPaddingRight(), mChooserTitleView.getPa ddingBottom());
55 }
56 mChooserTitleView.setLayoutParams(params);
57
58 super.onMeasure(widthMeasureSpec, heightMeasureSpec);
59 }
60
61 @Override
62 protected float getTopFadingEdgeStrength() {
63 // Disable fading out effect at the top of this ScrollView.
64 return 0;
65 }
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698