use of android.widget.RemoteViews in project PlayerHater by chrisrhoden.
the class ExpandableNotificationPlugin method getExpandedView.
private RemoteViews getExpandedView() {
if (mExpandedView == null) {
mExpandedView = new RemoteViews(getContext().getPackageName(), R.layout.zzz_ph_jbb_notification);
setListeners(mExpandedView);
mExpandedView.setTextViewText(R.id.zzz_ph_notification_title, mNotificationTitle);
mExpandedView.setTextViewText(R.id.zzz_ph_notification_text, mNotificationText);
mExpandedView.setImageViewUri(R.id.zzz_ph_notification_image, mNotificationImageUrl);
}
return mExpandedView;
}
use of android.widget.RemoteViews in project cw-advandroid by commonsguy.
the class WidgetProvider method onUpdate.
@Override
public void onUpdate(Context ctxt, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int i = 0; i < appWidgetIds.length; i++) {
Intent svcIntent = new Intent(ctxt, WidgetService.class);
svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
RemoteViews widget = new RemoteViews(ctxt.getPackageName(), R.layout.widget);
widget.setRemoteAdapter(appWidgetIds[i], R.id.words, svcIntent);
Intent clickIntent = new Intent(ctxt, LoremActivity.class);
PendingIntent clickPI = PendingIntent.getActivity(ctxt, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
widget.setPendingIntentTemplate(R.id.words, clickPI);
appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
}
super.onUpdate(ctxt, appWidgetManager, appWidgetIds);
}
use of android.widget.RemoteViews in project cw-advandroid by commonsguy.
the class AppWidget method buildUpdate.
private RemoteViews buildUpdate(Context ctxt, int[] appWidgetIds) {
RemoteViews updateViews = new RemoteViews(ctxt.getPackageName(), R.layout.widget);
Intent i = new Intent(ctxt, AppWidget.class);
i.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
updateViews.setImageViewResource(R.id.left_die, IMAGES[(int) (Math.random() * 6)]);
updateViews.setOnClickPendingIntent(R.id.left_die, pi);
updateViews.setImageViewResource(R.id.right_die, IMAGES[(int) (Math.random() * 6)]);
updateViews.setOnClickPendingIntent(R.id.right_die, pi);
updateViews.setOnClickPendingIntent(R.id.background, pi);
return (updateViews);
}
use of android.widget.RemoteViews in project Signal-Android by WhisperSystems.
the class KeyCachingService method foregroundServiceICS.
private void foregroundServiceICS() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.key_caching_notification);
remoteViews.setOnClickPendingIntent(R.id.lock_cache_icon, buildLockIntent());
builder.setSmallIcon(R.drawable.icon_cached);
builder.setContent(remoteViews);
builder.setContentIntent(buildLaunchIntent());
stopForeground(true);
startForeground(SERVICE_RUNNING_ID, builder.build());
}
use of android.widget.RemoteViews in project k-9 by k9mail.
the class UnreadWidgetProvider method updateWidget.
public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, String accountUuid) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.unread_widget_layout);
int unreadCount = 0;
String accountName = context.getString(R.string.app_name);
Intent clickIntent = null;
try {
BaseAccount account = null;
AccountStats stats = null;
SearchAccount searchAccount = null;
if (SearchAccount.UNIFIED_INBOX.equals(accountUuid)) {
searchAccount = SearchAccount.createUnifiedInboxAccount(context);
} else if (SearchAccount.ALL_MESSAGES.equals(accountUuid)) {
searchAccount = SearchAccount.createAllMessagesAccount(context);
}
if (searchAccount != null) {
account = searchAccount;
MessagingController controller = MessagingController.getInstance(context);
stats = controller.getSearchAccountStatsSynchronous(searchAccount, null);
clickIntent = MessageList.intentDisplaySearch(context, searchAccount.getRelatedSearch(), false, true, true);
} else {
Account realAccount = Preferences.getPreferences(context).getAccount(accountUuid);
if (realAccount != null) {
account = realAccount;
stats = realAccount.getStats(context);
if (K9.FOLDER_NONE.equals(realAccount.getAutoExpandFolderName())) {
clickIntent = FolderList.actionHandleAccountIntent(context, realAccount, false);
} else {
LocalSearch search = new LocalSearch(realAccount.getAutoExpandFolderName());
search.addAllowedFolder(realAccount.getAutoExpandFolderName());
search.addAccountUuid(account.getUuid());
clickIntent = MessageList.intentDisplaySearch(context, search, false, true, true);
}
clickIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
}
}
if (account != null) {
accountName = account.getDescription();
}
if (stats != null) {
unreadCount = stats.unreadMessageCount;
}
} catch (Exception e) {
Timber.e(e, "Error getting widget configuration");
}
if (unreadCount <= 0) {
// Hide TextView for unread count if there are no unread messages.
remoteViews.setViewVisibility(R.id.unread_count, View.GONE);
} else {
remoteViews.setViewVisibility(R.id.unread_count, View.VISIBLE);
String displayCount = (unreadCount <= MAX_COUNT) ? String.valueOf(unreadCount) : String.valueOf(MAX_COUNT) + "+";
remoteViews.setTextViewText(R.id.unread_count, displayCount);
}
remoteViews.setTextViewText(R.id.account_name, accountName);
if (clickIntent == null) {
// If the widget configuration couldn't be loaded we open the configuration
// activity when the user clicks the widget.
clickIntent = new Intent(context, UnreadWidgetConfiguration.class);
clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
}
clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, clickIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.unread_widget_layout, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
Aggregations