List of usage examples for android.net Uri withAppendedPath
public static Uri withAppendedPath(Uri baseUri, String pathSegment)
From source file:com.android.mms.ui.MessageUtils.java
public static List<MmsReportStatus> getMmsReportStatus(Context context, long messageId) { MmsLog.d(TAG, "getMmsReportStatus(): messageId = " + messageId); Uri uri = Uri.withAppendedPath(Mms.REPORT_STATUS_URI, String.valueOf(messageId)); Cursor c = SqliteWrapper.query(context, context.getContentResolver(), uri, new String[] { Mms.Addr.ADDRESS, "delivery_status", "read_status" }, null, null, null); if (c == null) { return null; }/*from ww w. j av a2 s . c o m*/ try { List<MmsReportStatus> mmsReportStatusList = new ArrayList<MmsReportStatus>(); while (c.moveToNext()) { int columnDeliveryStatus = 1; int columnReadStatus = 2; mmsReportStatusList .add(new MmsReportStatus(c.getInt(columnDeliveryStatus), c.getInt(columnReadStatus))); } return mmsReportStatusList; } finally { c.close(); } }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
/** * Returns the instance that was just filled out to the calling activity, if * requested./*ww w . j a v a 2s .c om*/ */ private void finishReturnInstance() { FormController formController = Collect.getInstance().getFormController(); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_EDIT.equals(action)) { // caller is waiting on a picked form String selection = InstanceColumns.INSTANCE_FILE_PATH + "=?"; String[] selectionArgs = { formController.getInstancePath().getAbsolutePath() }; Cursor c = null; try { c = getContentResolver().query(InstanceColumns.CONTENT_URI, null, selection, selectionArgs, null); if (c.getCount() > 0) { // should only be one... c.moveToFirst(); String id = c.getString(c.getColumnIndex(InstanceColumns._ID)); Uri instance = Uri.withAppendedPath(InstanceColumns.CONTENT_URI, id); setResult(RESULT_OK, new Intent().setData(instance)); } } finally { if (c != null) { c.close(); } } } finish(); }
From source file:com.android.mms.ui.MessageUtils.java
public static boolean haveEmailContact(String emailAddress, Context context) { Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(emailAddress)), new String[] { Contacts.DISPLAY_NAME }, null, null, null); if (cursor != null) { try {/*from w w w . j av a 2 s. c om*/ String name; while (cursor.moveToNext()) { name = cursor.getString(0); if (!TextUtils.isEmpty(name)) { return true; } } } finally { cursor.close(); } } return false; }
From source file:com.android.contacts.quickcontact.QuickContactActivity.java
private void shareContact() { final String lookupKey = mContactData.getLookupKey(); final Uri shareUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey); final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(Contacts.CONTENT_VCARD_TYPE); intent.putExtra(Intent.EXTRA_STREAM, shareUri); // Launch chooser to share contact via final CharSequence chooseTitle = getText(R.string.share_via); final Intent chooseIntent = Intent.createChooser(intent, chooseTitle); try {/*w w w . j a v a2 s. c om*/ mHasIntentLaunched = true; ImplicitIntentsUtil.startActivityOutsideApp(this, chooseIntent); } catch (final ActivityNotFoundException ex) { Toast.makeText(this, R.string.share_error, Toast.LENGTH_SHORT).show(); } }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri uri = Uri.withAppendedPath(Uri.parse("content://" + CloudContract.PROVIDER_AUTHORITY), "/keys.db/secret_keys/"); String[] projection = new String[] { CloudContract.COLUMN_ID, CloudContract.COLUMN_CLIENT_ID, CloudContract.COLUMN_CLIENT_SECRET_KEY }; switch (id) { case REQUEST_CODE_CLOUD_LIST_KEY: Uri uriAppendedPath = uri;//from w w w. j a va 2 s . c o m switch (OpenMode.getOpenMode(args.getInt(ARGS_KEY_LOADER, 6))) { case GDRIVE: uriAppendedPath = ContentUris.withAppendedId(uri, 1); break; case DROPBOX: uriAppendedPath = ContentUris.withAppendedId(uri, 2); break; case BOX: uriAppendedPath = ContentUris.withAppendedId(uri, 3); break; case ONEDRIVE: uriAppendedPath = ContentUris.withAppendedId(uri, 4); break; } return new CursorLoader(this, uriAppendedPath, projection, null, null, null); case REQUEST_CODE_CLOUD_LIST_KEYS: // we need a list of all secret keys Uri uriAll = Uri.withAppendedPath(Uri.parse("content://" + CloudContract.PROVIDER_AUTHORITY), "/keys.db/secret_keys"); CloudHandler cloudHandler = new CloudHandler(getApplicationContext()); try { List<CloudEntry> cloudEntries = cloudHandler.getAllEntries(); String ids[] = new String[cloudEntries.size()]; for (int i = 0; i < cloudEntries.size(); i++) { // we need to get only those cloud details which user wants switch (cloudEntries.get(i).getServiceType()) { case GDRIVE: ids[i] = 1 + ""; break; case DROPBOX: ids[i] = 2 + ""; break; case BOX: ids[i] = 3 + ""; break; case ONEDRIVE: ids[i] = 4 + ""; break; } } return new CursorLoader(this, uriAll, projection, CloudContract.COLUMN_ID, ids, null); } catch (CloudPluginException e) { e.printStackTrace(); Toast.makeText(this, getResources().getString(R.string.cloud_error_plugin), Toast.LENGTH_LONG) .show(); } case REQUEST_CODE_CLOUD_LIST_KEY_CLOUD: Uri uriAppendedPathCloud = ContentUris.withAppendedId(uri, 5); return new CursorLoader(this, uriAppendedPathCloud, projection, null, null, null); default: return null; } }
From source file:com.piusvelte.sonet.core.SonetService.java
private void buildWidgetButtons(Integer appWidgetId, boolean updatesReady, int page, boolean hasbuttons, int scrollable, int buttons_bg_color, int buttons_color, int buttons_textsize, boolean display_profile, int margin) { final String widget = Integer.toString(appWidgetId); // Push update for this widget to the home screen int layout;/*from w ww. j av a2 s.com*/ if (hasbuttons) { if (sNativeScrollingSupported) { if (margin > 0) layout = R.layout.widget_margin_scrollable; else layout = R.layout.widget_scrollable; } else if (display_profile) { if (margin > 0) layout = R.layout.widget_margin; else layout = R.layout.widget; } else { if (margin > 0) layout = R.layout.widget_noprofile_margin; else layout = R.layout.widget_noprofile; } } else { if (sNativeScrollingSupported) { if (margin > 0) layout = R.layout.widget_nobuttons_margin_scrollable; else layout = R.layout.widget_nobuttons_scrollable; } else if (display_profile) { if (margin > 0) layout = R.layout.widget_nobuttons_margin; else layout = R.layout.widget_nobuttons; } else { if (margin > 0) layout = R.layout.widget_nobuttons_noprofile_margin; else layout = R.layout.widget_nobuttons_noprofile; } } // wrap RemoteViews for backward compatibility RemoteViews views = new RemoteViews(getPackageName(), layout); if (hasbuttons) { Bitmap buttons_bg = Bitmap.createBitmap(1, 1, Config.ARGB_8888); Canvas buttons_bg_canvas = new Canvas(buttons_bg); buttons_bg_canvas.drawColor(buttons_bg_color); views.setImageViewBitmap(R.id.buttons_bg, buttons_bg); views.setTextColor(R.id.buttons_bg_clear, buttons_bg_color); views.setFloat(R.id.buttons_bg_clear, "setTextSize", buttons_textsize); views.setOnClickPendingIntent(R.id.button_post, PendingIntent.getActivity(SonetService.this, 0, Sonet.getPackageIntent(SonetService.this, SonetCreatePost.class) .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK) .setData(Uri.withAppendedPath(Widgets.getContentUri(SonetService.this), widget)), 0)); views.setTextColor(R.id.button_post, buttons_color); views.setFloat(R.id.button_post, "setTextSize", buttons_textsize); views.setOnClickPendingIntent(R.id.button_configure, PendingIntent.getActivity(SonetService.this, 0, Sonet.getPackageIntent(SonetService.this, ManageAccounts.class).setAction(widget), 0)); views.setTextColor(R.id.button_configure, buttons_color); views.setFloat(R.id.button_configure, "setTextSize", buttons_textsize); views.setOnClickPendingIntent(R.id.button_refresh, PendingIntent.getService(SonetService.this, 0, Sonet.getPackageIntent(SonetService.this, SonetService.class).setAction(widget), 0)); views.setTextColor(R.id.button_refresh, buttons_color); views.setFloat(R.id.button_refresh, "setTextSize", buttons_textsize); views.setTextColor(R.id.page_up, buttons_color); views.setFloat(R.id.page_up, "setTextSize", buttons_textsize); views.setTextColor(R.id.page_down, buttons_color); views.setFloat(R.id.page_down, "setTextSize", buttons_textsize); } // set margin if (scrollable == 0) { final AppWidgetManager mgr = AppWidgetManager.getInstance(SonetService.this); // check if native scrolling is supported if (sNativeScrollingSupported) { // native scrolling try { final Intent intent = SonetRemoteViewsServiceWrapper.getRemoteAdapterIntent(SonetService.this); if (intent != null) { intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.putExtra(Widgets.DISPLAY_PROFILE, display_profile); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); sSetRemoteAdapter.invoke(views, appWidgetId, R.id.messages, intent); // empty sSetEmptyView.invoke(views, R.id.messages, R.id.empty_messages); // onclick // Bind a click listener template for the contents of the message list final Intent onClickIntent = Sonet.getPackageIntent(SonetService.this, SonetWidget.class); onClickIntent.setAction(ACTION_ON_CLICK); onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(SonetService.this, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); sSetPendingIntentTemplate.invoke(views, R.id.messages, onClickPendingIntent); } else { // fallback on non-scrolling widget sNativeScrollingSupported = false; } } catch (NumberFormatException e) { Log.e(TAG, e.toString()); } catch (IllegalArgumentException e) { Log.e(TAG, e.toString()); } catch (IllegalAccessException e) { Log.e(TAG, e.toString()); } catch (InvocationTargetException e) { Log.e(TAG, e.toString()); } } if (!sNativeScrollingSupported) { Cursor statuses_styles = getContentResolver().query( Uri.withAppendedPath(Statuses_styles.getContentUri(SonetService.this), widget), new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE, Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE, Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.PROFILE_BG, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE }, null, null, Statuses_styles.CREATED + " DESC LIMIT " + page + ",-1"); if (statuses_styles.moveToFirst()) { int count_status = 0; views.removeAllViews(R.id.messages); while (!statuses_styles.isAfterLast() && (count_status < 16)) { int friend_color = statuses_styles.getInt(6), created_color = statuses_styles.getInt(7), friend_textsize = statuses_styles.getInt(9), created_textsize = statuses_styles.getInt(10), messages_color = statuses_styles.getInt(5), messages_textsize = statuses_styles.getInt(8); // get the item wrapper RemoteViews itemView; if (display_profile) { itemView = new RemoteViews(getPackageName(), R.layout.widget_item); // set profiles background byte[] profile_bg = statuses_styles.getBlob(13); if (profile_bg != null) { Bitmap profile_bgbmp = BitmapFactory.decodeByteArray(profile_bg, 0, profile_bg.length, sBFOptions); if (profile_bgbmp != null) itemView.setImageViewBitmap(R.id.profile_bg, profile_bgbmp); } byte[] profile = statuses_styles.getBlob(2); if (profile != null) { Bitmap profilebmp = BitmapFactory.decodeByteArray(profile, 0, profile.length, sBFOptions); if (profilebmp != null) itemView.setImageViewBitmap(R.id.profile, profilebmp); } } else itemView = new RemoteViews(getPackageName(), R.layout.widget_item_noprofile); itemView.setTextViewText(R.id.friend_bg_clear, statuses_styles.getString(1)); itemView.setFloat(R.id.friend_bg_clear, "setTextSize", friend_textsize); itemView.setTextViewText(R.id.message_bg_clear, statuses_styles.getString(3)); itemView.setFloat(R.id.message_bg_clear, "setTextSize", messages_textsize); // set friends background byte[] friend_bg = statuses_styles.getBlob(14); if (friend_bg != null) { Bitmap friend_bgbmp = BitmapFactory.decodeByteArray(friend_bg, 0, friend_bg.length, sBFOptions); if (friend_bgbmp != null) itemView.setImageViewBitmap(R.id.friend_bg, friend_bgbmp); } // set messages background byte[] status_bg = statuses_styles.getBlob(11); if (status_bg != null) { Bitmap status_bgbmp = BitmapFactory.decodeByteArray(status_bg, 0, status_bg.length, sBFOptions); if (status_bgbmp != null) itemView.setImageViewBitmap(R.id.status_bg, status_bgbmp); } // set an image byte[] image_bg = statuses_styles.getBlob(15); byte[] image = statuses_styles.getBlob(16); if ((image_bg != null) && (image != null)) { Bitmap image_bgBmp = BitmapFactory.decodeByteArray(image_bg, 0, image_bg.length, sBFOptions); if (image_bgBmp != null) { Bitmap imageBmp = BitmapFactory.decodeByteArray(image, 0, image.length, sBFOptions); itemView.setImageViewBitmap(R.id.image_clear, image_bgBmp); itemView.setImageViewBitmap(R.id.image, imageBmp); } } itemView.setTextViewText(R.id.message, statuses_styles.getString(3)); itemView.setTextColor(R.id.message, messages_color); itemView.setFloat(R.id.message, "setTextSize", messages_textsize); itemView.setOnClickPendingIntent(R.id.item, PendingIntent.getActivity(SonetService.this, 0, Sonet.getPackageIntent(SonetService.this, StatusDialog.class) .setData(Uri.withAppendedPath( Statuses_styles.getContentUri(SonetService.this), Long.toString(statuses_styles.getLong(0)))), 0)); itemView.setTextViewText(R.id.friend, statuses_styles.getString(1)); itemView.setTextColor(R.id.friend, friend_color); itemView.setFloat(R.id.friend, "setTextSize", friend_textsize); itemView.setTextViewText(R.id.created, statuses_styles.getString(4)); itemView.setTextColor(R.id.created, created_color); itemView.setFloat(R.id.created, "setTextSize", created_textsize); // set icons byte[] icon = statuses_styles.getBlob(12); if (icon != null) { Bitmap iconbmp = BitmapFactory.decodeByteArray(icon, 0, icon.length, sBFOptions); if (iconbmp != null) itemView.setImageViewBitmap(R.id.icon, iconbmp); } views.addView(R.id.messages, itemView); count_status++; statuses_styles.moveToNext(); } if (hasbuttons && (page < statuses_styles.getCount())) { // there are more statuses to show, allow paging down views.setOnClickPendingIntent(R.id.page_down, PendingIntent.getService(SonetService.this, 0, Sonet.getPackageIntent(SonetService.this, SonetService.class) .setAction(ACTION_PAGE_DOWN) .setData(Uri.withAppendedPath(Widgets.getContentUri(SonetService.this), widget)) .putExtra(ACTION_PAGE_DOWN, page + 1), PendingIntent.FLAG_UPDATE_CURRENT)); } } statuses_styles.close(); if (hasbuttons && (page > 0)) views.setOnClickPendingIntent(R.id.page_up, PendingIntent.getService(SonetService.this, 0, Sonet.getPackageIntent(SonetService.this, SonetService.class).setAction(ACTION_PAGE_UP) .setData(Uri.withAppendedPath(Widgets.getContentUri(SonetService.this), widget)) .putExtra(ACTION_PAGE_UP, page - 1), PendingIntent.FLAG_UPDATE_CURRENT)); } Log.d(TAG, "update native widget: " + appWidgetId); mgr.updateAppWidget(appWidgetId, views); if (sNativeScrollingSupported) { Log.d(TAG, "trigger widget query: " + appWidgetId); try { // trigger query sNotifyAppWidgetViewDataChanged.invoke(mgr, appWidgetId, R.id.messages); } catch (NumberFormatException e) { Log.e(TAG, e.toString()); } catch (IllegalArgumentException e) { Log.e(TAG, e.toString()); } catch (IllegalAccessException e) { Log.e(TAG, e.toString()); } catch (InvocationTargetException e) { Log.e(TAG, e.toString()); } } } else if (updatesReady) { // Log.d(TAG, "notify updatesReady"); getContentResolver().notifyChange(Statuses_styles.getContentUri(SonetService.this), null); } else { AppWidgetManager.getInstance(SonetService.this).updateAppWidget(Integer.parseInt(widget), views); buildScrollableWidget(appWidgetId, scrollable, display_profile); } }
From source file:com.shafiq.myfeedle.core.MyfeedleService.java
private void buildWidgetButtons(Integer appWidgetId, boolean updatesReady, int page, boolean hasbuttons, int scrollable, int buttons_bg_color, int buttons_color, int buttons_textsize, boolean display_profile, int margin) { final String widget = Integer.toString(appWidgetId); // Push update for this widget to the home screen int layout;//from w ww . j ava 2s.c o m if (hasbuttons) { if (sNativeScrollingSupported) { if (margin > 0) layout = R.layout.widget_margin_scrollable; else layout = R.layout.widget_scrollable; } else if (display_profile) { if (margin > 0) layout = R.layout.widget_margin; else layout = R.layout.widget; } else { if (margin > 0) layout = R.layout.widget_noprofile_margin; else layout = R.layout.widget_noprofile; } } else { if (sNativeScrollingSupported) { if (margin > 0) layout = R.layout.widget_nobuttons_margin_scrollable; else layout = R.layout.widget_nobuttons_scrollable; } else if (display_profile) { if (margin > 0) layout = R.layout.widget_nobuttons_margin; else layout = R.layout.widget_nobuttons; } else { if (margin > 0) layout = R.layout.widget_nobuttons_noprofile_margin; else layout = R.layout.widget_nobuttons_noprofile; } } // wrap RemoteViews for backward compatibility RemoteViews views = new RemoteViews(getPackageName(), layout); if (hasbuttons) { Bitmap buttons_bg = Bitmap.createBitmap(1, 1, Config.ARGB_8888); Canvas buttons_bg_canvas = new Canvas(buttons_bg); buttons_bg_canvas.drawColor(buttons_bg_color); views.setImageViewBitmap(R.id.buttons_bg, buttons_bg); views.setTextColor(R.id.buttons_bg_clear, buttons_bg_color); views.setFloat(R.id.buttons_bg_clear, "setTextSize", buttons_textsize); views.setOnClickPendingIntent(R.id.button_post, PendingIntent.getActivity(MyfeedleService.this, 0, Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleCreatePost.class) .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(Uri .withAppendedPath(Widgets.getContentUri(MyfeedleService.this), widget)), 0)); views.setTextColor(R.id.button_post, buttons_color); views.setFloat(R.id.button_post, "setTextSize", buttons_textsize); views.setOnClickPendingIntent(R.id.button_configure, PendingIntent.getActivity(MyfeedleService.this, 0, Myfeedle.getPackageIntent(MyfeedleService.this, ManageAccounts.class).setAction(widget), 0)); views.setTextColor(R.id.button_configure, buttons_color); views.setFloat(R.id.button_configure, "setTextSize", buttons_textsize); views.setOnClickPendingIntent(R.id.button_refresh, PendingIntent.getService(MyfeedleService.this, 0, Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleService.class).setAction(widget), 0)); views.setTextColor(R.id.button_refresh, buttons_color); views.setFloat(R.id.button_refresh, "setTextSize", buttons_textsize); views.setTextColor(R.id.page_up, buttons_color); views.setFloat(R.id.page_up, "setTextSize", buttons_textsize); views.setTextColor(R.id.page_down, buttons_color); views.setFloat(R.id.page_down, "setTextSize", buttons_textsize); } // set margin if (scrollable == 0) { final AppWidgetManager mgr = AppWidgetManager.getInstance(MyfeedleService.this); // check if native scrolling is supported if (sNativeScrollingSupported) { // native scrolling try { final Intent intent = MyfeedleRemoteViewsServiceWrapper .getRemoteAdapterIntent(MyfeedleService.this); if (intent != null) { intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.putExtra(Widgets.DISPLAY_PROFILE, display_profile); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); sSetRemoteAdapter.invoke(views, appWidgetId, R.id.messages, intent); // empty sSetEmptyView.invoke(views, R.id.messages, R.id.empty_messages); // onclick // Bind a click listener template for the contents of the message list final Intent onClickIntent = Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleWidget.class); onClickIntent.setAction(ACTION_ON_CLICK); onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(MyfeedleService.this, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); sSetPendingIntentTemplate.invoke(views, R.id.messages, onClickPendingIntent); } else { // fallback on non-scrolling widget sNativeScrollingSupported = false; } } catch (NumberFormatException e) { Log.e(TAG, e.toString()); } catch (IllegalArgumentException e) { Log.e(TAG, e.toString()); } catch (IllegalAccessException e) { Log.e(TAG, e.toString()); } catch (InvocationTargetException e) { Log.e(TAG, e.toString()); } } if (!sNativeScrollingSupported) { Cursor statuses_styles = getContentResolver().query( Uri.withAppendedPath(Statuses_styles.getContentUri(MyfeedleService.this), widget), new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE, Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE, Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.PROFILE_BG, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE }, null, null, Statuses_styles.CREATED + " DESC LIMIT " + page + ",-1"); if (statuses_styles.moveToFirst()) { int count_status = 0; views.removeAllViews(R.id.messages); while (!statuses_styles.isAfterLast() && (count_status < 16)) { int friend_color = statuses_styles.getInt(6), created_color = statuses_styles.getInt(7), friend_textsize = statuses_styles.getInt(9), created_textsize = statuses_styles.getInt(10), messages_color = statuses_styles.getInt(5), messages_textsize = statuses_styles.getInt(8); // get the item wrapper RemoteViews itemView; if (display_profile) { itemView = new RemoteViews(getPackageName(), R.layout.widget_item); // set profiles background byte[] profile_bg = statuses_styles.getBlob(13); if (profile_bg != null) { Bitmap profile_bgbmp = BitmapFactory.decodeByteArray(profile_bg, 0, profile_bg.length, sBFOptions); if (profile_bgbmp != null) itemView.setImageViewBitmap(R.id.profile_bg, profile_bgbmp); } byte[] profile = statuses_styles.getBlob(2); if (profile != null) { Bitmap profilebmp = BitmapFactory.decodeByteArray(profile, 0, profile.length, sBFOptions); if (profilebmp != null) itemView.setImageViewBitmap(R.id.profile, profilebmp); } } else itemView = new RemoteViews(getPackageName(), R.layout.widget_item_noprofile); itemView.setTextViewText(R.id.friend_bg_clear, statuses_styles.getString(1)); itemView.setFloat(R.id.friend_bg_clear, "setTextSize", friend_textsize); itemView.setTextViewText(R.id.message_bg_clear, statuses_styles.getString(3)); itemView.setFloat(R.id.message_bg_clear, "setTextSize", messages_textsize); // set friends background byte[] friend_bg = statuses_styles.getBlob(14); if (friend_bg != null) { Bitmap friend_bgbmp = BitmapFactory.decodeByteArray(friend_bg, 0, friend_bg.length, sBFOptions); if (friend_bgbmp != null) itemView.setImageViewBitmap(R.id.friend_bg, friend_bgbmp); } // set messages background byte[] status_bg = statuses_styles.getBlob(11); if (status_bg != null) { Bitmap status_bgbmp = BitmapFactory.decodeByteArray(status_bg, 0, status_bg.length, sBFOptions); if (status_bgbmp != null) itemView.setImageViewBitmap(R.id.status_bg, status_bgbmp); } // set an image byte[] image_bg = statuses_styles.getBlob(15); byte[] image = statuses_styles.getBlob(16); if ((image_bg != null) && (image != null)) { Bitmap image_bgBmp = BitmapFactory.decodeByteArray(image_bg, 0, image_bg.length, sBFOptions); if (image_bgBmp != null) { Bitmap imageBmp = BitmapFactory.decodeByteArray(image, 0, image.length, sBFOptions); itemView.setImageViewBitmap(R.id.image_clear, image_bgBmp); itemView.setImageViewBitmap(R.id.image, imageBmp); } } itemView.setTextViewText(R.id.message, statuses_styles.getString(3)); itemView.setTextColor(R.id.message, messages_color); itemView.setFloat(R.id.message, "setTextSize", messages_textsize); itemView.setOnClickPendingIntent(R.id.item, PendingIntent.getActivity(MyfeedleService.this, 0, Myfeedle.getPackageIntent(MyfeedleService.this, StatusDialog.class) .setData(Uri.withAppendedPath( Statuses_styles.getContentUri(MyfeedleService.this), Long.toString(statuses_styles.getLong(0)))), 0)); itemView.setTextViewText(R.id.friend, statuses_styles.getString(1)); itemView.setTextColor(R.id.friend, friend_color); itemView.setFloat(R.id.friend, "setTextSize", friend_textsize); itemView.setTextViewText(R.id.created, statuses_styles.getString(4)); itemView.setTextColor(R.id.created, created_color); itemView.setFloat(R.id.created, "setTextSize", created_textsize); // set icons byte[] icon = statuses_styles.getBlob(12); if (icon != null) { Bitmap iconbmp = BitmapFactory.decodeByteArray(icon, 0, icon.length, sBFOptions); if (iconbmp != null) itemView.setImageViewBitmap(R.id.icon, iconbmp); } views.addView(R.id.messages, itemView); count_status++; statuses_styles.moveToNext(); } if (hasbuttons && (page < statuses_styles.getCount())) { // there are more statuses to show, allow paging down views.setOnClickPendingIntent(R.id.page_down, PendingIntent.getService(MyfeedleService.this, 0, Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleService.class) .setAction(ACTION_PAGE_DOWN) .setData(Uri.withAppendedPath(Widgets.getContentUri(MyfeedleService.this), widget)) .putExtra(ACTION_PAGE_DOWN, page + 1), PendingIntent.FLAG_UPDATE_CURRENT)); } } statuses_styles.close(); if (hasbuttons && (page > 0)) views.setOnClickPendingIntent(R.id.page_up, PendingIntent.getService(MyfeedleService.this, 0, Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleService.class) .setAction(ACTION_PAGE_UP) .setData(Uri.withAppendedPath(Widgets.getContentUri(MyfeedleService.this), widget)) .putExtra(ACTION_PAGE_UP, page - 1), PendingIntent.FLAG_UPDATE_CURRENT)); } Log.d(TAG, "update native widget: " + appWidgetId); mgr.updateAppWidget(appWidgetId, views); if (sNativeScrollingSupported) { Log.d(TAG, "trigger widget query: " + appWidgetId); try { // trigger query sNotifyAppWidgetViewDataChanged.invoke(mgr, appWidgetId, R.id.messages); } catch (NumberFormatException e) { Log.e(TAG, e.toString()); } catch (IllegalArgumentException e) { Log.e(TAG, e.toString()); } catch (IllegalAccessException e) { Log.e(TAG, e.toString()); } catch (InvocationTargetException e) { Log.e(TAG, e.toString()); } } } else if (updatesReady) { // Log.d(TAG, "notify updatesReady"); getContentResolver().notifyChange(Statuses_styles.getContentUri(MyfeedleService.this), null); } else { AppWidgetManager.getInstance(MyfeedleService.this).updateAppWidget(Integer.parseInt(widget), views); buildScrollableWidget(appWidgetId, scrollable, display_profile); } }
From source file:com.piusvelte.sonet.core.SonetService.java
private void buildScrollableWidget(Integer appWidgetId, int scrollableVersion, boolean display_profile) { // set widget as scrollable Intent replaceDummy = new Intent(LauncherIntent.Action.ACTION_SCROLL_WIDGET_START); replaceDummy.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); replaceDummy.putExtra(LauncherIntent.Extra.EXTRA_VIEW_ID, R.id.messages); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_LISTVIEW_LAYOUT_ID, R.layout.widget_listview); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_PROVIDER_ALLOW_REQUERY, true); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_CHILDREN_CLICKABLE, true); //provider/*ww w.ja v a2s . c o m*/ Uri uri = Uri.withAppendedPath(Statuses_styles.getContentUri(SonetService.this), Integer.toString(appWidgetId)); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_URI, uri.toString()); String[] projection; if (display_profile) projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE, Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE, Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.PROFILE_BG, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE }; else projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE, Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE, Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE }; String sortOrder = Statuses_styles.CREATED + " DESC"; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_PROJECTION, projection); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SORT_ORDER, sortOrder); String whereClause = Statuses_styles.WIDGET + "=?"; String[] selectionArgs = new String[] { Integer.toString(appWidgetId) }; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION, whereClause); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION_ARGUMENTS, selectionArgs); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_ACTION_VIEW_URI_INDEX, SonetProvider.StatusesStylesColumns._id.ordinal()); switch (scrollableVersion) { case 1: if (display_profile) { replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID, R.layout.widget_item); int[] cursorIndices = new int[] { SonetProvider.StatusesStylesColumns.friend.ordinal(), SonetProvider.StatusesStylesColumns.message.ordinal(), SonetProvider.StatusesStylesColumns.status_bg.ordinal(), SonetProvider.StatusesStylesColumns.profile.ordinal(), SonetProvider.StatusesStylesColumns.friend.ordinal(), SonetProvider.StatusesStylesColumns.createdtext.ordinal(), SonetProvider.StatusesStylesColumns.message.ordinal(), SonetProvider.StatusesStylesColumns.icon.ordinal(), SonetProvider.StatusesStylesColumns.profile_bg.ordinal(), SonetProvider.StatusesStylesColumns.friend_bg.ordinal(), SonetProvider.StatusesStylesColumns.image_bg.ordinal(), SonetProvider.StatusesStylesColumns.image.ordinal() }; int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB }; int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg, R.id.profile, R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.profile_bg, R.id.friend_bg, R.id.image_clear, R.id.image }; int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false, false, false, false }; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable); } else { replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID, R.layout.widget_item_noprofile); int[] cursorIndices = new int[] { SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.icon.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(), SonetProvider.StatusesStylesColumnsNoProfile.image.ordinal() }; int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB }; int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg, R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.friend_bg, R.id.image_clear, R.id.image }; int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false, false }; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable); } break; case 2: if (display_profile) { BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item); Intent i = Sonet.getPackageIntent(SonetService.this, SonetWidget.class) .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pi = PendingIntent.getBroadcast(SonetService.this, 0, i, 0); itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS, SonetProvider.StatusesStylesColumns._id.ordinal()); itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText", SonetProvider.StatusesStylesColumns.friend.ordinal(), 0); itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize", SonetProvider.StatusesStylesColumns.friend_textsize.ordinal()); itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText", SonetProvider.StatusesStylesColumns.message.ordinal(), 0); itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize", SonetProvider.StatusesStylesColumns.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap", SonetProvider.StatusesStylesColumns.status_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap", SonetProvider.StatusesStylesColumns.image_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image, "setImageBitmap", SonetProvider.StatusesStylesColumns.image.ordinal(), 0); itemViews.setBoundBitmap(R.id.profile, "setImageBitmap", SonetProvider.StatusesStylesColumns.profile.ordinal(), 0); itemViews.setBoundCharSequence(R.id.friend, "setText", SonetProvider.StatusesStylesColumns.friend.ordinal(), 0); itemViews.setBoundCharSequence(R.id.created, "setText", SonetProvider.StatusesStylesColumns.createdtext.ordinal(), 0); itemViews.setBoundCharSequence(R.id.message, "setText", SonetProvider.StatusesStylesColumns.message.ordinal(), 0); itemViews.setBoundInt(R.id.friend, "setTextColor", SonetProvider.StatusesStylesColumns.friend_color.ordinal()); itemViews.setBoundInt(R.id.created, "setTextColor", SonetProvider.StatusesStylesColumns.created_color.ordinal()); itemViews.setBoundInt(R.id.message, "setTextColor", SonetProvider.StatusesStylesColumns.messages_color.ordinal()); itemViews.setBoundFloat(R.id.friend, "setTextSize", SonetProvider.StatusesStylesColumns.friend_textsize.ordinal()); itemViews.setBoundFloat(R.id.created, "setTextSize", SonetProvider.StatusesStylesColumns.created_textsize.ordinal()); itemViews.setBoundFloat(R.id.message, "setTextSize", SonetProvider.StatusesStylesColumns.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.icon, "setImageBitmap", SonetProvider.StatusesStylesColumns.icon.ordinal(), 0); itemViews.setBoundBitmap(R.id.profile_bg, "setImageBitmap", SonetProvider.StatusesStylesColumns.profile_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap", SonetProvider.StatusesStylesColumns.friend_bg.ordinal(), 0); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews); } else { BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item_noprofile); Intent i = Sonet.getPackageIntent(SonetService.this, SonetWidget.class) .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pi = PendingIntent.getBroadcast(SonetService.this, 0, i, 0); itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS, SonetProvider.StatusesStylesColumnsNoProfile._id.ordinal()); itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText", SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0); itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize", SonetProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal()); itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText", SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0); itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize", SonetProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap", SonetProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap", SonetProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image, "setImageBitmap", SonetProvider.StatusesStylesColumnsNoProfile.image.ordinal(), 0); itemViews.setBoundCharSequence(R.id.friend, "setText", SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0); itemViews.setBoundCharSequence(R.id.created, "setText", SonetProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(), 0); itemViews.setBoundCharSequence(R.id.message, "setText", SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0); itemViews.setBoundInt(R.id.friend, "setTextColor", SonetProvider.StatusesStylesColumnsNoProfile.friend_color.ordinal()); itemViews.setBoundInt(R.id.created, "setTextColor", SonetProvider.StatusesStylesColumnsNoProfile.created_color.ordinal()); itemViews.setBoundInt(R.id.message, "setTextColor", SonetProvider.StatusesStylesColumnsNoProfile.messages_color.ordinal()); itemViews.setBoundFloat(R.id.friend, "setTextSize", SonetProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal()); itemViews.setBoundFloat(R.id.created, "setTextSize", SonetProvider.StatusesStylesColumnsNoProfile.created_textsize.ordinal()); itemViews.setBoundFloat(R.id.message, "setTextSize", SonetProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.icon, "setImageBitmap", SonetProvider.StatusesStylesColumnsNoProfile.icon.ordinal(), 0); itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap", SonetProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(), 0); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews); } break; } sendBroadcast(replaceDummy); }
From source file:com.shafiq.myfeedle.core.MyfeedleService.java
private void buildScrollableWidget(Integer appWidgetId, int scrollableVersion, boolean display_profile) { // set widget as scrollable Intent replaceDummy = new Intent(LauncherIntent.Action.ACTION_SCROLL_WIDGET_START); replaceDummy.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); replaceDummy.putExtra(LauncherIntent.Extra.EXTRA_VIEW_ID, R.id.messages); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_LISTVIEW_LAYOUT_ID, R.layout.widget_listview); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_PROVIDER_ALLOW_REQUERY, true); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_CHILDREN_CLICKABLE, true); //provider//from w w w . jav a 2 s. co m Uri uri = Uri.withAppendedPath(Statuses_styles.getContentUri(MyfeedleService.this), Integer.toString(appWidgetId)); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_URI, uri.toString()); String[] projection; if (display_profile) projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE, Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE, Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.PROFILE_BG, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE }; else projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE, Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE, Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE }; String sortOrder = Statuses_styles.CREATED + " DESC"; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_PROJECTION, projection); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SORT_ORDER, sortOrder); String whereClause = Statuses_styles.WIDGET + "=?"; String[] selectionArgs = new String[] { Integer.toString(appWidgetId) }; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION, whereClause); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION_ARGUMENTS, selectionArgs); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_ACTION_VIEW_URI_INDEX, MyfeedleProvider.StatusesStylesColumns._id.ordinal()); switch (scrollableVersion) { case 1: if (display_profile) { replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID, R.layout.widget_item); int[] cursorIndices = new int[] { MyfeedleProvider.StatusesStylesColumns.friend.ordinal(), MyfeedleProvider.StatusesStylesColumns.message.ordinal(), MyfeedleProvider.StatusesStylesColumns.status_bg.ordinal(), MyfeedleProvider.StatusesStylesColumns.profile.ordinal(), MyfeedleProvider.StatusesStylesColumns.friend.ordinal(), MyfeedleProvider.StatusesStylesColumns.createdtext.ordinal(), MyfeedleProvider.StatusesStylesColumns.message.ordinal(), MyfeedleProvider.StatusesStylesColumns.icon.ordinal(), MyfeedleProvider.StatusesStylesColumns.profile_bg.ordinal(), MyfeedleProvider.StatusesStylesColumns.friend_bg.ordinal(), MyfeedleProvider.StatusesStylesColumns.image_bg.ordinal(), MyfeedleProvider.StatusesStylesColumns.image.ordinal() }; int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB }; int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg, R.id.profile, R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.profile_bg, R.id.friend_bg, R.id.image_clear, R.id.image }; int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false, false, false, false }; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable); } else { replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID, R.layout.widget_item_noprofile); int[] cursorIndices = new int[] { MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.icon.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(), MyfeedleProvider.StatusesStylesColumnsNoProfile.image.ordinal() }; int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB }; int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg, R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.friend_bg, R.id.image_clear, R.id.image }; int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false, false }; replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable); } break; case 2: if (display_profile) { BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item); Intent i = Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleWidget.class) .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pi = PendingIntent.getBroadcast(MyfeedleService.this, 0, i, 0); itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS, MyfeedleProvider.StatusesStylesColumns._id.ordinal()); itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText", MyfeedleProvider.StatusesStylesColumns.friend.ordinal(), 0); itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize", MyfeedleProvider.StatusesStylesColumns.friend_textsize.ordinal()); itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText", MyfeedleProvider.StatusesStylesColumns.message.ordinal(), 0); itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize", MyfeedleProvider.StatusesStylesColumns.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.status_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.image_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.image.ordinal(), 0); itemViews.setBoundBitmap(R.id.profile, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.profile.ordinal(), 0); itemViews.setBoundCharSequence(R.id.friend, "setText", MyfeedleProvider.StatusesStylesColumns.friend.ordinal(), 0); itemViews.setBoundCharSequence(R.id.created, "setText", MyfeedleProvider.StatusesStylesColumns.createdtext.ordinal(), 0); itemViews.setBoundCharSequence(R.id.message, "setText", MyfeedleProvider.StatusesStylesColumns.message.ordinal(), 0); itemViews.setBoundInt(R.id.friend, "setTextColor", MyfeedleProvider.StatusesStylesColumns.friend_color.ordinal()); itemViews.setBoundInt(R.id.created, "setTextColor", MyfeedleProvider.StatusesStylesColumns.created_color.ordinal()); itemViews.setBoundInt(R.id.message, "setTextColor", MyfeedleProvider.StatusesStylesColumns.messages_color.ordinal()); itemViews.setBoundFloat(R.id.friend, "setTextSize", MyfeedleProvider.StatusesStylesColumns.friend_textsize.ordinal()); itemViews.setBoundFloat(R.id.created, "setTextSize", MyfeedleProvider.StatusesStylesColumns.created_textsize.ordinal()); itemViews.setBoundFloat(R.id.message, "setTextSize", MyfeedleProvider.StatusesStylesColumns.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.icon, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.icon.ordinal(), 0); itemViews.setBoundBitmap(R.id.profile_bg, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.profile_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap", MyfeedleProvider.StatusesStylesColumns.friend_bg.ordinal(), 0); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews); } else { BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item_noprofile); Intent i = Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleWidget.class) .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); PendingIntent pi = PendingIntent.getBroadcast(MyfeedleService.this, 0, i, 0); itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS, MyfeedleProvider.StatusesStylesColumnsNoProfile._id.ordinal()); itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText", MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0); itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize", MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal()); itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText", MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0); itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize", MyfeedleProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap", MyfeedleProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap", MyfeedleProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(), 0); itemViews.setBoundBitmap(R.id.image, "setImageBitmap", MyfeedleProvider.StatusesStylesColumnsNoProfile.image.ordinal(), 0); itemViews.setBoundCharSequence(R.id.friend, "setText", MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0); itemViews.setBoundCharSequence(R.id.created, "setText", MyfeedleProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(), 0); itemViews.setBoundCharSequence(R.id.message, "setText", MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0); itemViews.setBoundInt(R.id.friend, "setTextColor", MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_color.ordinal()); itemViews.setBoundInt(R.id.created, "setTextColor", MyfeedleProvider.StatusesStylesColumnsNoProfile.created_color.ordinal()); itemViews.setBoundInt(R.id.message, "setTextColor", MyfeedleProvider.StatusesStylesColumnsNoProfile.messages_color.ordinal()); itemViews.setBoundFloat(R.id.friend, "setTextSize", MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal()); itemViews.setBoundFloat(R.id.created, "setTextSize", MyfeedleProvider.StatusesStylesColumnsNoProfile.created_textsize.ordinal()); itemViews.setBoundFloat(R.id.message, "setTextSize", MyfeedleProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal()); itemViews.setBoundBitmap(R.id.icon, "setImageBitmap", MyfeedleProvider.StatusesStylesColumnsNoProfile.icon.ordinal(), 0); itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap", MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(), 0); replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews); } break; } sendBroadcast(replaceDummy); }