Fixed: Icons disabled for mobile devices and browsers without support for extension icons

This commit is contained in:
nobody 2020-09-27 11:46:32 +02:00
parent cf27bde0c8
commit c75e98b9a7
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
3 changed files with 29 additions and 25 deletions

View File

@ -56,10 +56,8 @@ wrappers.setBadgeTextColor = function (details) {
wrappers.setIcon = function (details, type) { wrappers.setIcon = function (details, type) {
if (chrome.browserAction.setIcon) { if (chrome.browserAction.setIcon) {
details.path = IconType[details.path][type]; details.path = IconType[details.path][type];
} else { chrome.browserAction.setIcon(details);
details.path = IconType['Default'][type];
} }
chrome.browserAction.setIcon(details);
}; };
storageManager.type.get([Setting.BADGE_COLOR, Setting.BADGE_TEXT_COLOR], function (items) { storageManager.type.get([Setting.BADGE_COLOR, Setting.BADGE_TEXT_COLOR], function (items) {

View File

@ -47,6 +47,7 @@ options._renderContents = function () {
if (!chrome.browserAction.setIcon) { if (!chrome.browserAction.setIcon) {
document.getElementById('icon-style-div').style.display = 'none'; document.getElementById('icon-style-div').style.display = 'none';
options._platformSupportIcons = false;
} }
options._renderInfoPanel(); options._renderInfoPanel();
document.getElementById('label-version').textContent = helpers.formatVersion(chrome.runtime.getManifest().version); document.getElementById('label-version').textContent = helpers.formatVersion(chrome.runtime.getManifest().version);
@ -108,28 +109,29 @@ options._renderOptionsPanel = function () {
document.getElementById('storage-type-sync').checked = true; document.getElementById('storage-type-sync').checked = true;
} }
if (options._optionValues.selectedIcon === 'Default') { if (options._platformSupportIcons) {
document.getElementById('icon-default').checked = true; if (options._optionValues.selectedIcon === 'Default') {
} else if (options._optionValues.selectedIcon === 'Grey') { document.getElementById('icon-default').checked = true;
document.getElementById('icon-grey').checked = true; } else if (options._optionValues.selectedIcon === 'Grey') {
} else if (options._optionValues.selectedIcon === 'Light') { document.getElementById('icon-grey').checked = true;
document.getElementById('icon-light').checked = true; } else if (options._optionValues.selectedIcon === 'Light') {
document.getElementById('icon-light').checked = true;
}
url = chrome.runtime.getURL('icons/action/' + options._optionValues.selectedIcon.toLowerCase() + '/icon38-default.png');
document.getElementById('icon-badge-preview').src = url;
bgColor = options._optionValues.badgeColor || '#4A826C';
txtColor = options._optionValues.badgeTextColor || '#FFFFFF';
document.getElementById('counter-preview-badge').style.backgroundColor = bgColor;
document.getElementById('pre-badged-background-color').style.backgroundColor = bgColor;
document.getElementById('badged-background-color').value = bgColor;
document.getElementById('counter-preview-badge').style.color = txtColor;
document.getElementById('pre-badged-text-color').style.backgroundColor = txtColor;
document.getElementById('badged-text-color').value = txtColor;
} }
url = chrome.runtime.getURL('icons/action/' + options._optionValues.selectedIcon.toLowerCase() + '/icon38-default.png');
document.getElementById('icon-badge-preview').src = url;
bgColor = options._optionValues.badgeColor || '#4A826C';
txtColor = options._optionValues.badgeTextColor || '#FFFFFF';
document.getElementById('counter-preview-badge').style.backgroundColor = bgColor;
document.getElementById('pre-badged-background-color').style.backgroundColor = bgColor;
document.getElementById('badged-background-color').value = bgColor;
document.getElementById('counter-preview-badge').style.color = txtColor;
document.getElementById('pre-badged-text-color').style.backgroundColor = txtColor;
document.getElementById('badged-text-color').value = txtColor;
document.getElementById('last-mapping-update').textContent += ' ' + lastMappingUpdate; document.getElementById('last-mapping-update').textContent += ' ' + lastMappingUpdate;
document.getElementById('negate-html-filter-list-warning').addEventListener('click', function () { options._onLinkClick(Links.CODEBERG_HTML_FILTER); }); document.getElementById('negate-html-filter-list-warning').addEventListener('click', function () { options._onLinkClick(Links.CODEBERG_HTML_FILTER); });
document.getElementById('link-welcome-page').addEventListener('click', function () { options._onLinkClick(Links.WELCOME); }); document.getElementById('link-welcome-page').addEventListener('click', function () { options._onLinkClick(Links.WELCOME); });
@ -151,8 +153,10 @@ options._renderOptionsPanel = function () {
document.getElementById('import-data').addEventListener('click', storageManager.startImportFilePicker); document.getElementById('import-data').addEventListener('click', storageManager.startImportFilePicker);
document.getElementById('import-file-picker').addEventListener('change', storageManager.handleImportFilePicker); document.getElementById('import-file-picker').addEventListener('change', storageManager.handleImportFilePicker);
document.getElementById('badged-background-color').addEventListener('keyup', options._onChangedHexColor); if (options._platformSupportIcons) {
document.getElementById('badged-text-color').addEventListener('keyup', options._onChangedHexColor); document.getElementById('badged-background-color').addEventListener('keyup', options._onChangedHexColor);
document.getElementById('badged-text-color').addEventListener('keyup', options._onChangedHexColor);
}
document.getElementById('restore-background-color').addEventListener('click', options._setDefaultColor); document.getElementById('restore-background-color').addEventListener('click', options._setDefaultColor);
document.getElementById('restore-text-color').addEventListener('click', options._setDefaultColor); document.getElementById('restore-text-color').addEventListener('click', options._setDefaultColor);
@ -554,6 +558,7 @@ options._internalStatistics = false;
options._storageType = 'local'; options._storageType = 'local';
options._listOfFrameworks = {}; options._listOfFrameworks = {};
options._listOfCDNs = {}; options._listOfCDNs = {};
options._platformSupportIcons = true;
document.addEventListener('DOMContentLoaded', options._onDocumentLoaded); document.addEventListener('DOMContentLoaded', options._onDocumentLoaded);

View File

@ -26,6 +26,7 @@
</div> </div>
<ul> <ul>
<li>Updated: Internal module "Color Picker" v2.1.2 -> v2.1.3</li> <li>Updated: Internal module "Color Picker" v2.1.2 -> v2.1.3</li>
<li>Fixed: Icons disabled for mobile devices and browsers without support for extension icons</li>
</ul> </ul>
<div id="generator-section"> <div id="generator-section">
<div class="topic-label"> <div class="topic-label">