Skip to content

Commit c84d50c

Browse files
authored
Merge pull request #369 from smartdevicelink/feature/alert-manager
[SDL 0282] Screen Manager Alert Manager
2 parents 0899941 + b1be2a7 commit c84d50c

26 files changed

+2511
-132
lines changed

lib/js/src/manager/SdlManager.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class SdlManager extends _SdlManagerBase {
206206
// Instantiate sub managers
207207
this._permissionManager = new PermissionManager(this._lifecycleManager);
208208
this._fileManager = new FileManager(this._lifecycleManager);
209-
this._screenManager = new ScreenManager(this._lifecycleManager, this._fileManager);
209+
this._screenManager = new ScreenManager(this._lifecycleManager, this._fileManager, this._permissionManager);
210210

211211
// Start sub managers
212212
return Promise.all([
@@ -351,6 +351,10 @@ class SdlManager extends _SdlManagerBase {
351351
);
352352
}
353353

354+
this._lifecycleManager.getPermissionManager = () => {
355+
return this._permissionManager;
356+
};
357+
354358
/* FIXME: setSdlSecurity and related methods/classes do not exist
355359
if (this._sdlSecList.length > 0) {
356360
this._lifecycleManager.setSdlSecurity(this._sdlSecList, this._serviceEncryptionListener);

lib/js/src/manager/_ManagerUtility.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,41 @@ class _ManagerUtility {
116116
return highestFound;
117117
}
118118

119+
/**
120+
* Method to get number of alert textFields allowed to be set according to WindowCapability
121+
*
122+
* @param {WindowCapability} windowCapability - WindowCapability representing the capabilities of the desired window
123+
* @returns {Number} - linesFound Number of alert textFields found in WindowCapability
124+
*/
125+
static getMaxNumberOfAlertFieldLines (windowCapability) {
126+
let highestFound = 0;
127+
if (windowCapability !== null && windowCapability.getTextFields() !== null) {
128+
for (const field of windowCapability.getTextFields()) {
129+
let fieldNumber = 0;
130+
if (field !== null && field.getNameParam() !== null) {
131+
switch (field.getNameParam()) {
132+
case TextFieldName.alertText1:
133+
fieldNumber = 1;
134+
break;
135+
case TextFieldName.alertText2:
136+
fieldNumber = 2;
137+
break;
138+
case TextFieldName.alertText3:
139+
fieldNumber = 3;
140+
break;
141+
}
142+
}
143+
if (fieldNumber > 0) {
144+
highestFound = Math.max(highestFound, fieldNumber);
145+
if (highestFound === 3) {
146+
break;
147+
}
148+
}
149+
}
150+
}
151+
return highestFound;
152+
}
153+
119154
/**
120155
* Method to get a list of all available text fields
121156
* @private

lib/js/src/manager/screen/ScreenManager.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ class ScreenManager extends _ScreenManagerBase {
3838
* @class
3939
* @param {_LifecycleManager} lifecycleManager - An instance of _LifecycleManager.
4040
* @param {FileManager} fileManager - An instance of FileManager.
41+
* @param {PermissionManager} permissionManager - An instance of PermissionManager.
4142
*/
42-
constructor (lifecycleManager, fileManager) {
43-
super(lifecycleManager, fileManager);
43+
constructor (lifecycleManager, fileManager, permissionManager) {
44+
super(lifecycleManager, fileManager, permissionManager);
4445
}
4546
}
4647

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2020, Livio, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of the Livio Inc. nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
import { _AlertManagerBase } from './_AlertManagerBase.js';
34+
35+
class _AlertManager extends _AlertManagerBase {
36+
/**
37+
* Initializes an instance of _AlertManager.
38+
* @class
39+
* @param {_LifecycleManager} lifecycleManager - An instance of _LifecycleManager.
40+
* @param {FileManager} fileManager - An instance of FileManager.
41+
*/
42+
constructor (lifecycleManager, fileManager) {
43+
super(lifecycleManager, fileManager);
44+
}
45+
}
46+
47+
export { _AlertManager };

0 commit comments

Comments
 (0)