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

Side by Side Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeButtonView.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 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 2015 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.dom_distiller;
6
7 import android.content.Context;
8 import android.util.AttributeSet;
9 import android.view.LayoutInflater;
10 import android.view.MotionEvent;
11 import android.view.View;
12
13 import com.google.android.apps.chrome.R;
14
15 import org.chromium.chrome.browser.banners.SwipableOverlayView;
16 import org.chromium.content.browser.ContentViewCore;
17
18 /**
19 * Reader Mode "infobar"-style button at the bottom of the screen.
20 */
21 public class ReaderModeButtonView extends SwipableOverlayView {
22 private ReaderModeButtonViewDelegate mReaderModeButtonViewDelegate;
23
24 /**
25 * Called when the user swipes the button away or clicks it.
26 */
27 public interface ReaderModeButtonViewDelegate {
28 /* Called when the user clicks on the button. */
29 void onClick();
30 /* Called when the user swipes-away the button. */
31 void onSwipeAway();
32 }
33
34 /**
35 * Creates a ReaderModeButtonView and adds it to the given ContentViewCore.
36 *
37 * @param contentViewCore ContentViewCore for the ReaderModeButtonView.
38 * @param buttonViewDelegate A delegate for onClick/onDismiss events.
39 */
40 public static ReaderModeButtonView create(ContentViewCore contentViewCore,
41 ReaderModeButtonViewDelegate butto nViewDelegate) {
42 Context context = contentViewCore.getContext();
43 ReaderModeButtonView view =
44 (ReaderModeButtonView) LayoutInflater.from(context)
45 .inflate(R.layout.reader_mode_view, null);
46 view.initialize(buttonViewDelegate);
47 view.setContentViewCore(contentViewCore);
48 view.addToParentView(contentViewCore.getContainerView());
49 return view;
50 }
51
52 /**
53 * Creates a ReaderModeButtonView.
54 *
55 * @param context Context for acquiring resources.
56 * @param attrs Attributes from the XML layout inflation.
57 */
58 public ReaderModeButtonView(Context context, AttributeSet attrs) {
59 super(context, attrs);
60 }
61
62 private void initialize(ReaderModeButtonViewDelegate buttonViewDelegate) {
63 mReaderModeButtonViewDelegate = buttonViewDelegate;
64 findViewById(R.id.main_close).setOnClickListener(new OnClickListener() {
65 @Override
66 public void onClick(View v) {
67 mReaderModeButtonViewDelegate.onSwipeAway();
68 dismiss(true);
69 }
70 });
71 this.setClickable(true);
72 }
73
74 // Expose dismiss to other classes in this package.
75 @Override
76 protected boolean dismiss(boolean horizontally) {
77 return super.dismiss(horizontally);
78 }
79
80 @Override
81 protected void onViewClicked() {
82 mReaderModeButtonViewDelegate.onClick();
83 dismiss(true);
84 }
85
86 @Override
87 protected void onViewPressed(MotionEvent event) {
88 }
89
90 @Override
91 protected void onViewSwipedAway() {
92 mReaderModeButtonViewDelegate.onSwipeAway();
93 }
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698