Skip to content

Commit

Permalink
todo:backup does not save to downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
ragsav committed Oct 8, 2022
1 parent 7b0d3ae commit f426f93
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 127 deletions.
117 changes: 2 additions & 115 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"
/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />



Expand All @@ -21,6 +26,9 @@
android:allowBackup="false"
android:requestLegacyExternalStorage="true"
android:theme="@style/BootTheme">



<receiver
android:name="com.alarm.receivers.AlarmReceiver"
android:enabled="true"
Expand Down
18 changes: 15 additions & 3 deletions android/app/src/main/java/com/alarm/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,28 @@ static void start(Context context, String alarmUid) {
Log.d(TAG, "Starting " + activeAlarmUid);
}

// static void stop(Context context) {
// Log.d(TAG, "Stopping " + activeAlarmUid);
// if (sound != null) {
// sound.stop();
// }

// Alarm alarm = Storage.getAlarm(context, activeAlarmUid);
// if(alarm==null) return;
// AlarmDate date = Storage.getDate(context, activeAlarmUid);
// // Manager.remove(context,activeAlarmUid);
// activeAlarmUid = null;
// }
static void stop(Context context) {
Log.d(TAG, "Stopping " + activeAlarmUid);

if (sound != null) {
sound.stop();
}

Alarm alarm = Storage.getAlarm(context, activeAlarmUid);
if(alarm==null) return;
AlarmDate date = Storage.getDate(context, activeAlarmUid);
Manager.remove(context,activeAlarmUid);
Storage.saveAlarm(context, alarm);
Storage.removeDate(context, activeAlarmUid);
activeAlarmUid = null;
}

Expand Down
11 changes: 11 additions & 0 deletions android/app/src/main/res/drawable/ic_snooze.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF707070"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.93 6,11v5l-2,2v1h16v-1l-2,-2zM14.5,9.8l-2.8,3.4h2.8L14.5,15h-5v-1.8l2.8,-3.4L9.5,9.8L9.5,8h5v1.8z"
/>
</vector>
2 changes: 1 addition & 1 deletion constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions js/db/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
*
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions js/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
}
85 changes: 79 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f426f93

Please sign in to comment.