Search in sources :

Example 36 with RemoteViews

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;
}
Also used : RemoteViews(android.widget.RemoteViews)

Example 37 with RemoteViews

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);
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 38 with RemoteViews

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);
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 39 with RemoteViews

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());
}
Also used : RemoteViews(android.widget.RemoteViews) NotificationCompat(android.support.v4.app.NotificationCompat)

Example 40 with RemoteViews

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);
}
Also used : SearchAccount(com.fsck.k9.search.SearchAccount) Account(com.fsck.k9.Account) BaseAccount(com.fsck.k9.BaseAccount) UnreadWidgetConfiguration(com.fsck.k9.activity.UnreadWidgetConfiguration) MessagingController(com.fsck.k9.controller.MessagingController) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) SearchAccount(com.fsck.k9.search.SearchAccount) RemoteViews(android.widget.RemoteViews) LocalSearch(com.fsck.k9.search.LocalSearch) BaseAccount(com.fsck.k9.BaseAccount) PendingIntent(android.app.PendingIntent) AccountStats(com.fsck.k9.AccountStats)

Aggregations

RemoteViews (android.widget.RemoteViews)217 Intent (android.content.Intent)86 PendingIntent (android.app.PendingIntent)77 TextView (android.widget.TextView)35 Test (org.junit.Test)35 Notification (android.app.Notification)30 SmallTest (android.support.test.filters.SmallTest)30 View (android.view.View)29 ImageView (android.widget.ImageView)28 AppWidgetManager (android.appwidget.AppWidgetManager)26 ComponentName (android.content.ComponentName)24 Bitmap (android.graphics.Bitmap)24 Bundle (android.os.Bundle)16 NavigationBarView (com.android.systemui.statusbar.phone.NavigationBarView)15 RemoteInputView (com.android.systemui.statusbar.policy.RemoteInputView)15 NotificationCompat (android.support.v4.app.NotificationCompat)14 Resources (android.content.res.Resources)12 StatusBarNotification (android.service.notification.StatusBarNotification)12 SharedPreferences (android.content.SharedPreferences)11 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)11