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

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

Issue 1274373005: [Android] Limit context menu title to 1024 characters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unicode character ellipsis Created 5 years, 4 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 | « no previous file | 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
index 7a77d419e1e86ce211d84340b32b5f2972c89c33..05d2460763b9d8a4597fa7b2c0a99e91f838abf0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuTitleView.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.contextmenu;
import android.content.Context;
+import android.text.TextUtils;
import android.widget.ScrollView;
import android.widget.TextView;
@@ -16,6 +17,8 @@ import org.chromium.chrome.R;
public class ContextMenuTitleView extends ScrollView {
private static final int MAX_HEIGHT_DP = 70;
private static final int PADDING_DP = 16;
+ private static final int MAX_TITLE_CHARS = 1024;
+ private static final String ELLIPSIS = "\u2026";
private final float mDpToPx;
@@ -30,6 +33,12 @@ public class ContextMenuTitleView extends ScrollView {
setPadding(padding, padding, padding, 0);
TextView titleView = new TextView(context);
+ if (!TextUtils.isEmpty(title) && title.length() > MAX_TITLE_CHARS) {
+ StringBuilder sb = new StringBuilder(MAX_TITLE_CHARS + ELLIPSIS.length());
+ sb.append(title, 0, MAX_TITLE_CHARS);
+ sb.append(ELLIPSIS);
+ title = sb.toString();
+ }
titleView.setText(title);
titleView.setTextColor(getResources().getColor(R.color.default_text_color));
titleView.setPadding(0, 0, 0, padding);
@@ -42,4 +51,4 @@ public class ContextMenuTitleView extends ScrollView {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
-}
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698