From f426f93093a4ee5bc0622e3e9ebd2da5e9a4b201 Mon Sep 17 00:00:00 2001 From: ragsav Date: Sat, 8 Oct 2022 16:57:43 +0530 Subject: [PATCH] todo:backup does not save to downloads --- android/app/build.gradle | 117 +----------------- android/app/src/main/AndroidManifest.xml | 8 ++ .../app/src/main/java/com/alarm/Manager.java | 18 ++- .../app/src/main/res/drawable/ic_snooze.xml | 11 ++ constants.js | 2 +- js/db/sync.js | 4 + js/utils/logger.js | 4 +- package-lock.json | 85 ++++++++++++- package.json | 2 + 9 files changed, 124 insertions(+), 127 deletions(-) create mode 100644 android/app/src/main/res/drawable/ic_snooze.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index 17cb744..70bf6ac 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -3,131 +3,21 @@ project.ext.vectoricons = [ iconFontNames: ['MaterialIcons.ttf','MaterialCommunityIcons.ttf'] ] - apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" import com.android.build.OutputFile -/** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation. If none specified and - * // "index.android.js" exists, it will be used. Otherwise "index.js" is - * // default. Can be overridden with ENTRY_FILE environment variable. - * entryFile: "index.android.js", - * - * // https://reactnative.dev/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] - */ - project.ext.react = [ - enableHermes: false, // clean and rebuild if changing + enableHermes: false, ] apply from: "../../node_modules/react-native/react.gradle" -/** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. - */ -def enableSeparateBuildPerCPUArchitecture = false -/** - * Run Proguard to shrink the Java bytecode in release builds. - */ +def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = true - -/** - * The preferred build flavor of JavaScriptCore. - * - * For example, to use the international variant, you can use: - * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` - * - * The international variant includes ICU i18n library and necessary data - * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that - * give correct results when using with locales other than en-US. Note that - * this variant is about 6MiB larger per architecture than default. - */ def jscFlavor = 'org.webkit:android-jsc:+' - -/** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and that value will be read here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. - */ def enableHermes = project.ext.react.get("enableHermes", false); -/** - * Architectures to build native code for. - */ def reactNativeArchitectures() { def value = project.getProperties().get("reactNativeArchitectures") return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] @@ -254,9 +144,6 @@ android { // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ec0d712..be5b658 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,7 +9,12 @@ + + + @@ -21,6 +26,9 @@ android:allowBackup="false" android:requestLegacyExternalStorage="true" android:theme="@style/BootTheme"> + + + + + diff --git a/constants.js b/constants.js index c156757..5dbb0c6 100644 --- a/constants.js +++ b/constants.js @@ -3,7 +3,7 @@ export const CONSTANTS = Object.freeze({ 'Tasker-Notifications-dc5ee189-65a6-48a7-9ae6-b0ec9d067825', DAILY_REMINDER_ID: 1023, - NOTIFICATION_CLEAR_DELAY_BUFFER: 15 * 60 * 1000, + NOTIFICATION_CLEAR_DELAY_BUFFER: 1 * 60 * 1000, TABLE_NAMES: { LABELS: 'labels', diff --git a/js/db/sync.js b/js/db/sync.js index c050f12..7924cb8 100644 --- a/js/db/sync.js +++ b/js/db/sync.js @@ -9,6 +9,9 @@ import Label from './models/Label'; import Note from './models/Note'; import Task from './models/Task'; import {CONSTANTS} from '../../constants'; +import RNFetchBlob from 'rn-fetch-blob'; +import {Share} from 'react-native'; +import {decode as atob, encode as btoa} from 'base-64'; export class WTDBBackup { /** * @@ -50,6 +53,7 @@ export class WTDBBackup { Logger.pageLogger('WTDBBackup:fetchAllLocalRecords:recordsData', { recordsData, }); + const path = RNFS.DownloadDirectoryPath + '/backup.json'; await RNFS.writeFile(path, JSON.stringify(recordsData), 'utf8'); setIsLoading?.(false); diff --git a/js/utils/logger.js b/js/utils/logger.js index d5b3fb6..34b4efd 100644 --- a/js/utils/logger.js +++ b/js/utils/logger.js @@ -10,9 +10,9 @@ export class Logger { } const _s = String(page); if (_s.includes('error') || _s.includes('catch')) { - log.warn(_s, obj); + obj ? log.warn(_s, obj) : log.warn(_s); } else { - log.info(_s, obj); + obj ? log.info(_s, obj) : log.info(_s); } }; } diff --git a/package-lock.json b/package-lock.json index 490e5aa..b7cc4d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@react-navigation/native": "^6.0.11", "@react-navigation/native-stack": "^6.7.0", "@react-navigation/stack": "^6.2.3", + "base-64": "^1.0.0", "calendarize": "^1.1.1", "extract-urls": "^1.3.2", "link-preview-js": "^3.0.4", @@ -54,6 +55,7 @@ "react-redux": "^8.0.2", "redux": "^4.2.0", "redux-thunk": "^2.4.1", + "rn-fetch-blob": "^0.12.0", "uuid": "^9.0.0" }, "devDependencies": { @@ -5903,9 +5905,9 @@ } }, "node_modules/base-64": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", - "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz", + "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==" }, "node_modules/base/node_modules/define-property": { "version": "1.0.0", @@ -13965,6 +13967,11 @@ } } }, + "node_modules/react-native-fs/node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, "node_modules/react-native-gesture-handler": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.6.0.tgz", @@ -14748,6 +14755,36 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rn-fetch-blob": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/rn-fetch-blob/-/rn-fetch-blob-0.12.0.tgz", + "integrity": "sha512-+QnR7AsJ14zqpVVUbzbtAjq0iI8c9tCg49tIoKO2ezjzRunN7YL6zFSFSWZm6d+mE/l9r+OeDM3jmb2tBb2WbA==", + "dependencies": { + "base-64": "0.1.0", + "glob": "7.0.6" + } + }, + "node_modules/rn-fetch-blob/node_modules/base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, + "node_modules/rn-fetch-blob/node_modules/glob": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", + "integrity": "sha512-f8c0rE8JiCxpa52kWPAOa3ZaYEnzofDzCQLCn3Vdk0Z5OVLq3BsRFJI4S4ykpeVW6QMGBUkMeUpoEgWnMTnw5Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + } + }, "node_modules/rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", @@ -21363,9 +21400,9 @@ } }, "base-64": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", - "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz", + "integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg==" }, "base64-js": { "version": "1.5.1", @@ -27501,6 +27538,13 @@ "requires": { "base-64": "^0.1.0", "utf8": "^3.0.0" + }, + "dependencies": { + "base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + } } }, "react-native-gesture-handler": { @@ -28064,6 +28108,35 @@ "glob": "^7.1.3" } }, + "rn-fetch-blob": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/rn-fetch-blob/-/rn-fetch-blob-0.12.0.tgz", + "integrity": "sha512-+QnR7AsJ14zqpVVUbzbtAjq0iI8c9tCg49tIoKO2ezjzRunN7YL6zFSFSWZm6d+mE/l9r+OeDM3jmb2tBb2WbA==", + "requires": { + "base-64": "0.1.0", + "glob": "7.0.6" + }, + "dependencies": { + "base-64": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz", + "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==" + }, + "glob": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.6.tgz", + "integrity": "sha512-f8c0rE8JiCxpa52kWPAOa3ZaYEnzofDzCQLCn3Vdk0Z5OVLq3BsRFJI4S4ykpeVW6QMGBUkMeUpoEgWnMTnw5Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/package.json b/package.json index a5c66a2..64d03d9 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@react-navigation/native": "^6.0.11", "@react-navigation/native-stack": "^6.7.0", "@react-navigation/stack": "^6.2.3", + "base-64": "^1.0.0", "calendarize": "^1.1.1", "extract-urls": "^1.3.2", "link-preview-js": "^3.0.4", @@ -56,6 +57,7 @@ "react-redux": "^8.0.2", "redux": "^4.2.0", "redux-thunk": "^2.4.1", + "rn-fetch-blob": "^0.12.0", "uuid": "^9.0.0" }, "devDependencies": {