private void showNotification(String title, String note, boolean isTaskComplete) {

    Notification notification =
        new Notification(R.drawable.liltomato, null, System.currentTimeMillis());
    notification.flags = Notification.FLAG_ONGOING_EVENT;

    if (isTaskComplete) {

      notification = new Notification(R.drawable.liltomato_red, null, System.currentTimeMillis());
      notification.flags = Notification.FLAG_ONGOING_EVENT;
      String ringtone = taskDatabaseMap.getPreferences().getRingtone();
      if (ringtone == null) {
        ringtone =
            "android.resource://"
                + getApplication().getPackageName()
                + "/"
                + R.raw.freesoundprojectdotorg_32568__erh__indian_brass_pestle;
      }

      notification.sound = Uri.parse(ringtone);

      if (taskDatabaseMap.getPreferences().notifyPhoneVibrate()) {
        notification.vibrate = new long[] {0, 100, 200, 300};
      }

      notification.tickerText = title;
      notification.defaults |= Notification.DEFAULT_LIGHTS;
    }

    PendingIntent contentIntent =
        PendingIntent.getActivity(this, 0, new Intent(this, TaskBrowserActivity.class), 0);
    notification.setLatestEventInfo(this, title, note, contentIntent);
    notificationManager.notify(NOTIFICATION_ID, notification);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    taskDatabaseMap = TaskDatabaseMap.getInstance(this);

    addPreferencesFromResource(R.xml.preferences);

    initDurationPreference(ConfigType.TASK_DURATION);
    initDurationPreference(ConfigType.BREAK_DURATION);
    initDurationPreference(ConfigType.EVERY_FOURTH_BREAK_DURATION);

    ringTonePreference =
        (RingtonePreference) findPreference(ConfigType.NOTIFICATION_RINGTONE.name());
    ringTonePreference.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {

          public boolean onPreferenceChange(Preference preference, Object newValue) {

            updateRingtonePreferenceSummary((String) newValue);
            taskDatabaseMap.getPreferences().updateRingtone((String) newValue);
            return false;
          }
        });

    String selectedRingtone = taskDatabaseMap.getPreferences().getRingtone();
    if (selectedRingtone != null) {
      updateRingtonePreferenceSummary(selectedRingtone);
    }
  }
  @Override
  public void onCreate() {
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    taskDatabaseMap = TaskDatabaseMap.getInstance(this);

    broadcastReceiver =
        new BroadcastReceiver() {

          @Override
          public void onReceive(Context context, Intent intent) {

            AlarmAlertWakeLock.acquire(context);
            notifyTimeEnded();
            AlarmAlertWakeLock.release();
          }
        };
    IntentFilter filter = new IntentFilter("com.kpz.pomodorotasks.alert.ALARM_ALERT");
    registerReceiver(broadcastReceiver, filter);
  }
 private void initDurationPreference(ConfigType configType) {
   Preference durationPreference = findPreference(configType.name());
   int duration = taskDatabaseMap.getPreferences().getDurationPreference(configType);
   durationPreference.setSummary(duration + " min");
 }