Skip to content

Commit

Permalink
Merge branch 'archie94-webserver_bug'
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Jul 13, 2020
2 parents 8b8a7d2 + 7f1a4b5 commit e6f365b
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 31 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}

Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.junit.Rule
import org.junit.Test

/**
* Created by Arka Prava Basu <arka.basu@zomato.com> on 27/10/18.
* Created by Arka Prava Basu <arkaprava94@gmail.com> on 27/10/18.
*/
class RoomMigrationTest {
@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper

/**
* Created by Arka Prava Basu <arka.basu@zomato.com> on 27/10/18.
* Created by Arka Prava Basu <arkaprava94@gmail.com> on 27/10/18.
*/
class SugarDbOpenHelper(context: Context, dbName: String)
: SQLiteOpenHelper(context, dbName, null, 3) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.havenapp.main.database.migration

/**
* Created by Arka Prava Basu <arka.basu@zomato.com> on 28/10/18.
* Created by Arka Prava Basu <arkaprava94@gmail.com> on 28/10/18.
*/
class SugarDbTestHelper {

Expand Down
3 changes: 1 addition & 2 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
<activity
android:name=".ui.PPAppIntro"
android:screenOrientation="fullSensor" />
Expand Down
38 changes: 21 additions & 17 deletions src/main/java/org/havenapp/main/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;


Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/havenapp/main/database/DbConstants.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.havenapp.main.database

/**
* Created by Arka Prava Basu <arka.basu@zomato.com> on 19/10/18.
* Created by Arka Prava Basu <arkaprava94@gmail.com> on 19/10/18.
*/

const val DB_INIT_START = 0x1
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/org/havenapp/main/model/Event.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,6 +47,7 @@ class Event {
* <p>
* When [eventTriggers] is empty this method performs a blocking db lookup.
*/
@WorkerThread
fun getEventTriggers() : MutableList<EventTrigger> {

if (eventTriggers.size == 0) {
Expand All @@ -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)"
}
}
28 changes: 28 additions & 0 deletions src/main/java/org/havenapp/main/model/EventTrigger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/havenapp/main/service/HavenJobCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.evernote.android.job.Job
import com.evernote.android.job.JobCreator

/**
* Created by Arka Prava Basu <arka.basu@zomato.com> on 04/11/18.
* Created by Arka Prava Basu <arkaprava94@gmail.com> on 04/11/18.
*/
class HavenJobCreator : JobCreator {
override fun create(tag: String): Job? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.io.File
/**
* A [Job] to delete files related to deleted logs.
* <p>
* Created by Arka Prava Basu <arka.basu@zomato.com> on 28/10/18.
* Created by Arka Prava Basu <arkaprava94@gmail.com> on 28/10/18.
*/

const val SERVICE_TAG = "HavenCleanupJob"
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/havenapp/main/service/WebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("<b>");
page.append(title).append("</b><br/>");
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e6f365b

Please sign in to comment.