Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/json-sync
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	omniNotes/build.gradle
#	omniNotes/src/main/java/it/feio/android/omninotes/async/notes/SaveNoteTask.java
  • Loading branch information
federicoiosue committed Jan 30, 2016
2 parents e373057 + 8ffde3a commit 6a0fe17
Show file tree
Hide file tree
Showing 34 changed files with 455 additions and 276 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android:
- tools

# The BuildTools version used by your project
- build-tools-23.0.1
- build-tools-23.0.2

# The SDK version used to compile your project
- android-23
Expand All @@ -27,7 +27,7 @@ android:
#- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
#- addon-google_apis-google-19

# Specify at least one system image,
# if you need to run emulator(s) during your tests
Expand Down
9 changes: 0 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,16 @@ allprojects {
}
}







apply plugin: "sonar-runner"

sonarRunner {
sonarProperties {
// can be also set on command line like -Dsonar.analysis.mode=incremental
property "sonar.host.url", "http://localhost:9000"
property "sonar.analysis.mode", "incremental"
property 'sonar.sourceEncoding', 'UTF-8'
property 'sonar.language', 'java'
property 'sonar.profile', 'Default'
}
}

subprojects {
sonarRunner {
sonarProperties {
Expand Down
3 changes: 3 additions & 0 deletions etc/translations/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,12 @@
<string name="settings_attachments_on_bottom">Attachments on bottom</string>
<string name="settings_attachments_on_bottom_summary_on">Shows attachments below note content</string>
<string name="settings_attachments_on_bottom_summary_off">Shows attachments above note content</string>
<string name="settings_screen_privacy">Privacy</string>
<string name="settings_error_reporting">Error reporting</string>
<string name="settings_error_reporting_summary_on">When app crashes developer will be informed to help you</string>
<string name="settings_error_reporting_summary_off">No crash reports will be sent. Do not complain if something goes wrong!</string>
<string name="settings_send_analytics">Share anonymous data</string>
<string name="settings_send_analytics_summary">Help the developer by sending non-sensitive data like device model, language, frequently used app\'s features. This data are used only to improve the open-source app.</string>
<string name="settings_statistics">Statistics</string>


Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-2.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
9 changes: 5 additions & 4 deletions omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ apply plugin: 'me.tatarka.retrolambda'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.2"

defaultConfig {
applicationId project.PACKAGE
Expand Down Expand Up @@ -75,13 +75,13 @@ android {
}
}

final GPS_VERSION = '6.5.87'

dependencies {

androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.3'

testCompile 'junit:junit:4.12'

compile fileTree(include: '*.jar', dir: 'libs')

compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
Expand Down Expand Up @@ -127,4 +127,5 @@ dependencies {
compile 'com.github.federicoiosue:Springpad-Importer:1.0.1'
compile 'com.github.federicoiosue:Omni-Notes-Commons:1.1.0'
compile 'com.github.federicoiosue:CheckListView:3.0.2'
compile 'com.github.federicoiosue:pixlUI:2.2'
compile 'com.github.federicoiosue:pixlUI:2.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package it.feio.android.omninotes.test.utils.date;

import android.test.InstrumentationTestCase;
import it.feio.android.omninotes.utils.date.DateHelper;
import it.feio.android.omninotes.utils.date.DateUtils;
import org.junit.Assert;

import java.util.Calendar;
Expand All @@ -35,13 +35,13 @@ public void testNextReminderFromRecurrenceRule() {

// Daily test
String rruleDaily = "FREQ=DAILY;COUNT=30;WKST=MO";
long nextReminder = DateHelper.nextReminderFromRecurrenceRule(reminder, currentTime, rruleDaily);
long nextReminder = DateUtils.nextReminderFromRecurrenceRule(reminder, currentTime, rruleDaily);
Assert.assertNotEquals(nextReminder, 0);
Assert.assertEquals((nextReminder - reminder) / 60 / 60 / 1000, 24-1);

// 3-Daily test
String rruleDaily2 = "FREQ=DAILY;COUNT=30;INTERVAL=3";
long nextReminder2 = DateHelper.nextReminderFromRecurrenceRule(reminder, currentTime, rruleDaily2);
long nextReminder2 = DateUtils.nextReminderFromRecurrenceRule(reminder, currentTime, rruleDaily2);
Assert.assertNotEquals(nextReminder2, 0);
Assert.assertEquals((nextReminder2 - reminder) / 60 / 60 / 1000, 3*24 - 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import it.feio.android.omninotes.db.DbHelper;
import it.feio.android.omninotes.helpers.AnalyticsHelper;
import it.feio.android.omninotes.helpers.PermissionsHelper;
import it.feio.android.omninotes.helpers.date.DateHelper;
import it.feio.android.omninotes.models.*;
import it.feio.android.omninotes.models.adapters.AttachmentAdapter;
import it.feio.android.omninotes.models.adapters.NavDrawerCategoryAdapter;
Expand All @@ -93,17 +94,14 @@
import it.feio.android.omninotes.models.views.ExpandableHeightGridView;
import it.feio.android.omninotes.utils.*;
import it.feio.android.omninotes.utils.Display;
import it.feio.android.omninotes.utils.date.DateHelper;
import it.feio.android.omninotes.utils.date.DateUtils;
import it.feio.android.omninotes.utils.date.ReminderPickers;
import it.feio.android.pixlui.links.TextLinkClickListener;
import org.apache.commons.lang.StringUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.*;

import static com.nineoldandroids.view.ViewPropertyAnimator.animate;

Expand Down Expand Up @@ -531,13 +529,15 @@ private void initViews() {

private void initViewFooter() {
// Footer dates of creation...
String creation = DateHelper.prettyTime(noteTmp.getCreation());
String creation = DateHelper.getFormattedDate(noteTmp.getCreation(), prefs.getBoolean(Constants
.PREF_PRETTIFIED_DATES, true));
creationTextView.append(creation.length() > 0 ? getString(R.string.creation) + " " + creation : "");
if (creationTextView.getText().length() == 0)
creationTextView.setVisibility(View.GONE);

// ... and last modification
String lastModification = DateHelper.prettyTime(noteTmp.getLastModification());
String lastModification = DateHelper.getFormattedDate(noteTmp.getLastModification(), prefs.getBoolean(Constants
.PREF_PRETTIFIED_DATES, true));
lastModificationTextView.append(lastModification.length() > 0 ? getString(R.string.last_update) + " " + lastModification : "");
if (lastModificationTextView.getText().length() == 0)
lastModificationTextView.setVisibility(View.GONE);
Expand All @@ -551,7 +551,7 @@ private void initViewReminder() {
int pickerType = prefs.getBoolean("settings_simple_calendar", false) ? ReminderPickers.TYPE_AOSP :
ReminderPickers.TYPE_GOOGLE;
ReminderPickers reminderPicker = new ReminderPickers(mainActivity, mFragment, pickerType);
Long presetDateTime = noteTmp.getAlarm() != null ? Long.parseLong(noteTmp.getAlarm()) : DateHelper
Long presetDateTime = noteTmp.getAlarm() != null ? Long.parseLong(noteTmp.getAlarm()) : DateUtils
.getNextMinute();
reminderPicker.pick(presetDateTime, noteTmp.getRecurrenceRule());
onDateSetListener = reminderPicker;
Expand Down Expand Up @@ -639,6 +639,7 @@ private void initViewLocation() {
builder.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {

noteTmp.setLatitude("");
noteTmp.setLongitude("");
fade(locationTextView, false);
Expand Down Expand Up @@ -824,10 +825,11 @@ private void initViewContent() {


/**
* Force focus and shows soft keyboard
* Force focus and shows soft keyboard. Only happens if it's a new note, without shared content.
* {@link afterSavedReturnsToList} is used to check if the note is created from shared content.
*/
private void requestFocus(final EditText view) {
if (note.get_id() == null && !noteTmp.isChanged(note)) {
if (note.get_id() == null && !noteTmp.isChanged(note) && afterSavedReturnsToList) {
KeyboardUtils.showKeyboard(view);
}
}
Expand Down
119 changes: 67 additions & 52 deletions omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,49 +626,52 @@ private void initSearchView(final Menu menu) {

MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() {

boolean searchPerformed = false;
boolean searchPerformed = false;


@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
// Reinitialize notes list to all notes when search is collapsed
searchQuery = null;
if (searchLayout.getVisibility() == View.VISIBLE) {
toggleSearchLabel(false);
}
mainActivity.getIntent().setAction(Intent.ACTION_MAIN);
initNotesList(mainActivity.getIntent());
mainActivity.supportInvalidateOptionsMenu();
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
// Reinitialize notes list to all notes when search is collapsed
searchQuery = null;
if (searchLayout.getVisibility() == View.VISIBLE) {
toggleSearchLabel(false);
}
mainActivity.getIntent().setAction(Intent.ACTION_MAIN);
initNotesList(mainActivity.getIntent());
mainActivity.supportInvalidateOptionsMenu();
return true;
}


@Override
public boolean onMenuItemActionExpand(MenuItem item) {
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String arg0) {
return prefs.getBoolean("settings_instant_search", false);
}
@Override
public boolean onMenuItemActionExpand(MenuItem item) {

searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String arg0) {

@Override
public boolean onQueryTextChange(String pattern) {
if (prefs.getBoolean("settings_instant_search", false) && searchLayout != null &&
searchPerformed && mFragment.isAdded()) {
searchTags = null;
searchQuery = pattern;
NoteLoaderTask.getInstance().execute("getNotesByPattern", pattern);
return true;
} else {
searchPerformed = true;
return false;
}
}
});
return true;
}
});
return prefs.getBoolean("settings_instant_search", false);
}


@Override
public boolean onQueryTextChange(String pattern) {

if (prefs.getBoolean("settings_instant_search", false) && searchLayout != null &&
searchPerformed && mFragment.isAdded()) {
searchTags = null;
searchQuery = pattern;
NoteLoaderTask.getInstance().execute("getNotesByPattern", pattern);
return true;
} else {
searchPerformed = true;
return false;
}
}
});
return true;
}
});
}


Expand Down Expand Up @@ -840,15 +843,15 @@ private void switchNotesView() {
void editNote(final Note note, final View view) {
if (note.isLocked() && !prefs.getBoolean("settings_password_access", false)) {
BaseActivity.requestPassword(mainActivity, passwordConfirmed -> {
if (passwordConfirmed) {
note.setPasswordChecked(true);
AnimationsHelper.zoomListItem(mainActivity, view, getZoomListItemView(view, note),
listRoot, buildAnimatorListenerAdapter(note));
}
});
if (passwordConfirmed) {
note.setPasswordChecked(true);
AnimationsHelper.zoomListItem(mainActivity, view, getZoomListItemView(view, note),
listRoot, buildAnimatorListenerAdapter(note));
}
});
} else {
AnimationsHelper.zoomListItem(mainActivity, view, getZoomListItemView(view, note),
listRoot, buildAnimatorListenerAdapter(note));
listRoot, buildAnimatorListenerAdapter(note));
}
}

Expand Down Expand Up @@ -944,14 +947,26 @@ private void emptyTrash() {
.content(R.string.empty_trash_confirmation)
.positiveText(R.string.ok)
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
for (int i = 0; i < listAdapter.getCount(); i++) {
selectedNotes.add(listAdapter.getItem(i));
}
deleteNotesExecute();
}
}).build().show();
@Override
public void onPositive(MaterialDialog materialDialog) {

boolean mustDeleteLockedNotes = false;
for (int i = 0; i < listAdapter.getCount(); i++) {
selectedNotes.add(listAdapter.getItem(i));
mustDeleteLockedNotes = mustDeleteLockedNotes || listAdapter.getItem(i).isLocked();
}
if (mustDeleteLockedNotes) {
mainActivity.requestPassword(mainActivity, getSelectedNotes(),
passwordConfirmed -> {
if (passwordConfirmed) {
deleteNotesExecute();
}
});
} else {
deleteNotesExecute();
}
}
}).build().show();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
DetailFragment f = (DetailFragment) mFragmentManager.findFragmentByTag(FRAGMENT_DETAIL_TAG);
if (f != null && f.isAdded()) {
if (f != null && f.isAdded() && f.onDateSetListener != null) {
f.onDateSetListener.onDateSet(view, year, monthOfYear, dayOfMonth);
}
}
Expand Down
12 changes: 11 additions & 1 deletion omniNotes/src/main/java/it/feio/android/omninotes/OmniNotes.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onCreate() {
updateLanguage(this, null);

// Analytics initialization
AnalyticsHelper.init(this);
AnalyticsHelper.init(this, prefs.getBoolean(Constants.PREF_SEND_ANALYTICS, true));
}

private void initAcra(Application application) {
Expand All @@ -76,6 +76,7 @@ public static boolean isDebugBuild() {
return BuildConfig.BUILD_TYPE.equals("debug");
}


@Override
// Used to restore user selected locale when configuration changes
public void onConfigurationChanged(Configuration newConfig) {
Expand Down Expand Up @@ -124,4 +125,13 @@ private static Locale getLocale(String lang) {
}
}


/**
* Statically returns app's default SharedPreferences instance
* @return SharedPreferences object instance
*/
public static SharedPreferences getSharedPreferences(){
return getAppContext().getSharedPreferences(Constants.PREFS_NAME, MODE_MULTI_PROCESS);
}

}
Loading

0 comments on commit 6a0fe17

Please sign in to comment.