Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add application manager for client #524

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/absolute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

import PushManager from './push/push_manager';
import Notification from './notification/notification_manager';
import AppManager from './application/application_manager';
import IndexedDB from './indexeddb/indexeddb';

export default class absolute {
static push: PushManager = new PushManager();
static notification: Notification = new Notification();
static appManager: AppManager = new AppManager();
static indexeddb: IndexedDB = new IndexedDB();
}
22 changes: 22 additions & 0 deletions client/application/application_manager.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2017 The Absolute Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {} from 'jest';
import absolute from '../absolute';

test('absolute.appManager.isCromeBrowser()', async() => {
expect(await absolute.appManager.isCromeBrowser()).toBe(false);
});
27 changes: 27 additions & 0 deletions client/application/application_manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2017 The Absolute Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export default class ApplicationManager {

async isCromeBrowser(): Promise<boolean> {
var agent = navigator.userAgent.toLowerCase();
if(agent.indexOf('chrome') != -1){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not perfect. For example, Samsung Internet, Opera, Whale browser will also include the chrome keyword in UA string.
Also, Android system WebView also includes chrome keyword in UA string.
You will have to investigate more things.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elliekwon, if you are in trouble with this, take a look at the previous commit. link

return true;
} else {
return false;
}
}
}
1 change: 1 addition & 0 deletions client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import absolute from './absolute';
async function main() {
console.log(await absolute.push.register('key'));
console.log(await absolute.push.unregister());
console.log(await absolute.appManager.isCromeBrowser());
}

main();