org.chromium.components.bookmarks.BookmarkId Java Examples
The following examples show how to use
org.chromium.components.bookmarks.BookmarkId.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OfflinePageUtils.java From 365browser with Apache License 2.0 | 6 votes |
public static void saveBookmarkOffline(BookmarkId bookmarkId, Tab tab) { // If bookmark ID is missing there is nothing to save here. if (bookmarkId == null) return; // Making sure the feature is enabled. if (!OfflinePageBridge.isOfflineBookmarksEnabled()) return; // Making sure tab is worth keeping. if (shouldSkipSavingTabOffline(tab)) return; OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile()); if (offlinePageBridge == null) return; WebContents webContents = tab.getWebContents(); ClientId clientId = ClientId.createClientIdForBookmarkId(bookmarkId); offlinePageBridge.savePage(webContents, clientId, new OfflinePageBridge.SavePageCallback() { @Override public void onSavePageDone(int savePageResult, String url, long offlineId) { // Result of the call is ignored. } }); }
Example #2
Source File: BookmarkModel.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Delete one or multiple bookmarks from model. If more than one bookmarks are passed here, this * method will group these delete operations into one undo bundle so that later if the user * clicks undo, all bookmarks deleted here will be restored. * @param bookmarks Bookmarks to delete. Note this array should not contain a folder and its * children, because deleting folder will also remove all its children, and * deleting children once more will cause errors. */ public void deleteBookmarks(BookmarkId... bookmarks) { assert bookmarks != null && bookmarks.length > 0; // Store all titles of bookmarks. String[] titles = new String[bookmarks.length]; boolean isUndoable = true; for (int i = 0; i < bookmarks.length; i++) { titles[i] = getBookmarkTitle(bookmarks[i]); isUndoable &= (bookmarks[i].getType() == BookmarkType.NORMAL); } if (bookmarks.length == 1) { deleteBookmark(bookmarks[0]); } else { startGroupingUndos(); for (BookmarkId bookmark : bookmarks) { deleteBookmark(bookmark); } endGroupingUndos(); } for (BookmarkDeleteObserver observer : mDeleteObservers) { observer.onDeleteBookmarks(titles, isUndoable); } }
Example #3
Source File: BookmarkActionBar.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void onFolderStateSet(BookmarkId folder) { mCurrentFolder = mDelegate.getModel().getBookmarkById(folder); getMenu().findItem(R.id.search_menu_id).setVisible(true); getMenu().findItem(R.id.edit_menu_id).setVisible(mCurrentFolder.isEditable()); // If the parent folder is a top level node, we don't go up anymore. if (mDelegate.getModel().getTopLevelFolderParentIDs().contains( mCurrentFolder.getParentId())) { if (TextUtils.isEmpty(mCurrentFolder.getTitle())) { setTitle(R.string.bookmarks); } else { setTitle(mCurrentFolder.getTitle()); } setNavigationButton(NAVIGATION_BUTTON_MENU); } else { setTitle(mCurrentFolder.getTitle()); setNavigationButton(NAVIGATION_BUTTON_BACK); } }
Example #4
Source File: BookmarkItemsAdapter.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Set folders and bookmarks to show. * @param folders This can be null if there is no folders to show. */ private void setBookmarks(List<BookmarkId> folders, List<BookmarkId> bookmarks) { if (folders == null) folders = new ArrayList<BookmarkId>(); mFolderSection.clear(); mFolderSection.addAll(folders); mBookmarkSection.clear(); mBookmarkSection.addAll(bookmarks); updateHeader(); updateDividerSections(); // TODO(kkimlabs): Animation is disabled due to a performance issue on bookmark undo. // http://crbug.com/484174 notifyDataSetChanged(); }
Example #5
Source File: BookmarkFolderSelectActivity.java From 365browser with Apache License 2.0 | 6 votes |
private void updateFolderList() { List<BookmarkId> folderList = new ArrayList<>(); List<Integer> depthList = new ArrayList<>(); mModel.getMoveDestinations(folderList, depthList, mBookmarksToMove); List<FolderListEntry> entryList = new ArrayList<>(folderList.size() + 3); if (!mIsCreatingFolder) { entryList.add(new FolderListEntry(null, 0, getString(R.string.bookmark_add_folder), false, FolderListEntry.TYPE_NEW_FOLDER)); } for (int i = 0; i < folderList.size(); i++) { BookmarkId folder = folderList.get(i); if (!mModel.isFolderVisible(folder)) continue; String title = mModel.getBookmarkById(folder).getTitle(); entryList.add(new FolderListEntry(folder, depthList.get(i), title, folder.equals(mParentId), FolderListEntry.TYPE_NORMAL)); } mBookmarkIdsAdapter.setEntryList(entryList); }
Example #6
Source File: BookmarkUtils.java From 365browser with Apache License 2.0 | 6 votes |
/** * Opens a bookmark and reports UMA. * @param model Bookmarks model to manage the bookmark. * @param activity Activity requesting to open the bookmark. * @param bookmarkId ID of the bookmark to be opened. * @param launchLocation Location from which the bookmark is being opened. * @return Whether the bookmark was successfully opened. */ public static boolean openBookmark(BookmarkModel model, Activity activity, BookmarkId bookmarkId, int launchLocation) { if (model.getBookmarkById(bookmarkId) == null) return false; String url = model.getBookmarkById(bookmarkId).getUrl(); RecordUserAction.record("MobileBookmarkManagerEntryOpened"); RecordHistogram.recordEnumeratedHistogram( "Stars.LaunchLocation", launchLocation, BookmarkLaunchLocation.COUNT); if (DeviceFormFactor.isTablet()) { // For tablets, the bookmark manager is open in a tab in the ChromeActivity. Use // the ComponentName of the ChromeActivity passed into this method. openUrl(activity, url, activity.getComponentName()); } else { // For phones, the bookmark manager is a separate activity. When the activity is // launched, an intent extra is set specifying the parent component. ComponentName parentComponent = IntentUtils.safeGetParcelableExtra( activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT); openUrl(activity, url, parentComponent); } return true; }
Example #7
Source File: BookmarkDrawerListViewAdapter.java From delion with Apache License 2.0 | 5 votes |
/** * Sets folders to show. */ void setTopFolders(List<BookmarkId> folders) { mMiddleSection.clear(); if (folders.size() > 0) { // Add a divider and title to the top of the section. mMiddleSection.add(new Item(TYPE_DIVIDER)); mMiddleSection.add(new Item(TYPE_FOLDERS_TITLE)); } // Add the rest of the items. for (BookmarkId id : folders) { mMiddleSection.add(new Item(id)); } }
Example #8
Source File: BookmarkEditActivity.java From delion with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mModel = new BookmarkModel(); mBookmarkId = BookmarkId.getBookmarkIdFromString( getIntent().getStringExtra(INTENT_BOOKMARK_ID)); mModel.addObserver(mBookmarkModelObserver); BookmarkItem item = mModel.getBookmarkById(mBookmarkId); if (!mModel.doesBookmarkExist(mBookmarkId) || item == null) { finish(); return; } setContentView(R.layout.bookmark_edit); mTitleEditText = (EmptyAlertEditText) findViewById(R.id.title_text); mFolderTextView = (TextView) findViewById(R.id.folder_text); mUrlEditText = (EmptyAlertEditText) findViewById(R.id.url_text); mFolderTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BookmarkFolderSelectActivity.startFolderSelectActivity( BookmarkEditActivity.this, mBookmarkId); } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); updateViewContent(false); }
Example #9
Source File: BookmarkUtils.java From 365browser with Apache License 2.0 | 5 votes |
/** Starts an {@link BookmarkEditActivity} for the given {@link BookmarkId}. */ public static void startEditActivity(Context context, BookmarkId bookmarkId) { Intent intent = new Intent(context, BookmarkEditActivity.class); intent.putExtra(BookmarkEditActivity.INTENT_BOOKMARK_ID, bookmarkId.toString()); if (context instanceof BookmarkActivity) { ((BookmarkActivity) context).startActivityForResult( intent, BookmarkActivity.EDIT_BOOKMARK_REQUEST_CODE); } else { context.startActivity(intent); } }
Example #10
Source File: BookmarkBridge.java From delion with Apache License 2.0 | 5 votes |
/** * Fetches the folder hierarchy of the given folder. Callback will be * synchronous if the bookmark model is already loaded and async if it is loaded in the * background. * @param folderId The current folder id. * @param callback Instance of a callback object. */ public void getCurrentFolderHierarchy(BookmarkId folderId, BookmarksCallback callback) { if (mIsNativeBookmarkModelLoaded) { nativeGetCurrentFolderHierarchy(mNativeBookmarkBridge, folderId, callback, new ArrayList<BookmarkItem>()); } else { mDelayedBookmarkCallbacks.add(new DelayedBookmarkCallback(folderId, callback, DelayedBookmarkCallback.GET_CURRENT_FOLDER_HIERARCHY, this)); } }
Example #11
Source File: BookmarkAddEditFolderActivity.java From delion with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); assert mIsAddMode; if (requestCode == PARENT_FOLDER_REQUEST_CODE && resultCode == RESULT_OK) { BookmarkId selectedBookmark = BookmarkId.getBookmarkIdFromString(data.getStringExtra( BookmarkFolderSelectActivity.INTENT_SELECTED_FOLDER)); updateParent(selectedBookmark); } }
Example #12
Source File: BookmarkFolderSelectActivity.java From 365browser with Apache License 2.0 | 5 votes |
public FolderListEntry(BookmarkId bookmarkId, int depth, String title, boolean isSelected, int type) { assert type == TYPE_NEW_FOLDER || type == TYPE_NORMAL; mDepth = depth; mId = bookmarkId; mTitle = title; mIsSelected = isSelected; mType = type; }
Example #13
Source File: BookmarkDrawerListViewAdapter.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Sets folders to show. */ void setTopFolders(List<BookmarkId> folders) { mBottomSection.clear(); if (folders.size() > 0) { // Add a divider and title to the top of the section. mBottomSection.add(new Item(TYPE_DIVIDER)); mBottomSection.add(new Item(TYPE_FOLDERS_TITLE)); } // Add the rest of the items. for (BookmarkId id : folders) { mBottomSection.add(new Item(id)); } }
Example #14
Source File: BookmarkBridge.java From 365browser with Apache License 2.0 | 5 votes |
private DelayedBookmarkCallback(BookmarkId folderId, BookmarksCallback callback, int method, BookmarkBridge handler) { mFolderId = folderId; mCallback = callback; mCallbackMethod = method; mHandler = handler; }
Example #15
Source File: BookmarkUIState.java From AndroidChromium with Apache License 2.0 | 5 votes |
static Uri createFolderUrl(BookmarkId folderId) { Uri.Builder builder = Uri.parse(UrlConstants.BOOKMARKS_FOLDER_URL).buildUpon(); // Encodes the path and appends it to the base url. A simple appending // does not work because there might be spaces in suffix. builder.appendPath(folderId.toString()); return builder.build(); }
Example #16
Source File: BookmarkFolderSelectActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Starts a select folder activity for the new folder that is about to be created. This method * is only supposed to be called by {@link BookmarkAddEditFolderActivity} */ public static void startNewFolderSelectActivity( BookmarkAddEditFolderActivity activity, List<BookmarkId> bookmarks) { assert bookmarks.size() > 0; Intent intent = new Intent(activity, BookmarkFolderSelectActivity.class); intent.putExtra(INTENT_IS_CREATING_FOLDER, true); ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarks.size()); for (BookmarkId id : bookmarks) { bookmarkStrings.add(id.toString()); } intent.putStringArrayListExtra(INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings); activity.startActivityForResult(intent, BookmarkAddEditFolderActivity.PARENT_FOLDER_REQUEST_CODE); }
Example #17
Source File: BookmarkBridge.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The top level folder's parents. */ public List<BookmarkId> getTopLevelFolderParentIDs() { assert mIsNativeBookmarkModelLoaded; List<BookmarkId> result = new ArrayList<BookmarkId>(); nativeGetTopLevelFolderParentIDs(mNativeBookmarkBridge, result); return result; }
Example #18
Source File: BookmarkBridge.java From delion with Apache License 2.0 | 5 votes |
private DelayedBookmarkCallback(BookmarkId folderId, BookmarksCallback callback, int method, BookmarkBridge handler) { mFolderId = folderId; mCallback = callback; mCallbackMethod = method; mHandler = handler; }
Example #19
Source File: BookmarkAddEditFolderActivity.java From delion with Apache License 2.0 | 5 votes |
/** * Starts an add folder activity. This method should only be called by * {@link BookmarkFolderSelectActivity}. */ public static void startAddFolderActivity(BookmarkFolderSelectActivity activity, List<BookmarkId> bookmarksToMove) { assert bookmarksToMove.size() > 0; Intent intent = new Intent(activity, BookmarkAddEditFolderActivity.class); intent.putExtra(INTENT_IS_ADD_MODE, true); ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarksToMove.size()); for (BookmarkId id : bookmarksToMove) { bookmarkStrings.add(id.toString()); } intent.putStringArrayListExtra( BookmarkFolderSelectActivity.INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings); activity.startActivityForResult(intent, BookmarkFolderSelectActivity.CREATE_FOLDER_REQUEST_CODE); }
Example #20
Source File: BookmarkWidgetService.java From AndroidChromium with Apache License 2.0 | 5 votes |
@BinderThread private void updateBookmarkList() { BookmarkId folderId = BookmarkId .getBookmarkIdFromString(mPreferences.getString(PREF_CURRENT_FOLDER, null)); mCurrentFolder = loadBookmarks(folderId); mPreferences.edit().putString(PREF_CURRENT_FOLDER, mCurrentFolder.folder.id.toString()) .apply(); }
Example #21
Source File: BookmarkBridge.java From AndroidChromium with Apache License 2.0 | 5 votes |
private BookmarkItem(BookmarkId id, String title, String url, boolean isFolder, BookmarkId parentId, boolean isEditable, boolean isManaged) { mId = id; mTitle = title; mUrl = url; mIsFolder = isFolder; mParentId = parentId; mIsEditable = isEditable; mIsManaged = isManaged; }
Example #22
Source File: BookmarkFolderSelectActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Starts a select folder activity. */ public static void startFolderSelectActivity(Context context, BookmarkId... bookmarks) { assert bookmarks.length > 0; Intent intent = new Intent(context, BookmarkFolderSelectActivity.class); intent.putExtra(INTENT_IS_CREATING_FOLDER, false); ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarks.length); for (BookmarkId id : bookmarks) { bookmarkStrings.add(id.toString()); } intent.putStringArrayListExtra(INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings); context.startActivity(intent); }
Example #23
Source File: BookmarkFolderSelectActivity.java From delion with Apache License 2.0 | 5 votes |
public FolderListEntry(BookmarkId bookmarkId, int depth, String title, boolean isSelected, int type) { assert type == TYPE_NEW_FOLDER || type == TYPE_NORMAL; mDepth = depth; mId = bookmarkId; mTitle = title; mIsSelected = isSelected; mType = type; }
Example #24
Source File: BookmarkBridge.java From AndroidChromium with Apache License 2.0 | 5 votes |
@CalledByNative private static void addToBookmarkMatchList(List<BookmarkMatch> bookmarkMatchList, long id, int type, int[] titleMatchStartPositions, int[] titleMatchEndPositions, int[] urlMatchStartPositions, int[] urlMatchEndPositions) { bookmarkMatchList.add(new BookmarkMatch(new BookmarkId(id, type), createPairsList(titleMatchStartPositions, titleMatchEndPositions), createPairsList(urlMatchStartPositions, urlMatchEndPositions))); }
Example #25
Source File: BookmarkUtils.java From delion with Apache License 2.0 | 5 votes |
/** * @return The parent {@link BookmarkId} that the user used the last time or null if the user * has never selected a parent folder to use. */ static BookmarkId getLastUsedParent(Context context) { SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); if (!preferences.contains(PREF_LAST_USED_PARENT)) return null; return BookmarkId.getBookmarkIdFromString( preferences.getString(PREF_LAST_USED_PARENT, null)); }
Example #26
Source File: BookmarkManager.java From delion with Apache License 2.0 | 5 votes |
@Override public void clearSelection() { mSelectedBookmarks.clear(); for (BookmarkUIObserver observer : mUIObservers) { observer.onSelectionStateChange(new ArrayList<BookmarkId>(mSelectedBookmarks)); } }
Example #27
Source File: BookmarkFolderSelectActivity.java From 365browser with Apache License 2.0 | 5 votes |
/** * Starts a select folder activity for the new folder that is about to be created. This method * is only supposed to be called by {@link BookmarkAddEditFolderActivity} */ public static void startNewFolderSelectActivity( BookmarkAddEditFolderActivity activity, List<BookmarkId> bookmarks) { assert bookmarks.size() > 0; Intent intent = new Intent(activity, BookmarkFolderSelectActivity.class); intent.putExtra(INTENT_IS_CREATING_FOLDER, true); ArrayList<String> bookmarkStrings = new ArrayList<>(bookmarks.size()); for (BookmarkId id : bookmarks) { bookmarkStrings.add(id.toString()); } intent.putStringArrayListExtra(INTENT_BOOKMARKS_TO_MOVE, bookmarkStrings); activity.startActivityForResult(intent, BookmarkAddEditFolderActivity.PARENT_FOLDER_REQUEST_CODE); }
Example #28
Source File: BookmarkBridge.java From delion with Apache License 2.0 | 5 votes |
/** * Fetches the bookmarks of the current folder. Callback will be * synchronous if the bookmark model is already loaded and async if it is loaded in the * background. * @param folderId The current folder id. * @param callback Instance of a callback object. */ public void getBookmarksForFolder(BookmarkId folderId, BookmarksCallback callback) { if (mIsNativeBookmarkModelLoaded) { nativeGetBookmarksForFolder(mNativeBookmarkBridge, folderId, callback, new ArrayList<BookmarkItem>()); } else { mDelayedBookmarkCallbacks.add(new DelayedBookmarkCallback(folderId, callback, DelayedBookmarkCallback.GET_BOOKMARKS_FOR_FOLDER, this)); } }
Example #29
Source File: BookmarkActionBar.java From delion with Apache License 2.0 | 5 votes |
private static void openBookmarksInNewTabs( List<BookmarkId> bookmarks, TabDelegate tabDelegate, BookmarkModel model) { for (BookmarkId id : bookmarks) { tabDelegate.createNewTab(new LoadUrlParams(model.getBookmarkById(id).getUrl()), TabLaunchType.FROM_LONGPRESS_BACKGROUND, null); } }
Example #30
Source File: BookmarkItemsAdapter.java From 365browser with Apache License 2.0 | 5 votes |
/** * Set folders and bookmarks to show. * @param folders This can be null if there is no folders to show. */ private void setBookmarks(List<BookmarkId> folders, List<BookmarkId> bookmarks) { if (folders == null) folders = new ArrayList<BookmarkId>(); mFolderSection.clear(); mFolderSection.addAll(folders); mBookmarkSection.clear(); mBookmarkSection.addAll(bookmarks); updateHeaderAndNotify(); }