Skip to content

Commit

Permalink
fixed issue 160
Browse files Browse the repository at this point in the history
  • Loading branch information
konradrenner committed Apr 10, 2017
1 parent 4ad6365 commit 56521bd
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 30 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

You can also have a look on the GitHub release page: https://github.com/konradrenner/kolabnotes-android/releases

## [2.7.1] - 2017-04-10
### Fixed
- Fixed issue 160

## [2.7.0] - 2017-04-05
### Added
- Implemented issue 158 ("New note" app shortcut on Android >= 7.1 devices)
Expand Down Expand Up @@ -77,7 +81,8 @@ You can also have a look on the GitHub release page: https://github.com/konradre
### Fixed
- First stable release, support for all major features of the Kolab notes format

[Unreleased]: https://github.com/konradrenner/kolabnotes-android/compare/2.7.0...HEAD
[Unreleased]: https://github.com/konradrenner/kolabnotes-android/compare/2.7.1...HEAD
[2.7.1]: https://github.com/konradrenner/kolabnotes-android/compare/2.7.0...2.7.1
[2.7.0]: https://github.com/konradrenner/kolabnotes-android/compare/2.6.0...2.7.0
[2.6.0]: https://github.com/konradrenner/kolabnotes-android/compare/2.5.0...2.6.0
[2.5.0]: https://github.com/konradrenner/kolabnotes-android/compare/2.4.0...2.5.0
Expand Down
23 changes: 16 additions & 7 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,39 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.kore.kolabnotes.android"
minSdkVersion 16
targetSdkVersion 25
versionCode 90
versionName "2.7.0"
versionCode 91
versionName "2.7.1"

//Running test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ public class NoteRepository {
DatabaseHelper.COLUMN_UID_NOTEBOOK,
DatabaseHelper.COLUMN_DISCRIMINATOR,
DatabaseHelper.COLUMN_COLOR};

private String[] withoutDescriptionColumns = { DatabaseHelper.COLUMN_ID,
DatabaseHelper.COLUMN_ACCOUNT,
DatabaseHelper.COLUMN_ROOT_FOLDER,
DatabaseHelper.COLUMN_UID,
DatabaseHelper.COLUMN_PRODUCTID ,
DatabaseHelper.COLUMN_CREATIONDATE ,
DatabaseHelper.COLUMN_MODIFICATIONDATE ,
DatabaseHelper.COLUMN_SUMMARY ,
DatabaseHelper.COLUMN_CLASSIFICATION,
DatabaseHelper.COLUMN_UID_NOTEBOOK,
DatabaseHelper.COLUMN_DISCRIMINATOR,
DatabaseHelper.COLUMN_COLOR};

private String[] notebookUIDColumn = {DatabaseHelper.COLUMN_UID_NOTEBOOK};

private ModificationRepository modificationRepository;

public NoteRepository(Context context) {
Expand All @@ -56,7 +72,7 @@ public void insert(String account, String rootFolder, Note note, String uidNoteb
values.put(DatabaseHelper.COLUMN_DESCRIPTION, note.getDescription());
values.put(DatabaseHelper.COLUMN_UID_NOTEBOOK, uidNotebook);
values.put(DatabaseHelper.COLUMN_COLOR, note.getColor() == null ? null : note.getColor().getHexcode());
values.put(DatabaseHelper.COLUMN_CLASSIFICATION, note.getClassification().toString());
values.put(DatabaseHelper.COLUMN_CLASSIFICATION, note.getClassification() == null ? Note.Classification.PUBLIC.toString() : note.getClassification().toString());

ConnectionManager.getDatabase(context).insert(DatabaseHelper.TABLE_NOTES, null, values);

Expand All @@ -79,7 +95,7 @@ public void update(String account, String rootFolder,Note note,String uidNoteboo
values.put(DatabaseHelper.COLUMN_DESCRIPTION, note.getDescription());
values.put(DatabaseHelper.COLUMN_UID_NOTEBOOK, uidNotebook);
values.put(DatabaseHelper.COLUMN_COLOR, note.getColor() == null ? null : note.getColor().getHexcode());
values.put(DatabaseHelper.COLUMN_CLASSIFICATION, note.getClassification().toString());
values.put(DatabaseHelper.COLUMN_CLASSIFICATION, note.getClassification() == null ? Note.Classification.PUBLIC.toString() : note.getClassification().toString());

ConnectionManager.getDatabase(context).update(DatabaseHelper.TABLE_NOTES,
values,
Expand Down Expand Up @@ -143,8 +159,10 @@ public List<Note> getFromNotebookWithSummary(String account, String rootFolder,S
query.append(" AND "+DatabaseHelper.COLUMN_UID_NOTEBOOK + " = '" + uidNotebook+"' ");
}

String[] columns = Utils.getShowPreview(context) ? allColumns : withoutDescriptionColumns;

Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
columns,
query.toString(),
null,
null,
Expand Down Expand Up @@ -184,8 +202,10 @@ public List<Note> getFromNotebookWithDescriptionLoaded(String account, String ro
public List<Note> getFromNotebook(String account, String rootFolder,String uidNotebook, NoteSorting noteSorting) {
List<Note> notes = new ArrayList<Note>();

String[] columns = Utils.getShowPreview(context) ? allColumns : withoutDescriptionColumns;

Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
columns,
DatabaseHelper.COLUMN_ACCOUNT + " = '" + account + "' AND " +
DatabaseHelper.COLUMN_ROOT_FOLDER + " = '" + rootFolder + "' AND " +
DatabaseHelper.COLUMN_UID_NOTEBOOK + " = '" + uidNotebook + "' AND " +
Expand Down Expand Up @@ -227,8 +247,10 @@ public List<Note> getAllForSync(String account, String rootFolder) {
public List<Note> getAll(String account, String rootFolder, NoteSorting noteSorting) {
List<Note> notes = new ArrayList<Note>();

String[] columns = Utils.getShowPreview(context) ? allColumns : withoutDescriptionColumns;

Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
columns,
DatabaseHelper.COLUMN_ACCOUNT + " = '" + account + "' AND " +
DatabaseHelper.COLUMN_ROOT_FOLDER + " = '" + rootFolder + "' AND " +
DatabaseHelper.COLUMN_DISCRIMINATOR + " = '" + DatabaseHelper.DESCRIMINATOR_NOTE + "' ",
Expand All @@ -248,8 +270,10 @@ public List<Note> getAll(String account, String rootFolder, NoteSorting noteSort
public List<Note> getAll(NoteSorting noteSorting) {
List<Note> notes = new ArrayList<Note>();

String[] columns = Utils.getShowPreview(context) ? allColumns : withoutDescriptionColumns;

Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
columns,
DatabaseHelper.COLUMN_DISCRIMINATOR + " = '" + DatabaseHelper.DESCRIMINATOR_NOTE + "' ",
null,
null,
Expand Down Expand Up @@ -284,6 +308,28 @@ public Note getByUID(String account, String rootFolder,String uid) {
return note;
}

public Note getByUIDWithoutDescription(String account, String rootFolder,String uid) {
String[] columns = Utils.getShowPreview(context) ? allColumns : withoutDescriptionColumns;

Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
columns,
DatabaseHelper.COLUMN_ACCOUNT + " = '" + account + "' AND " +
DatabaseHelper.COLUMN_ROOT_FOLDER + " = '" + rootFolder + "' AND " +
DatabaseHelper.COLUMN_UID + " = '" + uid + "' AND " +
DatabaseHelper.COLUMN_DISCRIMINATOR + " = '" + DatabaseHelper.DESCRIMINATOR_NOTE + "' ",
null,
null,
null,
DatabaseHelper.COLUMN_MODIFICATIONDATE + " DESC");

Note note = null;
if (cursor.moveToNext()) {
note = cursorToNoteWithoutDescription(account,rootFolder,cursor);
}
cursor.close();
return note;
}

public AccountIdentifier getAccountFromNote(String uid) {
Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
Expand All @@ -304,7 +350,7 @@ public AccountIdentifier getAccountFromNote(String uid) {

public String getUIDofNotebook(String account, String rootFolder,String uid) {
Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
notebookUIDColumn,
DatabaseHelper.COLUMN_ACCOUNT + " = '" + account + "' AND " +
DatabaseHelper.COLUMN_ROOT_FOLDER + " = '" + rootFolder + "' AND " +
DatabaseHelper.COLUMN_UID + " = '" + uid + "' AND " +
Expand All @@ -316,7 +362,7 @@ public String getUIDofNotebook(String account, String rootFolder,String uid) {

String uidNB = null;
if (cursor.moveToNext()) {
uidNB = cursor.getString(10);
uidNB = cursor.getString(0);
}
cursor.close();
return uidNB;
Expand Down Expand Up @@ -358,11 +404,13 @@ private Note cursorToNoteWithoutDescription(String account, String rootFolder,Cu
Long modificationDate = cursor.getLong(6);
String summary = cursor.getString(7);
String description = null;

int index = 8;
if(Utils.getShowPreview(context)){
description = cursor.getString(8);
description = cursor.getString(index++);
}
String classification = cursor.getString(9);
String color = cursor.getString(12);
String classification = cursor.getString(index);
String color = cursor.getString(index+3);

AuditInformation audit = new AuditInformation(new Timestamp(creationDate),new Timestamp(modificationDate));
Identification ident = new Identification(uid,productId);
Expand Down Expand Up @@ -401,8 +449,10 @@ public List<Note> searchNotes(String account, String rootFolder, String keyWord,
query.append(DatabaseHelper.COLUMN_DISCRIMINATOR+" = '"+DatabaseHelper.DESCRIMINATOR_NOTE+"' AND ");
query.append(" "+DatabaseHelper.COLUMN_SUMMARY+" like '%"+keyWord.trim()+"%' COLLATE NOCASE ");

String[] columns = Utils.getShowPreview(context) ? allColumns : withoutDescriptionColumns;

Cursor cursor = ConnectionManager.getDatabase(context).query(DatabaseHelper.TABLE_NOTES,
allColumns,
columns,
query.toString(),
null,
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,17 +740,22 @@ private void loadImageFromUri(Uri uri) {
}

byte[] b = baos.toByteArray();
String imageEncoded = prefix + Base64.encodeToString(b, Base64.NO_WRAP);
if(b.length < 900000) {
String imageEncoded = prefix + Base64.encodeToString(b, Base64.NO_WRAP);

String alt = path;
String alt = path;

//issue 125
if(!editor.isFocused()){
//issue 125
if (!editor.isFocused()) {
/* Set focus, as after rotate focus is lost and it's impossible to insert an image */
editor.focusEditor();
editor.focusEditor();
}
editor.insertImage(imageEncoded, alt);
putImage(alt, imageEncoded);
}else{
Toast.makeText(activity, R.string.image_too_big, Toast.LENGTH_LONG).show();
}
editor.insertImage(imageEncoded, alt);
putImage(alt,imageEncoded);


if (activity instanceof OnFragmentCallback) {
((OnFragmentCallback) activity).fileSelected();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ void deleteNotes(final List<Integer> items) {
final ArrayList<Note> notes = new ArrayList<Note>();
for (int position : items) {
final String uid = mSelectedNotes.get(position);
final Note note = notesRepository.getByUID(account, rootFolder, uid);
final Note note = notesRepository.getByUIDWithoutDescription(account, rootFolder, uid);
notes.add(note);
}
mAdapter.deleteNotes(notes);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,5 @@
<string name="pref_preview">Notiz Vorschau</string>
<string name="pref_desc_preview">Anzeige eines Teils der Notiz als Vorschau</string>
<string name="empty_note_description" >Kein Notiztext</string>
<string name="image_too_big">Bild ist zu groß (Datei muss kleiner 900 kB sein!)</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,5 @@
<string name="pref_preview">Aperçu de la note</string>
<string name="pref_desc_preview"> Afficher certains caractères de texte d\'aperçu du texte de la note </string>
<string name="empty_note_description" >Pas de texte de note</string>
<string name="image_too_big">Image trop grande (la taille du fichier doit être inférieure à 900 kB)</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,5 @@
<string name="pref_preview"> Nota anteprima</string>
<string name="pref_desc_preview"> Mostra alcuni caratteri anteprima del testo di testo della nota </string>
<string name="empty_note_description" > Nessun testo della nota</string>
<string name="image_too_big">Immagine troppo grande (dimensione del file deve essere inferiore a 900 kB)</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,6 @@
<string name="pref_preview">プレビューノート </string>
<string name="pref_desc_preview"> メモテキストのいくつかのプレビューテキスト文字を表示する </string>
<string name="empty_note_description" >メモテキストなし</string>
<string name="image_too_big">イメージが大きすぎます(ファイルサイズは900 KB未満である必要があります)</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,6 @@
<string name="pref_preview">Предварительный просмотр заметок </string>
<string name="pref_desc_preview"> Показать некоторые текстовые символы для предварительного просмотра текста примечания</string>
<string name="empty_note_description" >Нет текста примечания</string>
<string name="image_too_big">Слишком большое изображение (размер файла не должен превышать 900 КБ)</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,5 @@
<string name="pref_preview">Chú ý xem trước </string>
<string name="pref_desc_preview">Hiển thị một số ký tự văn bản xem trước của văn bản lưu ý </string>
<string name="empty_note_description" >Không có văn bản lưu ý</string>
<string name="image_too_big">Hình ảnh quá lớn (kích thước tệp phải nhỏ hơn 900 kB)</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,6 @@
<string name="pref_preview">Note preview</string>
<string name="pref_desc_preview">Show some preview text characters of note text</string>
<string name="empty_note_description" >No note text</string>
<string name="image_too_big"> Image too big (file size must be less than 900 kB)</string>

</resources>

0 comments on commit 56521bd

Please sign in to comment.