Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Apr 16, 2023
2 parents 179ee19 + a53934d commit 96a2db3
Show file tree
Hide file tree
Showing 29 changed files with 588 additions and 73 deletions.
1 change: 1 addition & 0 deletions assets/translations/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
<string name="settings_sync_import_export">Sync and Backups</string>
<string name="settings_import">Restore or delete backups</string>
<string name="settings_import_summary">WARNING: No password is set, protected notes will not be restored from backup for security reasons</string>
<string name="settings_change_backup_folder">Change backup folder</string>
<string name="settings_import_legacy">Restore legacy backup</string>
<string name="settings_import_legacy_summary">Allows to restore old backups made with versions of Omni Notes prior to version 6</string>
<string name="settings_import_from_springpad">Import notes from Springpad</string>
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
VERSION_NAME=6.2.2
VERSION_CODE=317
VERSION_NAME=6.2.3
VERSION_CODE=318
PACKAGE=it.feio.android.omninotes
MIN_SDK=21
TARGET_SDK=31
Expand Down Expand Up @@ -43,4 +43,4 @@ CRASH_REPORTING_PASSWORD=
VERSION_CHECK_URL=
# Google Maps API key to provide addresses autocompletion feature
MAPS_API_KEY=
org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache=on
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package it.feio.android.omninotes.helpers;

import static it.feio.android.omninotes.utils.ConstantsBase.PREF_BACKUP_FOLDER_URI;
import static it.feio.android.omninotes.utils.ConstantsBase.PREF_PASSWORD;
import static org.junit.Assert.*;
import static rx.Observable.from;
Expand Down Expand Up @@ -198,6 +199,15 @@ public void importAttachment() throws BackupAttachmentException {
assertTrue(new File(attachment.getUri().getPath()).exists());
}

@Test
public void getBackupFolderPath() {
Prefs.putString(PREF_BACKUP_FOLDER_URI, "content://com.android.externalstorage.documents/tree/primary%3ADocuments%2FOmni%20Notes/document/primary%3ADocuments%2FOmni%20Notes");

var backupFolder = BackupHelper.getBackupFolderPath();

assertEquals("Documents/Omni Notes", backupFolder);
}

private Attachment createTestAttachmentBackup() {
var testAttachment = attachmentsBackupDir.createFile("", "testAttachment");
if (!testAttachment.exists() || !testAttachment.canRead()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import com.lazygeniouz.dfc.file.DocumentFileCompat;
import com.pixplicity.easyprefs.library.Prefs;
import it.feio.android.omninotes.async.DataBackupIntentService;
import it.feio.android.omninotes.exceptions.checked.ExternalStorageProviderException;
import it.feio.android.omninotes.helpers.AppVersionHelper;
import it.feio.android.omninotes.helpers.BackupHelper;
import it.feio.android.omninotes.helpers.ChangelogHelper;
Expand Down Expand Up @@ -150,20 +151,19 @@ public void onResume() {
// Export notes
Preference export = findPreference("settings_export_data");
if (export != null) {
export.setSummary(StorageHelper.getExternalStoragePublicDir().getAbsolutePath());
export.setSummary(BackupHelper.getBackupFolderPath());
export.setOnPreferenceClickListener(arg0 -> {
if (VERSION.SDK_INT >= VERSION_CODES.O) {
var backupFolder = scopedStorageFolderChoosen();
if (backupFolder == null) {
startIntentForScopedStorage(ACCESS_DATA_FOR_EXPORT);
} else {
try {
scopedStorageFolderChoosen();
exportNotes();
} catch (ExternalStorageProviderException e) {
startIntentForScopedStorage(ACCESS_DATA_FOR_EXPORT);
}
} else {
PermissionsHelper
.requestPermission(getActivity(), permission.WRITE_EXTERNAL_STORAGE, R
.string.permission_external_storage,
getActivity().findViewById(R.id.crouton_handle), this::exportNotes);
PermissionsHelper.requestPermission(getActivity(), permission.WRITE_EXTERNAL_STORAGE,
R.string.permission_external_storage, getActivity().findViewById(R.id.crouton_handle),
this::exportNotes);
}
return false;
});
Expand All @@ -177,22 +177,34 @@ public void onResume() {
}
importData.setOnPreferenceClickListener(arg0 -> {
if (VERSION.SDK_INT >= VERSION_CODES.O) {
var backupFolder = scopedStorageFolderChoosen();
if (backupFolder == null) {
startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), ACCESS_DATA_FOR_IMPORT);
} else {
DocumentFileCompat backupFolder;
try {
backupFolder = scopedStorageFolderChoosen();
importNotes(backupFolder);
} catch (ExternalStorageProviderException e) {
startIntentForScopedStorage(ACCESS_DATA_FOR_IMPORT);
}
} else {
PermissionsHelper
.requestPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, R
.string.permission_external_storage,
getActivity().findViewById(R.id.crouton_handle), this::importNotes);
PermissionsHelper
.requestPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, R
.string.permission_external_storage,
getActivity().findViewById(R.id.crouton_handle), this::importNotes);
}
return false;
});
}

if (VERSION.SDK_INT >= VERSION_CODES.O) {
Preference changeBackupFolder = findPreference("settings_change_backup_folder");
if (changeBackupFolder != null) {
changeBackupFolder.setVisible(true);
changeBackupFolder.setOnPreferenceClickListener(arg0 -> {
startIntentForScopedStorage(ACCESS_DATA_FOR_IMPORT);
return false;
});
}
}

// // Autobackup feature integrity check
// Preference backupIntegrityCheck = findPreference("settings_backup_integrity_check");
// if (backupIntegrityCheck != null) {
Expand Down Expand Up @@ -561,13 +573,18 @@ private void startIntentForScopedStorage(int intentRequestCode) {
}

@TargetApi(VERSION_CODES.O)
private DocumentFileCompat scopedStorageFolderChoosen() {
private DocumentFileCompat scopedStorageFolderChoosen() throws ExternalStorageProviderException {
var backupFolderUri = Prefs.getString(PREF_BACKUP_FOLDER_URI, null);
if (backupFolderUri == null) {
return null;
try {
var backupFolder = DocumentFileCompat.Companion.fromTreeUri(getContext(),
Uri.parse(backupFolderUri));
if (backupFolder == null || !backupFolder.canWrite()) {
throw new ExternalStorageProviderException("Can't write into " + backupFolder);
}
return backupFolder;
} catch (SecurityException | NullPointerException e) {
throw new ExternalStorageProviderException(e);
}
var backupFolder = DocumentFileCompat.Companion.fromTreeUri(getContext(), Uri.parse(backupFolderUri));
return backupFolder.canWrite() ? backupFolder : null;
}

private void importNotes() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2013-2022 Federico Iosue (federico@iosue.it)
*
* 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 Foundation, 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.exceptions.checked;

public class ExternalStorageProviderException extends Exception {

public ExternalStorageProviderException(Exception e) {
super(e);
}

public ExternalStorageProviderException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import androidx.annotation.NonNull;
Expand All @@ -46,7 +48,9 @@
import it.feio.android.omninotes.utils.TextHelper;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -316,6 +320,16 @@ public static DocumentFileCompat saveScopedStorageUriInPreferences(Intent intent
// return errors;
// }

public static String getBackupFolderPath() {
if (VERSION.SDK_INT >= VERSION_CODES.O) {
var backupFolder = Prefs.getString(PREF_BACKUP_FOLDER_URI, "");
var paths =URI.create(backupFolder).getPath().split(":");
return paths[paths.length - 1];
} else {
return StorageHelper.getExternalStoragePublicDir().getAbsolutePath();
}
}

private static void addIntegrityCheckError(List<LinkedList<DiffMatchPatch.Diff>> errors,
IOException e) {
LinkedList<DiffMatchPatch.Diff> l = new LinkedList<>();
Expand Down
9 changes: 8 additions & 1 deletion omniNotes/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
<changelog bulletedList="true">

<changelogversion
changeDate="Mar 24, 2022"
changeDate="Apr 16, 2023"
versionName="6.2.3">
<changelogtext>[b]New![/b] Backup folder is modifiable on Android Oreo and higher</changelogtext>
<changelogtext>[u]Fix[/u] Backups management for installations upgraded from version 6.1.0</changelogtext>
</changelogversion>

<changelogversion
changeDate="Mar 24, 2023"
versionName="6.2.0">
<changelogtext>[b]New![/b] Updated to Android 12 to get latest fixes and improvements
<![CDATA[[b][font color=red>IMPORTANT:[/font][/b] This will require to move your old backups to the new directory]]>
Expand Down
14 changes: 14 additions & 0 deletions omniNotes/src/main/res/values-ar-rSA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<string name="note_updated">نقطة محدثة</string>
<string name="empty_note_not_saved">النقط الفارغة لاتحفظ</string>
<string name="empty_note_not_shared">النقط الفارغة غير قابلة للإشراك</string>
<string name="attachment_not_found">لم يتم العثور على المرفق</string>
<string name="note_doesnt_exist">الملاحظة لم تعد موجودة بعد الآن</string>
<string name="note_archived">نقطة مؤرشفة</string>
<string name="note_unarchived">نقطة مستعادة من الأرشيف</string>
<string name="note">نقطة</string>
Expand All @@ -66,6 +68,7 @@
<string name="delete_all_attachments">حذف جميع المرفقات؟</string>
<string name="gallery">معرض الصور</string>
<string name="location">موقع</string>
<string name="location_set_high_accuracy">الرجاء تعيين وضع الموقع إلى درجة عالية من الدقة للمتابعة</string>
<string name="timestamp">الطابع الزمني</string>
<string name="pushbullet">بوشبوليت</string>
<string name="remove_location">إزالة الموقع؟</string>
Expand Down Expand Up @@ -124,6 +127,7 @@
<string name="no_items_in_list">لا شيء هنا!</string>
<string name="checklist_on">تفعيل قائمة مرجعية</string>
<string name="checklist_off">تعطيل قائمة مرجعية</string>
<string name="checklist_moveToBottom">نقل العناصر المحددة إلى الأسفل</string>
<string name="checklist_item_hint">عنصر جديد</string>
<string name="remove_checklist">إزالة قائمة؟</string>
<string name="checklist_keep_checked">الاحتفاظ بالعناصر المحددة</string>
Expand Down Expand Up @@ -153,6 +157,9 @@
<string name="grid_view">عرض الشبكة</string>
<string name="add_shortcut">اضف اختصار</string>
<string name="shortcut_added">تم اضافة الاختصار الي الشاشة الرئيسية</string>
<string name="shortcut_disabled">الاختصار غير صالح بعد الآن</string>
<string name="pin_note">تثبيت ملاحظة</string>
<string name="pined_note">تم تثبيت الملاحظة كإشعار</string>
<string name="shortcut_note_deleted">الاختصار ينتمي الي مدونات محذوفة</string>
<string name="widget_simple_description">اداة مبسطة مع ازرار</string>
<string name="widget_list_description">اداة بتمرير القائمة مع ازرار</string>
Expand Down Expand Up @@ -207,6 +214,8 @@
<string name="info">معلومات</string>
<string name="completed">مكتمل</string>
<string name="undo_changes_note_confirmation">تأكيد عكس التغييرات؟</string>
<string name="done">تم</string>
<string name="nothing_selected">لا شيء محدد</string>
<!-- Settings -->
<string name="dashclock_description">عرض بعض الاحصائيات و المذكرات المنتهية من مدونات أومني</string>
<string name="settings">إعدادات</string>
Expand All @@ -219,6 +228,8 @@
<string name="settings_export">النسخ الاحتياطي</string>
<string name="settings_sync_import_export">المزامنة والنسخ الاحتياطي</string>
<string name="settings_import">استعادة أو حذف النسخ الاحتياطية</string>
<string name="settings_import_summary">تحذير: لم يتم تعيين كلمة المرور، لن يتم استعادة الملاحظات المحمية من النسخ الاحتياطي لأسباب أمنية</string>
<string name="settings_change_backup_folder">تغيير مجلد النسخ الاحتياطي</string>
<string name="settings_import_legacy">استعادة النسخ الاحتياطي القديم </string>
<string name="settings_import_legacy_summary">السماح باستعادة النسخ الاحتياطية القديمة التي تم إنشاؤها مع إصدارات Omni Notes قبل الإصدار 6</string>
<string name="settings_import_from_springpad">إستيراد ملاحظات من Springpad</string>
Expand Down Expand Up @@ -270,6 +281,7 @@
<string name="settings_enable_editor_links_summary">تمكين أو تعطيل تسليط الضوء تلقائياعلى الروابط والبريد الإلكتروني في المحرر</string>
<string name="confirm_removing_backup">تأكيد إزالة النسخ الاحتياطي</string>
<string name="confirm_restoring_backup">تأكيد استعادة المدونات من النسخة الاحتياطية؟</string>
<string name="confirm_restoring_backup_warning">تحذير: تأكد من تعيين كلمة مرور في الإعدادات أو الملاحظات المحمية سيتم تخطي لأسباب أمنية!</string>
<string name="data_deletion_completed">تم حذف البيانات بنجاح</string>
<string name="settings_checked_items_behavior">قوائم مرجعية</string>
<string name="settings_checked_items_behavior_summary">ماهو السلوك عندما يتم إختيار عنصر؟</string>
Expand Down Expand Up @@ -405,4 +417,6 @@
<string name="channel_backups_description">الإشعارات لحالة النسخ الاحتياطي والنتائج</string>
<string name="channel_reminders_name">التنبيهات</string>
<string name="channel_reminders_description">إشعارات لتذكير الملاحظات</string>
<string name="channel_pinned_name">مثبتة</string>
<string name="channel_pinned_description">إشعارات للملاحظات المثبتة</string>
</resources>
Loading

0 comments on commit 96a2db3

Please sign in to comment.