diff --git a/build.gradle b/build.gradle index 1a5ee412..8c98ad8d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'com.android.tools.build:gradle:3.6.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } @@ -145,10 +145,10 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0" - implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.annotation:annotation:1.1.0' - implementation 'com.google.android.material:material:1.2.0-alpha03' + implementation 'com.google.android.material:material:1.2.0-alpha06' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.wdullaer:materialdatetimepicker:4.2.3' implementation 'com.github.guardianproject:signal-cli-android:v0.6.0-android-beta-1' diff --git a/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt b/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt index eaa89451..1372cd2a 100644 --- a/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt +++ b/src/androidTest/java/org/havenapp/main/database/migration/RoomMigrationTest.kt @@ -14,7 +14,7 @@ import org.junit.Rule import org.junit.Test /** - * Created by Arka Prava Basu on 27/10/18. + * Created by Arka Prava Basu on 27/10/18. */ class RoomMigrationTest { @get:Rule diff --git a/src/androidTest/java/org/havenapp/main/database/migration/SugarDbOpenHelper.kt b/src/androidTest/java/org/havenapp/main/database/migration/SugarDbOpenHelper.kt index e71a9be0..bb283ee5 100644 --- a/src/androidTest/java/org/havenapp/main/database/migration/SugarDbOpenHelper.kt +++ b/src/androidTest/java/org/havenapp/main/database/migration/SugarDbOpenHelper.kt @@ -5,7 +5,7 @@ import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper /** - * Created by Arka Prava Basu on 27/10/18. + * Created by Arka Prava Basu on 27/10/18. */ class SugarDbOpenHelper(context: Context, dbName: String) : SQLiteOpenHelper(context, dbName, null, 3) { diff --git a/src/androidTest/java/org/havenapp/main/database/migration/SugarDbTestHelper.kt b/src/androidTest/java/org/havenapp/main/database/migration/SugarDbTestHelper.kt index e013fffa..f27cf2f7 100644 --- a/src/androidTest/java/org/havenapp/main/database/migration/SugarDbTestHelper.kt +++ b/src/androidTest/java/org/havenapp/main/database/migration/SugarDbTestHelper.kt @@ -1,7 +1,7 @@ package org.havenapp.main.database.migration /** - * Created by Arka Prava Basu on 28/10/18. + * Created by Arka Prava Basu on 28/10/18. */ class SugarDbTestHelper { diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 5087f976..ff9b5e38 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -61,8 +61,7 @@ android:name=".SettingsActivity" android:configChanges="orientation|screenSize" android:label="@string/settings" - android:theme="@style/SettingsTheme" - android:windowSoftInputMode="stateHidden" /> + android:theme="@style/SettingsTheme" /> diff --git a/src/main/java/org/havenapp/main/SettingsFragment.java b/src/main/java/org/havenapp/main/SettingsFragment.java index 81a0339c..af70e5f1 100644 --- a/src/main/java/org/havenapp/main/SettingsFragment.java +++ b/src/main/java/org/havenapp/main/SettingsFragment.java @@ -9,7 +9,6 @@ import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -25,6 +24,17 @@ import android.widget.Switch; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.preference.EditTextPreference; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; +import androidx.preference.SwitchPreference; + import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; @@ -38,16 +48,6 @@ import java.io.File; import java.util.Locale; -import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.preference.EditTextPreference; -import androidx.preference.ListPreference; -import androidx.preference.Preference; -import androidx.preference.PreferenceFragmentCompat; -import androidx.preference.SwitchPreference; import info.guardianproject.netcipher.proxy.OrbotHelper; @@ -465,24 +465,28 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin break; case PreferenceManager.REMOTE_ACCESS_ONION: { - String text = ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ONION)).getText(); + EditTextPreference preference = findPreference(PreferenceManager.REMOTE_ACCESS_ONION); + assert preference != null; + String text = preference.getText(); if (checkValidString(text)) { preferences.setRemoteAccessOnion(text.trim()); - findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT); + preference.setSummary(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT); } else { preferences.setRemoteAccessOnion(text); - findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(R.string.remote_access_hint); + preference.setSummary(R.string.remote_access_hint); } break; } case PreferenceManager.REMOTE_ACCESS_CRED: { - String text = ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_CRED)).getText(); + EditTextPreference preference = findPreference(PreferenceManager.REMOTE_ACCESS_CRED); + assert preference != null; + String text = preference.getText(); if (checkValidString(text)) { preferences.setRemoteAccessCredential(text.trim()); - findPreference(PreferenceManager.REMOTE_ACCESS_CRED).setSummary(R.string.bullets); + preference.setSummary(R.string.bullets); } else { preferences.setRemoteAccessCredential(text); - findPreference(PreferenceManager.REMOTE_ACCESS_CRED).setSummary(R.string.remote_access_credential_hint); + preference.setSummary(R.string.remote_access_credential_hint); } break; } diff --git a/src/main/java/org/havenapp/main/database/DbConstants.kt b/src/main/java/org/havenapp/main/database/DbConstants.kt index 7ba25472..a127649f 100644 --- a/src/main/java/org/havenapp/main/database/DbConstants.kt +++ b/src/main/java/org/havenapp/main/database/DbConstants.kt @@ -1,7 +1,7 @@ package org.havenapp.main.database /** - * Created by Arka Prava Basu on 19/10/18. + * Created by Arka Prava Basu on 19/10/18. */ const val DB_INIT_START = 0x1 diff --git a/src/main/java/org/havenapp/main/model/Event.kt b/src/main/java/org/havenapp/main/model/Event.kt index fc7607aa..d60872bd 100644 --- a/src/main/java/org/havenapp/main/model/Event.kt +++ b/src/main/java/org/havenapp/main/model/Event.kt @@ -1,5 +1,6 @@ package org.havenapp.main.model +import androidx.annotation.WorkerThread import androidx.lifecycle.LiveData import androidx.lifecycle.Transformations import androidx.room.ColumnInfo @@ -46,6 +47,7 @@ class Event { *

* When [eventTriggers] is empty this method performs a blocking db lookup. */ + @WorkerThread fun getEventTriggers() : MutableList { if (eventTriggers.size == 0) { @@ -63,4 +65,30 @@ class Event { fun getEventTriggerCount(): Int { return eventTriggerCountLD?.value?.second ?: 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as Event + + if (id != other.id) return false + if (startTime != other.startTime) return false + if (eventTriggers != other.eventTriggers) return false + if (eventTriggerCountLD != other.eventTriggerCountLD) return false + + return true + } + + override fun hashCode(): Int { + var result = id?.hashCode() ?: 0 + result = 31 * result + (startTime?.hashCode() ?: 0) + result = 31 * result + eventTriggers.hashCode() + result = 31 * result + (eventTriggerCountLD?.hashCode() ?: 0) + return result + } + + override fun toString(): String { + return "Event(id=$id, startTime=$startTime, eventTriggers=$eventTriggers, eventTriggerCountLD=$eventTriggerCountLD)" + } } diff --git a/src/main/java/org/havenapp/main/model/EventTrigger.kt b/src/main/java/org/havenapp/main/model/EventTrigger.kt index a2f468c4..64344585 100644 --- a/src/main/java/org/havenapp/main/model/EventTrigger.kt +++ b/src/main/java/org/havenapp/main/model/EventTrigger.kt @@ -106,4 +106,32 @@ class EventTrigger { return mimeType } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as EventTrigger + + if (id != other.id) return false + if (type != other.type) return false + if (time != other.time) return false + if (eventId != other.eventId) return false + if (path != other.path) return false + + return true + } + + override fun hashCode(): Int { + var result = id?.hashCode() ?: 0 + result = 31 * result + (type ?: 0) + result = 31 * result + (time?.hashCode() ?: 0) + result = 31 * result + (eventId?.hashCode() ?: 0) + result = 31 * result + (path?.hashCode() ?: 0) + return result + } + + override fun toString(): String { + return "EventTrigger(id=$id, type=$type, time=$time, eventId=$eventId, path=$path)" + } } diff --git a/src/main/java/org/havenapp/main/service/HavenJobCreator.kt b/src/main/java/org/havenapp/main/service/HavenJobCreator.kt index f1a6f5ed..c57a3aa9 100644 --- a/src/main/java/org/havenapp/main/service/HavenJobCreator.kt +++ b/src/main/java/org/havenapp/main/service/HavenJobCreator.kt @@ -4,7 +4,7 @@ import com.evernote.android.job.Job import com.evernote.android.job.JobCreator /** - * Created by Arka Prava Basu on 04/11/18. + * Created by Arka Prava Basu on 04/11/18. */ class HavenJobCreator : JobCreator { override fun create(tag: String): Job? { diff --git a/src/main/java/org/havenapp/main/service/RemoveDeletedFilesJob.kt b/src/main/java/org/havenapp/main/service/RemoveDeletedFilesJob.kt index f2c3c954..864df32a 100644 --- a/src/main/java/org/havenapp/main/service/RemoveDeletedFilesJob.kt +++ b/src/main/java/org/havenapp/main/service/RemoveDeletedFilesJob.kt @@ -12,7 +12,7 @@ import java.io.File /** * A [Job] to delete files related to deleted logs. *

- * Created by Arka Prava Basu on 28/10/18. + * Created by Arka Prava Basu on 28/10/18. */ const val SERVICE_TAG = "HavenCleanupJob" diff --git a/src/main/java/org/havenapp/main/service/WebServer.java b/src/main/java/org/havenapp/main/service/WebServer.java index fd749a76..60b59e8c 100644 --- a/src/main/java/org/havenapp/main/service/WebServer.java +++ b/src/main/java/org/havenapp/main/service/WebServer.java @@ -180,7 +180,7 @@ private void showEvent (Event event, StringBuffer page) { { String title = eventTrigger.getStringType(new ResourceManager(mContext)); String desc = new SimpleDateFormat(Utils.DATE_TIME_PATTERN, - Locale.getDefault()).format(eventTrigger.getTime().toString()); + Locale.getDefault()).format(eventTrigger.getTime()); page.append(""); page.append(title).append("
"); @@ -253,7 +253,7 @@ private boolean safeEquals (String a, String b) { return MessageDigest.isEqual(aByteArray, bByteArray); } - class OnionCookie extends Cookie + static class OnionCookie extends Cookie { public OnionCookie(String name, String value, int numDays) {