MOBILE-2428 splash: Don't hide splash until init is done
parent
6979f18343
commit
c80700443d
|
@ -33,7 +33,7 @@
|
||||||
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
|
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
|
||||||
<preference name="iosPersistentFileLocation" value="Compatibility" />
|
<preference name="iosPersistentFileLocation" value="Compatibility" />
|
||||||
<preference name="SplashScreen" value="screen" />
|
<preference name="SplashScreen" value="screen" />
|
||||||
<preference name="SplashScreenDelay" value="10000" />
|
<preference name="SplashScreenDelay" value="15000" />
|
||||||
<preference name="SplashMaintainAspectRatio" value="true" />
|
<preference name="SplashMaintainAspectRatio" value="true" />
|
||||||
<feature name="StatusBar">
|
<feature name="StatusBar">
|
||||||
<param name="ios-package" onload="true" value="CDVStatusBar" />
|
<param name="ios-package" onload="true" value="CDVStatusBar" />
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<core-show-password item-content [name]="'password'">
|
<core-show-password item-content [name]="'password'">
|
||||||
<ion-label>{{ 'addon.mod_lesson.enterpassword' | translate }}</ion-label>
|
<ion-label>{{ 'addon.mod_lesson.enterpassword' | translate }}</ion-label>
|
||||||
<ion-input name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" core-auto-focus #passwordinput></ion-input>
|
<ion-input name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" [core-auto-focus] #passwordinput></ion-input>
|
||||||
</core-show-password>
|
</core-show-password>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<core-show-password item-content [name]="'password'">
|
<core-show-password item-content [name]="'password'">
|
||||||
<ion-label>{{ 'addon.mod_lesson.enterpassword' | translate }}</ion-label>
|
<ion-label>{{ 'addon.mod_lesson.enterpassword' | translate }}</ion-label>
|
||||||
<ion-input name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" core-auto-focus #passwordinput></ion-input>
|
<ion-input name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" [core-auto-focus] #passwordinput></ion-input>
|
||||||
</core-show-password>
|
</core-show-password>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { StatusBar } from '@ionic-native/status-bar';
|
import { StatusBar } from '@ionic-native/status-bar';
|
||||||
import { SplashScreen } from '@ionic-native/splash-screen';
|
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreEventsProvider } from '@providers/events';
|
import { CoreEventsProvider } from '@providers/events';
|
||||||
import { CoreLangProvider } from '@providers/lang';
|
import { CoreLangProvider } from '@providers/lang';
|
||||||
|
@ -33,7 +32,7 @@ export class MoodleMobileApp implements OnInit {
|
||||||
protected logger;
|
protected logger;
|
||||||
protected lastUrls = {};
|
protected lastUrls = {};
|
||||||
|
|
||||||
constructor(private platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, logger: CoreLoggerProvider,
|
constructor(private platform: Platform, statusBar: StatusBar, logger: CoreLoggerProvider,
|
||||||
private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider,
|
private eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider,
|
||||||
private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider) {
|
private appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider) {
|
||||||
this.logger = logger.getInstance('AppComponent');
|
this.logger = logger.getInstance('AppComponent');
|
||||||
|
@ -46,8 +45,6 @@ export class MoodleMobileApp implements OnInit {
|
||||||
} else {
|
} else {
|
||||||
statusBar.styleDefault();
|
statusBar.styleDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
splashScreen.hide();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</div>
|
</div>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-input type="text" name="value" placeholder="{{ 'core.login.usernameoremail' | translate }}" formControlName="value" autocapitalize="none" autocorrect="off" core-auto-focus></ion-input>
|
<ion-input type="text" name="value" placeholder="{{ 'core.login.usernameoremail' | translate }}" formControlName="value" autocapitalize="none" autocorrect="off" [core-auto-focus]></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<button text-wrap ion-button block [disabled]="!myForm.valid">{{ 'core.courses.search' | translate }}</button>
|
<button text-wrap ion-button block [disabled]="!myForm.valid">{{ 'core.courses.search' | translate }}</button>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { IonicPage, NavController } from 'ionic-angular';
|
import { IonicPage, NavController } from 'ionic-angular';
|
||||||
|
import { SplashScreen } from '@ionic-native/splash-screen';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreInitDelegate } from '@providers/init';
|
import { CoreInitDelegate } from '@providers/init';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
|
@ -31,7 +32,8 @@ import { CoreLoginHelperProvider } from '../../providers/helper';
|
||||||
export class CoreLoginInitPage {
|
export class CoreLoginInitPage {
|
||||||
|
|
||||||
constructor(private navCtrl: NavController, private appProvider: CoreAppProvider, private initDelegate: CoreInitDelegate,
|
constructor(private navCtrl: NavController, private appProvider: CoreAppProvider, private initDelegate: CoreInitDelegate,
|
||||||
private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider) { }
|
private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider,
|
||||||
|
private splashScreen: SplashScreen) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View loaded.
|
* View loaded.
|
||||||
|
@ -51,11 +53,11 @@ export class CoreLoginInitPage {
|
||||||
// The redirect is pointing to a site, load it.
|
// The redirect is pointing to a site, load it.
|
||||||
return this.sitesProvider.loadSite(redirectData.siteId).then(() => {
|
return this.sitesProvider.loadSite(redirectData.siteId).then(() => {
|
||||||
if (!this.loginHelper.isSiteLoggedOut(redirectData.page, redirectData.params)) {
|
if (!this.loginHelper.isSiteLoggedOut(redirectData.page, redirectData.params)) {
|
||||||
this.navCtrl.setRoot(redirectData.page, redirectData.params, { animate: false });
|
return this.navCtrl.setRoot(redirectData.page, redirectData.params, { animate: false });
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// Site doesn't exist.
|
// Site doesn't exist.
|
||||||
this.loadPage();
|
return this.loadPage();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// No site to load, just open the state.
|
// No site to load, just open the state.
|
||||||
|
@ -64,24 +66,37 @@ export class CoreLoginInitPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadPage();
|
return this.loadPage();
|
||||||
|
}).then(() => {
|
||||||
|
// If we hide the splash screen now, the init view is still seen for an instant. Wait a bit to make sure it isn't seen.
|
||||||
|
setTimeout(() => {
|
||||||
|
this.splashScreen.hide();
|
||||||
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the right page.
|
* Load the right page.
|
||||||
|
*
|
||||||
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected loadPage(): void {
|
protected loadPage(): Promise<any> {
|
||||||
if (this.sitesProvider.isLoggedIn()) {
|
if (this.sitesProvider.isLoggedIn()) {
|
||||||
if (!this.loginHelper.isSiteLoggedOut()) {
|
if (!this.loginHelper.isSiteLoggedOut()) {
|
||||||
this.loginHelper.goToSiteInitialPage();
|
// User is logged in, go to site initial page.
|
||||||
|
return this.loginHelper.goToSiteInitialPage();
|
||||||
|
} else {
|
||||||
|
// The site is marked as logged out. Logout and try again.
|
||||||
|
return this.sitesProvider.logout().then(() => {
|
||||||
|
return this.loadPage();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.sitesProvider.hasSites().then((hasSites) => {
|
return this.sitesProvider.hasSites().then((hasSites) => {
|
||||||
if (hasSites) {
|
if (hasSites) {
|
||||||
this.navCtrl.setRoot('CoreLoginSitesPage');
|
return this.navCtrl.setRoot('CoreLoginSitesPage');
|
||||||
} else {
|
} else {
|
||||||
this.loginHelper.goToAddSite(true);
|
return this.loginHelper.goToAddSite(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<form [formGroup]="credForm" (ngSubmit)="login()">
|
<form [formGroup]="credForm" (ngSubmit)="login()">
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<core-show-password item-content [name]="'password'">
|
<core-show-password item-content [name]="'password'">
|
||||||
<ion-input class="core-ioninput-password" name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" formControlName="password" core-auto-focus></ion-input>
|
<ion-input class="core-ioninput-password" name="password" type="password" placeholder="{{ 'core.login.password' | translate }}" formControlName="password" [core-auto-focus]></ion-input>
|
||||||
</core-show-password>
|
</core-show-password>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-grid>
|
<ion-grid>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<div *ngIf="!fixedSites">
|
<div *ngIf="!fixedSites">
|
||||||
<p padding>{{ 'core.login.newsitedescription' | translate }}</p>
|
<p padding>{{ 'core.login.newsitedescription' | translate }}</p>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-input type="url" name="url" placeholder="{{ 'core.login.siteaddress' | translate }}" formControlName="siteUrl" [core-auto-focus]></ion-input>
|
<ion-input type="url" name="url" placeholder="{{ 'core.login.siteaddress' | translate }}" formControlName="siteUrl" [core-auto-focus]="showKeyboard"></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { IonicPage, NavController, ModalController } from 'ionic-angular';
|
import { IonicPage, NavController, ModalController, NavParams } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
|
@ -33,10 +33,14 @@ export class CoreLoginSitePage {
|
||||||
siteForm: FormGroup;
|
siteForm: FormGroup;
|
||||||
fixedSites: any[];
|
fixedSites: any[];
|
||||||
displayAsButtons = false;
|
displayAsButtons = false;
|
||||||
|
showKeyboard = false;
|
||||||
|
|
||||||
constructor(private navCtrl: NavController, fb: FormBuilder, private appProvider: CoreAppProvider,
|
constructor(navParams: NavParams, private navCtrl: NavController, fb: FormBuilder, private appProvider: CoreAppProvider,
|
||||||
private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider,
|
private sitesProvider: CoreSitesProvider, private loginHelper: CoreLoginHelperProvider,
|
||||||
private modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider) {
|
private modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider) {
|
||||||
|
|
||||||
|
this.showKeyboard = !!navParams.get('showKeyboard');
|
||||||
|
|
||||||
let url = '';
|
let url = '';
|
||||||
|
|
||||||
// Load fixed sites if they're set.
|
// Load fixed sites if they're set.
|
||||||
|
|
|
@ -67,7 +67,7 @@ export class CoreLoginSitesPage {
|
||||||
* Go to the page to add a site.
|
* Go to the page to add a site.
|
||||||
*/
|
*/
|
||||||
add(): void {
|
add(): void {
|
||||||
this.loginHelper.goToAddSite(false);
|
this.loginHelper.goToAddSite(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +91,7 @@ export class CoreLoginSitesPage {
|
||||||
// If there are no sites left, go to add site.
|
// If there are no sites left, go to add site.
|
||||||
this.sitesProvider.hasSites().then((hasSites) => {
|
this.sitesProvider.hasSites().then((hasSites) => {
|
||||||
if (!hasSites) {
|
if (!hasSites) {
|
||||||
this.loginHelper.goToAddSite(true);
|
this.loginHelper.goToAddSite(true, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
|
|
@ -380,9 +380,10 @@ export class CoreLoginHelperProvider {
|
||||||
* If a fixed URL is configured, go to credentials instead.
|
* If a fixed URL is configured, go to credentials instead.
|
||||||
*
|
*
|
||||||
* @param {boolean} [setRoot] True to set the new page as root, false to add it to the stack.
|
* @param {boolean} [setRoot] True to set the new page as root, false to add it to the stack.
|
||||||
|
* @param {boolean} [showKeyboard] Whether to show keyboard in the new page. Only if no fixed URL set.
|
||||||
* @return {Promise<any>} Promise resolved when done.
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
goToAddSite(setRoot?: boolean): Promise<any> {
|
goToAddSite(setRoot?: boolean, showKeyboard?: boolean): Promise<any> {
|
||||||
let pageName,
|
let pageName,
|
||||||
params;
|
params;
|
||||||
|
|
||||||
|
@ -395,6 +396,9 @@ export class CoreLoginHelperProvider {
|
||||||
params = { siteUrl: url };
|
params = { siteUrl: url };
|
||||||
} else {
|
} else {
|
||||||
pageName = 'CoreLoginSitePage';
|
pageName = 'CoreLoginSitePage';
|
||||||
|
params = {
|
||||||
|
showKeyboard: showKeyboard
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setRoot) {
|
if (setRoot) {
|
||||||
|
|
Loading…
Reference in New Issue