Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to delete notebook if linked file gets deleted #918

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,12 @@ public static boolean syncOnResume(Context context) {
context.getResources().getBoolean(R.bool.pref_default_auto_sync_on_resume));
}

public static boolean syncDeletion(Context context) {
return getDefaultSharedPreferences(context).getBoolean(
context.getResources().getString(R.string.pref_key_sync_deletion),
context.getResources().getBoolean(R.bool.pref_default_sync_deletion));
}

/*
* Notes clipboard
*/
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/orgzly/android/sync/SyncService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,17 @@ class SyncService : Service() {
namesake.book.book.id,
BookAction.forNow(BookAction.Type.INFO, getString(R.string.canceled)))

} else if (AppPreferences.syncDeletion(context) &&
namesake.status == BookSyncStatus.ONLY_BOOK_WITH_LINK &&
namesake.rooks.isEmpty()) {
/* Delete book if file backing it does not exist */
dataRepository.deleteBook(namesake.book, false);
} else {
syncStatus.set(SyncStatus.Type.BOOK_STARTED, namesake.name, curr, namesakes.size)
announceActiveSyncStatus()



try {
val action = syncNamesake(dataRepository, namesake)
dataRepository.setBookLastActionAndSyncStatus(
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,6 @@
<string name="developer_options">Možnosti pro vývojáře</string>
<string name="git_repository_type">Typ Git repozitáře</string>
<string name="in_development">Ve vývoji</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if it is deleted from repo</string>

or it's, but it is good style to write it out in textual form

same for all the others

</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Opciones de desarrollador</string>
<string name="git_repository_type">Tipo de repositorio Git</string>
<string name="in_development">En desarrollo</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Options développeur</string>
<string name="git_repository_type">Type de dépôt Git</string>
<string name="in_development">En développement</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-hu-rHU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Fejlesztői beállítások</string>
<string name="git_repository_type">Git adattároló típusa</string>
<string name="in_development">Fejlesztés alatt</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-in-rID/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-it-rIT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,6 @@
<string name="developer_options">開発者オプション</string>
<string name="git_repository_type">リポジトリの種類</string>
<string name="in_development">開発中</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-nl-rNL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Ontwikkelaarsopties</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In ontwikkeling</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pl-rPL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Typ repozytorium Git</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Synchronizuj usunięcie</string>
<string name="pref_title_summary_sync_deletion">Usuń notatnik po usunięciu powiązanego pliku</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt-rPT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Opções de programador</string>
<string name="git_repository_type">Tipo de repositório Git</string>
<string name="in_development">Em desenvolvimento</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-ru-rRU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,6 @@
<string name="developer_options">Для разработчиков</string>
<string name="git_repository_type">Тип git-репозитория</string>
<string name="in_development">В разработке</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-sv-rSE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-tr-rTR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,4 +568,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-uk-rUA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,6 @@
<string name="developer_options">Параметри розробника</string>
<string name="git_repository_type">Тип git-репозиторію</string>
<string name="in_development">У розробці</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,6 @@
<string name="developer_options">开发者选项</string>
<string name="git_repository_type">Git 仓库类型</string>
<string name="in_development">开发中</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,6 @@
<string name="developer_options">開發人員選項</string>
<string name="git_repository_type">Git 儲存庫型式</string>
<string name="in_development">開發中</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if its deleted from repo</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/prefs_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@
<string name="pref_key_auto_sync_on_resume" translatable="false">pref_key_auto_sync_on_resume</string>
<bool name="pref_default_auto_sync_on_resume" translatable="false">false</bool>

<string name="pref_key_sync_deletion" translatable="false">pref_key_sync_deletion</string>
<bool name="pref_default_sync_deletion" translatable="false">false</bool>

<string name="pref_key_auto_sync_on_repo_change" translatable="false">pref_key_auto_sync_on_repo_change</string>
<bool name="pref_default_auto_sync_on_repo_change" translatable="false">false</bool>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -704,4 +704,6 @@
<string name="developer_options">Developer options</string>
<string name="git_repository_type">Git repository type</string>
<string name="in_development">In development</string>
<string name="pref_title_sync_deletion">Sync deletion</string>
<string name="pref_title_summary_sync_deletion">Delete notebook if linked file is deleted from repo</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/xml/prefs_screen_sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,10 @@
android:title="@string/org_file_format"
android:summary="@string/org_file_format_summary">
</androidx.preference.PreferenceScreen>
<SwitchPreference
android:defaultValue="@bool/pref_default_sync_deletion"
android:key="@string/pref_key_sync_deletion"
android:summary="@string/pref_title_summary_sync_deletion"
android:title="@string/pref_title_sync_deletion" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>