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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/PromoDialog.java

Issue 2855913002: Revert of ❄ Split off RadioButtonLayout from InfoBarControls (Closed)
Patch Set: 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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.widget; 5 package org.chromium.chrome.browser.widget;
6 6
7 import android.app.Dialog; 7 import android.app.Dialog;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.DialogInterface; 9 import android.content.DialogInterface;
10 import android.os.Bundle; 10 import android.os.Bundle;
11 import android.view.LayoutInflater; 11 import android.view.LayoutInflater;
12 import android.view.View; 12 import android.view.View;
13 import android.view.ViewGroup.LayoutParams; 13 import android.view.ViewGroup.LayoutParams;
14 import android.widget.FrameLayout; 14 import android.widget.FrameLayout;
15 15
16 import org.chromium.base.ApiCompatibilityUtils; 16 import org.chromium.base.ApiCompatibilityUtils;
17 import org.chromium.chrome.R; 17 import org.chromium.chrome.R;
18 import org.chromium.chrome.browser.infobar.InfoBarControlLayout;
18 19
19 /** 20 /**
20 * Generic builder for promo dialogs. 21 * Generic builder for promo dialogs.
21 */ 22 */
22 public abstract class PromoDialog 23 public abstract class PromoDialog
23 extends Dialog implements View.OnClickListener, DialogInterface.OnDismis sListener { 24 extends Dialog implements View.OnClickListener, DialogInterface.OnDismis sListener {
24 /** Parameters that can be used to create a new PromoDialog. */ 25 /** Parameters that can be used to create a new PromoDialog. */
25 public static class DialogParams { 26 public static class DialogParams {
26 /** Optional: Resource ID of the Drawable to use for the promo illustrat ion. */ 27 /** Optional: Resource ID of the Drawable to use for the promo illustrat ion. */
27 public int drawableResource; 28 public int drawableResource;
(...skipping 24 matching lines...) Expand all
52 53
53 mScrimView = new FrameLayout(context); 54 mScrimView = new FrameLayout(context);
54 mScrimView.setBackgroundColor(ApiCompatibilityUtils.getColor( 55 mScrimView.setBackgroundColor(ApiCompatibilityUtils.getColor(
55 context.getResources(), R.color.modal_dialog_scrim_color)); 56 context.getResources(), R.color.modal_dialog_scrim_color));
56 LayoutInflater.from(context).inflate(R.layout.promo_dialog_layout, mScri mView, true); 57 LayoutInflater.from(context).inflate(R.layout.promo_dialog_layout, mScri mView, true);
57 58
58 mDialogLayout = (PromoDialogLayout) mScrimView.findViewById(R.id.promo_d ialog_layout); 59 mDialogLayout = (PromoDialogLayout) mScrimView.findViewById(R.id.promo_d ialog_layout);
59 mDialogLayout.initialize(getDialogParams()); 60 mDialogLayout.initialize(getDialogParams());
60 } 61 }
61 62
62 /** 63 /** Add a standardized set of dialog controls. */
63 * Adds a View to the layout within the scrollable area. 64 protected InfoBarControlLayout addControlLayout() {
64 * See {@link PromoDialogLayout#addControl}. 65 return mDialogLayout.addControlLayout();
65 */
66 protected void addControl(View control) {
67 mDialogLayout.addControl(control);
68 } 66 }
69 67
70 @Override 68 @Override
71 protected void onCreate(Bundle savedInstanceState) { 69 protected void onCreate(Bundle savedInstanceState) {
72 super.onCreate(savedInstanceState); 70 super.onCreate(savedInstanceState);
73 setContentView(mScrimView); 71 setContentView(mScrimView);
74 72
75 // Force the window to allow the dialog contents be as wide as necessary . 73 // Force the window to allow the dialog contents be as wide as necessary .
76 getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARE NT); 74 getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARE NT);
77 75
78 // Connect all the buttons to this class. 76 // Connect all the buttons to this class.
79 for (int interactiveViewId : CLICKABLE_BUTTON_IDS) { 77 for (int interactiveViewId : CLICKABLE_BUTTON_IDS) {
80 View view = findViewById(interactiveViewId); 78 View view = findViewById(interactiveViewId);
81 if (view != null) view.setOnClickListener(this); 79 if (view != null) view.setOnClickListener(this);
82 } 80 }
83 } 81 }
84 82
85 @Override 83 @Override
86 public void onClick(View view) {} 84 public void onClick(View view) {}
87 85
88 /** Returns a set of {@link DialogParams} that define what is shown in the p romo dialog. */ 86 /** Returns a set of {@link DialogParams} that define what is shown in the p romo dialog. */
89 protected abstract DialogParams getDialogParams(); 87 protected abstract DialogParams getDialogParams();
90 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698