OLD | NEW |
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.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 import android.os.Bundle; | 8 import android.os.Bundle; |
9 import android.support.v7.widget.Toolbar; | 9 import android.support.v7.widget.Toolbar; |
10 import android.view.Menu; | 10 import android.view.Menu; |
11 import android.view.MenuItem; | 11 import android.view.MenuItem; |
12 import android.view.View; | 12 import android.view.View; |
13 import android.widget.TextView; | 13 import android.widget.TextView; |
14 | 14 |
15 import org.chromium.base.Log; | 15 import org.chromium.base.Log; |
16 import org.chromium.chrome.R; | 16 import org.chromium.chrome.R; |
17 import org.chromium.chrome.browser.SynchronousInitializationActivity; | 17 import org.chromium.chrome.browser.SynchronousInitializationActivity; |
18 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; | 18 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; |
19 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkModelObserve
r; | 19 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkModelObserve
r; |
20 import org.chromium.chrome.browser.util.UrlUtilities; | |
21 import org.chromium.chrome.browser.widget.EmptyAlertEditText; | 20 import org.chromium.chrome.browser.widget.EmptyAlertEditText; |
22 import org.chromium.chrome.browser.widget.TintedDrawable; | 21 import org.chromium.chrome.browser.widget.TintedDrawable; |
23 import org.chromium.components.bookmarks.BookmarkId; | 22 import org.chromium.components.bookmarks.BookmarkId; |
| 23 import org.chromium.components.url_formatter.UrlFormatter; |
24 | 24 |
25 /** | 25 /** |
26 * The activity that enables the user to modify the title, url and parent folder
of a bookmark. | 26 * The activity that enables the user to modify the title, url and parent folder
of a bookmark. |
27 */ | 27 */ |
28 public class BookmarkEditActivity extends SynchronousInitializationActivity { | 28 public class BookmarkEditActivity extends SynchronousInitializationActivity { |
29 /** The intent extra specifying the ID of the bookmark to be edited. */ | 29 /** The intent extra specifying the ID of the bookmark to be edited. */ |
30 public static final String INTENT_BOOKMARK_ID = "BookmarkEditActivity.Bookma
rkId"; | 30 public static final String INTENT_BOOKMARK_ID = "BookmarkEditActivity.Bookma
rkId"; |
31 | 31 |
32 private static final String TAG = "BookmarkEdit"; | 32 private static final String TAG = "BookmarkEdit"; |
33 | 33 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 mModel.getBookmarkById(mBookmarkId).getUrl(); | 135 mModel.getBookmarkById(mBookmarkId).getUrl(); |
136 final String title = mTitleEditText.getTrimmedText(); | 136 final String title = mTitleEditText.getTrimmedText(); |
137 final String url = mUrlEditText.getTrimmedText(); | 137 final String url = mUrlEditText.getTrimmedText(); |
138 | 138 |
139 if (!mTitleEditText.isEmpty()) { | 139 if (!mTitleEditText.isEmpty()) { |
140 mModel.setBookmarkTitle(mBookmarkId, title); | 140 mModel.setBookmarkTitle(mBookmarkId, title); |
141 } | 141 } |
142 | 142 |
143 if (!mUrlEditText.isEmpty() | 143 if (!mUrlEditText.isEmpty() |
144 && mModel.getBookmarkById(mBookmarkId).isUrlEditable()) { | 144 && mModel.getBookmarkById(mBookmarkId).isUrlEditable()) { |
145 String fixedUrl = UrlUtilities.fixupUrl(url); | 145 String fixedUrl = UrlFormatter.fixupUrl(url); |
146 if (fixedUrl != null && !fixedUrl.equals(originalUrl)) { | 146 if (fixedUrl != null && !fixedUrl.equals(originalUrl)) { |
147 mModel.setBookmarkUrl(mBookmarkId, fixedUrl); | 147 mModel.setBookmarkUrl(mBookmarkId, fixedUrl); |
148 } | 148 } |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 super.onStop(); | 152 super.onStop(); |
153 } | 153 } |
154 | 154 |
155 @Override | 155 @Override |
(...skipping 12 matching lines...) Expand all Loading... |
168 Intent intent = new Intent(); | 168 Intent intent = new Intent(); |
169 intent.putExtra(BookmarkActivity.INTENT_VISIT_BOOKMARK_ID, mBookmark
Id.toString()); | 169 intent.putExtra(BookmarkActivity.INTENT_VISIT_BOOKMARK_ID, mBookmark
Id.toString()); |
170 setResult(RESULT_OK, intent); | 170 setResult(RESULT_OK, intent); |
171 } else { | 171 } else { |
172 BookmarkUtils.openBookmark( | 172 BookmarkUtils.openBookmark( |
173 mModel, this, mBookmarkId, BookmarkLaunchLocation.BOOKMARK_E
DITOR); | 173 mModel, this, mBookmarkId, BookmarkLaunchLocation.BOOKMARK_E
DITOR); |
174 } | 174 } |
175 finish(); | 175 finish(); |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |