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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoView.java

Issue 1343433002: Add landscape specs for Data Reduction Proxy promo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 3 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/preferences/datareduction/DataReductionPromoView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoView.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoView.java
new file mode 100644
index 0000000000000000000000000000000000000000..d0a0b7f074b825ba808ad1ca9743f2a3f6af156f
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoView.java
@@ -0,0 +1,71 @@
+// Copyright 2015 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.preferences.datareduction;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.widget.PaddedFrameLayout;
+
+/**
+ * View that handles orientation changes for the Data Reduction Proxy promo. When the width is
+ * greater than the height, switches the promo content view from vertical to horizontal and moves
+ * the illustration from the top of the text to the side of the text.
+ */
+public class DataReductionPromoView extends PaddedFrameLayout {
+
+ private static final int HORIZONTAL_PADDING_DP = 24;
+
+ private View mDataReductionIllustration;
newt (away) 2015/09/15 23:08:43 suggestion: Since these private variables inside a
megjablon 2015/09/16 19:02:48 Done.
+ private LinearLayout mDataReductionPromoContent;
+ private int mMaxChildHeight;
+ private int mMaxChildWidth;
+ private int mMaxChildHeightHorizontal;
+ private int mMaxChildWidthHorizontal;
+ private int mPaddingBottom;
+ private float mScale;
newt (away) 2015/09/15 23:08:43 Save mPaddingSide as a member variable instead of
megjablon 2015/09/16 19:02:48 Done.
+
+ public DataReductionPromoView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mDataReductionIllustration = findViewById(R.id.data_reduction_illustration);
+ mDataReductionPromoContent = (LinearLayout) findViewById(R.id.data_reduction_promo_content);
+ mMaxChildHeight = (int) getResources()
+ .getDimension(R.dimen.data_reduction_promo_screen_height);
newt (away) 2015/09/15 23:08:43 use getDimensionPixelSize(), which returns an int
megjablon 2015/09/16 19:02:48 Done.
+ mMaxChildWidth = (int) getResources()
+ .getDimension(R.dimen.data_reduction_promo_screen_width);
+ mMaxChildHeightHorizontal = (int) getResources()
+ .getDimension(R.dimen.data_reduction_promo_screen_height_horizontal);
+ mMaxChildWidthHorizontal = (int) getResources()
+ .getDimension(R.dimen.data_reduction_promo_screen_width_horizontal);
+ mPaddingBottom = (int) getResources()
+ .getDimension(R.dimen.data_reduction_promo_illustration_margin_bottom);
+ mScale = getResources().getDisplayMetrics().density;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = MeasureSpec.getSize(heightMeasureSpec);
+
+ if (width >= 2 * mDataReductionIllustration.getWidth() && width > height) {
+ mDataReductionPromoContent.setOrientation(LinearLayout.HORIZONTAL);
+ setMaxChildHeight(mMaxChildHeightHorizontal);
+ setMaxChildWidth(mMaxChildWidthHorizontal);
+ int paddingInPixels = (int) (HORIZONTAL_PADDING_DP * mScale + 0.5f);
newt (away) 2015/09/15 23:08:43 Customarily, all dimension variables are in pixels
megjablon 2015/09/16 19:02:48 Done.
+ ApiCompatibilityUtils.setPaddingRelative(
+ mDataReductionIllustration, 0, 0, paddingInPixels, 0);
+ } else {
+ mDataReductionPromoContent.setOrientation(LinearLayout.VERTICAL);
+ setMaxChildHeight(mMaxChildHeight);
+ setMaxChildWidth(mMaxChildWidth);
+ mDataReductionIllustration.setPadding(0, 0, 0, mPaddingBottom);
+ }
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698