Example usage for android.database Cursor getBlob

List of usage examples for android.database Cursor getBlob

Introduction

In this page you can find the example usage for android.database Cursor getBlob.

Prototype

byte[] getBlob(int columnIndex);

Source Link

Document

Returns the value of the requested column as a byte array.

Usage

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

public Map<byte[], byte[]> getPublicKeySharedSecretMap() {
    HashMap<byte[], byte[]> key_ss = new HashMap<byte[], byte[]>();
    Cursor c = getReadableDatabase().query(Contact.TABLE,
            new String[] { Contact._ID, Contact.PUBLIC_KEY, Contact.SHARED_SECRET }, null, null, null, null,
            null);//from w  w  w .  j a  v  a 2 s. com
    try {
        if (c.moveToFirst())
            do {
                byte[] pk = c.getBlob(1);
                byte[] ss = c.getBlob(2);
                if (ss == null) {
                    Contact contact;
                    try {
                        contact = contactForContactId(c.getLong(0)).get();
                        ss = SharedSecretObj.getOrPushSecret(mContext, contact);
                    } catch (NoValError e) {
                        e.printStackTrace();
                    }
                }
                key_ss.put(pk, ss);
            } while (c.moveToNext());
        return key_ss;
    } finally {
        c.close();
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

public Map<Long, byte[]> getPublicKeyPrintSharedSecretMap() {
    HashMap<Long, byte[]> key_ss = new HashMap<Long, byte[]>();
    Cursor c = getReadableDatabase().query(Contact.TABLE,
            new String[] { Contact._ID, Contact.PUBLIC_KEY_HASH_64, Contact.SHARED_SECRET }, null, null, null,
            null, null);//from w ww .j  a  v a2  s .co m
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long pk = c.getLong(1);
        byte[] ss = c.getBlob(2);
        if (ss == null) {
            Contact contact;
            try {
                contact = contactForContactId(c.getLong(0)).get();
                ss = SharedSecretObj.getOrPushSecret(mContext, contact);
            } catch (NoValError e) {
                e.printStackTrace();
            }
        }
        key_ss.put(pk, ss);
        c.moveToNext();
    }
    c.close();
    return key_ss;
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

public byte[] getSharedSecret(long public_key) {
    Cursor c = getReadableDatabase().rawQuery("SELECT " + Contact._ID + "," + Contact.SHARED_SECRET + " FROM "
            + Contact.TABLE + " WHERE " + Contact.PUBLIC_KEY_HASH_64 + " = " + public_key, null);
    c.moveToFirst();// w ww .  j  av a 2 s .  co  m
    if (!c.moveToFirst()) {
        // no such person
        return null;
    }
    byte[] ss = c.getBlob(1);
    long id = c.getLong(0);
    c.close();
    if (ss != null) {
        return ss;
    }
    Contact contact;
    try {
        contact = contactForContactId(id).get();
        return SharedSecretObj.getOrPushSecret(mContext, contact);
    } catch (NoValError e) {
        return null;
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

public byte[] getSharedSecret(byte[] public_key) {
    String hex = new String(Hex.encodeHex(public_key));
    hex = hex.substring(0, hex.length() - 2);
    hex = hex.toUpperCase();/*from  ww  w . ja  v  a2  s . c  o m*/
    Cursor c = getReadableDatabase().rawQuery("SELECT " + Contact._ID + "," + Contact.SHARED_SECRET + " FROM "
            + Contact.TABLE + " WHERE HEX(" + Contact.PUBLIC_KEY + ") = '" + hex + "'", null);
    try {
        if (!c.moveToFirst()) {
            // no such person
            return null;
        }
        byte[] ss = c.getBlob(1);
        long id = c.getLong(0);

        if (ss != null) {
            return ss;
        }
        Contact contact;
        try {
            contact = contactForContactId(id).get();
            return SharedSecretObj.getOrPushSecret(mContext, contact);
        } catch (NoValError e) {
            return null;
        }
    } finally {
        c.close();
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.DBHelper.java

public EncodedObj getEncoded(long id) {
    Cursor c = getReadableDatabase().query(DbObject.TABLE, new String[] { DbObject.ENCODED, DbObject.HASH },
            DbObject._ID + "=?", new String[] { String.valueOf(id) }, null, null, null);

    try {//w w  w  .j a  v  a  2s .c o m
        if (!c.moveToFirst()) {
            Log.w(TAG, "no matching encoded obj");
            return null;
        }
        final byte[] encodedBytes = c.getBlob(0);
        if (encodedBytes == null) {
            Log.d(TAG, "obj found but with a null encoding");
            return null;
        }
        final long encodedHash = c.getLong(1);
        return new EncodedObj() {
            @Override
            public long getHash() {
                return encodedHash;
            }

            @Override
            public long getEncodingType() {
                return 0;
            }

            @Override
            public byte[] getEncoded() {
                return encodedBytes;
            }
        };
    } finally {
        c.close();
    }
}

From source file:edu.auburn.ppl.cyclecolumbus.NoteUploader.java

/******************************************************************************************
 * Generates JSONObject form of a note to be uploaded
 ******************************************************************************************
 * @param noteId Unique note ID to be uploaded
 * @return JSONObject of the note/* w w w .ja va 2  s.co  m*/
 * @throws JSONException
 ******************************************************************************************/
private JSONObject getNoteJSON(long noteId) throws JSONException {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    mDb.openReadOnly();
    Cursor noteCursor = mDb.fetchNote(noteId);

    Map<String, Integer> fieldMap = new HashMap<String, Integer>();
    fieldMap.put(NOTE_RECORDED, noteCursor.getColumnIndex(DbAdapter.K_NOTE_RECORDED));
    fieldMap.put(NOTE_LAT, noteCursor.getColumnIndex(DbAdapter.K_NOTE_LAT));
    fieldMap.put(NOTE_LGT, noteCursor.getColumnIndex(DbAdapter.K_NOTE_LGT));
    fieldMap.put(NOTE_HACC, noteCursor.getColumnIndex(DbAdapter.K_NOTE_ACC));
    fieldMap.put(NOTE_VACC, noteCursor.getColumnIndex(DbAdapter.K_NOTE_ACC));
    fieldMap.put(NOTE_ALT, noteCursor.getColumnIndex(DbAdapter.K_NOTE_ALT));
    fieldMap.put(NOTE_SPEED, noteCursor.getColumnIndex(DbAdapter.K_NOTE_SPEED));
    fieldMap.put(NOTE_TYPE, noteCursor.getColumnIndex(DbAdapter.K_NOTE_TYPE));
    fieldMap.put(NOTE_DETAILS, noteCursor.getColumnIndex(DbAdapter.K_NOTE_DETAILS));
    fieldMap.put(NOTE_IMGURL, noteCursor.getColumnIndex(DbAdapter.K_NOTE_IMGURL));

    JSONObject note = new JSONObject();

    note.put(NOTE_RECORDED, df.format(noteCursor.getDouble(fieldMap.get(NOTE_RECORDED))));
    note.put(NOTE_LAT, noteCursor.getDouble(fieldMap.get(NOTE_LAT)) / 1E6);
    note.put(NOTE_LGT, noteCursor.getDouble(fieldMap.get(NOTE_LGT)) / 1E6);
    note.put(NOTE_HACC, noteCursor.getDouble(fieldMap.get(NOTE_HACC)));
    note.put(NOTE_VACC, noteCursor.getDouble(fieldMap.get(NOTE_VACC)));
    note.put(NOTE_ALT, noteCursor.getDouble(fieldMap.get(NOTE_ALT)));
    note.put(NOTE_SPEED, noteCursor.getDouble(fieldMap.get(NOTE_SPEED)));
    note.put(NOTE_TYPE, noteCursor.getInt(fieldMap.get(NOTE_TYPE)));
    note.put(NOTE_DETAILS, noteCursor.getString(fieldMap.get(NOTE_DETAILS)));
    note.put(NOTE_IMGURL, noteCursor.getString(fieldMap.get(NOTE_IMGURL)));

    if (noteCursor.getString(fieldMap.get(NOTE_IMGURL)).equals("")) {
        imageDataNull = true;
    } else {
        imageDataNull = false;
        imageData = noteCursor.getBlob(noteCursor.getColumnIndex(DbAdapter.K_NOTE_IMGDATA));
    }

    noteCursor.close();
    mDb.close();
    return note;
}

From source file:org.sufficientlysecure.keychain.ui.ViewKeyTrustFragment.java

public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    /* TODO better error handling? May cause problems when a key is deleted,
     * because the notification triggers faster than the activity closes.
     */// ww  w  .  jav  a 2 s  . c  om
    // Avoid NullPointerExceptions...
    if (data.getCount() == 0) {
        return;
    }

    boolean nothingSpecial = true;
    StringBuilder message = new StringBuilder();

    // Swap the new cursor in. (The framework will take care of closing the
    // old cursor once we return.)
    if (data.moveToFirst()) {

        if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) {
            message.append(getString(R.string.key_trust_it_is_yours)).append("\n");
            nothingSpecial = false;
        } else if (data.getInt(INDEX_VERIFIED) != 0) {
            message.append(getString(R.string.key_trust_already_verified)).append("\n");
            nothingSpecial = false;
        }

        // If this key is revoked, dont trust it!
        if (data.getInt(INDEX_TRUST_IS_REVOKED) != 0) {
            message.append(getString(R.string.key_trust_revoked))
                    .append(getString(R.string.key_trust_old_keys));

            nothingSpecial = false;
        } else {
            if (data.getInt(INDEX_TRUST_IS_EXPIRED) != 0) {

                // if expired, dont trust it!
                message.append(getString(R.string.key_trust_expired))
                        .append(getString(R.string.key_trust_old_keys));

                nothingSpecial = false;
            }
        }

        if (nothingSpecial) {
            message.append(getString(R.string.key_trust_maybe));
        }

        final byte[] fp = data.getBlob(INDEX_TRUST_FINGERPRINT);
        final String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fp);
        if (fingerprint != null) {

            mStartSearch.setEnabled(true);
            mStartSearch.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    final Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(getActivity())
                            .getProxyPrefs();

                    Runnable ignoreTor = new Runnable() {
                        @Override
                        public void run() {
                            mStartSearch.setEnabled(false);
                            new DescribeKey(proxyPrefs.parcelableProxy).execute(fingerprint);
                        }
                    };

                    if (OrbotHelper.putOrbotInRequiredState(R.string.orbot_ignore_tor, ignoreTor, proxyPrefs,
                            getActivity())) {
                        mStartSearch.setEnabled(false);
                        new DescribeKey(proxyPrefs.parcelableProxy).execute(fingerprint);
                    }
                }
            });
        }
    }

    mTrustReadout.setText(message);
    setContentShown(true);
}

From source file:pl.selvin.android.syncframework.content.TableInfo.java

public void GetChanges(SQLiteDatabase db, JsonGenerator gen, ArrayList<TableInfo> notifyTableInfo)
        throws IOException {
    String[] cols = new String[columns.length + 3];
    int i = 0;/*from  ww w  .  ja v a  2 s  .co m*/
    for (; i < columns.length; i++)
        cols[i] = columns[i].name;
    cols[i] = _.uri;
    cols[i + 1] = _.tempId;
    cols[i + 2] = _.isDeleted;
    Cursor c = db.query(name, cols, _.isDirtyP, new String[] { "1" }, null, null, null);
    //to fix startPos  > actual rows for large cursors db operations should be done after cursor is closed ...
    final ArrayList<OperationHolder> operations = new ArrayList<OperationHolder>();
    if (c.moveToFirst()) {
        if (!notifyTableInfo.contains(this))
            notifyTableInfo.add(this);
        do {

            gen.writeStartObject();
            gen.writeObjectFieldStart(_.__metadata);
            gen.writeBooleanField(_.isDirty, true);
            gen.writeStringField(_.type, scope_name);
            //Log.d("before", scope_name + ":" + c.getLong(i + 3));
            String uri = c.getString(i);
            //Log.d("after", scope_name + ":" + c.getLong(i + 3));
            if (uri == null) {
                gen.writeStringField(_.tempId, c.getString(i + 1));
            } else {
                gen.writeStringField(_.uri, uri);
                final ContentValues update = new ContentValues(1);
                update.put(_.isDirty, 0);
                operations.add(new OperationHolder(name, OperationHolder.UPDATE, update, uri));
            }
            boolean isDeleted = c.getInt(i + 2) == 1;
            if (isDeleted) {
                gen.writeBooleanField(_.isDeleted, true);
                gen.writeEndObject();// meta
                operations.add(new OperationHolder(name, OperationHolder.DELETE, null, uri));
            } else {
                gen.writeEndObject();// meta
                for (i = 0; i < columns.length; i++) {
                    if (columns[i].nullable && c.isNull(i)) {
                        gen.writeNullField(columns[i].name);
                    } else {
                        switch (columns[i].type) {
                        case ColumnType.BLOB:
                            gen.writeBinaryField(columns[i].name, c.getBlob(i));
                            break;
                        case ColumnType.BOOLEAN:
                            gen.writeBooleanField(columns[i].name, c.getLong(i) == 1);
                            break;
                        case ColumnType.INTEGER:
                            gen.writeNumberField(columns[i].name, c.getLong(i));
                            break;
                        case ColumnType.DATETIME:
                            try {
                                gen.writeStringField(columns[i].name,
                                        String.format(msdate, sdf.parse(c.getString(i)).getTime()));
                            } catch (Exception e) {
                                if (BuildConfig.DEBUG) {
                                    Log.e("ListSync", e.getLocalizedMessage());
                                }
                            }
                            break;
                        case ColumnType.NUMERIC:
                            gen.writeNumberField(columns[i].name, c.getDouble(i));
                            break;
                        default:
                            gen.writeStringField(columns[i].name, c.getString(i));
                            break;
                        }
                    }
                }
            }
            gen.writeEndObject(); // end of row
        } while (c.moveToNext());
    }
    c.close();
    for (OperationHolder operation : operations)
        operation.execute(db);
}

From source file:us.theparamountgroup.android.inventory.ShellCursorAdapter.java

/**
 * This method binds the shell data (in the current row pointed to by cursor) to the given
 * list item layout. For example, the name for the current shell can be set on the name TextView
 * in the list item layout.//ww w  . j av a  2  s. c  o m
 *
 * @param view    Existing view, returned earlier by newView() method
 * @param context app context
 * @param cursor  The cursor from which to get the data. The cursor is already moved to the
 *                correct row.
 */

@Override
public void bindView(View view, final Context context, Cursor cursor) {

    // Find individual views that we want to modify in the list item layout
    TextView nameTextView = (TextView) view.findViewById(R.id.name);
    TextView colorTextView = (TextView) view.findViewById(R.id.color);
    final TextView quantityTextView = (TextView) view.findViewById(R.id.quantity);
    TextView priceTextView = (TextView) view.findViewById(R.id.price);
    ImageView photoImageView = (ImageView) view.findViewById(R.id.thumbnail);
    Button saleButton = (Button) view.findViewById(R.id.sale_button);
    final String idColumn = cursor.getString(cursor.getColumnIndexOrThrow(ShellContract.ShellEntry._ID));
    final String nameColumn = cursor
            .getString(cursor.getColumnIndexOrThrow(ShellContract.ShellEntry.COLUMN_SHELL_NAME));
    final Uri currentProductUri = ContentUris.withAppendedId(ShellContract.ShellEntry.CONTENT_URI,
            Long.parseLong(idColumn));
    // Find the columns of shell attributes that we're interested in
    int nameColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_NAME);
    int colorColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_COLOR);
    int photoColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_PHOTO);
    int quantityColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_QUANTITY);
    int priceColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_PRICE);
    int thumbnailColumnIndex = cursor.getColumnIndex(ShellContract.ShellEntry.COLUMN_SHELL_THUMBNAIL);

    // Read the shell attributes from the Cursor for the current shell

    final String shellName = cursor.getString(nameColumnIndex);
    String shellColor = cursor.getString(colorColumnIndex);
    String shellQuantity = cursor.getString(quantityColumnIndex);
    String shellPrice = cursor.getString(priceColumnIndex);
    String photo = cursor.getString(photoColumnIndex);

    // check if there is photo saved for item and assign the saved thumbnail to photoImageView
    if (!photo.isEmpty()) {
        try {
            byte[] thumbnail = cursor.getBlob(thumbnailColumnIndex);
            Bitmap thumbImage = getImage(thumbnail);
            photoImageView.setBackground(null);
            int cornerRadius = 10;
            RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(context.getResources(), thumbImage);
            dr.setCornerRadius(cornerRadius);
            photoImageView.setImageDrawable(dr);

        } catch (Exception e) {
            Log.e("ThumbnailUtils", "Problem extracting thumbnail", e);
            e.printStackTrace();
        }
    }

    // If the shell color is empty string or null, then use some default text
    // that says "Unknown color", so the TextView isn't blank.
    if (TextUtils.isEmpty(shellColor)) {
        shellColor = context.getString(R.string.unknown_color);
    }
    ;

    saleButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            int quantity;
            if (quantityTextView.getText().toString().isEmpty()) {
                quantity = 0;
            } else {
                quantity = Integer.parseInt(quantityTextView.getText().toString());
            }
            if (quantity > 0) {
                quantity = quantity - 1;
                quantityTextView.setText(String.valueOf(quantity));

                ContentValues values = new ContentValues();
                // values.put(ShellContract.ShellEntry.COLUMN_SHELL_NAME, shellName);
                values.put(ShellContract.ShellEntry.COLUMN_SHELL_QUANTITY, quantity);
                //values.put(ProductEntry.COLUMN_PRODUCT_PRICE, priceColumn);
                //values.put(ProductEntry.COLUMN_PRODUCT_PHOTO, photoColumn);

                int rowsAffected = context.getContentResolver().update(currentProductUri, values, null, null);
                if (rowsAffected == 0) {
                    // Toast.makeText(v.getContext(), v.getContext().getString("error updating"), Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(v.getContext(), "Sale Product " + nameColumn, Toast.LENGTH_LONG).show();
                }
            } else {
                Toast.makeText(v.getContext(), "Order Product", Toast.LENGTH_SHORT).show();
            }
        }
    });

    // Update the TextViews with the attributes for the current shell
    nameTextView.setText(shellName);
    colorTextView.setText(shellColor);
    quantityTextView.setText(shellQuantity);
    priceTextView.setText("$" + shellPrice);
}

From source file:com.aware.ui.Plugins_Manager.java

private void drawUI() {
    //Clear previous states
    store_grid.removeAllViews();//from  ww w  .  j a  v  a  2  s. co m

    //Build UI
    Cursor installed_plugins = getContentResolver().query(Aware_Plugins.CONTENT_URI, null, null, null,
            Aware_Plugins.PLUGIN_NAME + " ASC");
    if (installed_plugins != null && installed_plugins.moveToFirst()) {
        do {
            final String package_name = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_PACKAGE_NAME));
            final String name = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME));
            final String description = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_DESCRIPTION));
            final String developer = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_AUTHOR));
            final String version = installed_plugins
                    .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_VERSION));
            final int status = installed_plugins
                    .getInt(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_STATUS));

            final View pkg_view = inflater.inflate(R.layout.plugins_store_pkg_list_item, null, false);
            pkg_view.setTag(package_name); //each view has the package name as a tag for easier references

            try {
                ImageView pkg_icon = (ImageView) pkg_view.findViewById(R.id.pkg_icon);
                if (status != PLUGIN_NOT_INSTALLED) {
                    ApplicationInfo appInfo = getPackageManager().getApplicationInfo(package_name,
                            PackageManager.GET_META_DATA);
                    pkg_icon.setImageDrawable(appInfo.loadIcon(getPackageManager()));
                } else {
                    byte[] img = installed_plugins
                            .getBlob(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_ICON));
                    if (img != null)
                        pkg_icon.setImageBitmap(BitmapFactory.decodeByteArray(img, 0, img.length));
                }

                TextView pkg_title = (TextView) pkg_view.findViewById(R.id.pkg_title);
                pkg_title.setText(installed_plugins
                        .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME)));

                ImageView pkg_state = (ImageView) pkg_view.findViewById(R.id.pkg_state);

                switch (status) {
                case PLUGIN_DISABLED:
                    pkg_state.setVisibility(View.INVISIBLE);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setPositiveButton("Activate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.startPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_ACTIVE:
                    pkg_state.setImageResource(R.drawable.ic_pkg_active);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setPositiveButton("Deactivate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.stopPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_UPDATED:
                    pkg_state.setImageResource(R.drawable.ic_pkg_updated);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            if (isClassAvailable(package_name, "Settings")) {
                                builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.dismiss();
                                        Intent open_settings = new Intent();
                                        open_settings.setClassName(package_name, package_name + ".Settings");
                                        startActivity(open_settings);
                                    }
                                });
                            }
                            builder.setNeutralButton("Deactivate", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.stopPlugin(getApplicationContext(), package_name);
                                    drawUI();
                                }
                            });
                            builder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.downloadPlugin(getApplicationContext(), package_name, true);
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                case PLUGIN_NOT_INSTALLED:
                    pkg_state.setImageResource(R.drawable.ic_pkg_download);
                    pkg_view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            AlertDialog.Builder builder = getPluginInfoDialog(name, version, description,
                                    developer);
                            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                }
                            });
                            builder.setPositiveButton("Install", new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    Aware.downloadPlugin(getApplicationContext(), package_name, false);
                                }
                            });
                            builder.create().show();
                        }
                    });
                    break;
                }
                store_grid.addView(pkg_view);
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
        } while (installed_plugins.moveToNext());
    }
    if (installed_plugins != null && !installed_plugins.isClosed())
        installed_plugins.close();
}