diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index 92071ff9d..000000000 --- a/android/build.gradle +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -buildscript { - ext.kotlin_version = '1.3.11' - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:3.3.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - repositories { - google() - jcenter() - maven { - url "$rootDir/../react-native/node_modules/react-native/android" - } - } -} - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -android { - compileSdkVersion 28 - defaultConfig { - applicationId "org.isoron.habits" - minSdkVersion 21 - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation files("../core/build/libs/core-jvm.jar") - implementation "com.facebook.react:react-native:0.57.8" - implementation 'org.sqldroid:sqldroid:1.0.3' - implementation project(':react-native-svg') - - testImplementation 'junit:junit:4.12' - - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' -} diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index f2e8274f4..000000000 --- a/android/gradle.properties +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (C) 2016-2019 Álinson Santos Xavier -# -# This file is part of Loop Habit Tracker. -# -# Loop Habit Tracker is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# Loop Habit Tracker is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# - -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 87b738cbd..000000000 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 3bc259a2f..000000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (C) 2016-2019 Álinson Santos Xavier -# -# This file is part of Loop Habit Tracker. -# -# Loop Habit Tracker is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# Loop Habit Tracker is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# - -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index af6708ff2..000000000 --- a/android/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100644 index 0f8d5937c..000000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index f41cefdd3..000000000 --- a/android/settings.gradle +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -include ':react-native-svg' - -project(':react-native-svg').projectDir = new File(rootProject.projectDir, - '../react-native/node_modules/react-native-svg/android') diff --git a/android/src/androidTest/java/org/isoron/habits/AndroidDatabaseTest.kt b/android/src/androidTest/java/org/isoron/habits/AndroidDatabaseTest.kt deleted file mode 100644 index 36248728a..000000000 --- a/android/src/androidTest/java/org/isoron/habits/AndroidDatabaseTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import junit.framework.Assert.* -import org.isoron.uhabits.utils.* -import org.junit.* - -class AndroidDatabaseTest : BaseTest() { - @Test - fun testUsage() { - val dbFile = fileOpener.openUserFile("test.sqlite3") - if (dbFile.exists()) dbFile.delete() - val db = databaseOpener.open(dbFile) - - var stmt = db.prepareStatement("drop table if exists demo") - stmt.step() - stmt.finalize() - - stmt = db.prepareStatement("begin") - stmt.step() - stmt.finalize() - - stmt = db.prepareStatement("create table if not exists demo(key int, value text)") - stmt.step() - stmt.finalize() - - stmt = db.prepareStatement("insert into demo(key, value) values (?1, ?2)") - stmt.bindInt(1, 42) - stmt.bindText(2, "Hello World") - stmt.step() - stmt.finalize() - - stmt = db.prepareStatement("select * from demo where key > ?1") - stmt.bindInt(1, 10) - var result = stmt.step() - assertEquals(result, StepResult.ROW) - assertEquals(stmt.getInt(0), 42) - assertEquals(stmt.getText(1), "Hello World") - result = stmt.step() - assertEquals(result, StepResult.DONE) - stmt.finalize() - - stmt = db.prepareStatement("drop table demo") - stmt.step() - stmt.finalize() - - stmt = db.prepareStatement("commit") - stmt.step() - stmt.finalize() - - db.close() - dbFile.delete() - } -} \ No newline at end of file diff --git a/android/src/androidTest/java/org/isoron/habits/AndroidFilesTest.kt b/android/src/androidTest/java/org/isoron/habits/AndroidFilesTest.kt deleted file mode 100644 index 95b2f453a..000000000 --- a/android/src/androidTest/java/org/isoron/habits/AndroidFilesTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import org.junit.Test - -import org.junit.Assert.* -import java.io.* - -class AndroidFilesTest : BaseTest() { - - @Test - fun testUserFiles() { - val file = File(context.filesDir, "test.txt") - file.writeText("Hello world!") - - val af = fileOpener.openUserFile("test.txt") - assertTrue(af.exists()) - af.delete() - assertFalse(af.exists()) - } - - @Test - fun testResourceFiles() { - val file = fileOpener.openResourceFile("migrations/010.sql") - val lines = file.readLines() - assertEquals("delete from Score", lines[0]) - } -} \ No newline at end of file diff --git a/android/src/androidTest/java/org/isoron/habits/BaseTest.kt b/android/src/androidTest/java/org/isoron/habits/BaseTest.kt deleted file mode 100644 index a6cd8cd59..000000000 --- a/android/src/androidTest/java/org/isoron/habits/BaseTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import android.support.test.* - -open class BaseTest { - val context = InstrumentationRegistry.getTargetContext() - val fileOpener = AndroidFileOpener(context) - val databaseOpener = AndroidDatabaseOpener() -} \ No newline at end of file diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 23a91955d..000000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/android/src/main/assets b/android/src/main/assets deleted file mode 120000 index e99c645eb..000000000 --- a/android/src/main/assets +++ /dev/null @@ -1 +0,0 @@ -../../../core/assets/main/ \ No newline at end of file diff --git a/android/src/main/java/org/isoron/habits/AndroidDatabase.kt b/android/src/main/java/org/isoron/habits/AndroidDatabase.kt deleted file mode 100644 index 6240bd749..000000000 --- a/android/src/main/java/org/isoron/habits/AndroidDatabase.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import org.isoron.uhabits.database.* -import org.isoron.uhabits.utils.* -import java.sql.* - -class AndroidDatabaseOpener : DatabaseOpener { - override fun open(file: UserFile): Database { - val platformFile = file as AndroidUserFile - DriverManager.registerDriver(Class.forName("org.sqldroid.SQLDroidDriver").newInstance() as Driver) - val conn = DriverManager.getConnection("jdbc:sqlite:${platformFile.file.absolutePath}") - return JavaDatabase(conn, AndroidLog()) - } -} \ No newline at end of file diff --git a/android/src/main/java/org/isoron/habits/AndroidFiles.kt b/android/src/main/java/org/isoron/habits/AndroidFiles.kt deleted file mode 100644 index b627d578e..000000000 --- a/android/src/main/java/org/isoron/habits/AndroidFiles.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import android.content.* -import org.isoron.uhabits.utils.* -import java.io.* -import java.util.* - - -class AndroidFileOpener(val context: Context) : FileOpener { - override fun openUserFile(filename: String): UserFile { - return AndroidUserFile(File(context.filesDir, filename)) - } - - override fun openResourceFile(filename: String): ResourceFile { - return AndroidResourceFile(context, filename) - } -} - -class AndroidResourceFile(val context: Context, - val filename: String) : ResourceFile { - - override fun readLines(): List { - val asset = context.assets.open(filename) - val reader = BufferedReader(InputStreamReader(asset)) - val lines = ArrayList() - while (true) { - val line = reader.readLine() ?: break - lines.add(line) - } - return lines - } -} - -class AndroidUserFile(val file: File) : UserFile { - override fun delete() { - file.delete() - } - - override fun exists(): Boolean { - return file.exists() - } - -} diff --git a/android/src/main/java/org/isoron/habits/AndroidLog.kt b/android/src/main/java/org/isoron/habits/AndroidLog.kt deleted file mode 100644 index 54b7513f0..000000000 --- a/android/src/main/java/org/isoron/habits/AndroidLog.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import org.isoron.uhabits.utils.* - -class AndroidLog : Log { - override fun debug(msg: String) { - android.util.Log.d("LOOP", msg) - } - - override fun info(msg: String) { - android.util.Log.i("LOOP", msg) - } -} \ No newline at end of file diff --git a/android/src/main/java/org/isoron/habits/CoreModule.kt b/android/src/main/java/org/isoron/habits/CoreModule.kt deleted file mode 100644 index 8afc00178..000000000 --- a/android/src/main/java/org/isoron/habits/CoreModule.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import com.facebook.react.bridge.* -import com.facebook.react.modules.core.DeviceEventManagerModule.* -import org.isoron.uhabits.* - - -class CoreModule(private val context: ReactApplicationContext) : ReactContextBaseJavaModule(context) { - - private var backend = Backend(AndroidDatabaseOpener(), - AndroidFileOpener(context), - AndroidLog()) - - private lateinit var emitter: RCTDeviceEventEmitter - - override fun initialize() { - super.initialize() - emitter = context.getJSModule(RCTDeviceEventEmitter::class.java) - } - - override fun getName(): String { - return "CoreModule" - } - - @ReactMethod - fun requestHabitList() { - val result = backend.getHabitList() - val data = Arguments.createArray() - for (r in result) { - data.pushMap(Arguments.createMap().apply { - for ((key, value) in r) { - if (value is String) putString(key, value) - else if (value is Int) putInt(key, value) - } - }) - } - emitter.emit("onHabitList", data) - } - - @ReactMethod - fun createHabit(name: String) { - backend.createHabit(name) - } - - @ReactMethod - fun deletHabit(id: Int) { - backend.deleteHabit(id) - } - - @ReactMethod - fun updateHabit(id: Int, name: String) { - backend.updateHabit(id, name) - } -} \ No newline at end of file diff --git a/android/src/main/java/org/isoron/habits/CorePackage.kt b/android/src/main/java/org/isoron/habits/CorePackage.kt deleted file mode 100644 index 4d82b72de..000000000 --- a/android/src/main/java/org/isoron/habits/CorePackage.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import android.view.* -import com.facebook.react.* -import com.facebook.react.bridge.* -import com.facebook.react.uimanager.* -import com.facebook.react.uimanager.ViewManager -import java.util.* - -class CorePackage : ReactPackage { - - override fun createNativeModules(ctx: ReactApplicationContext) : MutableList { - return mutableListOf(CoreModule(ctx)) - } - - override fun createViewManagers(reactContext: ReactApplicationContext?) - : MutableList>> { - return Collections.emptyList() - } -} \ No newline at end of file diff --git a/android/src/main/java/org/isoron/habits/MainActivity.kt b/android/src/main/java/org/isoron/habits/MainActivity.kt deleted file mode 100644 index 70d48cf24..000000000 --- a/android/src/main/java/org/isoron/habits/MainActivity.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2016-2019 Álinson Santos Xavier - * - * This file is part of Loop Habit Tracker. - * - * Loop Habit Tracker is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * Loop Habit Tracker is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -package org.isoron.habits - -import android.content.* -import android.net.* -import android.os.* -import android.os.Build.VERSION.* -import android.os.Build.VERSION_CODES.* -import android.provider.* -import android.support.v7.app.* -import android.view.* -import com.facebook.react.* -import com.facebook.react.common.* -import com.facebook.react.shell.* -import com.horcrux.svg.* - -class MainActivity : AppCompatActivity() { - - private lateinit var reactInstanceManager: ReactInstanceManager - private lateinit var reactRootView: ReactRootView - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - if (SDK_INT >= M && !Settings.canDrawOverlays(this)) { - startActivityForResult(Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, - Uri.parse("package:$packageName")), 0) - } - - reactRootView = ReactRootView(this) - reactInstanceManager = ReactInstanceManager.builder() - .setApplication(application) - .setBundleAssetName("index.android.bundle") - .setJSMainModulePath("index.android") - .addPackage(MainReactPackage()) - .addPackage(CorePackage()) - .addPackage(SvgPackage()) - .setUseDeveloperSupport(BuildConfig.DEBUG) - .setInitialLifecycleState(LifecycleState.RESUMED) - .build() - - reactRootView.startReactApplication(reactInstanceManager, "LoopHabitTracker", null) - setContentView(reactRootView) - } - - override fun onPause() { - reactInstanceManager.onHostPause(this) - super.onPause() - } - - override fun onResume() { - super.onResume() - reactInstanceManager.onHostResume(this) - } - - override fun onDestroy() { - reactInstanceManager.onHostDestroy(this) - reactRootView.unmountReactApplication() - super.onDestroy() - } - - override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean { - if (keyCode == KeyEvent.KEYCODE_MENU) { - reactInstanceManager.showDevOptionsDialog() - return true - } - return super.onKeyUp(keyCode, event) - } -} diff --git a/android/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 1f6b5cefa..000000000 --- a/android/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - diff --git a/android/src/main/res/drawable/ic_launcher_background.xml b/android/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index dd6a8dc40..000000000 --- a/android/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index d906785e0..000000000 --- a/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index d906785e0..000000000 --- a/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/android/src/main/res/mipmap-hdpi/ic_launcher.png b/android/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a2f590828..000000000 Binary files a/android/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/android/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 1b5239980..000000000 Binary files a/android/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/src/main/res/mipmap-mdpi/ic_launcher.png b/android/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index ff10afd6e..000000000 Binary files a/android/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/android/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index 115a4c768..000000000 Binary files a/android/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index dcd3cd808..000000000 Binary files a/android/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 459ca609d..000000000 Binary files a/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 8ca12fe02..000000000 Binary files a/android/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index 8e19b410a..000000000 Binary files a/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index b824ebdd4..000000000 Binary files a/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index 4c19a13c2..000000000 Binary files a/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/android/src/main/res/values/colors.xml b/android/src/main/res/values/colors.xml deleted file mode 100644 index e46135677..000000000 --- a/android/src/main/res/values/colors.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - #3F51B5 - #303F9F - #FF4081 - diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml deleted file mode 100644 index 45fab93d1..000000000 --- a/android/src/main/res/values/strings.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - Loop Habit Tracker - diff --git a/android/src/main/res/values/styles.xml b/android/src/main/res/values/styles.xml deleted file mode 100644 index 81d6f73bd..000000000 --- a/android/src/main/res/values/styles.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - diff --git a/android/src/main/res/xml/network.xml b/android/src/main/res/xml/network.xml deleted file mode 100644 index f49ff97be..000000000 --- a/android/src/main/res/xml/network.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 127.0.0.1 - - \ No newline at end of file