mobile/android/base/home/HomeContextMenuInfo.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial