From b45f36937349eeed5427a4d5a9f48cc18b133745 Mon Sep 17 00:00:00 2001 From: john4650-hub Date: Fri, 29 Sep 2023 00:28:12 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85ctrl+S=20to=20save=20changes=20?= =?UTF-8?q?=E2=9C=85Now=20app=20can=20run=20in=20background=20=E2=9C=85Pre?= =?UTF-8?q?vent=20abrupt=20closure=20of=20app=20when=20using=20other=20app?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 6 +++-- sample.txt | 5 ++-- www/js/components/main_FileEntry.js | 36 +++++++++++++++++++++++------ www/js/components/tabs/changeLog.js | 3 +++ 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad97c24..7142e3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,9 @@ jobs: - run: sudo npm install -g cordova@11.0.0 - run: sudo cordova platform add android - run: ls - - run: sudo cordova plugin add cordova-plugin-file + - run: | + sudo cordova plugin add cordova-plugin-file + sudo cordova plugin add cordova-plugin-background-mode-fixed - uses: actions/setup-java@v3 with: @@ -66,7 +68,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.TK }} with: tag_name: ${{ github.run_number }} - release_name: ${{ github.event.repository.name }} v5.0.4 #release + release_name: ${{ github.event.repository.name }} v5.0.5 #release - name: upload Release Apk id: upload_release_assets diff --git a/sample.txt b/sample.txt index f93b5a9..c932a00 100644 --- a/sample.txt +++ b/sample.txt @@ -1,2 +1,3 @@ -✅Now able to close recently opened files -✅fixed error of files not being read +✅ctrl+S to save changes +✅Now app can run in background +✅Prevent abrupt closure of app when using other apps diff --git a/www/js/components/main_FileEntry.js b/www/js/components/main_FileEntry.js index fa42c3e..c00b643 100644 --- a/www/js/components/main_FileEntry.js +++ b/www/js/components/main_FileEntry.js @@ -6,6 +6,17 @@ import { FILES_NOT_ALLOWED, FILE_EXTENSIONS } from "./configs.js"; export async function onDeviceReady() { + cordova.plugins.backgroundMode.enable(); + cordova.plugins.backgroundMode.overrideBackButton(); + cordova.plugins.backgroundMode.setDefaults({ + title: 'Ace code', + text: 'Editor running', + icon: 'icon', // this will look for icon.png in platforms/android/res/drawable|mipmap + color: 'ffffff', // hex format like 'F14F4D' + resume: true, + hidden: true, + bigText: true + }) /*@@param {Promise} reads-directory-recursively Read the local storage and fill the sidebar with files in it **/ function listDir(url = '', result = []) { @@ -102,6 +113,17 @@ export async function onDeviceReady() { fE = fileEntry readFile(fE); //SAVE FILE when saveFs btn is clicked + aceEditor.commands.addCommand({ + name: 'save_file', + bindKey: { + win: 'Ctrl-S', + mac: 'Command-M' + }, + exec: function(editor) { + saveFile(); + }, + readOnly: true // false if this command should not apply in readOnly mode + }); SAVEFS.addEventListener('click', saveFile); @@ -117,21 +139,21 @@ export async function onDeviceReady() { insertAttr(['class=fs-6 fw-light fst-italic mb-0'], fPath) fPath.innerText = url let row = makeElm('div') - insertAttr(['class=row border-bottom border-white',`id=${url}`],row) + insertAttr(['class=row border-bottom border-white', `id=${url}`], row) insertAttr(['class=col-10 list-group-item bg-transparent border-0 h-25'], openedFile) let closeBtn = makeElm('button') closeBtn.innerHTML = '' - - insertAttr(['class=btn btn-dark col-2 fs-2 h-25 align-middle','type=button',`id=${url}row`], closeBtn) + + insertAttr(['class=btn btn-dark col-2 fs-2 h-25 align-middle', 'type=button', `id=${url}row`], closeBtn) closeBtn.addEventListener('click', function() { let rid = this.getAttribute('id') let ridlen = rid.length - let i_d = rid.slice(0,ridlen-3) - let recentElmId= recents.indexOf(i_d) + let i_d = rid.slice(0, ridlen - 3) + let recentElmId = recents.indexOf(i_d) let myRow = document.getElementById(i_d) myRow.remove() this.remove() - recents.splice(recentElmId,1) + recents.splice(recentElmId, 1) }) openedFile.innerText = name openedFile.addEventListener('click', function() { @@ -150,7 +172,7 @@ export async function onDeviceReady() { } if (foundMatch == false) { recentFilesTab.appendChild(row) - + row.appendChild(openedFile) row.appendChild(closeBtn) openedFile.appendChild(fPath) diff --git a/www/js/components/tabs/changeLog.js b/www/js/components/tabs/changeLog.js index 3b6496e..b941a8b 100644 --- a/www/js/components/tabs/changeLog.js +++ b/www/js/components/tabs/changeLog.js @@ -14,6 +14,9 @@ let log = [{ `},{version:'v5.0.3',info: `✅Bug fix `},{version:'v5.0.4',info: `✅Now able to close recently opened files ✅fixed error of files not being read +`},{version:'v5.0.5',info: `✅ctrl+S to save changes +✅Now app can run in background +✅Prevent abrupt closure of app when using other apps `} ]