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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeButtonView.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeButtonView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeButtonView.java
new file mode 100644
index 0000000000000000000000000000000000000000..fae8c4079e81d0945e383863b9909c0754d2d9cd
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeButtonView.java
@@ -0,0 +1,94 @@
+// 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.dom_distiller;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.chrome.browser.banners.SwipableOverlayView;
+import org.chromium.content.browser.ContentViewCore;
+
+/**
+ * Reader Mode "infobar"-style button at the bottom of the screen.
+ */
+public class ReaderModeButtonView extends SwipableOverlayView {
+ private ReaderModeButtonViewDelegate mReaderModeButtonViewDelegate;
+
+ /**
+ * Called when the user swipes the button away or clicks it.
+ */
+ public interface ReaderModeButtonViewDelegate {
+ /* Called when the user clicks on the button. */
+ void onClick();
+ /* Called when the user swipes-away the button. */
+ void onSwipeAway();
+ }
+
+ /**
+ * Creates a ReaderModeButtonView and adds it to the given ContentViewCore.
+ *
+ * @param contentViewCore ContentViewCore for the ReaderModeButtonView.
+ * @param buttonViewDelegate A delegate for onClick/onDismiss events.
+ */
+ public static ReaderModeButtonView create(ContentViewCore contentViewCore,
+ ReaderModeButtonViewDelegate buttonViewDelegate) {
+ Context context = contentViewCore.getContext();
+ ReaderModeButtonView view =
+ (ReaderModeButtonView) LayoutInflater.from(context)
+ .inflate(R.layout.reader_mode_view, null);
+ view.initialize(buttonViewDelegate);
+ view.setContentViewCore(contentViewCore);
+ view.addToParentView(contentViewCore.getContainerView());
+ return view;
+ }
+
+ /**
+ * Creates a ReaderModeButtonView.
+ *
+ * @param context Context for acquiring resources.
+ * @param attrs Attributes from the XML layout inflation.
+ */
+ public ReaderModeButtonView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ private void initialize(ReaderModeButtonViewDelegate buttonViewDelegate) {
+ mReaderModeButtonViewDelegate = buttonViewDelegate;
+ findViewById(R.id.main_close).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mReaderModeButtonViewDelegate.onSwipeAway();
+ dismiss(true);
+ }
+ });
+ this.setClickable(true);
+ }
+
+ // Expose dismiss to other classes in this package.
+ @Override
+ protected boolean dismiss(boolean horizontally) {
+ return super.dismiss(horizontally);
+ }
+
+ @Override
+ protected void onViewClicked() {
+ mReaderModeButtonViewDelegate.onClick();
+ dismiss(true);
+ }
+
+ @Override
+ protected void onViewPressed(MotionEvent event) {
+ }
+
+ @Override
+ protected void onViewSwipedAway() {
+ mReaderModeButtonViewDelegate.onSwipeAway();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698