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 {
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-kapt'
repositories {
maven { url 'https://maven.fabric.io/public' }
......@@ -20,15 +21,15 @@ apply plugin: 'realm-android'
// apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "srct.whatsopen"
minSdkVersion 16
targetSdkVersion 26
minSdkVersion 23
targetSdkVersion 29
versionCode 6
versionName "1.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionName '1.0.6'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
......@@ -46,33 +47,33 @@ android {
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'io.realm:android-adapters:2.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
implementation 'io.realm:android-adapters:2.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.4'
testCompile 'junit:junit:4.12'
compile 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'com.github.daniel-stoneuk:material-about-library:1.3.0'
compile 'com.takisoft.fix:preference-v7:25.1.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true;
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.8'
testImplementation 'junit:junit:4.12'
implementation 'com.jakewharton:butterknife:10.2.0'
kapt 'com.jakewharton:butterknife-compiler:10.2.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
implementation 'com.github.daniel-stoneuk:material-about-library:1.3.0'
implementation 'com.takisoft.fix:preference-v7:25.1.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
transitive = true
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41"
}
package srct.whatsopen;
import android.content.Context;
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;
......
......@@ -3,6 +3,7 @@ package srct.whatsopen.presenters;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.text.ParseException;
......@@ -49,6 +50,7 @@ public class MainPresenter {
// Gets a Call from the given Retrofit service, then asynchronously executes it
// On success, copies the resulting facility list to the Realm DB
public void loadFacilities() {
Log.d("srct.whatsopen", "loadFacilities: called");
if (mMainView != null)
mMainView.showProgressBar();
......@@ -58,22 +60,28 @@ public class MainPresenter {
Observable<List<Facility>> call = service.facilityList();
call.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(facilities1 -> setStatus(facilities1))
.map(this::setStatus)
.subscribeOn(Schedulers.io())
.subscribe(new Subscriber<List<Facility>>() {
@Override
public void onCompleted() {
if(mMainView != null)
if (mMainView != null) {
mMainView.dismissProgressBar();
Log.d("srct.whatsopen", "onCompleted: called");
}
}
@Override
public void onError(Throwable e) {
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; " +
"schedules may be out of date.", Toast.LENGTH_LONG).show();
"schedules may be out of date.", Toast.LENGTH_LONG).show();
}
}
@Override
public void onNext(List<Facility> facilities) {
writeToRealm(facilities);
......@@ -83,10 +91,11 @@ public class MainPresenter {
// Sets the favorite and open status of each Facility
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
facility.setFavorited(pref.getBoolean(facility.getName()+"FavoriteStatus", false));
facility.setFavorited(pref.getBoolean(facility.getName() + "FavoriteStatus", false));
facility.setOpen(getOpenStatus(facility, Calendar.getInstance()));
facility.setStatusDuration(getStatusDuration(facility, Calendar.getInstance()));
}
......@@ -106,15 +115,15 @@ public class MainPresenter {
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
for(Facility r : results) {
for (Facility r : results) {
boolean deleted = true;
for(Facility f : facilities) {
if( r.getName().equals(f.getName()) ) {
for (Facility f : facilities) {
if (r.getName().equals(f.getName())) {
deleted = false;
}
}
if(deleted) {
if (deleted) {
removeFacilityFromRealm(r);
}
}
......@@ -133,13 +142,13 @@ public class MainPresenter {
// Sets the open status and status duration of each facility in the Realm instance
private void updateOpenStatus() {
mRealm.executeTransactionAsync(bgRealm -> {
mRealm.executeTransactionAsync(bgRealm -> {
List<Facility> facilities = bgRealm.where(Facility.class).findAll();
for(Facility f : facilities) {
for (Facility f : facilities) {
f.setOpen(getOpenStatus(f, Calendar.getInstance()));
f.setStatusDuration(getStatusDuration(f, Calendar.getInstance()));
}
}, null, null);
}, null, null);
}
// Uses the device time to determine which facilities should be open
......@@ -157,7 +166,7 @@ public class MainPresenter {
int currentDay = (5 + now.get(Calendar.DAY_OF_WEEK)) % 7;
OpenTimes currentOpenTimes;
for(OpenTimes o : openTimesList) {
for (OpenTimes o : openTimesList) {
if (o.getStartDay() == currentDay && o.getEndDay() == currentDay) {
currentOpenTimes = o;
......@@ -173,9 +182,7 @@ public class MainPresenter {
pe.printStackTrace();
return false;
}
}
else if (o.getStartDay() == currentDay && o.getEndDay() > currentDay) {
} else if (o.getStartDay() == currentDay && o.getEndDay() > currentDay) {
currentOpenTimes = o;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
......@@ -189,9 +196,7 @@ public class MainPresenter {
pe.printStackTrace();
return false;
}
}
else if (o.getStartDay() < currentDay && o.getEndDay() == currentDay) {
} else if (o.getStartDay() < currentDay && o.getEndDay() == currentDay) {
currentOpenTimes = o;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
......@@ -215,24 +220,24 @@ public class MainPresenter {
public String getStatusDuration(Facility facility, Calendar now) {
Schedule schedule = getActiveSchedule(facility, now);
if(schedule.isOpen24Hours()) {
if (schedule.isOpen24Hours()) {
return "Open 24/7";
}
RealmList<OpenTimes> openTimesList = schedule.getOpenTimesList();
if(openTimesList == null)
if (openTimesList == null)
return "";
if(openTimesList.size() == 0)
if (openTimesList.size() == 0)
return "No open time on schedule";
int currentDay = (5 + now.get(Calendar.DAY_OF_WEEK)) % 7;
String durationMessage;
if(facility.isOpen()) {
if(getCurrentEndTime(openTimesList, currentDay).equals("23:59:59") &&
getCurrentStartTime(openTimesList, (currentDay+1)%7).equals("00:00:00")) {
if (facility.isOpen()) {
if (getCurrentEndTime(openTimesList, currentDay).equals("23:59:59") &&
getCurrentStartTime(openTimesList, (currentDay + 1) % 7).equals("00:00:00")) {
currentDay++;
}
......@@ -244,13 +249,13 @@ public class MainPresenter {
}
// Check if the facility opens later today
if(openTimesContains(openTimesList, currentDay)) {
if (openTimesContains(openTimesList, currentDay)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
try {
Date currentTime = sdf.parse(sdf.format(now.getTime()));
Date startTime = sdf.parse(getCurrentStartTime(openTimesList, currentDay));
if(currentTime.compareTo(startTime) < 0) {
if (currentTime.compareTo(startTime) < 0) {
String openingTime = getCurrentStartTime(openTimesList, currentDay);
openingTime = FacilityPresenter.parseTo12HourTime(openingTime);
......@@ -268,7 +273,7 @@ public class MainPresenter {
String openingTime = getCurrentStartTime(openTimesList, nextDay);
openingTime = FacilityPresenter.parseTo12HourTime(openingTime);
if(nextDay == (currentDay+1)%7) {
if (nextDay == (currentDay + 1) % 7) {
durationMessage = "Opens tomorrow at " + openingTime;
} else {
String nextDayStr = FacilityPresenter.parseIntToDay(nextDay);
......@@ -279,8 +284,8 @@ public class MainPresenter {
}
private boolean openTimesContains(RealmList<OpenTimes> openTimesList, int currentDay) {
for(OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
for (OpenTimes o : openTimesList) {
if (o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
return true;
}
return false;
......@@ -289,8 +294,8 @@ public class MainPresenter {
// Returns the next open day in the list of OpenTimes
private int findNextDay(RealmList<OpenTimes> openTimesList, int current) {
int nextDay = openTimesList.first().getStartDay();
for(OpenTimes o : openTimesList) {
if(o.getStartDay() > current) {
for (OpenTimes o : openTimesList) {
if (o.getStartDay() > current) {
nextDay = o.getStartDay();
break;
}
......@@ -302,8 +307,8 @@ public class MainPresenter {
// Returns the end time for the current day
private String getCurrentEndTime(RealmList<OpenTimes> openTimesList, int currentDay) {
String endTime = "";
for(OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
for (OpenTimes o : openTimesList) {
if (o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
endTime = o.getEndTime();
}
return endTime;
......@@ -312,8 +317,8 @@ public class MainPresenter {
// Returns the end time for the current day
private String getCurrentStartTime(RealmList<OpenTimes> openTimesList, int currentDay) {
String startTime = "";
for(OpenTimes o : openTimesList) {
if(o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
for (OpenTimes o : openTimesList) {
if (o.getStartDay() <= currentDay && o.getEndDay() >= currentDay)
startTime = o.getStartTime();
}
return startTime;
......@@ -327,11 +332,11 @@ public class MainPresenter {
try {
Date currentDate = now.getTime();
for(SpecialSchedule s : facility.getSpecialSchedules()) {
for (SpecialSchedule s : facility.getSpecialSchedules()) {
Date startDate = sdf.parse(s.getValidStart());
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;
}
}
......
......@@ -2,7 +2,7 @@ package srct.whatsopen.util;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import androidx.legacy.content.WakefulBroadcastReceiver;
public class NotificationReceiver extends WakefulBroadcastReceiver {
......
......@@ -7,8 +7,8 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.WakefulBroadcastReceiver;
import androidx.core.app.NotificationCompat;
import androidx.legacy.content.WakefulBroadcastReceiver;
import srct.whatsopen.R;
......
......@@ -3,7 +3,7 @@ package srct.whatsopen.views.activities;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import com.danielstone.materialaboutlibrary.MaterialAboutActivity;
import com.danielstone.materialaboutlibrary.model.MaterialAboutActionItem;
......
package srct.whatsopen.views.activities;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.ContextThemeWrapper;
......@@ -81,13 +79,7 @@ public abstract class BaseThemeActivity extends AppCompatActivity {
Method method = clazz.getMethod("getThemeResId");
method.setAccessible(true);
themeResId = (Integer) method.invoke(this);
} catch (NoSuchMethodException 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) {
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
Log.e(TAG, ".getThemeID Failed to get theme resource ID", e);
}
return themeResId;
......
......@@ -2,21 +2,9 @@ package srct.whatsopen.views.activities;
import android.content.Context;
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.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.transition.Slide;
import android.view.Display;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
......@@ -25,8 +13,9 @@ import android.widget.Button;
import android.widget.TextView;
import java.util.Calendar;
import java.util.Set;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentManager;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
......@@ -37,8 +26,8 @@ import srct.whatsopen.model.Facility;
import srct.whatsopen.model.NotificationSettings;
import srct.whatsopen.model.Schedule;
import srct.whatsopen.model.SpecialSchedule;
import srct.whatsopen.views.FacilityView;
import srct.whatsopen.presenters.FacilityPresenter;
import srct.whatsopen.views.FacilityView;
import srct.whatsopen.views.fragments.NotificationDialogFragment;
......@@ -91,12 +80,10 @@ public class DetailActivity extends BaseThemeActivity implements FacilityView,
}
private void setUpAnimations() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Slide slide = new Slide();
slide.setSlideEdge(Gravity.BOTTOM);
slide.setDuration(300);
getWindow().setEnterTransition(slide);
}
Slide slide = new Slide();
slide.setSlideEdge(Gravity.BOTTOM);
slide.setDuration(300);
getWindow().setEnterTransition(slide);
}
@Override
......@@ -126,11 +113,7 @@ public class DetailActivity extends BaseThemeActivity implements FacilityView,
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAfterTransition();
} else {
finish();
}
finishAfterTransition();
return true;
case R.id.action_favorite:
mPresenter.toggleFavorite(mFacility);
......@@ -171,15 +154,13 @@ public class DetailActivity extends BaseThemeActivity implements FacilityView,
// Configures the toolbar title, actions, etc
private void configureToolbar() {
Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
// Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(mFacility.getName());
// Set shared content name for transitions if Api >= 21
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getTextViewTitle(toolbar).setTransitionName("facility_name");
}
getTextViewTitle(toolbar).setTransitionName("facility_name");
// Display back button
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
......
......@@ -5,13 +5,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
......@@ -53,7 +53,8 @@ public class MainActivity extends BaseThemeActivity implements MainView {
mPresenter.loadFacilities();
// Configure toolbar
Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
// Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
toolbar.setLogo(R.drawable.wo_clock_toolbar);
......@@ -105,7 +106,8 @@ public class MainActivity extends BaseThemeActivity implements MainView {
mViewPager.setAdapter(new FacilityListFragmentPagerAdapter(getSupportFragmentManager()));
// Now give the TabStrip the ViewPager
TabLayout tabLayout = ButterKnife.findById(this, R.id.tabs);
// TabLayout tabLayout = ButterKnife.findById(this, R.id.tabs);
TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
// Set the default tab to 'All'
......
package srct.whatsopen.views.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import butterknife.ButterKnife;
import androidx.appcompat.widget.Toolbar;
import androidx.preference.PreferenceManager;
import srct.whatsopen.MyApplication;
import srct.whatsopen.R;
import srct.whatsopen.views.fragments.SettingsFragment;
public class SettingsActivity extends BaseThemeActivity {
private SharedPreferences mSharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -57,7 +49,8 @@ public class SettingsActivity extends BaseThemeActivity {
}
private void configureToolbar() {
Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
// Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Settings");
......@@ -68,17 +61,14 @@ public class SettingsActivity extends BaseThemeActivity {
}
private void setPreferenceChangeListener() {
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.OnSharedPreferenceChangeListener prefListener =
new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if(key.equals("turn_off_rotation_preference")) {
MyApplication.setRotation(SettingsActivity.this);
}else if (key.equals("dark_theme")){
Log.d("SettingsActivity", ".onSharedPreferenceChanged: Button was clicked to reset Themes.");
recreate();
}
SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);