Skip to content

Commit

Permalink
Adding ability to not export locked notes. Adding more upsells
Browse files Browse the repository at this point in the history
  • Loading branch information
BijoySingh committed Jun 17, 2018
1 parent 3b8c503 commit 5cb00cc
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
2 changes: 2 additions & 0 deletions base/src/main/java/com/maubis/scarlet/base/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ class MainActivity : ThemedActivity(), ITutorialActivity, INoteOptionSheetActivi
shouldShowAppUpdateInformationItem() -> getAppUpdateInformationItem(this)
shouldShowReviewInformationItem() -> getReviewInformationItem(this)
shouldShowInstallProInformationItem() -> getInstallProInformationItem(this)
shouldShowThemeInformationItem() -> getThemeInformationItem(this)
shouldShowBackupInformationItem() -> getBackupInformationItem(this)
else -> null
}
if (informationItem === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class BackupSettingsOptionsBottomSheet : OptionItemBottomSheetBase() {
},
enabled = exportAsMarkdown
))
options.add(OptionsItem(
title = R.string.import_export_locked,
subtitle = R.string.import_export_locked_details,
icon = R.drawable.ic_action_lock,
listener = View.OnClickListener {
exportLockedNotes = !exportLockedNotes
reset(dialog)
},
enabled = exportLockedNotes
))
val autoBackupEnabled = CoreConfig.instance.store().get(KEY_AUTO_BACKUP_MODE, false)
options.add(OptionsItem(
title = R.string.home_option_auto_export,
Expand Down Expand Up @@ -152,5 +162,9 @@ class BackupSettingsOptionsBottomSheet : OptionItemBottomSheetBase() {

sheet.show(activity.supportFragmentManager, sheet.tag)
}

var exportLockedNotes: Boolean
get() = CoreConfig.instance.store().get(KEY_BACKUP_LOCKED, true)
set(value) = CoreConfig.instance.store().put(KEY_BACKUP_LOCKED, value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.maubis.scarlet.base.config.CoreConfig
import com.maubis.scarlet.base.export.data.ExportableFileFormat
import com.maubis.scarlet.base.export.data.ExportableNote
import com.maubis.scarlet.base.export.data.ExportableTag
import com.maubis.scarlet.base.export.sheet.BackupSettingsOptionsBottomSheet
import com.maubis.scarlet.base.export.sheet.ExportNotesBottomSheet
import com.maubis.scarlet.base.note.getFullText
import com.maubis.scarlet.base.support.database.notesDB
Expand All @@ -17,6 +18,7 @@ import java.io.File
import java.util.*

const val KEY_NOTE_VERSION = "KEY_NOTE_VERSION"
const val KEY_BACKUP_LOCKED = "KEY_BACKUP_LOCKED"
const val KEY_BACKUP_MARKDOWN = "KEY_BACKUP_MARKDOWN"
const val KEY_BACKUP_LOCATION = "KEY_BACKUP_LOCATION"
const val KEY_AUTO_BACKUP_MODE = "KEY_AUTO_BACKUP_MODE"
Expand All @@ -35,7 +37,12 @@ class NoteExporter() {
return getMarkdownExportContent()
}

val notes = notesDB.getAll().map { ExportableNote(it) }
val exportLocked = BackupSettingsOptionsBottomSheet.exportLockedNotes

val notes = notesDB
.getAll()
.filter { exportLocked || !it.locked }
.map { ExportableNote(it) }
val tags = tagsDB.getAll().map { ExportableTag(it) }
val fileContent = ExportableFileFormat(EXPORT_VERSION, notes, tags)
return Gson().toJson(fileContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package com.maubis.scarlet.base.main.recycler

import android.content.Context
import com.github.bijoysingh.starter.util.IntentUtils
import com.maubis.scarlet.base.MainActivity
import com.maubis.scarlet.base.R
import com.maubis.scarlet.base.config.CoreConfig
import com.maubis.scarlet.base.export.sheet.BackupSettingsOptionsBottomSheet
import com.maubis.scarlet.base.settings.sheet.UISettingsOptionsBottomSheet
import com.maubis.scarlet.base.support.Flavor
import com.maubis.scarlet.base.support.recycler.RecyclerItem
import java.util.*
Expand All @@ -12,6 +15,8 @@ const val KEY_INFO_RATE_AND_REVIEW = "KEY_RATE_AND_REVIEW_INFO"
const val KEY_INFO_INSTALL_PRO_v2 = "KEY_INFO_INSTALL_PRO_v2"
const val KEY_INFO_SIGN_IN = "KEY_INFO_SIGN_IN"
const val KEY_FORCE_SHOW_SIGN_IN = "KEY_FORCE_SHOW_SIGN_IN"
const val KEY_THEME_OPTIONS = "KEY_THEME_OPTIONS"
const val KEY_BACKUP_OPTIONS = "KEY_BACKUP_OPTIONS"

const val KEY_INFO_INSTALL_PRO_MAX_COUNT = 10

Expand Down Expand Up @@ -49,6 +54,39 @@ fun getReviewInformationItem(context: Context): InformationRecyclerItem {
})
}

fun shouldShowThemeInformationItem(): Boolean {
return probability(0.01f)
&& !CoreConfig.instance.store().get(KEY_THEME_OPTIONS, false)
}

fun getThemeInformationItem(activity: MainActivity): InformationRecyclerItem {
return InformationRecyclerItem(
R.drawable.ic_action_grid,
R.string.home_option_ui_experience,
R.string.home_option_ui_experience_subtitle,
{
CoreConfig.instance.store().put(KEY_THEME_OPTIONS, true)
UISettingsOptionsBottomSheet.openSheet(activity)
})
}

fun shouldShowBackupInformationItem(): Boolean {
return probability(0.01f)
&& !CoreConfig.instance.store().get(KEY_BACKUP_OPTIONS, false)
}

fun getBackupInformationItem(activity: MainActivity): InformationRecyclerItem {
return InformationRecyclerItem(
R.drawable.ic_export,
R.string.home_option_backup_options,
R.string.home_option_backup_options_subtitle,
{
CoreConfig.instance.store().put(KEY_BACKUP_OPTIONS, true)
BackupSettingsOptionsBottomSheet.openSheet(activity)
})
}


fun shouldShowInstallProInformationItem(): Boolean {
return probability(0.01f)
&& CoreConfig.instance.store().get(KEY_INFO_INSTALL_PRO_v2, 0) < KEY_INFO_INSTALL_PRO_MAX_COUNT
Expand Down
2 changes: 2 additions & 0 deletions base/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
<string name="import_export_layout_exporting_done">Done</string>
<string name="import_export_layout_exporting_share">Share</string>
<string name="import_export_layout_filename" translatable="false">MaterialNotes/BACKUP.txt</string>
<string name="import_export_locked" translatable="false">Export locked notes</string>
<string name="import_export_locked_details" translatable="false">Also backup the notes which are locked</string>

<string name="file_size_kb" translatable="false">%s KB</string>
<string name="file_size_mb" translatable="false">%s MB</string>
Expand Down

0 comments on commit 5cb00cc

Please sign in to comment.