OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.firstrun; | 5 package org.chromium.chrome.browser.firstrun; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
9 import android.widget.FrameLayout; | 9 import android.widget.FrameLayout; |
| 10 import android.widget.ImageView; |
10 import android.widget.LinearLayout; | 11 import android.widget.LinearLayout; |
| 12 import android.widget.TextView; |
11 | 13 |
12 import org.chromium.base.ApiCompatibilityUtils; | 14 import org.chromium.base.ApiCompatibilityUtils; |
13 import org.chromium.chrome.R; | 15 import org.chromium.chrome.R; |
14 | 16 |
15 /** | 17 /** |
16 * View that handles orientation changes for Terms of Service and UMA first run
page. | 18 * View that handles orientation changes for the Data Saver first run page. |
17 */ | 19 */ |
18 public class TosAndUmaView extends FrameLayout { | 20 public class DataReductionProxyView extends FrameLayout { |
19 | 21 |
20 public TosAndUmaView(Context context, AttributeSet attrs) { | 22 public DataReductionProxyView(Context context, AttributeSet attrs) { |
21 super(context, attrs); | 23 super(context, attrs); |
22 } | 24 } |
23 | 25 |
24 @Override | 26 @Override |
25 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | 27 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
26 // This assumes that view's layout_width is set to match_parent. | 28 // This assumes that view's layout_width is set to match_parent. |
27 assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; | 29 assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; |
28 int width = MeasureSpec.getSize(widthMeasureSpec); | 30 int width = MeasureSpec.getSize(widthMeasureSpec); |
29 int height = MeasureSpec.getSize(heightMeasureSpec); | 31 int height = MeasureSpec.getSize(heightMeasureSpec); |
30 LinearLayout content = (LinearLayout) findViewById(R.id.fre_content); | 32 LinearLayout content = (LinearLayout) findViewById(R.id.fre_content); |
31 LinearLayout wrapper = (LinearLayout) findViewById(R.id.text_wrapper); | 33 LinearLayout wrapper = (LinearLayout) findViewById(R.id.data_reduction_i
nvitation_text); |
| 34 ImageView imageView = (ImageView) findViewById(R.id.data_reduction_illus
tration); |
| 35 TextView textView1 = (TextView) findViewById(R.id.data_reduction_title_1
); |
| 36 TextView textView2 = (TextView) findViewById(R.id.data_reduction_title_2
); |
32 MarginLayoutParams params = (MarginLayoutParams) wrapper.getLayoutParams
(); | 37 MarginLayoutParams params = (MarginLayoutParams) wrapper.getLayoutParams
(); |
33 int paddingStart = 0; | 38 int paddingStart = 0; |
34 if (width >= 2 * getResources().getDimension(R.dimen.fre_image_carousel_
width) | 39 if (width >= 2 * getResources().getDimension(R.dimen.fre_image_carousel_
width) |
35 && width > height) { | 40 && width > height) { |
36 content.setOrientation(LinearLayout.HORIZONTAL); | 41 content.setOrientation(LinearLayout.HORIZONTAL); |
37 paddingStart = getResources().getDimensionPixelSize(R.dimen.fre_marg
in); | 42 paddingStart = getResources().getDimensionPixelSize(R.dimen.fre_marg
in); |
38 params.width = 0; | 43 params.width = 0; |
39 params.height = LayoutParams.WRAP_CONTENT; | 44 params.height = LayoutParams.WRAP_CONTENT; |
| 45 imageView.getLayoutParams().width = |
| 46 (int) getResources().getDimension(R.dimen.fre_image_carousel
_width); |
| 47 textView1.setVisibility(VISIBLE); |
| 48 textView2.setVisibility(GONE); |
40 } else { | 49 } else { |
41 content.setOrientation(LinearLayout.VERTICAL); | 50 content.setOrientation(LinearLayout.VERTICAL); |
42 params.width = LayoutParams.WRAP_CONTENT; | 51 params.width = LayoutParams.WRAP_CONTENT; |
43 params.height = 0; | 52 params.height = 0; |
| 53 imageView.getLayoutParams().width = LayoutParams.WRAP_CONTENT; |
| 54 textView1.setVisibility(GONE); |
| 55 textView2.setVisibility(VISIBLE); |
44 } | 56 } |
45 ApiCompatibilityUtils.setPaddingRelative(content, | 57 ApiCompatibilityUtils.setPaddingRelative(content, |
46 paddingStart, | 58 paddingStart, |
47 content.getPaddingTop(), | 59 content.getPaddingTop(), |
48 ApiCompatibilityUtils.getPaddingEnd(content), | 60 ApiCompatibilityUtils.getPaddingEnd(content), |
49 content.getPaddingBottom()); | 61 content.getPaddingBottom()); |
50 wrapper.setLayoutParams(params); | 62 wrapper.setLayoutParams(params); |
51 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 63 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
52 } | 64 } |
53 } | 65 } |
OLD | NEW |