List of usage examples for android.widget RemoteViews RemoteViews
public RemoteViews(RemoteViews landscape, RemoteViews portrait)
From source file:com.commonsware.android.okhttp3.progress.Downloader.java
private NotificationCompat.Builder buildForeground(String filename) { NotificationCompat.Builder b = new NotificationCompat.Builder(this); RemoteViews content = new RemoteViews(getPackageName(), R.layout.notif_content); content.setTextViewText(android.R.id.title, "Downloading: " + filename); b.setOngoing(true).setContent(content).setSmallIcon(android.R.drawable.stat_sys_download); return (b);//from ww w .ja va2s. c om }
From source file:com.florianmski.tracktoid.trakt.tasks.get.UpdateShowsTask.java
private void createNotification() { notification = new Notification(R.drawable.ab_icon_refresh, "Refreshing...", System.currentTimeMillis()); nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); contentView = new RemoteViews(context.getPackageName(), R.layout.notification_progress); notification.contentView = contentView; Intent notificationIntent = new Intent(context, MyShowsActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.contentIntent = contentIntent; notification.flags = Notification.FLAG_NO_CLEAR; nm.notify(NOTIFICATION_ID, notification); }
From source file:com.mathi_amorim.emmanuel.metrictime.UpdateTimeService.java
private void updateWidget() { mCalendar.setTimeInMillis(System.currentTimeMillis()); MetricTime time = MetricTimeConverter.currentMetricTime(); String currentTime = String.format("%1$01d:%2$02d", time.hours, time.minutes); RemoteViews mRemoteViews = new RemoteViews(getPackageName(), R.layout.metric_time_widget); mRemoteViews.setTextViewText(R.id.widget1label, currentTime); Intent intent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); mRemoteViews.setOnClickPendingIntent(R.id.widget1label, pendingIntent); ComponentName mComponentName = new ComponentName(this, MetricTimeWidgetProvider.class); AppWidgetManager mAppWidgetManager = AppWidgetManager.getInstance(this); mAppWidgetManager.updateAppWidget(mComponentName, mRemoteViews); }
From source file:net.bible.android.device.ProgressNotificationManager.java
/** find the Progress object in our map to the associated Notifications * /* w w w .jav a2s. com*/ * @param prog * @return */ private Notification findOrCreateNotification(Progress prog) { Notification notification = progressMap.get(prog); if (notification == null) { Log.d(TAG, "Creating Notification for progress Hash:" + prog.hashCode()); // configure the intent Intent intent = new Intent(BibleApplication.getApplication(), ProgressStatus.class); final PendingIntent pendingIntent = PendingIntent.getActivity(BibleApplication.getApplication(), 0, intent, 0); notification = new Notification(R.drawable.bible, prog.getJobName(), System.currentTimeMillis()); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL; notification.contentView = new RemoteViews(SharedConstants.PACKAGE_NAME, R.layout.progress_notification); notification.contentIntent = pendingIntent; notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.bible); notification.contentView.setTextViewText(R.id.status_text, ""); notification.contentView.setProgressBar(R.id.status_progress, 100, prog.getWork(), false); progressMap.put(prog, notification); androidNotificationManager.notify(prog.hashCode(), notification); } return notification; }
From source file:net.hyx.app.volumenotification.NotificationFactory.java
private RemoteViews getCustomContentView() { RemoteViews view = new RemoteViews(_package, R.layout.view_layout_notification); List<Integer> buttons = new ArrayList<>(); int theme = resources.getIdentifier("style_" + settings.getTheme(), "style", _package); int background_color; int icon_color; if (theme != 0) { TypedArray attrs = context.obtainStyledAttributes(theme, R.styleable.styleable); background_color = attrs.getColor(R.styleable.styleable_background_color, 0); icon_color = attrs.getColor(R.styleable.styleable_icon_color, 0); attrs.recycle();/*from www.j av a 2 s .c o m*/ } else { background_color = settings.getColor(settings.getCustomThemeBackgroundColor()); icon_color = settings.getColor(settings.getCustomThemeIconColor()); } if (settings.getTransparent()) { background_color = android.R.color.transparent; } view.setInt(R.id.layout_background, "setBackgroundColor", background_color); view.removeAllViews(R.id.layout_buttons); for (int pos = 1; pos <= BUTTONS_SELECTION_SIZE; pos++) { int sel = settings.getButtonSelection(pos); if (!settings.getButtonChecked(pos) || buttons.contains(sel) || sel >= BUTTONS_SELECTION_SIZE) { continue; } buttons.add(sel); int btn_sel = sel + 1; int btn_id = resources.getIdentifier("btn_sel_" + btn_sel, "id", _package); RemoteViews btn = new RemoteViews(_package, resources.getIdentifier("view_btn_sel_" + btn_sel, "layout", _package)); Intent intent = new Intent(context, ReceiverSetVolume.class).putExtra("position", pos); PendingIntent event = PendingIntent.getBroadcast(context, btn_id, intent, PendingIntent.FLAG_UPDATE_CURRENT); btn.setOnClickPendingIntent(btn_id, event); //btn.setInt(btn_id, "setImageResource", settings.getDrawable(context, R.array.pref_buttons_icons_entries, settings.getButtonIcon(pos))); btn.setInt(btn_id, "setColorFilter", icon_color); view.addView(R.id.layout_buttons, btn); } return view; }
From source file:net.bible.service.device.ProgressNotificationManager.java
/** find the Progress object in our map to the associated Notifications * /* w w w.j a v a2 s . c o m*/ * @param prog * @return */ private Notification findOrCreateNotification(Progress prog) { Notification notification = progressMap.get(prog); if (notification == null) { Log.d(TAG, "Creating Notification for progress Hash:" + prog.hashCode()); // configure the intent Intent intent = new Intent(BibleApplication.getApplication(), ProgressStatus.class); final PendingIntent pendingIntent = PendingIntent.getActivity(BibleApplication.getApplication(), 0, intent, 0); notification = new Notification(R.drawable.ic_stat_ichthys, prog.getJobName(), System.currentTimeMillis()); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL; notification.contentView = new RemoteViews(SharedConstants.PACKAGE_NAME, R.layout.progress_notification); notification.contentIntent = pendingIntent; notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ichthys); notification.contentView.setTextViewText(R.id.status_text, ""); notification.contentView.setProgressBar(R.id.status_progress, 100, prog.getWork(), false); progressMap.put(prog, notification); androidNotificationManager.notify(prog.hashCode(), notification); } return notification; }
From source file:eu.trentorise.smartcampus.widget.shortcuts.StackWidgetService.java
@Override public RemoteViews getViewAt(int position) { // position will always range from 0 to getCount() - 1. // We construct a remote views item based on our widget item xml // file, and set the // text based on the position. RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item); ShapeDrawable sd1 = new ShapeDrawable(new RectShape()); sd1.getPaint().setColor(0xFFFFFFFF); sd1.getPaint().setStyle(Style.STROKE); sd1.getPaint().setStrokeWidth(1);/*from w ww .j av a 2 s.c om*/ Canvas c = new Canvas(); sd1.draw(c); Bitmap b = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888); c.drawBitmap(b, 0, 0, sd1.getPaint()); // Next, we set a fill-intent which will be used to fill-in the // pending intent template // which is set on the collection view in StackWidgetProvider. if (ALLPREFERENCES != null && ALLPREFERENCES[position] != null) { //ALLPREFERENCES dimensionato come le preferenze selezionate BookmarkDescriptor myDescriptor = ALLPREFERENCES[position]; // set the widgetbutton if (WidgetHelper.PARAM_TYPE.equals(myDescriptor.params.get(0).name)) { //controllare con gli input da config activity? String type = myDescriptor.params.get(0).value; if (WidgetHelper.TYPE_DT.equals(type)) { // dt -> put icons and hide text rv.setViewVisibility(R.id.text_widget_item, View.GONE); rv.setImageViewResource(R.id.image_widget_item, Integer.parseInt(myDescriptor.params.get(2).value)); rv.setInt(R.id.image_widget_item, "setBackgroundResource", R.drawable.rounded_border_dt); } else if (WidgetHelper.TYPE_JP.equals(type)) { // jp -> put text and hide icon rv.setViewVisibility(R.id.image_widget_item, View.GONE); // rv.setImageViewBitmap(R.id.text_widget_item, // getBackground(Color.parseColor("#6EB046"))); if (!("0".equals(myDescriptor.params.get(2).value))) { //bus rv.setTextViewTextSize(R.id.text_widget_item, TypedValue.COMPLEX_UNIT_DIP, 80); rv.setTextViewText(R.id.text_widget_item, RoutesHelper.getShortNameByRouteIdAndAgencyID( myDescriptor.params.get(4).value, myDescriptor.params.get(3).value)); //4,3 rv.setTextColor(R.id.text_widget_item, Integer.parseInt(myDescriptor.params.get(2).value));//rv.setInt(R.id.text_widget_item, "setBackgroundColor", //Integer.parseInt(myDescriptor.params.get(2).value)); rv.setInt(R.id.text_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp); } else { //train rv.setTextViewTextSize(R.id.text_widget_item, TypedValue.COMPLEX_UNIT_DIP, 12); //controllo contesto getRouteDescriptor i vari parametri rv.setTextViewText(R.id.text_widget_item, mContext.getString( RoutesHelper.getRouteDescriptorByRouteId(myDescriptor.params.get(3).value, myDescriptor.params.get(4).value).getNameResource())); rv.setTextColor(R.id.text_widget_item, Color.BLACK);//Int(R.id.text_widget_item, "setBackgroundColor",Color.BLACK); rv.setInt(R.id.text_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp); } } else if (WidgetHelper.TYPE_JP_PARKINGS.equals(type)) { // jp parcheggio -> put text and hide icon rv.setViewVisibility(R.id.text_widget_item, View.GONE); rv.setImageViewResource(R.id.image_widget_item, Integer.parseInt(myDescriptor.params.get(2).value)); rv.setInt(R.id.image_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp); } BookmarkDescriptor bookmark = myDescriptor; Bundle extras = new Bundle(); extras.putString(StackWidgetProvider.EXTRA_INTENT, bookmark.getIntent()); if (bookmark.getParams() != null) { for (Param param : bookmark.getParams()) { extras.putString(param.name, param.value); } } Intent fillInIntent = new Intent(bookmark.getIntent()); fillInIntent.putExtras(extras); rv.setOnClickFillInIntent(R.id.layout, fillInIntent); } } // Return the remote views object. // AppWidgetManager manager = AppWidgetManager.getInstance(mContext); // manager.updateAppWidget(thisWidget, rv); return rv; }
From source file:org.kei.android.phone.cellhistory.CellHistoryApp.java
private RemoteViews getRecorderRemoteViews(final long records, final String size, final int buffer, final int max) { final RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notification_recorder); contentView.setImageViewResource(R.id.imagenotileft, R.drawable.ic_launcher_green); contentView.setTextViewText(R.id.title, getString(R.string.app_name)); contentView.setTextViewText(R.id.textBuffer, "Buffer: "); contentView.setTextViewText(R.id.textPackets, "Records: " + records); contentView.setTextViewText(R.id.textSize, "Size: " + size); contentView.setProgressBar(R.id.pbBuffer, max, buffer, false); return contentView; }
From source file:com.example.samples.mp3player.Mp3PlayerService.java
/** * Show a notification while this service is running. *//*from w w w . ja v a 2 s. c o m*/ private Notification buildMp3PlayerNotification() { CharSequence title = getText(R.string.mp3player_service_started); CharSequence text = getText(R.string.mp3player_service_label); Intent i = new Intent(this, Mp3Player.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // The PendingIntent to launch our activity if the user selects this notification PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0); NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle() .addLine("M.Twain (Google+) Haiku is more than a cert...").addLine("M.Twain Reminder") .addLine("M.Twain Lunch?").addLine("M.Twain Revised Specs").addLine("M.Twain ") .addLine("Google Play Celebrate 25 billion apps with Goo..") .addLine("Stack Exchange StackOverflow weekly Newsl...").setBigContentTitle("6 new message") .setSummaryText("mtwain@android.com"); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.stat_sample).setContentTitle(title).setContentText(text); //.setContentIntent(contentIntent); Notification noti = mBuilder.build(); RemoteViews expandedView = new RemoteViews(this.getPackageName(), R.layout.mp3player_notification); expandedView.setOnClickPendingIntent(R.id.noti_image, contentIntent); expandedView.setOnClickPendingIntent(R.id.noti_button_play, contentIntent); noti.bigContentView = expandedView; noti.flags |= Notification.FLAG_NO_CLEAR; return noti; }
From source file:com.bellman.bible.service.device.ProgressNotificationManager.java
/** * find the Progress object in our map to the associated Notifications * * @param prog/*from w ww. j av a 2 s .com*/ * @return */ private Notification findOrCreateNotification(Progress prog) { Notification notification = progressMap.get(prog); if (notification == null) { Log.d(TAG, "Creating Notification for progress Hash:" + prog.hashCode()); // configure the intent Intent intent = new Intent(CurrentActivityHolder.getInstance().getApplication(), ProgressStatus.class); final PendingIntent pendingIntent = PendingIntent .getActivity(CurrentActivityHolder.getInstance().getApplication(), 0, intent, 0); notification = new Notification(R.drawable.ic_stat_ichthys, prog.getJobName(), System.currentTimeMillis()); notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL; notification.contentView = new RemoteViews(SharedConstants.PACKAGE_NAME, R.layout.progress_notification); notification.contentIntent = pendingIntent; notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.ichthys); notification.contentView.setTextViewText(R.id.status_text, ""); notification.contentView.setProgressBar(R.id.status_progress, 100, prog.getWork(), false); progressMap.put(prog, notification); androidNotificationManager.notify(prog.hashCode(), notification); } return notification; }