Unverified Commit 26eddbac authored by Dylan Jones's avatar Dylan Jones
Browse files

Updated most of the dependencies to newer versions

Also changed min api level to 23 and removed some redundant code
parent cf44d053
Pipeline #4689 passed with stages
in 4 minutes and 1 second
...@@ -10,6 +10,7 @@ buildscript { ...@@ -10,6 +10,7 @@ buildscript {
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'io.fabric' apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
...@@ -20,15 +21,15 @@ apply plugin: 'realm-android' ...@@ -20,15 +21,15 @@ apply plugin: 'realm-android'
// apply plugin: 'me.tatarka.retrolambda' // apply plugin: 'me.tatarka.retrolambda'
android { android {
compileSdkVersion 26 compileSdkVersion 29
buildToolsVersion '27.0.3' buildToolsVersion '29.0.2'
defaultConfig { defaultConfig {
applicationId "srct.whatsopen" applicationId "srct.whatsopen"
minSdkVersion 16 minSdkVersion 23
targetSdkVersion 26 targetSdkVersion 29
versionCode 6 versionCode 6
versionName "1.0.5" versionName '1.0.6'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
release { release {
...@@ -46,33 +47,33 @@ android { ...@@ -46,33 +47,33 @@ android {
} }
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
compile 'com.astuetz:pagerslidingtabstrip:1.0.1' implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'io.realm:android-adapters:2.0.0' implementation 'io.realm:android-adapters:2.0.0'
compile 'com.google.code.gson:gson:2.8.0' implementation 'com.google.code.gson:gson:2.8.5'
compile 'com.squareup.retrofit2:retrofit:2.1.0' implementation 'com.squareup.retrofit2:retrofit:2.6.1'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2' implementation 'com.squareup.retrofit2:adapter-rxjava:2.6.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0' implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
//noinspection GradleCompatible //noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:26.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
compile 'com.android.support:cardview-v7:26.1.0' implementation 'androidx.cardview:cardview:1.0.0'
compile 'com.android.support:support-v4:26.1.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compile 'com.android.support:recyclerview-v7:26.1.0' implementation 'androidx.recyclerview:recyclerview:1.0.0'
compile 'io.reactivex:rxandroid:1.2.0' implementation 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.4' implementation 'io.reactivex:rxjava:1.3.8'
testCompile 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1' implementation 'com.jakewharton:butterknife:10.2.0'
kapt 'com.jakewharton:butterknife-compiler:8.8.1' kapt 'com.jakewharton:butterknife-compiler:10.2.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5' debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
compile 'com.github.daniel-stoneuk:material-about-library:1.3.0' implementation 'com.github.daniel-stoneuk:material-about-library:1.3.0'
compile 'com.takisoft.fix:preference-v7:25.1.1.0' implementation 'com.takisoft.fix:preference-v7:25.1.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') { implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true; transitive = true
} }
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41"
} }
package srct.whatsopen; package srct.whatsopen;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
......
...@@ -3,6 +3,7 @@ package srct.whatsopen.presenters; ...@@ -3,6 +3,7 @@ package srct.whatsopen.presenters;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import java.text.ParseException; import java.text.ParseException;
...@@ -49,6 +50,7 @@ public class MainPresenter { ...@@ -49,6 +50,7 @@ public class MainPresenter {
// Gets a Call from the given Retrofit service, then asynchronously executes it // Gets a Call from the given Retrofit service, then asynchronously executes it
// On success, copies the resulting facility list to the Realm DB // On success, copies the resulting facility list to the Realm DB
public void loadFacilities() { public void loadFacilities() {
Log.d("srct.whatsopen", "loadFacilities: called");
if (mMainView != null) if (mMainView != null)
mMainView.showProgressBar(); mMainView.showProgressBar();
...@@ -58,22 +60,28 @@ public class MainPresenter { ...@@ -58,22 +60,28 @@ public class MainPresenter {
Observable<List<Facility>> call = service.facilityList(); Observable<List<Facility>> call = service.facilityList();
call.subscribeOn(Schedulers.io()) call.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.map(facilities1 -> setStatus(facilities1)) .map(this::setStatus)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(new Subscriber<List<Facility>>() { .subscribe(new Subscriber<List<Facility>>() {
@Override @Override
public void onCompleted() { public void onCompleted() {
if(mMainView != null) if (mMainView != null) {
mMainView.dismissProgressBar(); mMainView.dismissProgressBar();
Log.d("srct.whatsopen", "onCompleted: called");
}
} }
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
updateOpenStatus(); updateOpenStatus();
if(mMainView != null) { if (mMainView != null) {
Log.i("srct.whatsopen", "MainPresenter.onError: printing stack trace!");
e.printStackTrace();
Toast.makeText(mMainView.getContext(), "Error getting data; " + Toast.makeText(mMainView.getContext(), "Error getting data; " +
"schedules may be out of date.", Toast.LENGTH_LONG).show(); "schedules may be out of date.", Toast.LENGTH_LONG).show();
} }
} }
@Override @Override
public void onNext(List<Facility> facilities) { public void onNext(List<Facility> facilities) {
writeToRealm(facilities); writeToRealm(facilities);
...@@ -83,10 +91,11 @@ public class MainPresenter { ...@@ -83,10 +91,11 @@ public class MainPresenter {
// Sets the favorite and open status of each Facility // Sets the favorite and open status of each Facility
private List<Facility> setStatus(List<Facility> facilities) { private List<Facility> setStatus(List<Facility> facilities) {
Log.d("srct.whatsopen", "setStatus: called");
for(Facility facility : facilities) { for (Facility facility : facilities) {
// Query SharedReferences for each Facility's favorite status. defaults to false // Query SharedReferences for each Facility's favorite status. defaults to false
facility.setFavorited(pref.getBoolean(facility.getName()+"FavoriteStatus", false)); facility.setFavorited(pref.getBoolean(facility.getName() + "FavoriteStatus", false));
facility.setOpen(getOpenStatus(facility, Calendar.getInstance())); facility.setOpen(getOpenStatus(facility, Calendar.getInstance()));
facility.setStatusDuration(getStatusDuration(facility, Calendar.getInstance())); facility.setStatusDuration(getStatusDuration(facility, Calendar.getInstance()));
} }
...@@ -106,15 +115,15 @@ public class MainPresenter { ...@@ -106,15 +115,15 @@ public class MainPresenter {
RealmResults<Facility> results = mRealm.where(Facility.class).findAll(); RealmResults<Facility> results = mRealm.where(Facility.class).findAll();
// Not a pretty way to do this, but Facilities shouldn't ever have too many items anyway // Not a pretty way to do this, but Facilities shouldn't ever have too many items anyway
for(Facility r : results) { for (Facility r : results) {
boolean deleted = true; boolean deleted = true;
for(Facility f : facilities) { for (Facility f : facilities) {
if( r.getName().equals(f.getName()) ) { if (r.getName().equals(f.getName())) {
deleted = false; deleted = false;
} }
} }
if(deleted) { if (deleted) {
removeFacilityFromRealm(r); removeFacilityFromRealm(r);
} }
} }
...@@ -133,13 +142,13 @@ public class MainPresenter { ...@@ -133,13 +142,13 @@ public class MainPresenter {
// Sets the open status and status duration of each facility in the Realm instance // Sets the open status and status duration of each facility in the Realm instance
private void updateOpenStatus() { private void updateOpenStatus() {
mRealm.executeTransactionAsync(bgRealm -> { mRealm.executeTransactionAsync(bgRealm -> {
List<Facility> facilities = bgRealm.where(Facility.class).findAll(); List<Facility> facilities = bgRealm.where(Facility.class).findAll();
for(Facility f : facilities) { for (Facility f : facilities) {
f.setOpen(getOpenStatus(f, Calendar.getInstance())); f.setOpen(getOpenStatus(f, Calendar.getInstance()));
f.setStatusDuration(getStatusDuration(f, Calendar.getInstance())); f.setStatusDuration(getStatusDuration(f, Calendar.getInstance()));
} }
}, null, null); }, null, null);
} }
// Uses the device time to determine which facilities should be open // Uses the device time to determine which facilities should be open
...@@ -157,7 +166,7 @@ public class MainPresenter { ...@@ -157,7 +166,7 @@ public class MainPresenter {
int currentDay = (5 + now.get(Calendar.DAY_OF_WEEK)) % 7; int currentDay = (5 + now.get(Calendar.DAY_OF_WEEK)) % 7;
OpenTimes currentOpenTimes; OpenTimes currentOpenTimes;
for(OpenTimes o : openTimesList) { for (OpenTimes o : openTimesList) {
if (o.getStartDay() == currentDay && o.getEndDay() == currentDay) { if (o.getStartDay() == currentDay && o.getEndDay() == currentDay) {
currentOpenTimes = o; currentOpenTimes = o;
...@@ -173,9 +182,7 @@ public class MainPresenter { ...@@ -173,9 +182,7 @@ public class MainPresenter {
pe.printStackTrace(); pe.printStackTrace();
return false; return false;
} }
} } else if (o.getStartDay() == currentDay && o.getEndDay() > currentDay) {
else if (o.getStartDay() == currentDay && o.getEndDay() > currentDay) {
currentOpenTimes = o; currentOpenTimes = o;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
...@@ -189,9 +196,7 @@ public class MainPresenter { ...@@ -189,9 +196,7 @@ public class MainPresenter {
pe.printStackTrace(); pe.printStackTrace();
return false; return false;
} }
} } else if (o.getStartDay() < currentDay && o.getEndDay() == currentDay) {
else if (o.getStartDay() < currentDay && o.getEndDay() == currentDay) {
currentOpenTimes = o; currentOpenTimes = o;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
...@@ -215,24 +220,24 @@ public class MainPresenter { ...@@ -215,24 +220,24 @@ public class MainPresenter {
public String getStatusDuration(Facility facility, Calendar now) { public String getStatusDuration(Facility facility, Calendar now) {
Schedule schedule = getActiveSchedule(facility, now); Schedule schedule = getActiveSchedule(facility, now);
if(schedule.isOpen24Hours()) { if (schedule.isOpen24Hours()) {
return "Open 24/7"; return "Open 24/7";
} }
RealmList<OpenTimes> openTimesList = schedule.getOpenTimesList(); RealmList<OpenTimes> openTimesList = schedule.getOpenTimesList();
if(openTimesList == null) if (openTimesList == null)
return ""; return "";
if(openTimesList.size() == 0) if (openTimesList.size() == 0)
return "No open time on schedule"; return "No open time on schedule";
int currentDay = (5 + now.get(Calendar.DAY_OF_WEEK)) % 7; int currentDay = (5 + now.get(Calendar.DAY_OF_WEEK)) % 7;
String durationMessage; String durationMessage;
if(facility.isOpen()) { if (facility.isOpen()) {
if(getCurrentEndTime(openTimesList, currentDay).equals("23:59:59") && if (getCurrentEndTime(openTimesList, currentDay).equals("23:59:59") &&
getCurrentStartTime(openTimesList, (currentDay+1)%7).equals("00:00:00")) { getCurrentStartTime(openTimesList, (currentDay + 1) % 7).equals("00:00:00")) {
currentDay++; currentDay++;
} }
...@@ -244,13 +249,13 @@ public class MainPresenter { ...@@ -244,13 +249,13 @@ public class MainPresenter {
} }
// Check if the facility opens later today // Check if the facility opens later today
if(openTimesContains(openTimesList, currentDay)) { if (openTimesContains(openTimesList, currentDay)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
try { try {
Date currentTime = sdf.parse(sdf.format(now.getTime())); Date currentTime = sdf.parse(sdf.format(now.getTime()));
Date startTime = sdf.parse(getCurrentStartTime(openTimesList, currentDay)); Date startTime = sdf.parse(getCurrentStartTime(openTimesList, currentDay));
if(currentTime.compareTo(startTime) < 0) { if (currentTime.compareTo(startTime) < 0) {
String openingTime = getCurrentStartTime(openTimesList, currentDay); String openingTime = getCurrentStartTime(openTimesList, currentDay);
openingTime = FacilityPresenter.parseTo12HourTime(openingTime); openingTime = FacilityPresenter.parseTo12HourTime(openingTime);
...@@ -268,7 +273,7 @@ public class MainPresenter { ...@@ -268,7 +273,7 @@ public class MainPresenter {
String openingTime = getCurrentStartTime(openTimesList, nextDay); String openingTime = getCurrentStartTime(openTimesList, nextDay);
openingTime = FacilityPresenter.parseTo12HourTime(openingTime); openingTime = FacilityPresenter.parseTo12HourTime(openingTime);
if(nextDay == (currentDay+1)%7) { if (nextDay == (currentDay + 1) % 7) {
durationMessage = "Opens tomorrow at " + openingTime; durationMessage = "Opens tomorrow at " + openingTime;
} else { } else {
String nextDayStr = FacilityPresenter.parseIntToDay(nextDay); String nextDayStr = FacilityPresenter.parseIntToDay(nextDay);
...@@ -279,8 +284,8 @@ public class MainPresenter { ...@@ -279,8 +284,8 @@ public class MainPresenter {
} }
private boolean openTimesContains(RealmList<OpenTimes> openTimesList, int currentDay) { private boolean openTimesContains(RealmList<OpenTimes> openTimesList, int currentDay) {
for(OpenTimes o : openTimesList) { for (OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay) if (o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
return true; return true;
} }
return false; return false;
...@@ -289,8 +294,8 @@ public class MainPresenter { ...@@ -289,8 +294,8 @@ public class MainPresenter {
// Returns the next open day in the list of OpenTimes // Returns the next open day in the list of OpenTimes
private int findNextDay(RealmList<OpenTimes> openTimesList, int current) { private int findNextDay(RealmList<OpenTimes> openTimesList, int current) {
int nextDay = openTimesList.first().getStartDay(); int nextDay = openTimesList.first().getStartDay();
for(OpenTimes o : openTimesList) { for (OpenTimes o : openTimesList) {
if(o.getStartDay() > current) { if (o.getStartDay() > current) {
nextDay = o.getStartDay(); nextDay = o.getStartDay();
break; break;
} }
...@@ -302,8 +307,8 @@ public class MainPresenter { ...@@ -302,8 +307,8 @@ public class MainPresenter {
// Returns the end time for the current day // Returns the end time for the current day
private String getCurrentEndTime(RealmList<OpenTimes> openTimesList, int currentDay) { private String getCurrentEndTime(RealmList<OpenTimes> openTimesList, int currentDay) {
String endTime = ""; String endTime = "";
for(OpenTimes o : openTimesList) { for (OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay) if (o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
endTime = o.getEndTime(); endTime = o.getEndTime();
} }
return endTime; return endTime;
...@@ -312,8 +317,8 @@ public class MainPresenter { ...@@ -312,8 +317,8 @@ public class MainPresenter {
// Returns the end time for the current day // Returns the end time for the current day
private String getCurrentStartTime(RealmList<OpenTimes> openTimesList, int currentDay) { private String getCurrentStartTime(RealmList<OpenTimes> openTimesList, int currentDay) {
String startTime = ""; String startTime = "";
for(OpenTimes o : openTimesList) { for (OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay) if (o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
startTime = o.getStartTime(); startTime = o.getStartTime();
} }
return startTime; return startTime;
...@@ -327,11 +332,11 @@ public class MainPresenter { ...@@ -327,11 +332,11 @@ public class MainPresenter {
try { try {
Date currentDate = now.getTime(); Date currentDate = now.getTime();
for(SpecialSchedule s : facility.getSpecialSchedules()) { for (SpecialSchedule s : facility.getSpecialSchedules()) {
Date startDate = sdf.parse(s.getValidStart()); Date startDate = sdf.parse(s.getValidStart());
Date endDate = sdf.parse(s.getValidEnd()); Date endDate = sdf.parse(s.getValidEnd());
if(currentDate.compareTo(startDate) >= 0 && currentDate.compareTo(endDate) <= 0) { if (currentDate.compareTo(startDate) >= 0 && currentDate.compareTo(endDate) <= 0) {
return s; return s;
} }
} }
......
...@@ -2,7 +2,7 @@ package srct.whatsopen.util; ...@@ -2,7 +2,7 @@ package srct.whatsopen.util;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver; import androidx.legacy.content.WakefulBroadcastReceiver;
public class NotificationReceiver extends WakefulBroadcastReceiver { public class NotificationReceiver extends WakefulBroadcastReceiver {
......
...@@ -7,8 +7,8 @@ import android.content.Intent; ...@@ -7,8 +7,8 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import android.support.v4.content.WakefulBroadcastReceiver; import androidx.legacy.content.WakefulBroadcastReceiver;
import srct.whatsopen.R; import srct.whatsopen.R;
......
...@@ -3,7 +3,7 @@ package srct.whatsopen.views.activities; ...@@ -3,7 +3,7 @@ package srct.whatsopen.views.activities;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import androidx.annotation.Nullable;
import com.danielstone.materialaboutlibrary.MaterialAboutActivity; import com.danielstone.materialaboutlibrary.MaterialAboutActivity;
import com.danielstone.materialaboutlibrary.model.MaterialAboutActionItem; import com.danielstone.materialaboutlibrary.model.MaterialAboutActionItem;
......
package srct.whatsopen.views.activities; package srct.whatsopen.views.activities;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
...@@ -81,13 +79,7 @@ public abstract class BaseThemeActivity extends AppCompatActivity { ...@@ -81,13 +79,7 @@ public abstract class BaseThemeActivity extends AppCompatActivity {
Method method = clazz.getMethod("getThemeResId"); Method method = clazz.getMethod("getThemeResId");
method.setAccessible(true); method.setAccessible(true);
themeResId = (Integer) method.invoke(this); themeResId = (Integer) method.invoke(this);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
Log.e(TAG, ".getThemeID Failed to get theme resource ID", e);
} catch (IllegalAccessException e) {
Log.e(TAG, ".getThemeID Failed to get theme resource ID", e);
} catch (IllegalArgumentException e) {
Log.e(TAG, ".getThemeID Failed to get theme resource ID", e);
} catch (InvocationTargetException e) {
Log.e(TAG, ".getThemeID Failed to get theme resource ID", e); Log.e(TAG, ".getThemeID Failed to get theme resource ID", e);
} }
return themeResId; return themeResId;
......
...@@ -2,21 +2,9 @@ package srct.whatsopen.views.activities; ...@@ -2,21 +2,9 @@ package srct.whatsopen.views.activities;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Html; import android.text.Html;
import android.transition.Slide; import android.transition.Slide;
import android.view.Display;
import android.view.Gravity;