Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Fixes issue where closing iOS app with immediate fingerprint would mo…
Browse files Browse the repository at this point in the history
…mentarily show fingerprint auth alert, 3.0.8
  • Loading branch information
moughxyz committed May 22, 2019
1 parent 0bda45b commit 347f93a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 30 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion

versionCode 3000070
versionName "3.0.7"
versionCode 3000080
versionName "3.0.8"

multiDexEnabled true

Expand Down
6 changes: 5 additions & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
rootProject.name = 'StandardNotes'

include ':@react-native-community_async-storage'
project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')

include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

include ':react-native-file-viewer'
project(':react-native-file-viewer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-viewer/android')

include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')

include ':app'

include ':react-native-gesture-handler'
Expand Down Expand Up @@ -35,4 +40,3 @@ project(':react-native-fingerprint-scanner').projectDir = new File(rootProject.p

include ':react-native-flag-secure-android'
project(':react-native-flag-secure-android').projectDir = new File(rootProject.projectDir, '../vendor/react-native-flag-secure-android/android')

2 changes: 1 addition & 1 deletion ios/StandardNotes/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.7</string>
<string>3.0.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "StandardNotes",
"version": "3.0.7",
"versionIOS": "3.0.7",
"versionAndroid": "3.0.7",
"version": "3.0.8",
"versionIOS": "3.0.8",
"versionAndroid": "3.0.8",
"license": "AGPL-3.0-or-later",
"private": true,
"scripts": {
Expand Down
29 changes: 12 additions & 17 deletions src/lib/ApplicationState.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default class ApplicationState {
this.observers = [];
this.eventSubscribers = [];
this.locked = true;
this.previousEvents = [];
this._isAndroid = Platform.OS === "android";

this.setTabletModeEnabled(this.isTabletDevice);
Expand Down Expand Up @@ -163,8 +162,6 @@ export default class ApplicationState {
var isLosingFocus = nextAppState == 'inactive';

if(isEnteringBackground) {
// Set most recent state before notifying observers, in case they need to query this value.
this.mostRecentState = ApplicationState.Backgrounding;
this.notifyOfState(ApplicationState.Backgrounding);

if(this.shouldLockApplication()) {
Expand All @@ -174,17 +171,14 @@ export default class ApplicationState {

if(isResumingFromBackground || isResuming) {
if(isResumingFromBackground) {
this.mostRecentState = ApplicationState.ResumingFromBackground;
this.notifyOfState(ApplicationState.ResumingFromBackground);
}

// Notify of GainingFocus even if resuming from background
this.mostRecentState = ApplicationState.GainingFocus;
this.notifyOfState(ApplicationState.GainingFocus);
}

if(isLosingFocus) {
this.mostRecentState = ApplicationState.LosingFocus;
this.notifyOfState(ApplicationState.LosingFocus);

// If a privileges authentication session is in progress, we don't want to lock the application
Expand All @@ -201,9 +195,9 @@ export default class ApplicationState {
If we are backgrounding or losing focus, I assume we no longer care about previous events that occurred.
(This was added in relation to the issue where pressing the Android back button would reconstruct App and cause all events to be re-forwarded)
*/
if(isEnteringBackground || isLosingFocus) {
this.clearPreviousState();
}
// if(isEnteringBackground || isLosingFocus) {
// this.clearPreviousState();
// }
}

// Visibility change events are like active, inactive, background,
Expand Down Expand Up @@ -237,16 +231,17 @@ export default class ApplicationState {

didLaunch() {
this.notifyOfState(ApplicationState.Launching);
this.mostRecentState = ApplicationState.Launching;
}

notifyOfState(state) {
if(this.ignoreStateChanges) {return;}

// Set most recent state before notifying observers, in case they need to query this value.
this.mostRecentState = state;

for(var observer of this.observers) {
observer.callback(state);
}

this.previousEvents.push(state);
}

/* End State */
Expand All @@ -272,16 +267,16 @@ export default class ApplicationState {
var observer = {key: Math.random, callback: callback};
this.observers.push(observer);

for(var prevState of this.previousEvents) {
callback(prevState);
if(this.mostRecentState) {
callback(this.mostRecentState);
}

return observer;
}

clearPreviousState() {
this.previousEvents = [];
}
// clearPreviousState() {
// this.previousEvents = [];
// }

removeStateObserver(observer) {
_.pull(this.observers, observer);
Expand Down
31 changes: 25 additions & 6 deletions src/screens/Authentication/Authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export default class Authenticate extends Abstract {

componentWillFocus() {
super.componentWillFocus();
this.begin();

if(ApplicationState.get().getMostRecentState() !== ApplicationState.LosingFocus) {
this.begin();
}
}

cancel() {
Expand Down Expand Up @@ -194,21 +197,37 @@ export default class Authenticate extends Abstract {
}

onSuccess() {
// Wait for componentWillBlur to call onSuccess callback.
// Wait for componentWillBlur/componentDidlBlur to call onSuccess callback.
// This way, if the callback has another route change, the dismissal
// of this one won't affect it.
this.successful = true;
this.needsSuccessCallback = true;
this.dismiss();
}

componentWillBlur() {
super.componentWillBlur();
if(this.successful) {
this.getProp("onSuccess")(this._sessionLength);
this.successful = false;
if(this.needsSuccessCallback) {
this.triggerSuccessCallback();
}
}

/*
On Android, when pressing physical back then re-opening app and authenticating and closing modal,
componentWillBlur is not called for some reason. componentDidBlur is called however, albiet ~2 seconds later.
Note however that this only seems to happen on the emulator, and not on physical device.
*/
componentDidBlur() {
super.componentDidBlur();
if(this.needsSuccessCallback) {
this.triggerSuccessCallback();
}
}

triggerSuccessCallback() {
this.getProp("onSuccess")(this._sessionLength);
this.needsSuccessCallback = false;
}

inputTextChanged(text, source) {
source.setAuthenticationValue(text);
this.forceUpdate();
Expand Down

0 comments on commit 347f93a

Please sign in to comment.