Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-06-07 18:35:40 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2020-06-07 20:11:33 +0300
commit67609666256181cfc5ffcd044ce12e794c57d70a (patch)
tree628b35a79b8e07382ba8cd555289d514ceaaeefe /app/src/main
parent45ce9019411d2f78f0051574600cd204be0f32bb (diff)
#116 "Help: format" option in the menu
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml6
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java15
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/formattinghelp/FormattingHelpActivity.java105
-rw-r--r--app/src/main/res/drawable/ic_baseline_help_outline_24.xml5
-rw-r--r--app/src/main/res/layout/activity_formatting_help.xml43
-rw-r--r--app/src/main/res/raw/formatting_help.md150
-rw-r--r--app/src/main/res/values/strings.xml1
7 files changed, 318 insertions, 7 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fc42c3cf..f3117ead 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -63,6 +63,12 @@
android:label="@string/app_name" />
<activity
+ android:name=".formattinghelp.FormattingHelpActivity"
+ android:label="@string/action_formatting_help"
+ android:parentActivityName=".android.activity.NotesListViewActivity"
+ android:windowSoftInputMode="stateHidden" />
+
+ <activity
android:name=".manageaccounts.ManageAccountsActivity"
android:label="@string/manage_accounts"
android:parentActivityName=".android.activity.NotesListViewActivity"
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java
index 6efa0ce6..3daf809a 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/activity/NotesListViewActivity.java
@@ -58,6 +58,7 @@ import it.niedermann.owncloud.notes.branding.BrandedSnackbar;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
import it.niedermann.owncloud.notes.databinding.ActivityNotesListViewBinding;
import it.niedermann.owncloud.notes.databinding.DrawerLayoutBinding;
+import it.niedermann.owncloud.notes.formattinghelp.FormattingHelpActivity;
import it.niedermann.owncloud.notes.model.Capabilities;
import it.niedermann.owncloud.notes.model.Category;
import it.niedermann.owncloud.notes.model.DBNote;
@@ -83,6 +84,7 @@ import static android.view.View.VISIBLE;
import static it.niedermann.owncloud.notes.branding.BrandingUtil.getSecondaryForegroundColorDependingOnTheme;
import static it.niedermann.owncloud.notes.util.ColorUtil.contrastRatioIsSufficient;
import static it.niedermann.owncloud.notes.util.SSOUtil.askForNewAccount;
+import static java.util.Arrays.asList;
public class NotesListViewActivity extends LockedActivity implements NoteClickListener, ViewProvider, MoveAccountListener, AccountSwitcherListener {
@@ -555,19 +557,18 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi
}
private void setupNavigationMenu() {
+ final NavigationItem itemFormattingHelp = new NavigationItem("formattingHelp", getString(R.string.action_formatting_help), null, R.drawable.ic_baseline_help_outline_24);
final NavigationItem itemTrashbin = new NavigationItem("trashbin", getString(R.string.action_trashbin), null, R.drawable.ic_delete_grey600_24dp);
final NavigationItem itemSettings = new NavigationItem("settings", getString(R.string.action_settings), null, R.drawable.ic_settings_grey600_24dp);
final NavigationItem itemAbout = new NavigationItem("about", getString(R.string.simple_about), null, R.drawable.ic_info_outline_grey600_24dp);
- ArrayList<NavigationItem> itemsMenu = new ArrayList<>(3);
- itemsMenu.add(itemTrashbin);
- itemsMenu.add(itemSettings);
- itemsMenu.add(itemAbout);
-
NavigationAdapter adapterMenu = new NavigationAdapter(this, new NavigationAdapter.ClickListener() {
@Override
public void onItemClick(NavigationItem item) {
- if (itemSettings.equals(item)) {
+ if (itemFormattingHelp.equals(item)) {
+ Intent formattingHelpIntent = new Intent(getApplicationContext(), FormattingHelpActivity.class);
+ startActivity(formattingHelpIntent);
+ } else if (itemSettings.equals(item)) {
Intent settingsIntent = new Intent(getApplicationContext(), PreferencesActivity.class);
startActivityForResult(settingsIntent, server_settings);
} else if (itemAbout.equals(item)) {
@@ -583,7 +584,7 @@ public class NotesListViewActivity extends LockedActivity implements NoteClickLi
onItemClick(item);
}
});
- adapterMenu.setItems(itemsMenu);
+ adapterMenu.setItems(asList(itemFormattingHelp, itemTrashbin, itemSettings, itemAbout));
binding.navigationMenu.setAdapter(adapterMenu);
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/formattinghelp/FormattingHelpActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/formattinghelp/FormattingHelpActivity.java
new file mode 100644
index 00000000..332cbb7e
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/formattinghelp/FormattingHelpActivity.java
@@ -0,0 +1,105 @@
+package it.niedermann.owncloud.notes.formattinghelp;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.widget.Toast;
+
+import androidx.annotation.Nullable;
+
+import com.yydcdut.markdown.MarkdownProcessor;
+import com.yydcdut.markdown.syntax.text.TextFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import it.niedermann.owncloud.notes.R;
+import it.niedermann.owncloud.notes.android.fragment.ExceptionDialogFragment;
+import it.niedermann.owncloud.notes.branding.BrandedActivity;
+import it.niedermann.owncloud.notes.databinding.ActivityFormattingHelpBinding;
+
+import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_CHECKED_MINUS;
+import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_CHECKED_STAR;
+import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_MINUS;
+import static it.niedermann.owncloud.notes.util.MarkDownUtil.CHECKBOX_UNCHECKED_STAR;
+import static it.niedermann.owncloud.notes.util.MarkDownUtil.getMarkDownConfiguration;
+import static it.niedermann.owncloud.notes.util.MarkDownUtil.parseCompat;
+
+public class FormattingHelpActivity extends BrandedActivity {
+
+ private static final String TAG = FormattingHelpActivity.class.getSimpleName();
+ private ActivityFormattingHelpBinding binding;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ binding = ActivityFormattingHelpBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+
+ setSupportActionBar(binding.toolbar);
+ final StringBuilder stringBuilder = new StringBuilder();
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.formatting_help)))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ stringBuilder.append(line).append("\n");
+ }
+ } catch (IOException e) {
+ ExceptionDialogFragment.newInstance(e).show(getSupportFragmentManager(), ExceptionDialogFragment.class.getSimpleName());
+ }
+
+ String content = stringBuilder.toString();
+
+ final MarkdownProcessor markdownProcessor = new MarkdownProcessor(this);
+ markdownProcessor.factory(TextFactory.create());
+ markdownProcessor.config(getMarkDownConfiguration(binding.content.getContext())
+ .setOnTodoClickCallback((view, line, lineNumber) -> {
+ try {
+ String[] lines = TextUtils.split(content, "\\r?\\n");
+ /*
+ * Workaround for RxMarkdown-bug:
+ * When (un)checking a checkbox in a note which contains code-blocks, the "`"-characters get stripped out in the TextView and therefore the given lineNumber is wrong
+ * Find number of lines starting with ``` before lineNumber
+ */
+ for (int i = 0; i < lines.length; i++) {
+ if (lines[i].startsWith("```")) {
+ lineNumber++;
+ }
+ if (i == lineNumber) {
+ break;
+ }
+ }
+
+ /*
+ * Workaround for multiple RxMarkdown-bugs:
+ * When (un)checking a checkbox which is in the last line, every time it gets toggled, the last character of the line gets lost.
+ * When (un)checking a checkbox, every markdown gets stripped in the given line argument
+ */
+ if (lines[lineNumber].startsWith(CHECKBOX_UNCHECKED_MINUS) || lines[lineNumber].startsWith(CHECKBOX_UNCHECKED_STAR)) {
+ lines[lineNumber] = lines[lineNumber].replace(CHECKBOX_UNCHECKED_MINUS, CHECKBOX_CHECKED_MINUS);
+ lines[lineNumber] = lines[lineNumber].replace(CHECKBOX_UNCHECKED_STAR, CHECKBOX_CHECKED_STAR);
+ } else {
+ lines[lineNumber] = lines[lineNumber].replace(CHECKBOX_CHECKED_MINUS, CHECKBOX_UNCHECKED_MINUS);
+ lines[lineNumber] = lines[lineNumber].replace(CHECKBOX_CHECKED_STAR, CHECKBOX_UNCHECKED_STAR);
+ }
+
+ binding.content.setText(parseCompat(markdownProcessor, TextUtils.join("\n", lines)));
+ } catch (IndexOutOfBoundsException e) {
+ Toast.makeText(this, R.string.checkbox_could_not_be_toggled, Toast.LENGTH_SHORT).show();
+ e.printStackTrace();
+ }
+ return line;
+ }
+ )
+ .setOnLinkClickCallback((view, link) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))))
+ .build());
+ binding.content.setText(parseCompat(markdownProcessor, content));
+ }
+
+ @Override
+ public void applyBrand(int mainColor, int textColor) {
+
+ }
+}
diff --git a/app/src/main/res/drawable/ic_baseline_help_outline_24.xml b/app/src/main/res/drawable/ic_baseline_help_outline_24.xml
new file mode 100644
index 00000000..7897850e
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_help_outline_24.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp" android:tint="#757575"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#757575" android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"/>
+</vector>
diff --git a/app/src/main/res/layout/activity_formatting_help.xml b/app/src/main/res/layout/activity_formatting_help.xml
new file mode 100644
index 00000000..69c6838d
--- /dev/null
+++ b/app/src/main/res/layout/activity_formatting_help.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/primary"
+ android:orientation="vertical">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:contentInsetStartWithNavigation="0dp"
+ app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
+ app:title="@string/action_formatting_help"
+ app:titleMarginStart="0dp" />
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <ScrollView
+ android:id="@+id/scrollView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:context="it.niedermann.owncloud.notes.android.activity.EditNoteActivity">
+
+ <com.yydcdut.markdown.MarkdownTextView
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/spacer_2x"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/fg_default"
+ android:textIsSelectable="true"
+ android:theme="@style/textViewStyle"
+ tools:text="@tools:sample/lorem/random" />
+ </ScrollView>
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/raw/formatting_help.md b/app/src/main/res/raw/formatting_help.md
new file mode 100644
index 00000000..79cc6ac3
--- /dev/null
+++ b/app/src/main/res/raw/formatting_help.md
@@ -0,0 +1,150 @@
+# Context based formatting
+
+A major design goal of the Notes app is to provide a distraction free tool. Though you will be able to format your texts with Markdown. For various of the below mentioned examples, you can use shortcuts so you can format your notes without typing in the codes below.
+Just select a range of text or tap on your cursor at any position and you will get a popup menu which contains next to the default entries `Cut`, `Copy`, `Select all` entries like `Link` or `Checkbox`.
+
+---
+
+# Text
+
+It's very easy to make some words **bold** and other words *italic* with Markdown. You can ~~strike~~ some words through and even [link to Google](http://google.com).
+
+```
+It's very easy to make some words **bold** and other words *italic* with Markdown. You can ~~strike~~ some words through and even [link to Google](http://google.com).
+```
+
+---
+
+# Lists
+
+Sometimes you want numbered lists:
+
+1. One
+2. Two
+3. Three
+
+Sometimes you want bullet points:
+
+* Start a line with a star
+* Profit!
+
+Alternatively,
+
+- Dashes work just as well
+- And if you have sub points, put two spaces before the dash or star:
+ - Like this
+ - And this
+
+```
+Sometimes you want numbered lists:
+
+1. One
+2. Two
+3. Three
+
+Sometimes you want bullet points:
+
+* Start a line with a star
+* Profit!
+
+Alternatively,
+
+- Dashes work just as well
+- And if you have sub points, put two spaces before the dash or star:
+ - Like this
+ - And this
+```
+
+---
+
+# Checkbox
+
+To create a checkbox, use a list followed by brackets
+
+- [ ] Item 1
+* [ ] Item 2
+
+```
+To create a checkbox, use a list followed by brackets
+
+- [ ] Item 1
+* [ ] Item 2
+```
+
+---
+
+# Structured documents
+
+Sometimes it's useful to have different levels of headings to structure your documents. Start lines with a `#` to create headings. Multiple `##` in a row denote smaller heading sizes.
+
+### This is a third-tier heading
+
+You can use one `#` all the way up to `######` six for different heading sizes.
+
+If you'd like to quote someone, use the > character before the line:
+
+> Coffee. The finest organic suspension ever devised... I beat the Borg with it.
+> - Captain Janeway
+
+```
+# Structured documents
+
+Sometimes it's useful to have different levels of headings to structure your documents. Start lines with a `#` to create headings. Multiple `##` in a row denote smaller heading sizes.
+
+### This is a third-tier heading
+
+You can use one `#` all the way up to `######` six for different heading sizes.
+
+If you'd like to quote someone, use the > character before the line:
+
+> Coffee. The finest organic suspension ever devised... I beat the Borg with it.
+> - Captain Janeway
+```
+
+---
+
+# Code
+
+There are many different ways to style code with Markdown. If you have inline code blocks, wrap them in backticks:
+
+\`var example = true\`
+`var example = true`
+
+Markdown also supports something called code fencing, which allows for multiple lines without indentation:
+
+\`\`\`
+if (isAwesome){
+ return true
+}
+\`\`\`
+
+```
+if (isAwesome){
+ return true
+}
+```
+
+And if you'd like to use syntax highlighting, include the language:
+
+\`\`\`javascript
+if (isAwesome){
+ return true
+}
+\`\`\`
+
+```javascript
+if (isAwesome){
+ return true
+}
+```
+
+---
+
+# Unsupported
+
+While we try to continuously improve the support for Markdown, there are a few features which are not yet supported by Notes:
+
+- Tables
+- Images
+
+If you are interested in contributing support for one of those features, get in contact with us via GitHub or E-Mail. \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index e45acb06..6e6a6a4c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -197,6 +197,7 @@
<string name="simple_behavior">Behavior</string>
<string name="share_multiple">Share content of %1$d notes</string>
<string name="manage_accounts">Manage accounts</string>
+ <string name="action_formatting_help">Formatting</string>
<!-- Array: note modes -->
<string-array name="noteMode_entries">