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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunChooserView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunChooserView.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunChooserView.java
new file mode 100644
index 0000000000000000000000000000000000000000..5728e8ff15a4c285ff91cf0cf50bcdc576f8e5e6
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunChooserView.java
@@ -0,0 +1,66 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.firstrun;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ScrollView;
+
+import org.chromium.chrome.R;
+
+/**
+ * View that is used when asking the user to choose between options during First Run.
+ *
+ * Manages the appearance of a large header at the top of the dialog.
+ */
+public class FirstRunChooserView extends ScrollView {
+ private View mChooserTitleView;
+
+ public FirstRunChooserView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mChooserTitleView = findViewById(R.id.chooser_title);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // This assumes that view's layout_width and layout_height are set to match_parent.
+ assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
+ assert MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY;
+
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = MeasureSpec.getSize(heightMeasureSpec);
+
+ ViewGroup.LayoutParams params = mChooserTitleView.getLayoutParams();
+ if (height > width) {
+ // Sets the title aspect ratio to be 16:9.
+ params.height = width * 9 / 16;
+ mChooserTitleView.setPadding(mChooserTitleView.getPaddingLeft(), 0,
+ mChooserTitleView.getPaddingRight(), mChooserTitleView.getPaddingBottom());
+ } else {
+ params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+
+ // Adds top padding.
+ mChooserTitleView.setPadding(mChooserTitleView.getPaddingLeft(),
+ getResources().getDimensionPixelOffset(R.dimen.signin_screen_top_padding),
+ mChooserTitleView.getPaddingRight(), mChooserTitleView.getPaddingBottom());
+ }
+ mChooserTitleView.setLayoutParams(params);
+
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ @Override
+ protected float getTopFadingEdgeStrength() {
+ // Disable fading out effect at the top of this ScrollView.
+ return 0;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698