From bd28e3e4a16ae9c7e3dff3e88d79a387099b649c Mon Sep 17 00:00:00 2001 From: Andrii Chubko Date: Tue, 24 Aug 2021 15:34:32 +0300 Subject: [PATCH 1/3] Use updated commons library --- app/build.gradle | 3 +- app/src/main/AndroidManifest.xml | 116 +++++++++++++++---------------- 2 files changed, 58 insertions(+), 61 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c9a55db0..29c0b376 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,7 +56,8 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:c45f0d662a' +// implementation 'com.github.SimpleMobileTools:Simple-Commons:c45f0d662a' + implementation 'com.github.qwertyfinger:Simple-Commons:d61a1c0910' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' implementation 'androidx.documentfile:documentfile:1.0.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 36bd7705..5242cbe4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,5 @@ - @@ -9,11 +7,9 @@ android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" /> - - + android:required="false" /> + android:theme="@style/SplashTheme" /> - - - + + + - - - + + + @@ -51,49 +47,49 @@ android:screenOrientation="portrait" android:theme="@style/MyWidgetConfigTheme"> - + + android:parentActivityName=".activities.MainActivity" /> + android:parentActivityName=".activities.SettingsActivity" /> + android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity" /> + android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity" /> + android:parentActivityName=".activities.MainActivity" /> + android:permission="android.permission.BIND_REMOTEVIEWS" /> - + + android:resource="@xml/widget_info" /> - - + + @@ -117,8 +113,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -130,8 +126,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -143,8 +139,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -156,8 +152,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -169,8 +165,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -182,8 +178,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -195,8 +191,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -208,8 +204,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -221,8 +217,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -234,8 +230,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -247,8 +243,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -260,8 +256,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -273,8 +269,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -285,8 +281,8 @@ android:roundIcon="@mipmap/ic_launcher" android:targetActivity=".activities.SplashActivity"> - - + + @@ -298,8 +294,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -311,8 +307,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -324,8 +320,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + @@ -337,8 +333,8 @@ android:targetActivity=".activities.SplashActivity"> - - + + From fadf9bed7e221d75da466bc1865b8a64e89e2fc9 Mon Sep 17 00:00:00 2001 From: Andrii Chubko Date: Tue, 24 Aug 2021 19:24:55 +0300 Subject: [PATCH 2/3] Use updated security API --- app/build.gradle | 2 +- .../notes/pro/activities/MainActivity.kt | 29 +++++++++++-------- .../pro/activities/WidgetConfigureActivity.kt | 24 +++++++-------- .../notes/pro/fragments/NoteFragment.kt | 14 +++++---- 4 files changed, 37 insertions(+), 32 deletions(-) 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() From c72b7bd9bd899e0b5d89cf58fd4a67ec1d554940 Mon Sep 17 00:00:00 2001 From: Andrii Chubko Date: Tue, 24 Aug 2021 20:05:28 +0300 Subject: [PATCH 3/3] Set correct commons dependency --- app/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 881e11e2..4d9e613c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -56,8 +56,7 @@ android { } dependencies { -// implementation 'com.github.SimpleMobileTools:Simple-Commons:c45f0d662a' - implementation 'com.github.qwertyfinger:Simple-Commons:615349768d' + implementation 'com.github.SimpleMobileTools:Simple-Commons:79c625cbe0' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' implementation 'androidx.documentfile:documentfile:1.0.1'