Skip to content

Commit 2e756e3

Browse files
committed
version 1.1.14.112
☞ Option to disable floating button ☞ Remebers state of quicktools ☞ Bugs fixes ☞ UI improvement ☞ Add any directory to explorer using SAF ☞ Performance improvement ☞ Smaller APK size
1 parent a3fbaa4 commit 2e756e3

28 files changed

+280
-211
lines changed

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8' ?>
2-
<widget id="com.foxdebug.acode" android-versionCode="111" version="1.1.14.111"
2+
<widget id="com.foxdebug.acode" android-versionCode="112" version="1.1.14.112"
33
xmlns="http://www.w3.org/ns/widgets"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:cdv="http://cordova.apache.org/ns/1.0">

src/lib/applySettings.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import quickTools from "./handlers/quickTools";
2+
3+
export default {
4+
beforeRender() {
5+
//animation
6+
if (!appSettings.value.animation)
7+
app.classList.add('no-animation');
8+
9+
//apply theme
10+
if (/free/.test(BuildInfo.packageName) && appSettings.value.appTheme === "dark") {
11+
appSettings.value.appTheme = "default";
12+
appSettings.update();
13+
}
14+
15+
//full-screen
16+
if (appSettings.value.fullscreen)
17+
Acode.exec("enable-fullscreen");
18+
19+
//disable-floating-button
20+
if (appSettings.value.disableFloatingButton)
21+
root.classList.add("disable-floating-button");
22+
23+
//setup vibration
24+
app.addEventListener('touchstart', function (e) {
25+
const el = e.target;
26+
27+
if (el instanceof HTMLElement && el.hasAttribute('vibrate')) {
28+
if (appSettings.value.vibrateOnTap) navigator.vibrate(constants.VIBRATION_TIME);
29+
}
30+
});
31+
32+
//setup autosave
33+
const autoSave = parseInt(appSettings.value.autosave);
34+
if (autoSave) {
35+
saveInterval = setInterval(() => {
36+
editorManager.files.map(file => {
37+
if (
38+
!file.readOnly &&
39+
(file.fileUri || file.contentUri) &&
40+
file.isUnsaved &&
41+
!file.isSaving
42+
) Acode.exec("save", false);
43+
return file;
44+
});
45+
}, autoSave);
46+
}
47+
},
48+
afterRender() {
49+
50+
//quick-tools
51+
if (appSettings.value.quickTools)
52+
quickTools.actions("enable-quick-tools");
53+
54+
}
55+
};

src/lib/createEditorFromURI.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ function createEditorFromURI(uri, isContentUri, data = {}) {
4444
location = Url.dirname(fileUri);
4545
}
4646
}
47+
48+
if (!fileUri && !contentUri) return;
49+
const ext = helpers.extname(name);
50+
if (appSettings.defaultSettings.filesNotAllowed.includes((ext || '').toLowerCase()))
51+
return alert(strings.notice.toUpperCase(), `'${ext}' ${strings['file is not supported']}`);
52+
4753
const settings = appSettings.value;
4854
const {
4955
cursorPos,

src/lib/handlers/quickTools.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,29 @@ function actions(action) {
171171
}
172172

173173
function enableQuickTools() {
174-
let $row1 = $footer.querySelector('#row1');
175-
if ($row1) return;
176-
$row1 = tag.parse($_row1);
177-
if ($footer.firstElementChild)
178-
$footer.insertBefore($row1, $footer.firstElementChild);
174+
if (root.hasAttribute('quicktools')) return; //Quicktools is already enabled
175+
176+
const quickToolsState = (parseInt(localStorage.quickToolsState) || 1);
177+
const $row1 = tag.parse($_row1);
178+
const $row2 = tag.parse($_row2);
179+
180+
if (quickToolsState == 2)
181+
$footer.append($row1, $row2);
179182
else
180183
$footer.append($row1);
181184

182-
incFooterHeightBy(1);
185+
root.setAttribute("quicktools", "enabled");
186+
incFooterHeightBy(quickToolsState);
187+
if (editorManager.activeFile && editorManager.activeFile.isUnsaved)
188+
$row1.querySelector("[action='save']").classList.add('notice');
189+
183190
}
184191

185192
function disableQuickTools() {
193+
const height = root.getAttribute('footer-height');
186194
let $row1 = $footer.querySelector('#row1');
187195
let $row2 = $footer.querySelector('#row2');
196+
localStorage.quickToolsState = height;
188197
if ($row1) {
189198
$row1.remove();
190199
incFooterHeightBy(-1);
@@ -193,6 +202,8 @@ function actions(action) {
193202
$row2.remove();
194203
incFooterHeightBy(-1);
195204
}
205+
206+
root.removeAttribute("quicktools");
196207
}
197208

198209
function removeRow2() {

src/lib/main.js

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import loadPolyFill from "./polyfill";
3838
import internalFs from "./fileSystem/internalFs";
3939
import Url from "./utils/Url";
4040
import backupRestore from "../pages/settings/backup-restore";
41+
import applySettings from "./applySettings";
4142
//@ts-check
4243

4344
loadPolyFill.apply(window);
@@ -156,11 +157,6 @@ function Main() {
156157

157158
function ondeviceready() {
158159

159-
if (/free/.test(BuildInfo.packageName) && appSettings.value.appTheme === "dark") {
160-
appSettings.value.appTheme = "default";
161-
appSettings.update();
162-
}
163-
164160
if (!('files' in localStorage)) {
165161
localStorage.setItem('files', '[]');
166162
}
@@ -278,14 +274,6 @@ function runApp() {
278274
}
279275
});
280276

281-
app.addEventListener('touchstart', function (e) {
282-
const el = e.target;
283-
284-
if (el instanceof HTMLElement && el.hasAttribute('vibrate')) {
285-
if (appSettings.value.vibrateOnTap) navigator.vibrate(constants.VIBRATION_TIME);
286-
}
287-
});
288-
289277
const Acode = {
290278
/**
291279
*
@@ -409,11 +397,11 @@ function App() {
409397
Acode.exec("toggle-quick-tools");
410398
};
411399

412-
window.restoreTheme();
413-
$main.setAttribute("data-empty-msg", strings['no editor message']);
414-
415400
//#region rendering
401+
applySettings.beforeRender();
402+
window.restoreTheme();
416403
root.append($header, $main, $footer, $headerToggler, $quickToolToggler);
404+
applySettings.afterRender();
417405
//#endregion
418406

419407
$fileMenu.addEventListener('click', handleMenu);
@@ -423,10 +411,6 @@ function App() {
423411
document.addEventListener('keydown', handleMainKeyDown);
424412
document.addEventListener('keyup', handleMainKeyUp);
425413

426-
if (appSettings.value.fullscreen)
427-
Acode.exec("enable-fullscreen");
428-
429-
if (appSettings.value.quickTools) quickTools.actions("enable-quick-tools");
430414
window.beforeClose = saveState;
431415

432416
loadFolders();
@@ -438,7 +422,6 @@ function App() {
438422

439423
setTimeout(() => {
440424
app.classList.remove('loading', 'splash');
441-
if (!appSettings.value.animation) app.classList.add('no-animation');
442425
onAppLoad();
443426
}, 500);
444427
//#region event listeners
@@ -457,21 +440,6 @@ function App() {
457440
});
458441
document.addEventListener('resume', checkFiles);
459442
checkFiles();
460-
461-
const autoSave = parseInt(appSettings.value.autosave);
462-
if (autoSave) {
463-
saveInterval = setInterval(() => {
464-
editorManager.files.map(file => {
465-
if (
466-
!file.readOnly &&
467-
(file.fileUri || file.contentUri) &&
468-
file.isUnsaved &&
469-
!file.isSaving
470-
) Acode.exec("save", false);
471-
return file;
472-
});
473-
}, autoSave);
474-
}
475443
});
476444

477445
editorManager.onupdate = function () {

src/lib/settings.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Settings {
3636
sortByName: true
3737
},
3838
maxFileSize: 5,
39-
filesNotAllowed: ['zip', 'apk', 'doc', 'docx', 'mp3', 'mp4', 'avi', 'flac', 'mov', 'rar', 'pdf', 'gif'],
39+
filesNotAllowed: ['zip', 'apk', 'doc', 'docx', 'mp3', 'mp4', 'avi', 'flac', 'mov', 'rar', 'pdf', 'gif', 'flv'],
4040
search: {
4141
caseSensitive: false,
4242
regExp: false,
@@ -61,7 +61,8 @@ class Settings {
6161
editorFont: "default",
6262
vibrateOnTap: true,
6363
fullscreen: false,
64-
floatingButtonActivation: "click"
64+
floatingButtonActivation: "click",
65+
disableFloatingButton: false
6566
};
6667
this.settingsFile = DATA_STORAGE + 'settings.json';
6768
this.loaded = false;

src/pages/fileBrowser/fileBrowser.include.js

Lines changed: 26 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -128,38 +128,16 @@ function FileBrowserInclude(type, option) {
128128
const value = e.target.getAttribute('value');
129129
create(value);
130130
} else if (action === "add-path") {
131-
dialogs.multiPrompt(strings["add path"], [{
132-
id: "name",
133-
placeholder: "Name",
134-
type: "text",
135-
required: true
136-
}, {
137-
id: "uri",
138-
placeholder: "path",
139-
type: "text",
140-
required: true,
141-
onclick: function () {
142-
SDcard.getStorageAccessPermission("", res => {
143-
this.value = res;
144-
}, err => {
145-
helpers.error(err);
146-
});
147-
}
148-
}])
149-
.then(values => {
150-
const {
151-
name,
152-
uri
153-
} = values;
154-
155-
customUuid.push({
156-
name,
157-
uri,
158-
uuid: helpers.uuid()
159-
});
131+
util.addPath()
132+
.then(res => {
133+
customUuid.push(res);
160134
localStorage.customUuid = JSON.stringify(customUuid);
161135
navigate.pop();
162136
renderStorages();
137+
})
138+
.catch(err => {
139+
helpers.error(err);
140+
console.error(err);
163141
});
164142
}
165143
};
@@ -200,35 +178,26 @@ function FileBrowserInclude(type, option) {
200178
renderStorages();
201179

202180
function renderStorages() {
203-
// const list = [];
204-
// const version = parseInt(device.version);
205-
// if (version < 7) {
206-
// renderList(getStorageList());
207-
// } else {
208-
// let storages;
209-
210-
// externalFs.listStorages()
211-
// .then(res => {
212-
// storages = res;
213-
// if (!Array.isArray(res))
214-
// storages = [];
215-
216-
// return getPermission([...storages]);
217-
// })
218-
// .then(res => {
219-
// storages.map(storage => {
220-
// util.pushFolder(list, storage.name, res[storage.uuid]);
221-
// });
222-
223-
// list.push(...getStorageList());
224-
// renderList(list);
225-
// })
226-
// .catch(err => {
227-
// console.error(err);
228-
// });
229-
// }
230-
231181
renderList(getStorageList());
182+
183+
if (!localStorage.fileBrowserInit) {
184+
externalFs.listStorages()
185+
.then(res => {
186+
if (Array.isArray(res))
187+
util.addPath(res[0].name)
188+
.then(res => {
189+
customUuid.push(res);
190+
localStorage.customUuid = JSON.stringify(customUuid);
191+
navigate.pop();
192+
renderStorages();
193+
})
194+
.catch(err => {
195+
helpers.error(err);
196+
console.error(err);
197+
});
198+
});
199+
localStorage.fileBrowserInit = true;
200+
}
232201
}
233202

234203
function renderList(list) {
@@ -243,35 +212,6 @@ function FileBrowserInclude(type, option) {
243212
render(list);
244213
}
245214

246-
// function getPermission(uuidDataAr) {
247-
// const uuidUri = JSON.parse(localStorage.uuidUri || '{}');
248-
249-
// return new Promise((resolve, reject) => {
250-
// (function get() {
251-
// const uuidData = uuidDataAr.pop();
252-
// if (uuidData) {
253-
// const {
254-
// uuid,
255-
// name
256-
// } = uuidData;
257-
// if (uuid in uuidUri) {
258-
// get(uuidDataAr);
259-
// } else {
260-
// externalFs.getStorageAccessPermission(uuid, name)
261-
// .then(res => {
262-
// uuidUri[uuid] = res;
263-
// get(uuidDataAr, resolve);
264-
// });
265-
// }
266-
// } else {
267-
// localStorage.uuidUri = JSON.stringify(uuidUri);
268-
// resolve(uuidUri);
269-
// }
270-
// })();
271-
// });
272-
273-
// }
274-
275215
function resolve(data) {
276216
localStorage.setItem("lastDir", currentDir.url);
277217
_resolve(data);

0 commit comments

Comments
 (0)