| 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.enhancedbookmarks; | 5 package org.chromium.chrome.browser.enhancedbookmarks; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 public void onAction(Object actionData) { | 91 public void onAction(Object actionData) { |
| 92 @SuppressWarnings("unchecked") | 92 @SuppressWarnings("unchecked") |
| 93 Pair<EnhancedBookmarksModel, BookmarkId> pair = (Pair< | 93 Pair<EnhancedBookmarksModel, BookmarkId> pair = (Pair< |
| 94 EnhancedBookmarksModel, BookmarkId>) actionData; | 94 EnhancedBookmarksModel, BookmarkId>) actionData; |
| 95 // Show edit activity with the name of parent folder hig
hlighted. | 95 // Show edit activity with the name of parent folder hig
hlighted. |
| 96 startEditActivity(activity, enhancedId); | 96 startEditActivity(activity, enhancedId); |
| 97 pair.first.destroy(); | 97 pair.first.destroy(); |
| 98 } | 98 } |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 int messageId = bookmarkModel.getOfflinePageBridge() == null | 101 int messageId; |
| 102 ? R.string.enhanced_bookmark_page_saved | 102 int buttonId; |
| 103 : R.string.enhanced_bookmark_page_saved_offline_pages; | 103 if (bookmarkModel.getOfflinePageBridge() == null) { |
| 104 messageId = R.string.enhanced_bookmark_page_saved; |
| 105 buttonId = R.string.enhanced_bookmark_item_edit; |
| 106 } else { |
| 107 boolean isStorageAlmostFull = |
| 108 bookmarkModel.getOfflinePageBridge().isStorageAlmost
Full(); |
| 109 messageId = isStorageAlmostFull |
| 110 ? R.string.enhanced_bookmark_page_saved_offline_page
s_storage_near_full |
| 111 : R.string.enhanced_bookmark_page_saved_offline_page
s; |
| 112 // TODO(fgorski): show "FREE UP SPACE" button. |
| 113 buttonId = R.string.enhanced_bookmark_item_edit; |
| 114 } |
| 104 snackbarManager.showSnackbar(Snackbar.make( | 115 snackbarManager.showSnackbar(Snackbar.make( |
| 105 activity.getString(messageId), snackbarController) | 116 activity.getString(messageId), snackbarController) |
| 106 .setAction(activity.getString(R.string.enhanced_bookmark
_item_edit), pair)); | 117 .setAction(activity.getString(buttonId), pair)); |
| 107 } | 118 } |
| 108 }; | 119 }; |
| 109 | 120 |
| 110 bookmarkModel.addBookmarkAsync(bookmarkModel.getDefaultFolder(), 0, tab.
getTitle(), | 121 bookmarkModel.addBookmarkAsync(bookmarkModel.getDefaultFolder(), 0, tab.
getTitle(), |
| 111 tab.getUrl(), tab.getWebContents(), callb
ack); | 122 tab.getUrl(), tab.getWebContents(), callb
ack); |
| 112 } | 123 } |
| 113 | 124 |
| 114 /** | 125 /** |
| 115 * Shows enhanced bookmark main UI, if it is turned on. Does nothing if it i
s turned off. | 126 * Shows enhanced bookmark main UI, if it is turned on. Does nothing if it i
s turned off. |
| 116 * @return True if enhanced bookmark is on, false otherwise. | 127 * @return True if enhanced bookmark is on, false otherwise. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 /** | 206 /** |
| 196 * Updates the title of chrome shown in recent tasks. It only takes effect i
n document mode. | 207 * Updates the title of chrome shown in recent tasks. It only takes effect i
n document mode. |
| 197 */ | 208 */ |
| 198 public static void setTaskDescriptionInDocumentMode(Activity activity, Strin
g description) { | 209 public static void setTaskDescriptionInDocumentMode(Activity activity, Strin
g description) { |
| 199 if (FeatureUtilities.isDocumentMode(activity)) { | 210 if (FeatureUtilities.isDocumentMode(activity)) { |
| 200 // Setting icon to be null and color to be 0 will means "take no eff
ect". | 211 // Setting icon to be null and color to be 0 will means "take no eff
ect". |
| 201 ApiCompatibilityUtils.setTaskDescription(activity, description, null
, 0); | 212 ApiCompatibilityUtils.setTaskDescription(activity, description, null
, 0); |
| 202 } | 213 } |
| 203 } | 214 } |
| 204 } | 215 } |
| OLD | NEW |