Android Open Source - umbrella.alert Notifications Manager






From Project

Back to project page umbrella.alert.

License

The source code is released under:

GNU General Public License

If you think the Android project umbrella.alert listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package macbury.umbrella.managers;
//from w w w  . ja v a2 s .  com
import android.app.Notification;
import android.app.NotificationManager;
import android.content.ContentResolver;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;

import java.util.Date;

import macbury.umbrella.R;
import macbury.umbrella.UmbrellaApplication;


/**
 * Created by macbury on 27.08.14.
 */
public class NotificationsManager {
  private static final int NOTIFICATION_COLOR = 0x3498db;
  private static final int NOTIFICATION_TAKE_UMBRELLA_ID = 69;
  private final Context context;
  private final NotificationManager manager;
  private final Uri notificationSound;
  private final UmbrellaApplication app;

  public NotificationsManager(Context context) {
    this.app       = (UmbrellaApplication)context.getApplicationContext();
    this.context   = context;
    this.manager   = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    this.notificationSound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://macbury.umbrella/raw/"+R.raw.notification);
  }

  public void showTakeUmbrella() {
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
    mBuilder.setSmallIcon(R.drawable.ic_launcher);
    mBuilder.setContentTitle(context.getString(R.string.take_your_umbrella_notification_title));
    mBuilder.setContentText(context.getString(R.string.take_your_umbrella_notification_message_rain));
    mBuilder.setLights(NOTIFICATION_COLOR, 500, 100);
    mBuilder.setSound(notificationSound);
    mBuilder.setAutoCancel(true);
    mBuilder.setSmallIcon(R.drawable.ic_stat_umbrella);
    mBuilder.setContentIntent(app.intents.showMainActivity(true));
    mBuilder.setDeleteIntent(app.intents.dismissTakeUmbrellaNotificationReceiver());

    Notification notification = mBuilder.build();
    manager.notify(NOTIFICATION_TAKE_UMBRELLA_ID, notification);
  }

  public void syncWeatherNotification() {
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
    mBuilder.setSmallIcon(R.drawable.ic_launcher);
    mBuilder.setContentTitle("synced");
    Date date = new Date();
    mBuilder.setContentText(date.toString());
    mBuilder.setAutoCancel(true);

    Notification notification = mBuilder.build();
    manager.notify((int)date.getTime(), notification);
  }

  public void hideTakeUmbrella() {
    manager.cancel(NOTIFICATION_TAKE_UMBRELLA_ID);
  }
}




Java Source Code List

macbury.umbrella.ApplicationTest.java
macbury.umbrella.ForecastTest.java
macbury.umbrella.UmbrellaApplication.java
macbury.umbrella.activity.ForecastActivity.java
macbury.umbrella.activity.SettingsActivity.java
macbury.umbrella.cards.AboutCard.java
macbury.umbrella.cards.CityCard.java
macbury.umbrella.cards.PrecipitationCard.java
macbury.umbrella.factories.WeatherForecastFactory.java
macbury.umbrella.fragments.ForecastFragment.java
macbury.umbrella.fragments.LoadingFragment.java
macbury.umbrella.fragments.SettingsFragment.java
macbury.umbrella.managers.AlarmsManager.java
macbury.umbrella.managers.IntentsManager.java
macbury.umbrella.managers.NotificationsManager.java
macbury.umbrella.managers.ServicesManager.java
macbury.umbrella.managers.StoreManager.java
macbury.umbrella.model.Forecast.java
macbury.umbrella.model.RainData.java
macbury.umbrella.providers.ForecastProviderError.java
macbury.umbrella.providers.ForecastProviderListener.java
macbury.umbrella.providers.ForecastProvider.java
macbury.umbrella.receiver.CheckWeatherReceiver.java
macbury.umbrella.receiver.DissmisedTakeUmbrellaNotificationReceiver.java
macbury.umbrella.receiver.SyncStatusBroadcastReceiver.java
macbury.umbrella.service.CheckWeatherService.java