org.chromium.chrome.browser.favicon.LargeIconBridge Java Examples

The following examples show how to use org.chromium.chrome.browser.favicon.LargeIconBridge. 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: BookmarkWidgetService.java    From delion with Apache License 2.0 6 votes vote down vote up
BookmarkLoader(Context context, final BookmarkId folderId,
        BookmarkLoaderCallback callback) {
    mCallback = callback;

    Resources res = context.getResources();
    mLargeIconBridge = new LargeIconBridge(
            Profile.getLastUsedProfile().getOriginalProfile());
    mMinIconSizeDp = (int) res.getDimension(R.dimen.default_favicon_min_size);
    mDisplayedIconSize = res.getDimensionPixelSize(R.dimen.default_favicon_size);
    mCornerRadius = res.getDimensionPixelSize(R.dimen.default_favicon_corner_radius);
    int textSize = res.getDimensionPixelSize(R.dimen.default_favicon_icon_text_size);
    int iconColor =
            ApiCompatibilityUtils.getColor(res, R.color.default_favicon_background_color);
    mIconGenerator = new RoundedIconGenerator(mDisplayedIconSize, mDisplayedIconSize,
            mCornerRadius, iconColor, textSize);

    mRemainingTaskCount = 1;
    mBookmarkModel = new BookmarkModel();
    mBookmarkModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            loadBookmarks(folderId);
        }
    });
}
 
Example #2
Source File: BookmarkWidgetService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@UiThread
public void initialize(Context context, final BookmarkId folderId,
        BookmarkLoaderCallback callback) {
    mCallback = callback;

    Resources res = context.getResources();
    mLargeIconBridge = new LargeIconBridge(
            Profile.getLastUsedProfile().getOriginalProfile());
    mMinIconSizeDp = (int) res.getDimension(R.dimen.default_favicon_min_size);
    mDisplayedIconSize = res.getDimensionPixelSize(R.dimen.default_favicon_size);
    mCornerRadius = res.getDimensionPixelSize(R.dimen.default_favicon_corner_radius);
    int textSize = res.getDimensionPixelSize(R.dimen.default_favicon_icon_text_size);
    int iconColor =
            ApiCompatibilityUtils.getColor(res, R.color.default_favicon_background_color);
    mIconGenerator = new RoundedIconGenerator(mDisplayedIconSize, mDisplayedIconSize,
            mCornerRadius, iconColor, textSize);

    mRemainingTaskCount = 1;
    mBookmarkModel = new BookmarkModel();
    mBookmarkModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            loadBookmarks(folderId);
        }
    });
}
 
Example #3
Source File: BookmarkWidgetService.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@UiThread
public void initialize(Context context, final BookmarkId folderId,
        BookmarkLoaderCallback callback) {
    mCallback = callback;

    Resources res = context.getResources();
    mLargeIconBridge = new LargeIconBridge(
            Profile.getLastUsedProfile().getOriginalProfile());
    mMinIconSizeDp = (int) res.getDimension(R.dimen.default_favicon_min_size);
    mDisplayedIconSize = res.getDimensionPixelSize(R.dimen.default_favicon_size);
    mCornerRadius = res.getDimensionPixelSize(R.dimen.default_favicon_corner_radius);
    int textSize = res.getDimensionPixelSize(R.dimen.default_favicon_icon_text_size);
    int iconColor =
            ApiCompatibilityUtils.getColor(res, R.color.default_favicon_background_color);
    mIconGenerator = new RoundedIconGenerator(mDisplayedIconSize, mDisplayedIconSize,
            mCornerRadius, iconColor, textSize);

    mRemainingTaskCount = 1;
    mBookmarkModel = new BookmarkModel();
    mBookmarkModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            loadBookmarks(folderId);
        }
    });
}
 
Example #4
Source File: BookmarkManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of {@link BookmarkManager}. It also initializes resources,
 * bookmark models and jni bridges.
 * @param activity The activity context to use.
 * @param isDialogUi Whether the main bookmarks UI will be shown in a dialog, not a NativePage.
 */
public BookmarkManager(Activity activity, boolean isDialogUi) {
    mActivity = activity;
    mIsDialogUi = isDialogUi;

    mBookmarkModel = new BookmarkModel();
    mMainView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.bookmark_main, null);
    mDrawer = (DrawerLayout) mMainView.findViewById(R.id.bookmark_drawer_layout);
    mDrawerListView = (BookmarkDrawerListView) mMainView.findViewById(
            R.id.bookmark_drawer_list);
    mContentView = (BookmarkContentView) mMainView.findViewById(R.id.bookmark_content_view);
    mViewSwitcher = (ViewSwitcher) mMainView.findViewById(R.id.bookmark_view_switcher);
    mUndoController = new BookmarkUndoController(activity, mBookmarkModel,
            ((SnackbarManageable) activity).getSnackbarManager());
    mSearchView = (BookmarkSearchView) getView().findViewById(R.id.bookmark_search_view);
    mBookmarkModel.addObserver(mBookmarkModelObserver);
    initializeToLoadingState();
    mBookmarkModel.runAfterBookmarkModelLoaded(mModelLoadedRunnable);

    // Load partner bookmarks explicitly. We load partner bookmarks in the deferred startup
    // code, but that might be executed much later. Especially on L, showing loading
    // progress bar blocks that so it won't be loaded. http://crbug.com/429383
    PartnerBookmarksShim.kickOffReading(activity);

    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(activityManager.getMemoryClass() / 4 * 1024 * 1024,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);
}
 
Example #5
Source File: ConfirmImportantSitesDialogFragment.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
Example #6
Source File: HistoryManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @return The {@link LargeIconBridge} used to fetch large favicons.
 */
public LargeIconBridge getLargeIconBridge() {
    return mLargeIconBridge;
}
 
Example #7
Source File: HistoryManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new HistoryManager.
 * @param activity The Activity associated with the HistoryManager.
 * @param isSeparateActivity Whether the history UI will be shown in a separate activity than
 *                           the main Chrome activity.
 * @param snackbarManager The {@link SnackbarManager} used to display snackbars.
 */
@SuppressWarnings("unchecked") // mSelectableListLayout
public HistoryManager(
        Activity activity, boolean isSeparateActivity, SnackbarManager snackbarManager) {
    mActivity = activity;
    mIsSeparateActivity = isSeparateActivity;
    mSnackbarManager = snackbarManager;

    mSelectionDelegate = new SelectionDelegate<>();
    mSelectionDelegate.addObserver(this);
    mHistoryAdapter = new HistoryAdapter(mSelectionDelegate, this,
            sProviderForTests != null ? sProviderForTests : new BrowsingHistoryBridge());

    // 1. Create SelectableListLayout.
    mSelectableListLayout =
            (SelectableListLayout<HistoryItem>) LayoutInflater.from(activity).inflate(
                    R.layout.history_main, null);

    // 2. Initialize RecyclerView.
    mRecyclerView = mSelectableListLayout.initializeRecyclerView(mHistoryAdapter);

    // 3. Initialize toolbar.
    mToolbar = (HistoryManagerToolbar) mSelectableListLayout.initializeToolbar(
            R.layout.history_toolbar, mSelectionDelegate, R.string.menu_history, null,
            R.id.normal_menu_group, R.id.selection_mode_menu_group,
            R.color.default_primary_color, this);
    mToolbar.setManager(this);
    mToolbar.initializeSearchView(this, R.string.history_manager_search, R.id.search_menu_id);

    // 4. Width constrain the SelectableListLayout.
    mSelectableListLayout.configureWideDisplayStyle();

    // 5. Initialize empty view.
    mEmptyView = mSelectableListLayout.initializeEmptyView(
            VectorDrawableCompat.create(
                    mActivity.getResources(), R.drawable.history_big, mActivity.getTheme()),
            R.string.history_manager_empty, R.string.history_manager_no_results);

    // 6. Create large icon bridge.
    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min((activityManager.getMemoryClass() / 4) * MEGABYTES_TO_BYTES,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    // 7. Initialize the adapter to load items.
    mHistoryAdapter.initialize();

    // 8. Add scroll listener to page in more items when necessary.
    mRecyclerView.addOnScrollListener(new OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (!mHistoryAdapter.canLoadMoreItems()) return;

            // Load more items if the scroll position is close to the bottom of the list.
            LinearLayoutManager layoutManager =
                    (LinearLayoutManager) recyclerView.getLayoutManager();
            if (layoutManager.findLastVisibleItemPosition()
                    > (mHistoryAdapter.getItemCount() - 25)) {
                mHistoryAdapter.loadMoreItems();
                recordUserActionWithOptionalSearch("LoadMoreOnScroll");
            }
        }});

    // 9. Listen to changes in sign in state.
    SigninManager.get(mActivity).addSignInStateObserver(this);

    recordUserAction("Show");
}
 
Example #8
Source File: SuggestionsUiDelegateImpl.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Utility method to lazily create the {@link LargeIconBridge}, and avoid unnecessary native
 * calls in tests.
 */
private LargeIconBridge getLargeIconBridge() {
    assert !mIsDestroyed;
    if (mLargeIconBridge == null) mLargeIconBridge = new LargeIconBridge(mProfile);
    return mLargeIconBridge;
}
 
Example #9
Source File: ConfirmImportantSitesDialogFragment.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
Example #10
Source File: BookmarkManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public LargeIconBridge getLargeIconBridge() {
    return mLargeIconBridge;
}
 
Example #11
Source File: BookmarkManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of {@link BookmarkManager}. It also initializes resources,
 * bookmark models and jni bridges.
 * @param activity The activity context to use.
 * @param isDialogUi Whether the main bookmarks UI will be shown in a dialog, not a NativePage.
 * @param snackbarManager The {@link SnackbarManager} used to display snackbars.
 */
public BookmarkManager(Activity activity, boolean isDialogUi, SnackbarManager snackbarManager) {
    mActivity = activity;
    mIsDialogUi = isDialogUi;

    mSelectionDelegate = new SelectionDelegate<BookmarkId>() {
        @Override
        public boolean toggleSelectionForItem(BookmarkId bookmark) {
            if (!mBookmarkModel.getBookmarkById(bookmark).isEditable()) return false;
            return super.toggleSelectionForItem(bookmark);
        }
    };

    mBookmarkModel = new BookmarkModel();
    mMainView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.bookmark_main, null);

    @SuppressWarnings("unchecked")
    SelectableListLayout<BookmarkId> selectableList =
            (SelectableListLayout<BookmarkId>) mMainView.findViewById(R.id.selectable_list);
    mSelectableListLayout = selectableList;
    mSelectableListLayout.initializeEmptyView(
            VectorDrawableCompat.create(
                    mActivity.getResources(), R.drawable.bookmark_big, mActivity.getTheme()),
            R.string.bookmarks_folder_empty, R.string.bookmark_no_result);

    mAdapter = new BookmarkItemsAdapter(activity);

    mRecyclerView = mSelectableListLayout.initializeRecyclerView(mAdapter);

    mToolbar = (BookmarkActionBar) mSelectableListLayout.initializeToolbar(
            R.layout.bookmark_action_bar, mSelectionDelegate, 0, null, R.id.normal_menu_group,
            R.id.selection_mode_menu_group, R.color.default_primary_color, null);
    mToolbar.initializeSearchView(
            this, R.string.bookmark_action_bar_search, R.id.search_menu_id);

    mSelectableListLayout.configureWideDisplayStyle();

    mUndoController = new BookmarkUndoController(activity, mBookmarkModel, snackbarManager);
    mBookmarkModel.addObserver(mBookmarkModelObserver);
    initializeToLoadingState();
    mBookmarkModel.runAfterBookmarkModelLoaded(mModelLoadedRunnable);

    // Load partner bookmarks explicitly. We load partner bookmarks in the deferred startup
    // code, but that might be executed much later. Especially on L, showing loading
    // progress bar blocks that so it won't be loaded. http://crbug.com/429383
    PartnerBookmarksShim.kickOffReading(activity);

    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(activityManager.getMemoryClass() / 4 * 1024 * 1024,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    RecordUserAction.record("MobileBookmarkManagerOpen");
    if (!isDialogUi) {
        RecordUserAction.record("MobileBookmarkManagerPageOpen");
    }

    // TODO(twellington): Remove this when Chrome version 59 is a distant memory and users
    // are unlikely to have the old PREF_SEARCH_HISTORY in shared preferences.
    ContextUtils.getAppSharedPreferences().edit().remove(PREF_SEARCH_HISTORY).apply();
}
 
Example #12
Source File: BookmarkManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public LargeIconBridge getLargeIconBridge() {
    return mLargeIconBridge;
}
 
Example #13
Source File: BookmarkManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of {@link BookmarkManager}. It also initializes resources,
 * bookmark models and jni bridges.
 * @param activity The activity context to use.
 * @param isDialogUi Whether the main bookmarks UI will be shown in a dialog, not a NativePage.
 */
public BookmarkManager(Activity activity, boolean isDialogUi) {
    mActivity = activity;
    mIsDialogUi = isDialogUi;

    mSelectionDelegate = new SelectionDelegate<BookmarkId>() {
        @Override
        public boolean toggleSelectionForItem(BookmarkId bookmark) {
            if (!mBookmarkModel.getBookmarkById(bookmark).isEditable()) return false;
            return super.toggleSelectionForItem(bookmark);
        }
    };

    mBookmarkModel = new BookmarkModel();
    mMainView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.bookmark_main, null);
    mDrawer = (DrawerLayout) mMainView.findViewById(R.id.bookmark_drawer_layout);
    mDrawerListView = (BookmarkDrawerListView) mMainView.findViewById(
            R.id.bookmark_drawer_list);
    mContentView = (BookmarkContentView) mMainView.findViewById(R.id.bookmark_content_view);
    mViewSwitcher = (ViewSwitcher) mMainView.findViewById(R.id.bookmark_view_switcher);
    mUndoController = new BookmarkUndoController(activity, mBookmarkModel,
            ((SnackbarManageable) activity).getSnackbarManager());
    mSearchView = (BookmarkSearchView) getView().findViewById(R.id.bookmark_search_view);
    mBookmarkModel.addObserver(mBookmarkModelObserver);
    initializeToLoadingState();
    mBookmarkModel.runAfterBookmarkModelLoaded(mModelLoadedRunnable);

    // Load partner bookmarks explicitly. We load partner bookmarks in the deferred startup
    // code, but that might be executed much later. Especially on L, showing loading
    // progress bar blocks that so it won't be loaded. http://crbug.com/429383
    PartnerBookmarksShim.kickOffReading(activity);

    mLargeIconBridge = new LargeIconBridge(Profile.getLastUsedProfile().getOriginalProfile());
    ActivityManager activityManager = ((ActivityManager) ContextUtils
            .getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(activityManager.getMemoryClass() / 4 * 1024 * 1024,
            FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    RecordUserAction.record("MobileBookmarkManagerOpen");
    if (!isDialogUi) {
        RecordUserAction.record("MobileBookmarkManagerPageOpen");
    }
}
 
Example #14
Source File: ConfirmImportantSitesDialogFragment.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null || mImportantDomains == null || mFaviconURLs == null) {
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                // Return our deselected domains.
                Intent data = new Intent();
                String[] deselectedDomains = mDeselectedDomains.toArray(new String[0]);
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains);
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
Example #15
Source File: BookmarkManager.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public LargeIconBridge getLargeIconBridge() {
    return mLargeIconBridge;
}
 
Example #16
Source File: BookmarkDelegate.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * @return LargeIconBridge instance. By sharing the instance, we can also share the cache.
 */
LargeIconBridge getLargeIconBridge();
 
Example #17
Source File: BookmarkDelegate.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * @return LargeIconBridge instance. By sharing the instance, we can also share the cache.
 */
LargeIconBridge getLargeIconBridge();
 
Example #18
Source File: BookmarkDelegate.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * @return LargeIconBridge instance. By sharing the instance, we can also share the cache.
 */
LargeIconBridge getLargeIconBridge();