diff --git a/app/build.gradle b/app/build.gradle index 29c0b376..881e11e2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,7 +57,7 @@ android { dependencies { // implementation 'com.github.SimpleMobileTools:Simple-Commons:c45f0d662a' - implementation 'com.github.qwertyfinger:Simple-Commons:d61a1c0910' + implementation 'com.github.qwertyfinger:Simple-Commons:615349768d' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' implementation 'androidx.documentfile:documentfile:1.0.1' diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 2733c451..dd42450e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -83,7 +83,8 @@ class MainActivity : SimpleActivity() { initViewPager(intent.getLongExtra(OPEN_NOTE_ID, -1L)) pager_title_strip.setTextSize(TypedValue.COMPLEX_UNIT_PX, getPercentageFontSize()) - pager_title_strip.layoutParams.height = (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2 * (config.fontSizePercentage / 100f)).toInt() + pager_title_strip.layoutParams.height = + (pager_title_strip.height + resources.getDimension(R.dimen.activity_margin) * 2 * (config.fontSizePercentage / 100f)).toInt() checkWhatsNewDialog() checkIntents(intent) @@ -1080,18 +1081,22 @@ class MainActivity : SimpleActivity() { } private fun unlockNote() { - SecurityDialog(this, mCurrentNote.protectionHash, mCurrentNote.protectionType) { hash, type, success -> - if (success) { - mCurrentNote.protectionHash = "" - mCurrentNote.protectionType = PROTECTION_NONE - NotesHelper(this).insertOrUpdateNote(mCurrentNote) { - getCurrentFragment()?.apply { - shouldShowLockedContent = true - checkLockState() - } - invalidateOptionsMenu() - } + performSecurityCheck( + protectionType = mCurrentNote.protectionType, + requiredHash = mCurrentNote.protectionHash, + successCallback = { _, _ -> removeProtection() } + ) + } + + private fun removeProtection() { + mCurrentNote.protectionHash = "" + mCurrentNote.protectionType = PROTECTION_NONE + NotesHelper(this).insertOrUpdateNote(mCurrentNote) { + getCurrentFragment()?.apply { + shouldShowLockedContent = true + checkLockState() } + invalidateOptionsMenu() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt index 80b40300..3e88f15a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/WidgetConfigureActivity.kt @@ -13,7 +13,6 @@ import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog -import com.simplemobiletools.commons.dialogs.SecurityDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS import com.simplemobiletools.commons.helpers.PROTECTION_NONE @@ -105,13 +104,12 @@ class WidgetConfigureActivity : SimpleActivity() { if (mNotes.size == 1 && note == null) { note = mNotes.first() - SecurityDialog(this, note.protectionHash, note.protectionType) { hash, type, success -> - if (success) { - updateCurrentNote(note) - } else { - finish() - } - } + performSecurityCheck( + protectionType = note.protectionType, + requiredHash = note.protectionHash, + successCallback = { _, _ -> updateCurrentNote(note) }, + failureCallback = { finish() } + ) } else { if (note != null) { updateCurrentNote(note) @@ -132,11 +130,11 @@ class WidgetConfigureActivity : SimpleActivity() { if (note.protectionType == PROTECTION_NONE) { updateCurrentNote(note) } else { - SecurityDialog(this, note.protectionHash, note.protectionType) { hash, type, success -> - if (success) { - updateCurrentNote(note) - } - } + performSecurityCheck( + protectionType = note.protectionType, + requiredHash = note.protectionHash, + successCallback = { _, _ -> updateCurrentNote(note) } + ) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/NoteFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/NoteFragment.kt index d0d4470d..a266935c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/NoteFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/NoteFragment.kt @@ -3,10 +3,10 @@ package com.simplemobiletools.notes.pro.fragments import android.util.TypedValue import android.view.ViewGroup import androidx.fragment.app.Fragment -import com.simplemobiletools.commons.dialogs.SecurityDialog import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor +import com.simplemobiletools.commons.extensions.performSecurityCheck import com.simplemobiletools.commons.helpers.PROTECTION_NONE import com.simplemobiletools.notes.pro.extensions.config import com.simplemobiletools.notes.pro.extensions.getPercentageFontSize @@ -22,10 +22,10 @@ abstract class NoteFragment : Fragment() { note_locked_layout.beVisibleIf(note.isLocked() && !shouldShowLockedContent) note_locked_image.applyColorFilter(config!!.textColor) - note_locked_label.setTextColor(context!!.config.textColor) + note_locked_label.setTextColor(requireContext().config.textColor) note_locked_label.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize()) - note_locked_show.setTextColor(context!!.getAdjustedPrimaryColor()) + note_locked_show.setTextColor(requireContext().getAdjustedPrimaryColor()) note_locked_show.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getPercentageFontSize()) note_locked_show.setOnClickListener { handleUnlocking() @@ -39,13 +39,15 @@ abstract class NoteFragment : Fragment() { return } - SecurityDialog(activity!!, note!!.protectionHash, note!!.protectionType) { hash, type, success -> - if (success) { + activity?.performSecurityCheck( + protectionType = note!!.protectionType, + requiredHash = note!!.protectionHash, + successCallback = { _, _ -> shouldShowLockedContent = true checkLockState() callback?.invoke() } - } + ) } abstract fun checkLockState()