MOBILE-2428 splash: Don't hide splash until init is done

main
Dani Palou 2018-06-15 10:47:44 +02:00
parent 6979f18343
commit c80700443d
11 changed files with 44 additions and 24 deletions

View File

@ -33,7 +33,7 @@
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="iosPersistentFileLocation" value="Compatibility" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="10000" />
<preference name="SplashScreenDelay" value="15000" />
<preference name="SplashMaintainAspectRatio" value="true" />
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />

View File

@ -37,7 +37,7 @@
<ion-item>
<core-show-password item-content [name]="'password'">
<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>
</ion-item>
<ion-item>

View File

@ -13,7 +13,7 @@
<ion-item>
<core-show-password item-content [name]="'password'">
<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>
</ion-item>
<ion-item>

View File

@ -15,7 +15,6 @@
import { Component, OnInit } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { CoreAppProvider } from '@providers/app';
import { CoreEventsProvider } from '@providers/events';
import { CoreLangProvider } from '@providers/lang';
@ -33,7 +32,7 @@ export class MoodleMobileApp implements OnInit {
protected logger;
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 appProvider: CoreAppProvider, private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider) {
this.logger = logger.getInstance('AppComponent');
@ -46,8 +45,6 @@ export class MoodleMobileApp implements OnInit {
} else {
statusBar.styleDefault();
}
splashScreen.hide();
});
}

View File

@ -25,7 +25,7 @@
</ion-item>
</div>
<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>
<button text-wrap ion-button block [disabled]="!myForm.valid">{{ 'core.courses.search' | translate }}</button>

View File

@ -14,6 +14,7 @@
import { Component } from '@angular/core';
import { IonicPage, NavController } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { CoreAppProvider } from '@providers/app';
import { CoreInitDelegate } from '@providers/init';
import { CoreSitesProvider } from '@providers/sites';
@ -31,7 +32,8 @@ import { CoreLoginHelperProvider } from '../../providers/helper';
export class CoreLoginInitPage {
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.
@ -51,11 +53,11 @@ export class CoreLoginInitPage {
// The redirect is pointing to a site, load it.
return this.sitesProvider.loadSite(redirectData.siteId).then(() => {
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(() => {
// Site doesn't exist.
this.loadPage();
return this.loadPage();
});
} else {
// 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.
*
* @return {Promise<any>} Promise resolved when done.
*/
protected loadPage(): void {
protected loadPage(): Promise<any> {
if (this.sitesProvider.isLoggedIn()) {
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 {
this.sitesProvider.hasSites().then((hasSites) => {
return this.sitesProvider.hasSites().then((hasSites) => {
if (hasSites) {
this.navCtrl.setRoot('CoreLoginSitesPage');
return this.navCtrl.setRoot('CoreLoginSitesPage');
} else {
this.loginHelper.goToAddSite(true);
return this.loginHelper.goToAddSite(true);
}
});
}

View File

@ -33,7 +33,7 @@
<form [formGroup]="credForm" (ngSubmit)="login()">
<ion-item>
<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>
</ion-item>
<ion-grid>

View File

@ -19,7 +19,7 @@
<div *ngIf="!fixedSites">
<p padding>{{ 'core.login.newsitedescription' | translate }}</p>
<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>
</div>

View File

@ -13,7 +13,7 @@
// limitations under the License.
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 { CoreSitesProvider } from '@providers/sites';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
@ -33,10 +33,14 @@ export class CoreLoginSitePage {
siteForm: FormGroup;
fixedSites: any[];
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 modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider) {
this.showKeyboard = !!navParams.get('showKeyboard');
let url = '';
// Load fixed sites if they're set.

View File

@ -67,7 +67,7 @@ export class CoreLoginSitesPage {
* Go to the page to add a site.
*/
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.
this.sitesProvider.hasSites().then((hasSites) => {
if (!hasSites) {
this.loginHelper.goToAddSite(true);
this.loginHelper.goToAddSite(true, true);
}
});
}).catch((error) => {

View File

@ -380,9 +380,10 @@ export class CoreLoginHelperProvider {
* 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} [showKeyboard] Whether to show keyboard in the new page. Only if no fixed URL set.
* @return {Promise<any>} Promise resolved when done.
*/
goToAddSite(setRoot?: boolean): Promise<any> {
goToAddSite(setRoot?: boolean, showKeyboard?: boolean): Promise<any> {
let pageName,
params;
@ -395,6 +396,9 @@ export class CoreLoginHelperProvider {
params = { siteUrl: url };
} else {
pageName = 'CoreLoginSitePage';
params = {
showKeyboard: showKeyboard
};
}
if (setRoot) {