Skip to content

Commit

Permalink
Update SDK to version 30. Update several libraries. Use SAF to create…
Browse files Browse the repository at this point in the history
… backup files
  • Loading branch information
Zoe Anderson committed Oct 18, 2020
1 parent 4c2952f commit f23c65b
Show file tree
Hide file tree
Showing 55 changed files with 247 additions and 297 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

4 changes: 4 additions & 0 deletions .idea/gradle.xml

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

45 changes: 45 additions & 0 deletions .idea/jarRepositories.xml

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

4 changes: 2 additions & 2 deletions .idea/modules.xml

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

66 changes: 24 additions & 42 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'realm-android'

android {
compileSdkVersion 27
compileSdkVersion 30
defaultConfig {
applicationId "com.log28"
minSdkVersion 15
targetSdkVersion 27
versionCode 11
versionName "0.6.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 19
targetSdkVersion 30
versionCode 12
versionName "0.6.2"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
Expand All @@ -25,56 +21,42 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// needed for ACRA
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

androidExtensions {
experimental = true
}

def support_version = "27.1.1"
def acraVersion = '5.1.3'
def androidx_version = "1.1.0"

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"
// preferences fix
implementation "com.takisoft.fix:preference-v7:27.1.1.0"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.vectordrawable:vectordrawable:$androidx_version"
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.recyclerview:recyclerview:$androidx_version"

// preference eXtended
implementation 'com.takisoft.preferencex:preferencex:1.1.0'

// groupie recyclerview library
implementation 'com.xwray:groupie:2.1.0'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.1.0'
implementation 'com.xwray:groupie:2.8.1'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.8.1'

//calendar
implementation 'pl.rafman.widgets:scroll-calendar:1.5.1', {
exclude group: 'com.android.support'
}
implementation 'pl.rafman.widgets:scroll-calendar:1.5.1'

// top calendar
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation project(':horizontalcalendar')

// app intro
implementation 'com.github.apl-devs:appintro:v4.2.3'

// crash reporting
implementation "ch.acra:acra-http:$acraVersion"
implementation "ch.acra:acra-notification:$acraVersion"

// file picker
implementation 'com.github.isabsent:filepicker:1.1.01'
implementation 'com.github.AppIntro:AppIntro:6.0.0'

implementation 'com.android.support:support-v4:27.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
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'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
4 changes: 2 additions & 2 deletions app/src/androidTest/java/com/log28/ExampleInstrumentedTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.log28

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.log28">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:name=".Log28"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/log28/CalendarView.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.log28

import android.os.Bundle
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.util.Log
import android.view.LayoutInflater
import android.view.View
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/log28/CycleHistory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package com.log28


import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.GridLayoutManager
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.log28.groupie.HistoryItem
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.ViewHolder
import com.xwray.groupie.GroupieViewHolder
import devs.mulham.horizontalcalendar.utils.Utils
import io.realm.Realm
import io.realm.RealmResults
Expand Down Expand Up @@ -67,7 +68,7 @@ class CycleHistory : Fragment() {
cycleLengths: List<Int>) {
val layout = GridLayoutManager(context, 3)
val dividerItem = DividerItemDecoration(context, layout.orientation)
val groupAdapter = GroupAdapter<ViewHolder>()
val groupAdapter = GroupAdapter<GroupieViewHolder>()

previous_cycles.apply {
layoutManager = layout
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/log28/CycleOverview.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package com.log28


import android.os.Bundle
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import android.util.AttributeSet
import android.util.Log
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.kotlinandroidextensions.ViewHolder
import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
import io.realm.RealmResults
import kotlinx.android.synthetic.main.fragment_cycle_overview.*
import com.log28.groupie.OverviewItem
Expand All @@ -34,7 +34,7 @@ class CycleOverview : Fragment() {
private var periodDates = realm.getPeriodDaysDecending()
private var dayData = realm.getDataByDate(Calendar.getInstance())
private var cycleInfo = realm.getCycleInfo()
private val groupAdapter = GroupAdapter<ViewHolder>()
private val groupAdapter = GroupAdapter<GroupieViewHolder>()


override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
Expand Down
33 changes: 15 additions & 18 deletions app/src/main/java/com/log28/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ open class Symptom(@PrimaryKey var name: String = "",
var category: Category? = null,
var active: Boolean = true): RealmObject() {
override fun equals(other: Any?): Boolean {
if (other !is Symptom) return false
else return (this.name == other.name && this.category == other.category)
return if (other !is Symptom) false
else (this.name == other.name && this.category == other.category)
}

fun toggleActive() {
Expand Down Expand Up @@ -168,14 +168,21 @@ fun insertAppetite(context: Context) {
realm.close()
}

fun exportDBToLocation(location: File): String {
val outputFile = File(location, "log28-backup-${Calendar.getInstance().formatDate()}")
if (outputFile.exists()) outputFile.delete()
fun exportDBToURI(uri: Uri?, context: Context): Boolean {
if (uri == null) return false
val outputStream = context.contentResolver.openOutputStream(uri, "w") ?: return false
val tmpFile = File(context.applicationContext.filesDir, TMP_REALM_FILE_NAME)

if (tmpFile.exists()) {
tmpFile.delete()
}

val realm = Realm.getDefaultInstance()
realm.writeCopyTo(outputFile)
realm.writeCopyTo(tmpFile)
realm.close()
return outputFile.absolutePath

tmpFile.inputStream().copyTo(outputStream)
return true
}

fun importDBFromUri(input: Uri?, context: Context): Boolean {
Expand All @@ -184,17 +191,7 @@ fun importDBFromUri(input: Uri?, context: Context): Boolean {

val stream = context.contentResolver.openInputStream(input)
val tmpFile = File(context.applicationContext.filesDir, TMP_REALM_FILE_NAME)
stream.copyTo(tmpFile.outputStream())
return checkAndImportDB(tmpFile, context)
}

fun importDBFromFile(inputFile: File, context: Context): Boolean {
Log.d(TAG, "Importing database file from ${inputFile.absolutePath}")

if (!inputFile.exists()) return false

val tmpFile = File(context.applicationContext.filesDir, TMP_REALM_FILE_NAME)
inputFile.copyTo(tmpFile, overwrite = true)
stream?.copyTo(tmpFile.outputStream())
return checkAndImportDB(tmpFile, context)
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/log28/DayView.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.log28

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import android.util.Log
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -40,7 +40,7 @@ class DayView : Fragment() {
private val categories = realm.getActiveCategories()
private val symptoms = realm.getActiveSymptoms()

private val groupAdapter = GroupAdapter<ViewHolder>()
private val groupAdapter = GroupAdapter<GroupieViewHolder>()

// we store our categories and symptom groups here so we can update them
private val categoryGroup = mutableListOf<ExpandableGroup>()
Expand Down
21 changes: 0 additions & 21 deletions app/src/main/java/com/log28/Log28.kt
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
package com.log28

import android.app.Application
import android.content.Context
import io.realm.Realm
import org.acra.annotation.*
import org.acra.ACRA
import org.acra.BuildConfig
import org.acra.annotation.AcraCore
import org.acra.sender.HttpSender

// This is the code that sets up crash reporting
// When the application crashes, we have a notification that asks the user to send a crash report
// It is sent currently to a ACRA server running on my network.
// TODO get an actual server for crash reproting
@AcraCore(buildConfigClass = BuildConfig::class)
@AcraHttpSender(uri = "http://crash.log28.com:55000/send", httpMethod = HttpSender.Method.POST)
@AcraNotification(resTitle = R.string.crash_title,
resText = R.string.crash_text,
resChannelName = R.string.notification_channel)
class Log28 : Application() {

override fun onCreate() {
super.onCreate()
Realm.init(this)
}

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
ACRA.init(this);
}
}
Loading

0 comments on commit f23c65b

Please sign in to comment.