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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeActivityDelegate.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/ReaderModeActivityDelegate.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeActivityDelegate.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeActivityDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..bcf087ecfef68a36e8ae42317e305b57e040c605
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/dom_distiller/ReaderModeActivityDelegate.java
@@ -0,0 +1,90 @@
+// 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.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.google.android.apps.chrome.R;
+
+import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.widget.ReaderModeControl;
+import org.chromium.ui.resources.dynamics.DynamicResourceLoader;
+
+
+/**
+ * Manager for the Reader Mode feature.
+ * This class keeps track of the status of Reader Mode and coordinates the control
+ * with the layout.
+ */
+public class ReaderModeActivityDelegate {
+ private static final String TAG = "ReaderModeActivityDelegate";
+
+ private DynamicResourceLoader mResourceLoader;
+ private ReaderModeControl mControl;
+ private final ChromeActivity mActivity;
+ private ViewGroup mParentView;
+
+ /**
+ * Constructs the manager for the given activity, and will attach views to the given parent.
+ * @param activity The {@code ChromeActivity} in use.
+ */
+ public ReaderModeActivityDelegate(ChromeActivity activity) {
+ mActivity = activity;
+ }
+
+ /**
+ * Initializes this manager. Must be called before {@link #getReaderModeControl()}.
+ * @param parentView The parent view to attach Reader Mode UX to.
+ */
+ public void initialize(ViewGroup parentView) {
+ mParentView = parentView;
+ }
+
+ /**
+ * Destroys the Reader Mode activity delegate.
+ */
+ public void destroy() {
+ if (mControl != null) {
+ ((ViewGroup) mControl.getParent()).removeView(mControl);
+ mControl = null;
+ if (mResourceLoader != null) {
+ mResourceLoader.unregisterResource(R.id.contextual_search_view);
+ }
+ }
+ mParentView = null;
+ }
+
+ /**
+ * @param resourceLoader The {@link DynamicResourceLoader} to register and unregister the view.
+ */
+ public void setDynamicResourceLoader(DynamicResourceLoader resourceLoader) {
+ mResourceLoader = resourceLoader;
+ if (mControl != null) {
+ mResourceLoader.registerResource(R.id.reader_mode_view,
+ mControl.getResourceAdapter());
+ }
+ }
+
+ /**
+ * Inflates the Reader Mode control, if needed.
+ */
+ public ReaderModeControl getReaderModeControl() {
+ assert mParentView != null;
+ if (mControl == null) {
+ LayoutInflater.from(mActivity).inflate(R.layout.reader_mode_control, mParentView);
+ mControl = (ReaderModeControl)
+ mParentView.findViewById(R.id.reader_mode_view);
+ if (mResourceLoader != null) {
+ mResourceLoader.registerResource(R.id.reader_mode_view,
+ mControl.getResourceAdapter());
+ }
+ }
+ assert mControl != null;
+ mControl.setVisibility(View.INVISIBLE);
+ return mControl;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698