Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | package org.mozilla.gecko.home; |
michael@0 | 7 | |
michael@0 | 8 | import org.mozilla.gecko.db.BrowserContract.Combined; |
michael@0 | 9 | import org.mozilla.gecko.util.StringUtils; |
michael@0 | 10 | |
michael@0 | 11 | import android.database.Cursor; |
michael@0 | 12 | import android.text.TextUtils; |
michael@0 | 13 | import android.view.View; |
michael@0 | 14 | import android.widget.AdapterView.AdapterContextMenuInfo; |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * A ContextMenuInfo for HomeListView |
michael@0 | 18 | */ |
michael@0 | 19 | public class HomeContextMenuInfo extends AdapterContextMenuInfo { |
michael@0 | 20 | |
michael@0 | 21 | public String url; |
michael@0 | 22 | public String title; |
michael@0 | 23 | public boolean isFolder = false; |
michael@0 | 24 | public int display = Combined.DISPLAY_NORMAL; |
michael@0 | 25 | public int historyId = -1; |
michael@0 | 26 | public int bookmarkId = -1; |
michael@0 | 27 | public int readingListItemId = -1; |
michael@0 | 28 | |
michael@0 | 29 | public HomeContextMenuInfo(View targetView, int position, long id) { |
michael@0 | 30 | super(targetView, position, id); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | public boolean hasBookmarkId() { |
michael@0 | 34 | return bookmarkId > -1; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | public boolean hasHistoryId() { |
michael@0 | 38 | return historyId > -1; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | public boolean isInReadingList() { |
michael@0 | 42 | return readingListItemId > -1; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | public boolean canRemove() { |
michael@0 | 46 | return hasBookmarkId() || hasHistoryId() || isInReadingList(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | public String getDisplayTitle() { |
michael@0 | 50 | if (!TextUtils.isEmpty(title)) { |
michael@0 | 51 | return title; |
michael@0 | 52 | } |
michael@0 | 53 | return StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url, StringUtils.UrlFlags.STRIP_HTTPS)); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | /* |
michael@0 | 57 | * Interface for creating ContextMenuInfo from cursors |
michael@0 | 58 | */ |
michael@0 | 59 | public interface Factory { |
michael@0 | 60 | public HomeContextMenuInfo makeInfoForCursor(View view, int position, long id, Cursor cursor); |
michael@0 | 61 | } |
michael@0 | 62 | } |