Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 911696 - [Dialer] [Flatfish] hide dialer app in homescreen if no …
Browse files Browse the repository at this point in the history
…telephony support
  • Loading branch information
gasolin committed Sep 25, 2013
1 parent b0e4a13 commit 54c0b89
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 32 deletions.
36 changes: 34 additions & 2 deletions apps/homescreen/js/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ var GridManager = (function() {
// previously already
var svPreviouslyInstalledApps = [];

// XXX bug 911696 filter out launch_path
var launchPathBlacklist = [];

var container;

var windowWidth = window.innerWidth;
Expand Down Expand Up @@ -1014,7 +1017,25 @@ var GridManager = (function() {
if (!entryPoints[entryPoint].icons)
continue;

createOrUpdateIconForApp(app, entryPoint);
// do the normal procedure
if (launchPathBlacklist.length === 0) {
createOrUpdateIconForApp(app, entryPoint);
continue;
}

var found = false;
// filtering with blacklist
for (var i = 0, elemNum = launchPathBlacklist.length;
i < elemNum; i++) {
if (entryPoints[entryPoint].launch_path === launchPathBlacklist[i]) {
found = true;
break;
}
}

if (!found) {
createOrUpdateIconForApp(app, entryPoint);
}
}
}

Expand Down Expand Up @@ -1312,7 +1333,18 @@ var GridManager = (function() {
}
}

doInit(options, callback);
// XXX bug 911696 get entrypoints blacklist from settings
// then doInit
if ('mozSettings' in navigator) {
var key = 'app.launch_path.blacklist';
var req = navigator.mozSettings.createLock().get(key);
req.onsuccess = function onsuccess() {
launchPathBlacklist = req.result[key] || [];
doInit(options, callback);
};
} else {
doInit(options, callback);
}
},

onDragStart: function gm_onDragSart() {
Expand Down
7 changes: 6 additions & 1 deletion apps/homescreen/test/unit/everything.me_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

require('/shared/js/lazy_loader.js');
require('/shared/test/unit/mocks/mock_navigator_moz_settings.js');

requireApp('homescreen/test/unit/mock_everything.me.html.js');
requireApp('homescreen/test/unit/mock_asyncStorage.js');
Expand All @@ -13,11 +14,14 @@ if (!this.asyncStorage) {

suite('everything.me.js >', function() {
var wrapperNode,
realAsyncStorage;
realAsyncStorage,
realMozSettings;

suiteSetup(function() {
realAsyncStorage = window.asyncStorage;
window.asyncStorage = MockasyncStorage;
realMozSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;

wrapperNode = document.createElement('section');
wrapperNode.innerHTML = MockEverythingMeHtml;
Expand All @@ -28,6 +32,7 @@ suite('everything.me.js >', function() {

suiteTeardown(function() {
window.asyncStorage = realAsyncStorage;
navigator.mozSettings = realMozSettings;

document.body.removeChild(wrapperNode);
});
Expand Down
6 changes: 6 additions & 0 deletions apps/homescreen/test/unit/grid_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

mocha.globals(['mozRequestAnimationFrame']);

require('/shared/test/unit/mocks/mock_navigator_moz_settings.js');

requireApp('homescreen/test/unit/mock_page.js');
requireApp('homescreen/test/unit/mock_icon.js');
requireApp('homescreen/test/unit/mock_dock_manager.js');
Expand Down Expand Up @@ -41,6 +43,7 @@ suite('grid.js >', function() {

var wrapperNode, containerNode;
var realMozApps;
var realMozSettings;

var mocksHelper = mocksHelperForGrid;

Expand All @@ -50,11 +53,14 @@ suite('grid.js >', function() {
window.navigator.mozApps = {
mgmt: MockAppsMgmt
};
realMozSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;

});

suiteTeardown(function() {
window.navigator.mozApps = realMozApps;
navigator.mozSettings = realMozSettings;

mocksHelper.suiteTeardown();
});
Expand Down
21 changes: 0 additions & 21 deletions apps/homescreen/test/unit/mock_moz_settings.js

This file was deleted.

17 changes: 10 additions & 7 deletions apps/homescreen/test/unit/wallpaper_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

requireApp('homescreen/test/unit/mock_moz_settings.js');
require('/shared/test/unit/mocks/mock_navigator_moz_settings.js');

requireApp('homescreen/test/unit/mock_moz_activity.js');

requireApp('homescreen/js/wallpaper.js');
Expand All @@ -19,9 +20,12 @@ mocksHelperForWallpaper.init();
suite('wallpaper.js >', function() {

var mocksHelper = mocksHelperForWallpaper, icongrid;
var realMozSettings;

suiteSetup(function() {
mocksHelper.suiteSetup();
realMozSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;

icongrid = document.createElement('div');
icongrid.id = 'icongrid';
Expand All @@ -33,7 +37,7 @@ suite('wallpaper.js >', function() {
suiteTeardown(function() {
document.body.removeChild(icongrid);

navigator.mozSettings.suiteTeardown();
navigator.mozSettings = realMozSettings;

mocksHelper.suiteTeardown();
delete window.ForwardLock;
Expand All @@ -45,8 +49,8 @@ suite('wallpaper.js >', function() {
});

teardown(function() {
window.MockNavigatorSettings.mSettings['wallpaper.image'] = null;
mocksHelper.teardown();
navigator.mozSettings.teardown();
});

function dispatchLongPress() {
Expand Down Expand Up @@ -98,8 +102,7 @@ suite('wallpaper.js >', function() {
startMozActivity('onsuccess', fakeblob);

// We set the wallpaper.image property to "banana"
assert.equal(Object.keys(navigator.mozSettings.result).length, 1);
assert.deepEqual(navigator.mozSettings.result['wallpaper.image'],
assert.deepEqual(window.MockNavigatorSettings.mSettings['wallpaper.image'],
fakeblob);
});

Expand All @@ -108,14 +111,14 @@ suite('wallpaper.js >', function() {
startMozActivity('onsuccess');

// No blob then wallpaper.image property is not defined
assert.isNull(navigator.mozSettings.result);
assert.isNull(window.MockNavigatorSettings.mSettings['wallpaper.image']);
});

test('Pick activity has been cancelled ', function() {
// User cancels
startMozActivity('onerror');

// Then wallpaper.image property is not defined
assert.isNull(navigator.mozSettings.result);
assert.isNull(window.MockNavigatorSettings.mSettings['wallpaper.image']);
});
});
1 change: 1 addition & 0 deletions build/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function execute() {
'accessibility.invert': false,
'accessibility.screenreader': false,
'alarm.enabled': false,
'app.launch_path.blacklist': [],
'app.reportCrashes': 'ask',
'app.update.interval': 86400,
'audio.volume.alarm': 15,
Expand Down
2 changes: 1 addition & 1 deletion distribution_tablet/settings.json

Large diffs are not rendered by default.

0 comments on commit 54c0b89

Please sign in to comment.