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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java

Issue 1183113005: Make context menu dialog title scrollable for alt-text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 5 years, 6 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java
new file mode 100644
index 0000000000000000000000000000000000000000..7a77d419e1e86ce211d84340b32b5f2972c89c33
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java
@@ -0,0 +1,45 @@
+// 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.contextmenu;
+
+import android.content.Context;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import org.chromium.chrome.R;
+
+/**
+ * Context menu title text view that is restricted height and scrollable.
+ */
+public class ContextMenuTitleView extends ScrollView {
+ private static final int MAX_HEIGHT_DP = 70;
+ private static final int PADDING_DP = 16;
+
+ private final float mDpToPx;
+
+ /**
+ * @param context Context to be used to inflate this view.
+ * @param title String to be displayed as the title.
+ */
+ public ContextMenuTitleView(Context context, String title) {
+ super(context);
+ mDpToPx = getContext().getResources().getDisplayMetrics().density;
+ int padding = (int) (PADDING_DP * mDpToPx);
+ setPadding(padding, padding, padding, 0);
+
+ TextView titleView = new TextView(context);
+ titleView.setText(title);
+ titleView.setTextColor(getResources().getColor(R.color.default_text_color));
+ titleView.setPadding(0, 0, 0, padding);
+ addView(titleView);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int maxHeight = (int) (MAX_HEIGHT_DP * mDpToPx);
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698