diff --git a/base/src/main/ic_launcher-web.png b/base/src/main/ic_launcher-web.png index 8b45d312..ac9a026d 100644 Binary files a/base/src/main/ic_launcher-web.png and b/base/src/main/ic_launcher-web.png differ diff --git a/base/src/main/java/com/maubis/scarlet/base/main/sheets/WhatsNewItemsBottomSheet.kt b/base/src/main/java/com/maubis/scarlet/base/main/sheets/WhatsNewItemsBottomSheet.kt index 4f1b2cb7..9bd405a4 100644 --- a/base/src/main/java/com/maubis/scarlet/base/main/sheets/WhatsNewItemsBottomSheet.kt +++ b/base/src/main/java/com/maubis/scarlet/base/main/sheets/WhatsNewItemsBottomSheet.kt @@ -34,10 +34,12 @@ class WhatsNewItemsBottomSheet : ThemedBottomSheetFragment() { optionsTitle.setTextColor(CoreConfig.instance.themeController().get(ThemeColorType.SECONDARY_TEXT)) val whatsNew = "> A lot has changed in this update, here is a summary of those changes.\n" + "### New Features\n" + + "- **History:** Adding undo / redo options for notes\n" + + "- **Merge Notes:** Adding option to merge multiple notes into one\n" + "- **Search Tags:** Choose multiple tags to filter notes\n" + "- **Search Colors:** Choose colors to filter notes by color of the note\n" + "- **Sorting Mode:** Sort the notes in alphabetical order\n" + - "- **Markdown Export:** Export in Markdown format\n" + + "- **Markdown Export:** Export in Markdown format, Optionally not export locked notes \n" + "- **Multiple Exports:** Export files now contain time, date information, allowing multiple backups\n" + "- **Note Background Color:** Set the note viewer background as the note color (Pro Only)\n" + "### Bugs Fix\n" + @@ -74,7 +76,7 @@ class WhatsNewItemsBottomSheet : ThemedBottomSheetFragment() { override fun getBackgroundCardViewIds(): Array = arrayOf(R.id.whats_new_card) companion object { - val WHATS_NEW_UID = 5 + val WHATS_NEW_UID = 6 val GOOGLE_TRANSLATE_URL = "https://translate.google.com/#auto/" fun openSheet(activity: ThemedActivity) { diff --git a/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/CreateNoteActivity.kt b/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/CreateNoteActivity.kt index e59b7f3b..190fe991 100644 --- a/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/CreateNoteActivity.kt +++ b/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/CreateNoteActivity.kt @@ -40,10 +40,12 @@ import java.util.* open class CreateNoteActivity : ViewAdvancedNoteActivity() { private var active = false - private var lastNoteInstance: Note? = null private var maxUid = 0 private var toolbarMode: ToolbarMode = ToolbarMode.FORMAT + private var historyIndex = 0 + private var historySize = 0L + val text: ImageView by bind(R.id.format_text) val heading: ImageView by bind(R.id.format_heading) val subHeading: ImageView by bind(R.id.format_sub_heading) @@ -59,13 +61,16 @@ open class CreateNoteActivity : ViewAdvancedNoteActivity() { val chevronLeft: ImageView by bind(R.id.toolbar_chevron_left) val chevronRight: ImageView by bind(R.id.toolbar_chevron_right) + val history: MutableList = emptyList().toMutableList() + override val editModeValue: Boolean get() = true override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setTouchListener() startHandler() - lastNoteInstance = NoteBuilder().copy(note!!) + history.add(NoteBuilder().copy(note!!)) + notifyHistoryIcons() } override fun setEditMode() { @@ -144,6 +149,19 @@ open class CreateNoteActivity : ViewAdvancedNoteActivity() { } override fun setTopToolbar() { + actionUndo.setOnClickListener { + historyIndex = if (historyIndex == 0) 0 else (historyIndex - 1) + note = NoteBuilder().copy(history.get(historyIndex)) + notifyHistoryIcons() + setNote() + } + actionRedo.setOnClickListener { + val maxHistoryIndex = history.size - 1 + historyIndex = if (historyIndex == maxHistoryIndex) maxHistoryIndex else (historyIndex + 1) + note = NoteBuilder().copy(history.get(historyIndex)) + notifyHistoryIcons() + setNote() + } actionDelete.visibility = GONE actionShare.visibility = GONE actionCopy.visibility = GONE @@ -257,7 +275,7 @@ open class CreateNoteActivity : ViewAdvancedNoteActivity() { protected fun maybeUpdateNoteWithoutSync() { val vNote = note!! - val vLastNoteInstance = lastNoteInstance ?: note!! + val vLastNoteInstance = history.getOrNull(historyIndex) ?: note!! vNote.description = FormatBuilder().getDescription(formats) @@ -266,9 +284,39 @@ open class CreateNoteActivity : ViewAdvancedNoteActivity() { return } + addNoteToHistory(NoteBuilder().copy(vNote)) vNote.updateTimestamp = Calendar.getInstance().timeInMillis maybeSaveNote(false) - lastNoteInstance = NoteBuilder().copy(vNote) + } + + @Synchronized + private fun addNoteToHistory(note: Note) { + while (historyIndex != history.size - 1) { + history.removeAt(historyIndex) + } + + history.add(note) + historySize += note.description.length + historyIndex += 1 + + // 0.5MB limit on history + if (historySize >= 1024 * 512 || history.size >= 15) { + val item = history.removeAt(0) + historySize -= item.description.length + historyIndex -= 1 + } + notifyHistoryIcons() + } + + private fun notifyHistoryIcons() { + actionRedo.alpha = when (historyIndex != history.size - 1) { + true -> 1.0f + false -> 0.4f + } + actionUndo.alpha = when (historyIndex == 0) { + true -> 0.4f + false -> 1.0f + } } private fun startHandler() { diff --git a/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/ViewNoteActivity.kt b/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/ViewNoteActivity.kt index b3b68297..13bafac4 100644 --- a/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/ViewNoteActivity.kt +++ b/base/src/main/java/com/maubis/scarlet/base/note/creation/activity/ViewNoteActivity.kt @@ -62,6 +62,8 @@ open class ViewAdvancedNoteActivity : ThemedActivity(), INoteOptionSheetActivity val rootView: View by bind(R.id.root_layout) val backButton: ImageView by bind(R.id.back_button) + val actionUndo: ImageView by bind(R.id.undo_button) + val actionRedo: ImageView by bind(R.id.redo_button) val actionCopy: ImageView by bind(R.id.copy_button) val actionDelete: ImageView by bind(R.id.delete_button) val actionShare: ImageView by bind(R.id.share_button) @@ -122,10 +124,15 @@ open class ViewAdvancedNoteActivity : ThemedActivity(), INoteOptionSheetActivity resetBundle() setNote() - actionDone.visibility = if (mode) VISIBLE else GONE - toolbar.visibility = if (mode) VISIBLE else GONE - primaryFab.visibility = if (mode || isDistractionFree) GONE else VISIBLE - secondaryFab.visibility = if (mode || isDistractionFree) GONE else VISIBLE + val visibleInEditMode = if (mode) VISIBLE else GONE + actionDone.visibility = visibleInEditMode + actionUndo.visibility = visibleInEditMode + actionRedo.visibility = visibleInEditMode + toolbar.visibility = visibleInEditMode + + val visibleInNormalMode = if (mode || isDistractionFree) GONE else VISIBLE + primaryFab.visibility = visibleInNormalMode + secondaryFab.visibility = visibleInNormalMode markdownToolbar.visibility = GONE } @@ -295,6 +302,8 @@ open class ViewAdvancedNoteActivity : ThemedActivity(), INoteOptionSheetActivity } backButton.setColorFilter(toolbarIconColor) + actionRedo.setColorFilter(toolbarIconColor) + actionUndo.setColorFilter(toolbarIconColor) actionCopy.setColorFilter(toolbarIconColor) actionDelete.setColorFilter(toolbarIconColor) actionShare.setColorFilter(toolbarIconColor) diff --git a/base/src/main/java/com/maubis/scarlet/base/settings/sheet/NoteSettingsOptionsBottomSheet.kt b/base/src/main/java/com/maubis/scarlet/base/settings/sheet/NoteSettingsOptionsBottomSheet.kt index cb3179dc..3cd051ca 100644 --- a/base/src/main/java/com/maubis/scarlet/base/settings/sheet/NoteSettingsOptionsBottomSheet.kt +++ b/base/src/main/java/com/maubis/scarlet/base/settings/sheet/NoteSettingsOptionsBottomSheet.kt @@ -27,7 +27,7 @@ class NoteSettingsOptionsBottomSheet : OptionItemBottomSheetBase() { object : ColorPickerBottomSheet.ColorPickerDefaultController { override fun getSheetTitle(): Int = R.string.choose_note_color - override fun getColorList(): IntArray = resources.getIntArray(R.array.bright_colors) + override fun getColorList(): IntArray = activity.resources.getIntArray(R.array.bright_colors) override fun onColorSelected(color: Int) { CoreConfig.instance.store().put(KEY_NOTE_DEFAULT_COLOR, color) diff --git a/base/src/main/res/drawable-hdpi/ic_redo_history.png b/base/src/main/res/drawable-hdpi/ic_redo_history.png new file mode 100644 index 00000000..bd705ed9 Binary files /dev/null and b/base/src/main/res/drawable-hdpi/ic_redo_history.png differ diff --git a/base/src/main/res/drawable-hdpi/ic_undo_history.png b/base/src/main/res/drawable-hdpi/ic_undo_history.png new file mode 100644 index 00000000..2b40260e Binary files /dev/null and b/base/src/main/res/drawable-hdpi/ic_undo_history.png differ diff --git a/base/src/main/res/drawable-mdpi/ic_redo_history.png b/base/src/main/res/drawable-mdpi/ic_redo_history.png new file mode 100644 index 00000000..ad6d1090 Binary files /dev/null and b/base/src/main/res/drawable-mdpi/ic_redo_history.png differ diff --git a/base/src/main/res/drawable-mdpi/ic_undo_history.png b/base/src/main/res/drawable-mdpi/ic_undo_history.png new file mode 100644 index 00000000..c09d7410 Binary files /dev/null and b/base/src/main/res/drawable-mdpi/ic_undo_history.png differ diff --git a/base/src/main/res/drawable-xhdpi/ic_redo_history.png b/base/src/main/res/drawable-xhdpi/ic_redo_history.png new file mode 100644 index 00000000..6c958565 Binary files /dev/null and b/base/src/main/res/drawable-xhdpi/ic_redo_history.png differ diff --git a/base/src/main/res/drawable-xhdpi/ic_undo_history.png b/base/src/main/res/drawable-xhdpi/ic_undo_history.png new file mode 100644 index 00000000..b3b7f337 Binary files /dev/null and b/base/src/main/res/drawable-xhdpi/ic_undo_history.png differ diff --git a/base/src/main/res/drawable-xxhdpi/ic_redo_history.png b/base/src/main/res/drawable-xxhdpi/ic_redo_history.png new file mode 100644 index 00000000..93eacdf0 Binary files /dev/null and b/base/src/main/res/drawable-xxhdpi/ic_redo_history.png differ diff --git a/base/src/main/res/drawable-xxhdpi/ic_undo_history.png b/base/src/main/res/drawable-xxhdpi/ic_undo_history.png new file mode 100644 index 00000000..bf47f8cf Binary files /dev/null and b/base/src/main/res/drawable-xxhdpi/ic_undo_history.png differ diff --git a/base/src/main/res/drawable/ic_scarlet_logo.png b/base/src/main/res/drawable/ic_scarlet_logo.png index 4fe93cbd..c2010875 100644 Binary files a/base/src/main/res/drawable/ic_scarlet_logo.png and b/base/src/main/res/drawable/ic_scarlet_logo.png differ diff --git a/base/src/main/res/layout/toolbar_advanced_note.xml b/base/src/main/res/layout/toolbar_advanced_note.xml index d3c30e4b..f12a5b6d 100644 --- a/base/src/main/res/layout/toolbar_advanced_note.xml +++ b/base/src/main/res/layout/toolbar_advanced_note.xml @@ -1,7 +1,6 @@ - + style="@style/NoteCreatorToolbarIcon" + android:src="@drawable/ic_close_white_48dp" /> + + + + + + style="@style/NoteCreatorToolbarIcon" + android:src="@drawable/ic_delete_white_48dp" /> + android:src="@drawable/ic_content_copy_white_48dp" /> + style="@style/NoteCreatorToolbarIcon" + android:src="@drawable/ic_share_white_48dp" /> + style="@style/NoteCreatorToolbarIcon" + android:src="@drawable/ic_done_white_48dp" /> \ No newline at end of file diff --git a/base/src/main/res/layout/toolbar_main.xml b/base/src/main/res/layout/toolbar_main.xml index eedbddb0..33e72622 100644 --- a/base/src/main/res/layout/toolbar_main.xml +++ b/base/src/main/res/layout/toolbar_main.xml @@ -19,7 +19,7 @@ android:id="@+id/home_button" android:layout_width="@dimen/icon_size_large" android:layout_height="@dimen/icon_size_large" - android:padding="@dimen/spacing_xsmall" + android:padding="@dimen/spacing_xxsmall" android:layout_marginEnd="@dimen/spacing_xsmall" android:src="@drawable/ic_scarlet_logo" android:tint="@color/colorAccent" /> diff --git a/base/src/main/res/mipmap-hdpi/ic_launcher.png b/base/src/main/res/mipmap-hdpi/ic_launcher.png index cf7fd782..453bed29 100644 Binary files a/base/src/main/res/mipmap-hdpi/ic_launcher.png and b/base/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/base/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/base/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index dce0368f..0030f59f 100644 Binary files a/base/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/base/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/base/src/main/res/mipmap-hdpi/ic_launcher_round.png b/base/src/main/res/mipmap-hdpi/ic_launcher_round.png index e8c8e840..0e77e5bc 100644 Binary files a/base/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/base/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/base/src/main/res/mipmap-mdpi/ic_launcher.png b/base/src/main/res/mipmap-mdpi/ic_launcher.png index ab9547a7..a93e8352 100644 Binary files a/base/src/main/res/mipmap-mdpi/ic_launcher.png and b/base/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/base/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/base/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 93146dec..f1808333 100644 Binary files a/base/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/base/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/base/src/main/res/mipmap-mdpi/ic_launcher_round.png b/base/src/main/res/mipmap-mdpi/ic_launcher_round.png index c27b41ef..3acdf4a1 100644 Binary files a/base/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/base/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/base/src/main/res/mipmap-xhdpi/ic_launcher.png b/base/src/main/res/mipmap-xhdpi/ic_launcher.png index 10603f46..66eb7fb3 100644 Binary files a/base/src/main/res/mipmap-xhdpi/ic_launcher.png and b/base/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/base/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/base/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index 5b838013..726239b6 100644 Binary files a/base/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/base/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/base/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/base/src/main/res/mipmap-xhdpi/ic_launcher_round.png index 45fbc66d..00e24b5e 100644 Binary files a/base/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/base/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/base/src/main/res/mipmap-xxhdpi/ic_launcher.png b/base/src/main/res/mipmap-xxhdpi/ic_launcher.png index 224af131..eebde4a8 100644 Binary files a/base/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/base/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/base/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/base/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index e8c33d87..9918e2ea 100644 Binary files a/base/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/base/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/base/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/base/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index be3e8446..9ad61ce8 100644 Binary files a/base/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/base/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/base/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/base/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 6805c2bf..41619e87 100644 Binary files a/base/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/base/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/base/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/base/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 33b05934..873b6e09 100644 Binary files a/base/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/base/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/base/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/base/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index 7856eda0..71fa9481 100644 Binary files a/base/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/base/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/base/src/main/res/values/styles.xml b/base/src/main/res/values/styles.xml index 8c0a40fe..1d6b8aaa 100644 --- a/base/src/main/res/values/styles.xml +++ b/base/src/main/res/values/styles.xml @@ -44,7 +44,6 @@ @dimen/icon_size_large @color/light_hint_text @dimen/spacing_xsmall - ?attr/selectableItemBackgroundBorderless center_vertical|end @@ -138,4 +137,11 @@ @dimen/spacing_xxsmall @dimen/spacing_xxsmall + + diff --git a/build.gradle b/build.gradle index 147e1cfd..d38624c9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.41' + ext.kotlin_version = '1.2.50' ext.android_basics = '4.4.1' ext.room_version = '1.0.0' ext.ui_basics = '0.6.1' ext.android_support_version = '27.1.1' ext.firebase_version = '15.0.0' - ext.appconfig_version_code = 92 - ext.appconfig_version = '5.8.2' + ext.appconfig_version_code = 95 + ext.appconfig_version = '5.9.7' ext.appconfig_min_os_version = 17 ext.appconfig_target_os_version = 27 ext.appconfig_build_tool_version = '27.0.3' @@ -20,7 +20,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:3.1.3' classpath 'com.google.gms:google-services:3.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.github.zellius:android-shortcut-gradle-plugin:0.1.2'