mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Android: Fixes #53: Back button should exit app if nothing to go back to
This commit is contained in:
parent
c72e0a14c0
commit
818537933a
@ -1,5 +1,5 @@
|
|||||||
const React = require('react'); const Component = React.Component;
|
const React = require('react'); const Component = React.Component;
|
||||||
const { Keyboard, NativeModules } = require('react-native');
|
const { Keyboard, NativeModules, BackHandler } = require('react-native');
|
||||||
const { connect, Provider } = require('react-redux');
|
const { connect, Provider } = require('react-redux');
|
||||||
const { BackButtonService } = require('lib/services/back-button.js');
|
const { BackButtonService } = require('lib/services/back-button.js');
|
||||||
const AlarmService = require('lib/services/AlarmService.js');
|
const AlarmService = require('lib/services/AlarmService.js');
|
||||||
@ -255,7 +255,7 @@ const appReducer = (state = appDefaultState, action) => {
|
|||||||
|
|
||||||
let store = createStore(appReducer, applyMiddleware(generalMiddleware));
|
let store = createStore(appReducer, applyMiddleware(generalMiddleware));
|
||||||
|
|
||||||
async function initialize(dispatch, backButtonHandler) {
|
async function initialize(dispatch) {
|
||||||
shimInit();
|
shimInit();
|
||||||
|
|
||||||
Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
|
Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
|
||||||
@ -372,8 +372,6 @@ async function initialize(dispatch, backButtonHandler) {
|
|||||||
reg.logger().error('Initialization error:', error);
|
reg.logger().error('Initialization error:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackButtonService.initialize(backButtonHandler);
|
|
||||||
|
|
||||||
reg.setupRecurrentSync();
|
reg.setupRecurrentSync();
|
||||||
|
|
||||||
PoorManIntervals.setTimeout(() => {
|
PoorManIntervals.setTimeout(() => {
|
||||||
@ -394,6 +392,10 @@ class AppComponent extends React.Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.lastSyncStarted_ = defaultState.syncStarted;
|
this.lastSyncStarted_ = defaultState.syncStarted;
|
||||||
|
|
||||||
|
this.backButtonHandler_ = () => {
|
||||||
|
return this.backButtonHandler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
@ -403,7 +405,7 @@ class AppComponent extends React.Component {
|
|||||||
state: 'initializing',
|
state: 'initializing',
|
||||||
});
|
});
|
||||||
|
|
||||||
await initialize(this.props.dispatch, this.backButtonHandler.bind(this));
|
await initialize(this.props.dispatch);
|
||||||
|
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
type: 'APP_STATE_SET',
|
type: 'APP_STATE_SET',
|
||||||
@ -411,6 +413,8 @@ class AppComponent extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BackButtonService.initialize(this.backButtonHandler_);
|
||||||
|
|
||||||
AlarmService.setInAppNotificationHandler(async (alarmId) => {
|
AlarmService.setInAppNotificationHandler(async (alarmId) => {
|
||||||
const alarm = await Alarm.load(alarmId);
|
const alarm = await Alarm.load(alarmId);
|
||||||
const notification = await Alarm.makeNotification(alarm);
|
const notification = await Alarm.makeNotification(alarm);
|
||||||
@ -434,6 +438,8 @@ class AppComponent extends React.Component {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BackHandler.exitApp();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user