Skip to content

Commit

Permalink
Merged hotfix/5.2.18 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Oct 5, 2016
2 parents 60e27ad + 33f8019 commit 7b4447b
Show file tree
Hide file tree
Showing 15 changed files with 205 additions and 106 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

MIN_SDK=14
TARGET_SDK=23
VERSION_NAME=5.2.17
VERSION_CODE=227
VERSION_NAME=5.2.18
VERSION_CODE=228
PACKAGE=it.feio.android.omninotes

# The following properties are empty defaults to allow build and can EVENTUALLY be overridden to allow:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1617,9 +1617,8 @@ void saveNote(OnNoteSaved mOnNoteSaved) {

noteTmp.setAttachmentsListOld(note.getAttachmentsList());

// Saving changes to the note
SaveNoteTask saveNoteTask = new SaveNoteTask(mOnNoteSaved, lastModificationUpdatedNeeded());
saveNoteTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, noteTmp);
new SaveNoteTask(mOnNoteSaved, lastModificationUpdatedNeeded()).executeOnExecutor(AsyncTask
.THREAD_POOL_EXECUTOR, noteTmp);
}


Expand All @@ -1631,7 +1630,7 @@ private boolean saveNotNeeded() {
note.setLatitude(noteTmp.getLatitude());
note.setLongitude(noteTmp.getLongitude());
}
return !noteTmp.isChanged(note);
return !noteTmp.isChanged(note) || (noteTmp.isLocked() && !noteTmp.isPasswordChecked());
}


Expand All @@ -1650,8 +1649,8 @@ private boolean lastModificationUpdatedNeeded() {

@Override
public void onNoteSaved(Note noteSaved) {
MainActivity.notifyAppWidgets(OmniNotes.getAppContext());
if (!activityPausing) {
MainActivity.notifyAppWidgets(OmniNotes.getAppContext());
EventBus.getDefault().post(new NotesUpdatedEvent());
deleteMergedNotes(mergedNotesIds);
if (noteTmp.getAlarm() != null && !noteTmp.getAlarm().equals(note.getAlarm())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,27 @@

package it.feio.android.omninotes;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import com.afollestad.materialdialogs.MaterialDialog;
import de.greenrobot.event.EventBus;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.LifecycleCallback;
import it.feio.android.omninotes.async.bus.NotesUpdatedEvent;
import it.feio.android.omninotes.db.DbHelper;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.models.ONStyle;
import it.feio.android.omninotes.utils.Constants;
import it.feio.android.omninotes.utils.Security;

import java.util.List;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.schedulers.Schedulers;


public class PasswordActivity extends BaseActivity {
Expand Down Expand Up @@ -130,63 +137,97 @@ public void onPositive(MaterialDialog materialDialog) {
}


/**
* Removes the lock from all notes
*/
private void unlockAllNotes() {
List<Note> lockedNotes = DbHelper.getInstance().getNotesWithLock(true);
for (Note lockedNote : lockedNotes) {
lockedNote.setLocked(false);
DbHelper.getInstance().updateNote(lockedNote, false);
}
}
@SuppressLint("CommitPrefEdits")
private void updatePassword(String passwordText, String questionText, String answerText) {
if (passwordText == null) {
if (prefs.getString(Constants.PREF_PASSWORD, "").length() == 0) {
Crouton.makeText(mActivity, R.string.password_not_set, ONStyle.WARN, crouton_handle).show();
return;
}
new MaterialDialog.Builder(mActivity)
.content(R.string.agree_unlocking_all_notes)
.positiveText(R.string.ok)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
removePassword();
}
}).build().show();
} else if (passwordText.length() == 0) {
Crouton.makeText(mActivity, R.string.empty_password, ONStyle.WARN, crouton_handle).show();
} else {
Observable
.from(DbHelper.getInstance().getNotesWithLock(true))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(() -> prefs.edit()
.putString(Constants.PREF_PASSWORD, Security.md5(passwordText))
.putString(Constants.PREF_PASSWORD_QUESTION, questionText)
.putString(Constants.PREF_PASSWORD_ANSWER, Security.md5(answerText))
.commit())
.doOnNext(note -> DbHelper.getInstance().updateNote(note, false))
.doOnCompleted(() -> {
Crouton crouton = Crouton.makeText(mActivity, R.string.password_successfully_changed, ONStyle
.CONFIRM, crouton_handle);
crouton.setLifecycleCallback(new LifecycleCallback() {
@Override
public void onDisplayed() {
// Does nothing!
}


private void updatePassword(String passwordText, String questionText, String answerText) {
if (passwordText == null) {
if (prefs.getString(Constants.PREF_PASSWORD, "").length() == 0) {
Crouton.makeText(mActivity, R.string.password_not_set, ONStyle.WARN, crouton_handle).show();
return;
}
new MaterialDialog.Builder(mActivity)
.content(R.string.agree_unlocking_all_notes)
.positiveText(R.string.ok)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
removePassword();
}
}).build().show();
} else if (passwordText.length() == 0) {
Crouton.makeText(mActivity, R.string.empty_password, ONStyle.WARN, crouton_handle).show();

} else {
prefs.edit()
.putString(Constants.PREF_PASSWORD, Security.md5(passwordText))
.putString(Constants.PREF_PASSWORD_QUESTION, questionText)
.putString(Constants.PREF_PASSWORD_ANSWER, Security.md5(answerText))
.apply();
Crouton.makeText(mActivity, R.string.password_successfully_changed, ONStyle.CONFIRM, crouton_handle).show();
}
}
@Override
public void onRemoved() {
onBackPressed();
}
});
crouton.show();
})
.subscribe();
}
}


private void removePassword() {
unlockAllNotes();
passwordCheck.setText("");
password.setText("");
question.setText("");
answer.setText("");
answerCheck.setText("");
prefs.edit()
.remove(Constants.PREF_PASSWORD)
.remove(Constants.PREF_PASSWORD_QUESTION)
.remove(Constants.PREF_PASSWORD_ANSWER)
.remove("settings_password_access")
.apply();
Crouton.makeText(mActivity, R.string.password_successfully_removed,
ONStyle.ALERT, crouton_handle).show();
}
private void removePassword() {
Observable
.from(DbHelper.getInstance().getNotesWithLock(true))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(note -> {
note.setLocked(false);
DbHelper.getInstance().updateNote(note, false);
})
.doOnCompleted(() -> {
passwordCheck.setText("");
password.setText("");
question.setText("");
answer.setText("");
answerCheck.setText("");
prefs.edit()
.remove(Constants.PREF_PASSWORD)
.remove(Constants.PREF_PASSWORD_QUESTION)
.remove(Constants.PREF_PASSWORD_ANSWER)
.remove("settings_password_access")
.apply();
Crouton crouton = Crouton.makeText(mActivity, R.string.password_successfully_removed, ONStyle
.ALERT,
crouton_handle);
crouton.setLifecycleCallback(new LifecycleCallback() {
@Override
public void onDisplayed() {
// Does nothing!
}


@Override
public void onRemoved() {
onBackPressed();
}
});
crouton.show();

}).subscribe();
}


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
import it.feio.android.omninotes.db.DbHelper;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.services.NotificationListener;
import it.feio.android.omninotes.utils.BitmapHelper;
import it.feio.android.omninotes.utils.Constants;
import it.feio.android.omninotes.utils.NotificationsHelper;
import it.feio.android.omninotes.utils.TextHelper;
import it.feio.android.omninotes.utils.*;


public class AlarmReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context mContext, Intent intent) {
try {
Note note = intent.getExtras().getParcelable(Constants.INTENT_NOTE);
Note note = ParcelableUtil.unmarshall(intent.getExtras().getByteArray(Constants.INTENT_NOTE), Note
.CREATOR);
createNotification(mContext, note);
SnoozeActivity.setNextRecurrentReminder(note);
if (Build.VERSION.SDK_INT >= 18 && !NotificationListener.isRunning()) {
Expand Down Expand Up @@ -110,21 +108,24 @@ private void createNotification(Context mContext, Note note) {
it.feio.android.omninotes.utils.TextHelper.capitalize(mContext.getString(R.string
.add_reminder)), piPostpone);

setRingtone(prefs, notificationsHelper);
setRingtone(prefs, notificationsHelper);

setVibrate(prefs, notificationsHelper);

notificationsHelper.show(note.get_id());
}

private void setRingtone(SharedPreferences prefs,NotificationsHelper notificationsHelper) {
String ringtone = prefs.getString("settings_notification_ringtone", null);
if (ringtone != null) notificationsHelper.setRingtone(ringtone);
}

private void setVibrate(SharedPreferences prefs, NotificationsHelper notificationsHelper) {
if (prefs.getBoolean("settings_notification_vibration", true)) notificationsHelper.setVibration();
}
private void setRingtone(SharedPreferences prefs, NotificationsHelper notificationsHelper) {
String ringtone = prefs.getString("settings_notification_ringtone", null);
if (ringtone != null) notificationsHelper.setRingtone(ringtone);
}


private void setVibrate(SharedPreferences prefs, NotificationsHelper notificationsHelper) {
if (prefs.getBoolean("settings_notification_vibration", true)) notificationsHelper.setVibration();
}


private int getUniqueRequestCode(Note note) {
return note.get_id().intValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2016 Federico Iosue ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundatibehaon, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package it.feio.android.omninotes.utils;

import android.os.Parcel;
import android.os.Parcelable;


public class ParcelableUtil {

public static byte[] marshall(Parcelable parceable) {
Parcel parcel = Parcel.obtain();
parceable.writeToParcel(parcel, 0);
byte[] bytes = parcel.marshall();
parcel.recycle();
return bytes;
}


public static Parcel unmarshall(byte[] bytes) {
Parcel parcel = Parcel.obtain();
parcel.unmarshall(bytes, 0, bytes.length);
parcel.setDataPosition(0); // This is extremely important!
return parcel;
}


public static <T> T unmarshall(byte[] bytes, Parcelable.Creator<T> creator) {
Parcel parcel = unmarshall(bytes);
T result = creator.createFromParcel(parcel);
parcel.recycle();
return result;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import it.feio.android.omninotes.helpers.date.DateHelper;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.receiver.AlarmReceiver;
import it.feio.android.omninotes.utils.date.DateUtils;

import java.util.Calendar;

Expand All @@ -46,7 +45,7 @@ public static void addReminder(Context context, Note note) {

public static void addReminder(Context context, Note note, long reminder) {
Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra(Constants.INTENT_NOTE, (android.os.Parcelable) note);
intent.putExtra(Constants.INTENT_NOTE, ParcelableUtil.marshall(note));
PendingIntent sender = PendingIntent.getBroadcast(context, getRequestCode(note), intent,
PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Expand Down
7 changes: 7 additions & 0 deletions omniNotes/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
-->
<changelog bulletedList="true">

<changelogversion versionName="5.2.18" changeDate="Oct 5, 2016">
<changelogtext>[i]Improved[/i] Updated translations</changelogtext>
<changelogtext>[u]Fix[/u] Reminders now work again on Android Nougat</changelogtext>
<changelogtext>[u]Fix[/u] Protected notes are no more updated rotating screen without inserting password before</changelogtext>
<changelogtext>[u]Fix[/u] Encrypted notes are now reprocessed on security password change</changelogtext>
</changelogversion>

<changelogversion versionName="5.2.17" changeDate="Sep 09, 2016">
<changelogtext>[i]Improved[/i] Updated translations</changelogtext>
<changelogtext>[u]Fix[/u] Location retrieval should work again thanks to new API key</changelogtext>
Expand Down
Loading

0 comments on commit 7b4447b

Please sign in to comment.