/**
   * find the Progress object in our map to the associated Notifications
   *
   * @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;
  }
Example #2
0
 /** Returns true if at least one Orientation sensor is available */
 public boolean isLightSensor() {
   boolean isLightSensor = false;
   SensorManager sm =
       (SensorManager) BibleApplication.getApplication().getSystemService(Context.SENSOR_SERVICE);
   if (sm != null) {
     List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_LIGHT);
     isLightSensor = (sensors.size() > 0);
   }
   return isLightSensor;
 }
Example #3
0
  private synchronized void ensureMonitoringLightLevel() {
    if (!mMonitoring) {
      if (isLightSensor()) {
        SensorManager sm =
            (SensorManager)
                BibleApplication.getApplication().getSystemService(Context.SENSOR_SERVICE);
        Sensor oSensor = sm.getDefaultSensor(Sensor.TYPE_LIGHT);

        sm.registerListener(myLightListener, oSensor, SensorManager.SENSOR_DELAY_UI);

        // wait for first event
        try {
          Thread.sleep(100);
        } catch (InterruptedException ie) {
          Log.e(TAG, "Interrupted getting light signal", ie);
        }
      }
      mMonitoring = true;
    }
  }
 private NotificationManager getNotificationManager() {
   // add it to the NotificationManager
   return (NotificationManager)
       BibleApplication.getApplication().getSystemService(Application.NOTIFICATION_SERVICE);
 }
Example #5
0
 public String getDayDesc() {
   return BibleApplication.getApplication().getString(R.string.rdg_plan_day, mDay);
 }