Merge branch 'master' into 831-room

# Conflicts:
#	app/build.gradle
#	app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java
#	app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java
#	app/src/main/java/it/niedermann/owncloud/notes/edit/format/ContextBasedRangeFormattingCallback.java
#	app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java
#	app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java
#	app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java
#	app/src/main/java/it/niedermann/owncloud/notes/shared/util/NotesColorUtil.java
This commit is contained in:
Stefan Niedermann 2020-11-18 15:04:35 +01:00
commit 674fc96694
9 changed files with 122 additions and 82 deletions

View file

@ -30,6 +30,7 @@ import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException;
import com.nextcloud.android.sso.helper.SingleAccountHelper;
import com.nextcloud.android.sso.model.SingleSignOnAccount;
import it.niedermann.android.util.ColorUtil;
import java.util.ArrayList;
import java.util.Calendar;

View file

@ -60,66 +60,64 @@ public class ContextBasedRangeFormattingCallback implements ActionMode.Callback
final String markdown;
switch (item.getItemId()) {
case R.id.bold:
markdown = "**";
if (hasAlreadyMarkdown(start, end, markdown)) {
this.removeMarkdown(ssb, start, end, markdown);
int itemId = item.getItemId();
if (itemId == R.id.bold) {
markdown = "**";
if (hasAlreadyMarkdown(start, end, markdown)) {
this.removeMarkdown(ssb, start, end, markdown);
} else {
this.addMarkdown(ssb, start, end, markdown, Typeface.BOLD);
}
editText.setText(ssb);
editText.setSelection(end + markdown.length() * 2);
return true;
} else if (itemId == R.id.italic) {
markdown = "*";
if (hasAlreadyMarkdown(start, end, markdown)) {
this.removeMarkdown(ssb, start, end, markdown);
} else {
this.addMarkdown(ssb, start, end, markdown, Typeface.ITALIC);
}
editText.setText(ssb);
editText.setSelection(end + markdown.length() * 2);
return true;
} else if (itemId == R.id.link) {
boolean textToFormatIsLink = TextUtils.indexOf(editText.getText().subSequence(start, end), "http") == 0;
if (textToFormatIsLink) {
ssb.insert(end, ")");
ssb.insert(start, "[](");
} else {
String clipboardURL = ClipboardUtil.INSTANCE.getClipboardURLorNull(editText.getContext());
if (clipboardURL != null) {
ssb.insert(end, "](" + clipboardURL + ")");
end += clipboardURL.length();
} else {
this.addMarkdown(ssb, start, end, markdown, Typeface.BOLD);
ssb.insert(end, "]()");
}
editText.setText(ssb);
editText.setSelection(end + markdown.length() * 2);
ssb.insert(start, "[");
}
end++;
ssb.setSpan(new StyleSpan(Typeface.NORMAL), start, end, 1);
editText.setText(ssb);
if (textToFormatIsLink) {
editText.setSelection(start + 1);
} else {
editText.setSelection(end + 2); // after <end>](
}
return true;
} else if (itemId == android.R.id.cut) {// https://github.com/stefan-niedermann/nextcloud-notes/issues/604
// https://github.com/stefan-niedermann/nextcloud-notes/issues/477
try {
editText.onTextContextMenuItem(item.getItemId());
return true;
case R.id.italic:
markdown = "*";
if (hasAlreadyMarkdown(start, end, markdown)) {
this.removeMarkdown(ssb, start, end, markdown);
} else {
this.addMarkdown(ssb, start, end, markdown, Typeface.ITALIC);
}
editText.setText(ssb);
editText.setSelection(end + markdown.length() * 2);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
editText.setSelection(0, 0);
editText.clearFocus();
return true;
case R.id.link:
boolean textToFormatIsLink = TextUtils.indexOf(editText.getText().subSequence(start, end), "http") == 0;
if (textToFormatIsLink) {
ssb.insert(end, ")");
ssb.insert(start, "[](");
} else {
String clipboardURL = ClipboardUtil.INSTANCE.getClipboardURLorNull(editText.getContext());
if (clipboardURL != null) {
ssb.insert(end, "](" + clipboardURL + ")");
end += clipboardURL.length();
} else {
ssb.insert(end, "]()");
}
ssb.insert(start, "[");
}
end++;
ssb.setSpan(new StyleSpan(Typeface.NORMAL), start, end, 1);
editText.setText(ssb);
if (textToFormatIsLink) {
editText.setSelection(start + 1);
} else {
editText.setSelection(end + 2); // after <end>](
}
return true;
case android.R.id.cut:
// https://github.com/stefan-niedermann/nextcloud-notes/issues/604
// https://github.com/stefan-niedermann/nextcloud-notes/issues/477
try {
editText.onTextContextMenuItem(item.getItemId());
return true;
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
editText.setSelection(0, 0);
editText.clearFocus();
return true;
}
default:
return false;
}
}
return false;
}
@Override

View file

@ -13,9 +13,8 @@ public final class NotesColorUtil {
private static final Map<ColorPair, Boolean> CONTRAST_RATIO_SUFFICIENT_CACHE = new HashMap<>();
// ---------------------------------------------------
// Based on https://github.com/LeaVerou/contrast-ratio
// ---------------------------------------------------
private NotesColorUtil() {
}
public static boolean contrastRatioIsSufficient(@ColorInt int colorOne, @ColorInt int colorTwo) {
ColorPair key = new ColorPair(colorOne, colorTwo);
@ -42,7 +41,6 @@ public final class NotesColorUtil {
return second == colorPair.second;
}
@SuppressWarnings("ConstantConditions")
@Override
public int hashCode() {
int result = first;

View file

@ -44,7 +44,7 @@
<string name="settings_theme_title">Tema</string>
<string name="settings_font_title"> Fonte monospaçada</string>
<string name="settings_font_size">Tamanho da fonte</string>
<string name="settings_wifi_only">Sincronizar somente por Wi-Fi</string>
<string name="settings_wifi_only">Sincronizar apenas por Wi-Fi</string>
<string name="settings_lock">Proteção com senha</string>
<string name="settings_background_sync">Sincronização em segundo plano</string>
@ -191,6 +191,19 @@
<item quantity="one">%d selecionado</item>
<item quantity="other">%d selecionados</item>
</plurals>
<plurals name="bulk_notes_deleted">
<item quantity="one">Uma nota excluída</item>
<item quantity="other">%1$d notas excluídas</item>
</plurals>
<plurals name="bulk_notes_restored">
<item quantity="one">Uma nota restaurada</item>
<item quantity="other">%1$d notas restauradas</item>
</plurals>
<plurals name="share_multiple">
<item quantity="one">Compartilhar conteúdo de %1$d nota</item>
<item quantity="other">Compartilhar conteúdo de %1$d notas</item>
</plurals>
<string name="formatting_help_divider" translateable="false">---</string>
<string name="formatting_help_codefence_inline" translateable="false">`%1$s`</string>
<string name="formatting_help_codefence_inline_escaped" translateable="false">\\`%1$s\\`</string>
@ -201,7 +214,7 @@
<string name="formatting_help_cbf_body_2">Basta selecionar um intervalo de texto ou tocar no cursor em qualquer posição e você obterá um menu pop-up que contém ao lado das entradas padrão %1$s, %2$s, %3$s entradas como %4$s ou %5$s.</string>
<string name="formatting_help_text_title">Texto</string>
<string name="formatting_help_text_body">É muito fácil fazer algumas palavras %1$snegritas%1$s e outras %2$sitálicas%2$s com Markdown. Você pode %3$sriscar%3$salgumas palavras e até [linkar para o Nextcloud](https://nextcloud.com).</string>
<string name="formatting_help_text_body">É muito fácil fazer algumas palavras %1$snegritas%1$s e outras %2$sitálicas%2$s com Markdown. Você pode %3$sriscar%3$s algumas palavras e até [linkar para o Nextcloud](https://nextcloud.com).</string>
<string name="formatting_help_lists_title">Listas</string>
<string name="formatting_help_lists_body_1">Às vezes você deseja listas numeradas:</string>
@ -220,9 +233,9 @@
<string name="formatting_help_checkboxes_body_3">Item 2</string>
<string name="formatting_help_structured_documents_title">Documentos estruturados</string>
<string name="formatting_help_structured_documents_body_1">Às vezes, é útil ter diferentes níveis de títulos para estruturar seus documentos. Iniciar linhas com um %1$spara criar cabeçalhos. Vários %2$s em sequência indicam tamanhos de cabeçalho menores. </string>
<string name="formatting_help_structured_documents_body_1">Às vezes, é útil ter diferentes níveis de títulos para estruturar seus documentos. Iniciar linhas com um %1$s para criar cabeçalhos. Vários %2$s em sequência indicam tamanhos de cabeçalho menores. </string>
<string name="formatting_help_structured_documents_body_2">Este é um cabeçalho de terceira camada</string>
<string name="formatting_help_structured_documents_body_3">Você pode usar um %1$sem todo o trecho até seis %2$spara diferentes tamanhos de cabeçalho .</string>
<string name="formatting_help_structured_documents_body_3">Você pode usar um %1$s em todo o trecho até seis %2$s para diferentes tamanhos de cabeçalho.</string>
<string name="formatting_help_structured_documents_body_4">Se você quiser citar alguém, use o caractere %1$s antes da linha:</string>
<string name="formatting_help_structured_documents_body_5">Imaginação é mais importante que conhecimento. O conhecimento é limitado. A imaginação dá voltas no mundo.</string>
<string name="formatting_help_structured_documents_body_6">- Albert Einstein</string>

View file

@ -193,6 +193,25 @@
<item quantity="few">%d izbrane</item>
<item quantity="other">%d izbranih</item>
</plurals>
<plurals name="bulk_notes_deleted">
<item quantity="one">Izbrisana je ena zabeležka</item>
<item quantity="two">Izbrisani sta %1$d zabeležki</item>
<item quantity="few">Izbrisane so %1$d zabeležke</item>
<item quantity="other">Izbrisanih je %1$d zabeležk</item>
</plurals>
<plurals name="bulk_notes_restored">
<item quantity="one">Obnovljena je ena zabeležka</item>
<item quantity="two">Obnovljeni sta %1$d zabeležki</item>
<item quantity="few">Obnovljene so %1$d zabeležke</item>
<item quantity="other">Obnovljenih je %1$d zabeležk</item>
</plurals>
<plurals name="share_multiple">
<item quantity="one">Souporaba vsebine %1$d zabeležke</item>
<item quantity="two">Souporaba vsebine %1$d zabeležk</item>
<item quantity="few">Souporaba vsebine %1$d zabeležk</item>
<item quantity="other">Souporaba vsebine %1$d zabeležk</item>
</plurals>
<string name="formatting_help_divider" translateable="false">---</string>
<string name="formatting_help_codefence_inline" translateable="false">» %1$s «</string>
<string name="formatting_help_codefence_inline_escaped" translateable="false">\\`%1$s\\`</string>

View file

@ -192,6 +192,22 @@
<item quantity="few">%d означене</item>
<item quantity="other">%d означених</item>
</plurals>
<plurals name="bulk_notes_deleted">
<item quantity="one">Обрисана једна белешка</item>
<item quantity="few">Обрисано %1$d белешке</item>
<item quantity="other">Обрисано %1$d белешки</item>
</plurals>
<plurals name="bulk_notes_restored">
<item quantity="one">Повраћена једна белешка</item>
<item quantity="few">Повраћене %1$d белешке</item>
<item quantity="other">Повраћено %1$d белешки</item>
</plurals>
<plurals name="share_multiple">
<item quantity="one">Подели садржај %1$d белешке</item>
<item quantity="few">Подели садржај %1$d белешке</item>
<item quantity="other">Подели садржај %1$d белешки</item>
</plurals>
<string name="formatting_help_divider" translateable="false">---</string>
<string name="formatting_help_codefence_inline" translateable="false">`%1$s`</string>
<string name="formatting_help_codefence_inline_escaped" translateable="false">\\`%1$s\\`</string>

View file

@ -191,6 +191,19 @@
<item quantity="one">%d seçilmiş</item>
<item quantity="other">%d seçilmiş</item>
</plurals>
<plurals name="bulk_notes_deleted">
<item quantity="one">Bir not silindi</item>
<item quantity="other">%1$d not silindi</item>
</plurals>
<plurals name="bulk_notes_restored">
<item quantity="one">Bir not geri yüklendi</item>
<item quantity="other">%1$dnot geri yüklendi</item>
</plurals>
<plurals name="share_multiple">
<item quantity="one">%1$d notun içeriğini paylaş</item>
<item quantity="other">%1$d notun içeriğini paylaş</item>
</plurals>
<string name="formatting_help_divider" translateable="false">---</string>
<string name="formatting_help_codefence_inline" translateable="false">`%1$s`</string>
<string name="formatting_help_codefence_inline_escaped" translateable="false">\\`%1$s\\`</string>

View file

@ -40,7 +40,6 @@
<string name="listview_updated_this_month">This month</string>
<string name="listview_updated_last_month">Last month</string>
<!-- Settings -->
<string name="settings_note_mode">Display mode for notes</string>
<string name="settings_theme_title">Theme</string>
<string name="settings_font_title">Monospace font</string>
@ -49,24 +48,17 @@
<string name="settings_lock">Password protection</string>
<string name="settings_background_sync">Background synchronization</string>
<!-- Network -->
<!-- Error -->
<string name="error_sync">Synchronization failed: %1$s</string>
<string name="error_synchronization">Synchronization failed</string>
<string name="error_json">Is the Notes app activated on the server?</string>
<string name="error_no_network">No network connection</string>
<string name="error_unknown">An unknown error has occurred.</string>
<!-- Snackbar Actions -->
<!-- URLs -->
<string name="url_source" translatable="false">https://github.com/stefan-niedermann/nextcloud-notes</string>
<string name="url_issues" translatable="false">https://github.com/stefan-niedermann/nextcloud-notes/issues/new/choose</string>
<string name="url_license" translatable="false">https://github.com/stefan-niedermann/nextcloud-notes/blob/master/LICENSE</string>
<string name="url_translations" translatable="false">https://www.transifex.com/nextcloud/nextcloud/</string>
<!-- About -->
<string name="about_version_title">Version</string>
<string name="about_version">You are currently using &lt;strong>%1$s&lt;/strong></string>
<string name="about_maintainer_title">Maintainer</string>
@ -93,7 +85,6 @@
<string name="about_contribution_tab_title">Contribution</string>
<string name="about_license_tab_title">License</string>
<!-- Widgets -->
<string name="widget_note_list_title">Note list</string>
<string name="widget_note_list_placeholder">No notes</string>
<string name="widget_single_note_title">Single note</string>
@ -105,10 +96,8 @@
<string name="activity_select_single_note">Select note</string>
<!-- Shortcuts -->
<string name="shortcut_create_long">Create a new note</string>
<!-- Key / Values for preferences -->
<string name="pref_key_note_mode" translatable="false">noteMode</string>
<string name="pref_key_theme" translatable="false">darkTheme</string>
<string name="pref_key_font" translatable="false">font</string>
@ -133,7 +122,6 @@
<string name="pref_value_theme_light" translatable="false">LIGHT</string>
<string name="pref_value_theme_dark" translatable="false">DARK</string>
<string name="pref_value_theme_system_default" translatable="false">SYSTEM_DEFAULT</string>
<!-- These values should not be translatable. They should be migrated at some point. -->
<string name="pref_value_font_normal">Normal</string>
<string name="pref_value_wifi_and_mobile">Sync on Wi-Fi and mobile data</string>
<string name="pref_value_lock">Password protection</string>
@ -196,21 +184,18 @@
<string name="manage_accounts">Manage accounts</string>
<string name="action_formatting_help">Formatting</string>
<!-- Array: note modes -->
<string-array name="noteMode_entries">
<item>Open in edit mode</item>
<item>Open in preview mode</item>
<item>Remember my last selection</item>
</string-array>
<!-- Array: font size -->
<string-array name="fontSize_entries">
<item>Small</item>
<item>Medium</item>
<item>Large</item>
</string-array>
<!-- Array: background synchronization -->
<string-array name="sync_entries">
<item>Off</item>
<item>15 minutes</item>
@ -224,7 +209,6 @@
<item>System Default</item>
</string-array>
<!-- Plurals -->
<plurals name="ab_selected">
<item quantity="one">%d selected</item>
<item quantity="other">%d selected</item>
@ -242,8 +226,6 @@
<item quantity="other">Share content of %1$d notes</item>
</plurals>
<!-- Formatting help -->
<string name="formatting_help_title" translatable="false"># %1$s</string>
<string name="formatting_help_title_level_3" translatable="false">### %1$s</string>
<string name="formatting_help_divider" translateable="false">---</string>

View file

@ -8,7 +8,7 @@ buildscript {
}
dependencies {
apply plugin: 'maven'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:4.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files