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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/EmptyAlertEditText.java

Issue 1278963004: Revert of [Android] Make enhanced bookmark editing UI more straightforward. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkEditActivity.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.widget; 5 package org.chromium.chrome.browser.widget;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.TypedArray; 8 import android.content.res.TypedArray;
9 import android.support.v7.widget.AppCompatEditText; 9 import android.support.v7.widget.AppCompatEditText;
10 import android.text.Editable; 10 import android.text.Editable;
(...skipping 25 matching lines...) Expand all
36 super.onFinishInflate(); 36 super.onFinishInflate();
37 addTextChangedListener(new TextWatcher() { 37 addTextChangedListener(new TextWatcher() {
38 @Override 38 @Override
39 public void beforeTextChanged(CharSequence s, int start, int count, int after) {} 39 public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
40 40
41 @Override 41 @Override
42 public void onTextChanged(CharSequence s, int start, int before, int count) {} 42 public void onTextChanged(CharSequence s, int start, int before, int count) {}
43 43
44 @Override 44 @Override
45 public void afterTextChanged(Editable s) { 45 public void afterTextChanged(Editable s) {
46 if (isEmpty()) { 46 if (s.toString().trim().length() != 0 && getError() != null) set Error(null);
47 if (getError() != null) setError(null);
48 } else {
49 setError(mAlertMessage);
50 }
51 } 47 }
52 }); 48 });
53 } 49 }
54 50
55 /** 51 /**
56 * @return Trimmed text for validation. 52 * @return Trimmed text for validation.
57 */ 53 */
58 public String getTrimmedText() { 54 public String getTrimmedText() {
59 return getText().toString().trim(); 55 return getText().toString().trim();
60 } 56 }
61 57
62 /** 58 /**
63 * Sets the alert message to be shown when the text content is empty. 59 * Sets the alert message to be shown when the text content is empty.
64 */ 60 */
65 public void setAlertMessage(String message) { 61 public void setAlertMessage(String message) {
66 mAlertMessage = message; 62 mAlertMessage = message;
67 } 63 }
68 64
69 /** 65 /**
66 * Checks whether the content is empty. If empty, an alert message will be s hown.
70 * @return Whether the content is empty. 67 * @return Whether the content is empty.
71 */ 68 */
72 public boolean isEmpty() { 69 public boolean validate() {
73 return getTrimmedText().length() > 0; 70 if (getTrimmedText().length() == 0) {
71 setError(mAlertMessage);
72 return false;
73 }
74 return true;
74 } 75 }
75 } 76 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkEditActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698