Skip to content
Merged
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
10 changes: 3 additions & 7 deletions app/src/main/kotlin/org/fossify/notes/App.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.fossify.notes

import android.app.Application
import org.fossify.commons.extensions.checkUseEnglish
import org.fossify.commons.FossifyApp

class App : Application() {
override fun onCreate() {
super.onCreate()
checkUseEnglish()
}
class App : FossifyApp() {
override val isAppLockFeatureAvailable = true
}
474 changes: 360 additions & 114 deletions app/src/main/kotlin/org/fossify/notes/activities/MainActivity.kt

Large diffs are not rendered by default.

161 changes: 130 additions & 31 deletions app/src/main/kotlin/org/fossify/notes/activities/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,58 @@ import org.fossify.commons.dialogs.ConfirmationDialog
import org.fossify.commons.dialogs.PermissionRequiredDialog
import org.fossify.commons.dialogs.RadioGroupDialog
import org.fossify.commons.dialogs.SecurityDialog
import org.fossify.commons.extensions.*
import org.fossify.commons.helpers.*
import org.fossify.commons.extensions.beGone
import org.fossify.commons.extensions.beVisible
import org.fossify.commons.extensions.beVisibleIf
import org.fossify.commons.extensions.getProperPrimaryColor
import org.fossify.commons.extensions.openRequestExactAlarmSettings
import org.fossify.commons.extensions.showErrorToast
import org.fossify.commons.extensions.toast
import org.fossify.commons.extensions.updateTextColors
import org.fossify.commons.extensions.viewBinding
import org.fossify.commons.helpers.IS_CUSTOMIZING_COLORS
import org.fossify.commons.helpers.NavigationIcon
import org.fossify.commons.helpers.PROTECTION_FINGERPRINT
import org.fossify.commons.helpers.SHOW_ALL_TABS
import org.fossify.commons.helpers.ensureBackgroundThread
import org.fossify.commons.helpers.isOreoPlus
import org.fossify.commons.helpers.isQPlus
import org.fossify.commons.helpers.isRPlus
import org.fossify.commons.helpers.isSPlus
import org.fossify.commons.helpers.isTiramisuPlus
import org.fossify.commons.models.RadioItem
import org.fossify.notes.BuildConfig
import org.fossify.notes.R
import org.fossify.notes.databinding.ActivitySettingsBinding
import org.fossify.notes.dialogs.ExportNotesDialog
import org.fossify.notes.dialogs.ManageAutoBackupsDialog
import org.fossify.notes.extensions.*
import org.fossify.notes.helpers.*
import org.fossify.notes.extensions.cancelScheduledAutomaticBackup
import org.fossify.notes.extensions.config
import org.fossify.notes.extensions.requestUnlockNotes
import org.fossify.notes.extensions.scheduleNextAutomaticBackup
import org.fossify.notes.extensions.updateWidgets
import org.fossify.notes.extensions.widgetsDB
import org.fossify.notes.helpers.CUSTOMIZED_WIDGET_BG_COLOR
import org.fossify.notes.helpers.CUSTOMIZED_WIDGET_ID
import org.fossify.notes.helpers.CUSTOMIZED_WIDGET_KEY_ID
import org.fossify.notes.helpers.CUSTOMIZED_WIDGET_NOTE_ID
import org.fossify.notes.helpers.CUSTOMIZED_WIDGET_SHOW_TITLE
import org.fossify.notes.helpers.CUSTOMIZED_WIDGET_TEXT_COLOR
import org.fossify.notes.helpers.FONT_SIZE_100_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_125_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_150_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_175_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_200_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_250_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_300_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_50_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_60_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_75_PERCENT
import org.fossify.notes.helpers.FONT_SIZE_90_PERCENT
import org.fossify.notes.helpers.GRAVITY_CENTER
import org.fossify.notes.helpers.GRAVITY_END
import org.fossify.notes.helpers.GRAVITY_START
import org.fossify.notes.helpers.NotesHelper
import org.fossify.notes.models.Note
import org.fossify.notes.models.Widget
import java.util.Locale
Expand All @@ -47,7 +89,12 @@ class SettingsActivity : SimpleActivity() {
super.onCreate(savedInstanceState)
setContentView(binding.root)

updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
updateMaterialActivityViews(
mainCoordinatorLayout = binding.settingsCoordinator,
nestedView = binding.settingsHolder,
useTransparentNavigation = true,
useTopSearchMenu = false
)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
}

Expand Down Expand Up @@ -105,18 +152,19 @@ class SettingsActivity : SimpleActivity() {
}
}

private val saveDocument = registerForActivityResult(ActivityResultContracts.CreateDocument(notesFileType)) { uri ->
if (uri != null) {
toast(org.fossify.commons.R.string.exporting)
NotesHelper(this).getNotes { notes ->
requestUnlockNotes(notes) { unlockedNotes ->
val notLockedNotes = notes.filterNot { it.isLocked() }
val notesToExport = unlockedNotes + notLockedNotes
exportNotes(notesToExport, uri)
private val saveDocument =
registerForActivityResult(ActivityResultContracts.CreateDocument(notesFileType)) { uri ->
if (uri != null) {
toast(org.fossify.commons.R.string.exporting)
NotesHelper(this).getNotes { notes ->
requestUnlockNotes(notes) { unlockedNotes ->
val notLockedNotes = notes.filterNot { it.isLocked() }
val notesToExport = unlockedNotes + notLockedNotes
exportNotes(notesToExport, uri)
}
}
}
}
}

private fun setupCustomizeColors() {
binding.settingsColorCustomizationHolder.setOnClickListener {
Expand All @@ -136,9 +184,13 @@ class SettingsActivity : SimpleActivity() {

private fun setupLanguage() {
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
binding.settingsLanguageHolder.setOnClickListener {
launchChangeAppLanguageIntent()
if (isTiramisuPlus()) {
binding.settingsLanguageHolder.beVisible()
binding.settingsLanguageHolder.setOnClickListener {
launchChangeAppLanguageIntent()
}
} else {
binding.settingsLanguageHolder.beGone()
}
}

Expand Down Expand Up @@ -241,7 +293,9 @@ class SettingsActivity : SimpleActivity() {
private fun setupGravity() {
binding.settingsGravity.text = getGravityText()
binding.settingsGravityHolder.setOnClickListener {
val items = listOf(GRAVITY_START, GRAVITY_CENTER, GRAVITY_END).map { RadioItem(it, getGravityOptionLabel(it)) }
val items = listOf(GRAVITY_START, GRAVITY_CENTER, GRAVITY_END).map {
RadioItem(it, getGravityOptionLabel(it))
}
RadioGroupDialog(this@SettingsActivity, ArrayList(items), config.gravity) {
config.gravity = it as Int
binding.settingsGravity.text = getGravityText()
Expand All @@ -251,13 +305,15 @@ class SettingsActivity : SimpleActivity() {
}

private fun getGravityOptionLabel(gravity: Int): String {
val leftToRightDirection = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR
val leftToRightDirection = TextUtilsCompat
.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR
val leftRightLabels = listOf(R.string.left, R.string.right)
val startEndLabels = if (leftToRightDirection) {
leftRightLabels
} else {
leftRightLabels.reversed()
}

return getString(
when (gravity) {
GRAVITY_START -> startEndLabels.first()
Expand Down Expand Up @@ -436,8 +492,17 @@ class SettingsActivity : SimpleActivity() {
private fun setupAppPasswordProtection() {
binding.settingsAppPasswordProtection.isChecked = config.isAppPasswordProtectionOn
binding.settingsAppPasswordProtectionHolder.setOnClickListener {
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
val tabToShow = if (config.isAppPasswordProtectionOn) {
config.appProtectionType
} else {
SHOW_ALL_TABS
}

SecurityDialog(
activity = this,
requiredHash = config.appPasswordHash,
showTabIndex = tabToShow
) { hash, type, success ->
if (success) {
val hasPasswordProtection = config.isAppPasswordProtectionOn
binding.settingsAppPasswordProtection.isChecked = !hasPasswordProtection
Expand All @@ -446,31 +511,65 @@ class SettingsActivity : SimpleActivity() {
config.appProtectionType = type

if (config.isAppPasswordProtectionOn) {
val confirmationTextId = if (config.appProtectionType == PROTECTION_FINGERPRINT)
org.fossify.commons.R.string.fingerprint_setup_successfully else org.fossify.commons.R.string.protection_setup_successfully
ConfirmationDialog(this, "", confirmationTextId, org.fossify.commons.R.string.ok, 0) { }
val confirmationTextId =
if (config.appProtectionType == PROTECTION_FINGERPRINT) {
org.fossify.commons.R.string.fingerprint_setup_successfully
} else {
org.fossify.commons.R.string.protection_setup_successfully
}

ConfirmationDialog(
activity = this,
message = "",
messageId = confirmationTextId,
positive = org.fossify.commons.R.string.ok,
negative = 0
) { }
}
}
}
}
}

private fun setupNoteDeletionPasswordProtection() {
binding.settingsNoteDeletionPasswordProtection.isChecked = config.isDeletePasswordProtectionOn
binding.settingsNoteDeletionPasswordProtection.isChecked =
config.isDeletePasswordProtectionOn

binding.settingsNoteDeletionPasswordProtectionHolder.setOnClickListener {
val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS
SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success ->
val tabToShow = if (config.isDeletePasswordProtectionOn) {
config.deleteProtectionType
} else {
SHOW_ALL_TABS
}

SecurityDialog(
activity = this,
requiredHash = config.deletePasswordHash,
showTabIndex = tabToShow
) { hash, type, success ->
if (success) {
val hasPasswordProtection = config.isDeletePasswordProtectionOn
binding.settingsNoteDeletionPasswordProtection.isChecked = !hasPasswordProtection
binding.settingsNoteDeletionPasswordProtection.isChecked =
!hasPasswordProtection
config.isDeletePasswordProtectionOn = !hasPasswordProtection
config.deletePasswordHash = if (hasPasswordProtection) "" else hash
config.deleteProtectionType = type

if (config.isDeletePasswordProtectionOn) {
val confirmationTextId = if (config.deleteProtectionType == PROTECTION_FINGERPRINT)
org.fossify.commons.R.string.fingerprint_setup_successfully else org.fossify.commons.R.string.protection_setup_successfully
ConfirmationDialog(this, "", confirmationTextId, org.fossify.commons.R.string.ok, 0) { }
val confirmationTextId =
if (config.deleteProtectionType == PROTECTION_FINGERPRINT) {
org.fossify.commons.R.string.fingerprint_setup_successfully
} else {
org.fossify.commons.R.string.protection_setup_successfully
}

ConfirmationDialog(
activity = this,
message = "",
messageId = confirmationTextId,
positive = org.fossify.commons.R.string.ok,
negative = 0
) { }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ open class SimpleActivity : BaseSimpleActivity() {
)

override fun getAppLauncherName() = getString(R.string.app_launcher_name)

override fun getRepositoryName() = "Notes"
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ class WidgetConfigureActivity : SimpleActivity() {
} else {
mBgColor = extras?.getInt(CUSTOMIZED_WIDGET_BG_COLOR) ?: config.widgetBgColor
mTextColor = extras?.getInt(CUSTOMIZED_WIDGET_TEXT_COLOR) ?: config.widgetTextColor
mShowTitle = extras?.getBoolean(CUSTOMIZED_WIDGET_SHOW_TITLE) ?: false
mShowTitle = extras?.getBoolean(CUSTOMIZED_WIDGET_SHOW_TITLE) == true
}

if (mTextColor == resources.getColor(org.fossify.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) {
if (mTextColor == resources.getColor(org.fossify.commons.R.color.default_widget_text_color) && isDynamicTheme()) {
mTextColor = resources.getColor(org.fossify.commons.R.color.you_primary_color, theme)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class OpenNoteAdapter(
Color.BLACK
}

val cardBackground = if (context.config.isUsingSystemTheme) {
val cardBackground = if (context.isDynamicTheme()) {
org.fossify.commons.R.drawable.dialog_you_background
} else {
org.fossify.commons.R.drawable.dialog_bg
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[versions]
#jetbrains
kotlin = "1.9.24"
kotlin = "1.9.25"
#KSP
kotlinxSerializationJson = "1.6.3"
ksp = "1.9.24-1.0.20"
ksp = "1.9.25-1.0.20"
#Detekt
detekt = "1.23.3"
#AndroidX
androidx-constraintlayout = "2.1.4"
androidx-constraintlayout = "2.2.1"
androidx-documentfile = "1.0.1"
#Room
room = "2.6.1"
#Fossify
commons = "54f71d56a6"
commons = "29e9b0d13e"
#Gradle
gradlePlugins-agp = "8.5.0"
gradlePlugins-agp = "8.9.0"
#build
app-build-compileSDKVersion = "34"
app-build-targetSDK = "34"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Tue Nov 03 19:54:48 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
Loading
Loading