31  public static final Uri CONTENT_URI =
 
   32      Uri.parse(
"content://com.freerdp.afreerdp.services.freerdpsuggestionprovider");
 
   34  @Override 
public int delete(Uri uri, String selection, String[] selectionArgs)
 
   40  @Override 
public String getType(Uri uri)
 
   42    return "vnd.android.cursor.item/vnd.freerdp.remote";
 
   45  @Override 
public Uri insert(Uri uri, ContentValues values)
 
   51  @Override 
public boolean onCreate()
 
   57  public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
 
   61    String query = (selectionArgs != 
null && selectionArgs.length > 0) ? selectionArgs[0] : 
"";
 
   64    ArrayList<BookmarkBase> history =
 
   65        GlobalApp.getQuickConnectHistoryGateway().findHistory(query);
 
   68    ArrayList<BookmarkBase> manualBookmarks;
 
   69    if (query.length() > 0)
 
   70      manualBookmarks = GlobalApp.getManualBookmarkGateway().findByLabelOrHostnameLike(query);
 
   72      manualBookmarks = GlobalApp.getManualBookmarkGateway().findAll();
 
   74    return createResultCursor(history, manualBookmarks);
 
   78  public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
 
   84  private void addBookmarksToCursor(ArrayList<BookmarkBase> bookmarks, MatrixCursor resultCursor)
 
   86    Object[] row = 
new Object[5];
 
   87    for (BookmarkBase bookmark : bookmarks)
 
   89      row[0] = bookmark.getId();
 
   90      row[1] = bookmark.getLabel();
 
   91      row[2] = bookmark.<ManualBookmark>
get().getHostname();
 
   92      row[3] = ConnectionReference.getManualBookmarkReference(bookmark.getId());
 
   93      row[4] = 
"android.resource://" + getContext().getPackageName() + 
"/" +
 
   94               R.drawable.icon_star_on;
 
   95      resultCursor.addRow(row);
 
   99  private void addHistoryToCursor(ArrayList<BookmarkBase> history, MatrixCursor resultCursor)
 
  101    Object[] row = 
new Object[5];
 
  102    for (BookmarkBase bookmark : history)
 
  105      row[1] = bookmark.getLabel();
 
  106      row[2] = bookmark.getLabel();
 
  107      row[3] = ConnectionReference.getHostnameReference(bookmark.getLabel());
 
  108      row[4] = 
"android.resource://" + getContext().getPackageName() + 
"/" +
 
  109               R.drawable.icon_star_off;
 
  110      resultCursor.addRow(row);
 
  114  private Cursor createResultCursor(ArrayList<BookmarkBase> history,
 
  115                                    ArrayList<BookmarkBase> manualBookmarks)
 
  119    int totalCount = history.size() + manualBookmarks.size();
 
  120    String[] columns = { android.provider.BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1,
 
  121                       SearchManager.SUGGEST_COLUMN_TEXT_2,
 
  122                       SearchManager.SUGGEST_COLUMN_INTENT_DATA,
 
  123                       SearchManager.SUGGEST_COLUMN_ICON_2 };
 
  124    MatrixCursor matrixCursor = 
new MatrixCursor(columns, totalCount);
 
  129      addHistoryToCursor(history, matrixCursor);
 
  130      addBookmarksToCursor(manualBookmarks, matrixCursor);