Skip to content

Commit

Permalink
When their reminder is fired notes are pulled out of the archive
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Jan 20, 2019
1 parent 926facf commit 59de47d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.text.Spanned;
import android.util.Log;

import java.util.List;

import it.feio.android.omninotes.R;
import it.feio.android.omninotes.SnoozeActivity;
import it.feio.android.omninotes.db.DbHelper;
import it.feio.android.omninotes.models.Attachment;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.services.NotificationListener;
import it.feio.android.omninotes.utils.BitmapHelper;
Expand All @@ -48,14 +52,19 @@ public void onReceive(Context mContext, Intent intent) {
.CREATOR);
createNotification(mContext, note);
SnoozeActivity.setNextRecurrentReminder(note);
if (Build.VERSION.SDK_INT >= 18 && !NotificationListener.isRunning()) {
DbHelper.getInstance().setReminderFired(note.get_id(), true);
}
updateNote(note);
} catch (Exception e) {
Log.e(Constants.TAG, "Error on receiving reminder", e);
}
}

private void updateNote(Note note) {
note.setArchived(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && !NotificationListener.isRunning()) {
note.setReminderFired(true);
}
DbHelper.getInstance().updateNote(note, false);
}

private void createNotification(Context mContext, Note note) {

Expand Down Expand Up @@ -101,21 +110,18 @@ private void createNotification(Context mContext, Note note) {
notificationsHelper.createNotification(NotificationChannels.NotificationChannelNames.Reminders, R.drawable.ic_stat_notification, title, notifyIntent).setLedActive()
.setMessage(text);

if (note.getAttachmentsList().size() > 0 && !note.getAttachmentsList().get(0).getMime_type().equals(Constants
.MIME_TYPE_FILES)) {
notificationsHelper.setLargeIcon(BitmapHelper.getBitmapFromAttachment(mContext, note.getAttachmentsList()
.get(0), 128, 128));
List<Attachment> attachments = note.getAttachmentsList();
if (!attachments.isEmpty() && !attachments.get(0).getMime_type().equals(Constants.MIME_TYPE_FILES)) {
Bitmap notificationIcon = BitmapHelper.getBitmapFromAttachment(mContext, note.getAttachmentsList().get(0), 128, 128);
notificationsHelper.setLargeIcon(notificationIcon);
}

notificationsHelper.getBuilder()
.addAction(R.drawable.ic_material_reminder_time_light, it.feio.android.omninotes.utils.TextHelper
.capitalize(mContext.getString(R.string.snooze)) + ": " + snoozeDelay, piSnooze)
.addAction(R.drawable.ic_remind_later_light,
it.feio.android.omninotes.utils.TextHelper.capitalize(mContext.getString(R.string
.addAction(R.drawable.ic_material_reminder_time_light, TextHelper.capitalize(mContext.getString(R.string.snooze)) + ": " + snoozeDelay, piSnooze)
.addAction(R.drawable.ic_remind_later_light, TextHelper.capitalize(mContext.getString(R.string
.add_reminder)), piPostpone);

setRingtone(prefs, notificationsHelper);

setVibrate(prefs, notificationsHelper);

notificationsHelper.show(note.get_id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ public void onEventAsync(NotificationRemovedEvent event) {


public static boolean isRunning() {

ContentResolver contentResolver = OmniNotes.getAppContext().getContentResolver();
String enabledNotificationListeners = Settings.Secure.getString(contentResolver,
"enabled_notification_listeners");
String enabledNotificationListeners = Settings.Secure.getString(contentResolver, "enabled_notification_listeners");
return enabledNotificationListeners != null && enabledNotificationListeners.contains(NotificationListener
.class.getSimpleName());
}
Expand Down
3 changes: 2 additions & 1 deletion omniNotes/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
<changelog bulletedList="true">

<changelogversion
changeDate="Jan 19, 2019"
changeDate="Jan 22, 2019"
versionName="6.0.0 Beta 7">
<changelogtext>[i]Improved![/i] Backup notification contains now missing attachments number</changelogtext>
<changelogtext>[i]Improved![/i] When their reminder is fired notes are pulled out of the archive</changelogtext>
</changelogversion>

<changelogversion
Expand Down

0 comments on commit 59de47d

Please sign in to comment.